button-edit.blade.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. @extends('layouts.base')
  2. @section('title', '编辑按钮')
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  5. <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
  6. <style>
  7. th {border-bottom: 1px solid #EBEEF5 !important;}
  8. .dialog-cover{z-index:2001}
  9. .dialog-content{z-index:2002}
  10. </style>
  11. <div class="all">
  12. <div id="app" v-cloak>
  13. <el-form ref="form" :model="form" :rules="rules" label-width="15%">
  14. <div class="vue-main">
  15. <div class="vue-main-title">
  16. <div class="vue-main-title-left"></div>
  17. <div class="vue-main-title-content">编辑按钮</div>
  18. </div>
  19. <div class="vue-main-form">
  20. <el-form-item label="排序" prop="sequence">
  21. <el-input v-model="form.sequence" style="width:70%;"></el-input>
  22. </el-form-item>
  23. <el-form-item label="按钮名称" prop="name">
  24. <el-input v-model="form.name" style="width:70%;"></el-input>
  25. </el-form-item>
  26. <el-form-item label="按钮图片" prop="thumb">
  27. <div class="upload-box" @click="openUpload('img')" v-if="!form.button_img">
  28. <i class="el-icon-plus" style="font-size:32px"></i>
  29. </div>
  30. <div @click="openUpload('img')" class="upload-boxed" v-if="form.button_img" style="height:150px">
  31. <img :src="form.button_img" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
  32. <div class="upload-boxed-text">点击重新上传</div>
  33. </div>
  34. <!-- <div class="tip">建议尺寸: 640*350,请将所有按钮图片尺寸保持一致</div> -->
  35. </el-form-item>
  36. <el-form-item label="跳转链接链接" prop="url">
  37. <el-input v-model="form.url" style="width:70%;" placeholder=" 请填写指向的链接 (请以https://开头, 不填则不显示)"></el-input>
  38. <el-button @click="showLink('link','url')">选择链接</el-button>
  39. </el-form-item>
  40. <el-form-item label="小程序跳转链接" prop="app_url">
  41. <el-input v-model="form.app_url" style="width:70%;"></el-input>
  42. <el-button @click="showLink('mini','app_url')">选择小程序链接</el-button>
  43. </el-form-item>
  44. <el-form-item label="是否显示" prop="is_show">
  45. <el-switch v-model="form.is_show" :active-value="1" :inactive-value="0"></el-switch>
  46. </el-form-item>
  47. </div>
  48. </div>
  49. </el-form>
  50. <!-- 分页 -->
  51. <div class="vue-page">
  52. <div class="vue-center">
  53. <el-button type="primary" @click="submitForm('form')">提交</el-button>
  54. <el-button @click="goBack">返回</el-button>
  55. </div>
  56. </div>
  57. <upload-img :upload-show="uploadShow" :name="chooseImgName" @replace="changeProp" @sure="sureImg"></upload-img>
  58. <pop :show="show" @replace="changeLink" @add="parHref"></pop>
  59. <program :pro="pro" @replacepro="changeprogram" @addpro="parpro"></program>
  60. </div>
  61. </div>
  62. @include('public.admin.uploadImg')
  63. @include('public.admin.pop')
  64. @include('public.admin.program')
  65. <script>
  66. let data = {!! json_encode($data) !!};
  67. console.log(data)
  68. var app = new Vue({
  69. el:"#app",
  70. delimiters: ['[[', ']]'],
  71. name: 'test',
  72. data() {
  73. return{
  74. show:false,//是否开启公众号弹窗
  75. pro:false ,//是否开启小程序弹窗
  76. chooseLink:'',
  77. chooseMiniLink:'',
  78. id:0,
  79. form:{
  80. sequence:"0",
  81. name:"",
  82. img:"",
  83. button_img:"",
  84. url:"",
  85. app_url:"",
  86. is_show:0,
  87. ...data
  88. },
  89. uploadShow:false,
  90. chooseImgName:'',
  91. submit_url:'',
  92. showVisible:false,
  93. loading: false,
  94. uploadImg1:'',
  95. rules:{
  96. name:{ required: true, message: '请输入按钮标题'},
  97. },
  98. }
  99. },
  100. created() {
  101. },
  102. mounted() {
  103. this.id = this.getParam("id");
  104. if(this.id) {
  105. this.submit_url = `{!! yzWebFullUrl('plugin.circle.admin.button.save') !!}`
  106. }
  107. else{
  108. this.submit_url = `{!! yzWebFullUrl('plugin.circle.admin.button.save') !!}`
  109. }
  110. },
  111. methods: {
  112. getParam(name) {
  113. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  114. var r = window.location.search.substr(1).match(reg);
  115. if (r != null) return unescape(r[2]);
  116. return null;
  117. },
  118. submitForm(formName) {
  119. let that = this;
  120. let json = {
  121. sequence:this.form.sequence,
  122. name:this.form.name,
  123. img:this.form.img,
  124. url:this.form.url,
  125. app_url:this.form.app_url,
  126. is_show:this.form.is_show,
  127. };
  128. if(this.id) {
  129. json.id = this.id
  130. }
  131. this.$refs[formName].validate((valid) => {
  132. if (valid) {
  133. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  134. this.$http.post(this.submit_url,json).then(response => {
  135. if (response.data.result) {
  136. this.$message({type: 'success',message: '操作成功!'});
  137. this.goBack();
  138. } else {
  139. this.$message({message: response.data.msg,type: 'error'});
  140. }
  141. loading.close();
  142. },response => {
  143. loading.close();
  144. });
  145. }
  146. else {
  147. console.log('error submit!!');
  148. return false;
  149. }
  150. });
  151. },
  152. goBack() {
  153. history.go(-1)
  154. },
  155. openUpload(str) {
  156. this.chooseImgName = str;
  157. this.uploadShow = true;
  158. },
  159. changeProp(val) {
  160. if(val == true) {
  161. this.uploadShow = false;
  162. }
  163. else {
  164. this.uploadShow = true;
  165. }
  166. },
  167. sureImg(name,image,image_url) {
  168. this.form[name] = image;
  169. this.form['button_'+name] = image_url;
  170. },
  171. clearImg(str) {
  172. this.form[str] = "";
  173. this.form['button_'+str] = "";
  174. this.$forceUpdate();
  175. },
  176. //弹窗显示与隐藏的控制
  177. changeLink(item){
  178. this.show=item;
  179. },
  180. //当前链接的增加
  181. parHref(child,confirm){
  182. this.show=confirm;
  183. // this.form.link=child;
  184. this.form[this.chooseLink] = child;
  185. },
  186. changeprogram(item){
  187. this.pro=item;
  188. },
  189. parpro(child,confirm){
  190. this.pro=confirm;
  191. // this.form.prolink=child;
  192. this.form[this.chooseMiniLink] = child;
  193. },
  194. showLink(type,name) {
  195. if(type=="link") {
  196. this.chooseLink = name;
  197. this.show = true;
  198. }
  199. else {
  200. this.chooseMiniLink = name;
  201. this.pro = true;
  202. }
  203. },
  204. },
  205. })
  206. </script>
  207. @endsection