| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- @extends('layouts.base')
- @section('title', '编辑按钮')
- @section('content')
- <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
- <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
- <style>
- th {border-bottom: 1px solid #EBEEF5 !important;}
- .dialog-cover{z-index:2001}
- .dialog-content{z-index:2002}
- </style>
- <div class="all">
- <div id="app" v-cloak>
- <el-form ref="form" :model="form" :rules="rules" label-width="15%">
- <div class="vue-main">
- <div class="vue-main-title">
- <div class="vue-main-title-left"></div>
- <div class="vue-main-title-content">编辑按钮</div>
- </div>
- <div class="vue-main-form">
- <el-form-item label="排序" prop="sequence">
- <el-input v-model="form.sequence" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="按钮名称" prop="name">
- <el-input v-model="form.name" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="按钮图片" prop="thumb">
- <div class="upload-box" @click="openUpload('img')" v-if="!form.button_img">
- <i class="el-icon-plus" style="font-size:32px"></i>
- </div>
- <div @click="openUpload('img')" class="upload-boxed" v-if="form.button_img" style="height:150px">
- <img :src="form.button_img" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
- <div class="upload-boxed-text">点击重新上传</div>
- </div>
- <!-- <div class="tip">建议尺寸: 640*350,请将所有按钮图片尺寸保持一致</div> -->
- </el-form-item>
- <el-form-item label="跳转链接链接" prop="url">
- <el-input v-model="form.url" style="width:70%;" placeholder=" 请填写指向的链接 (请以https://开头, 不填则不显示)"></el-input>
- <el-button @click="showLink('link','url')">选择链接</el-button>
- </el-form-item>
- <el-form-item label="小程序跳转链接" prop="app_url">
- <el-input v-model="form.app_url" style="width:70%;"></el-input>
- <el-button @click="showLink('mini','app_url')">选择小程序链接</el-button>
- </el-form-item>
-
- <el-form-item label="是否显示" prop="is_show">
- <el-switch v-model="form.is_show" :active-value="1" :inactive-value="0"></el-switch>
- </el-form-item>
- </div>
- </div>
- </el-form>
- <!-- 分页 -->
- <div class="vue-page">
- <div class="vue-center">
- <el-button type="primary" @click="submitForm('form')">提交</el-button>
- <el-button @click="goBack">返回</el-button>
- </div>
- </div>
- <upload-img :upload-show="uploadShow" :name="chooseImgName" @replace="changeProp" @sure="sureImg"></upload-img>
- <pop :show="show" @replace="changeLink" @add="parHref"></pop>
- <program :pro="pro" @replacepro="changeprogram" @addpro="parpro"></program>
- </div>
- </div>
-
- @include('public.admin.uploadImg')
- @include('public.admin.pop')
- @include('public.admin.program')
- <script>
- let data = {!! json_encode($data) !!};
- console.log(data)
- var app = new Vue({
- el:"#app",
- delimiters: ['[[', ']]'],
- name: 'test',
- data() {
- return{
- show:false,//是否开启公众号弹窗
- pro:false ,//是否开启小程序弹窗
- chooseLink:'',
- chooseMiniLink:'',
- id:0,
- form:{
- sequence:"0",
- name:"",
- img:"",
- button_img:"",
- url:"",
- app_url:"",
- is_show:0,
- ...data
- },
- uploadShow:false,
- chooseImgName:'',
- submit_url:'',
- showVisible:false,
-
- loading: false,
- uploadImg1:'',
-
- rules:{
- name:{ required: true, message: '请输入按钮标题'},
- },
- }
- },
- created() {
-
- },
- mounted() {
- this.id = this.getParam("id");
- if(this.id) {
- this.submit_url = `{!! yzWebFullUrl('plugin.circle.admin.button.save') !!}`
- }
- else{
- this.submit_url = `{!! yzWebFullUrl('plugin.circle.admin.button.save') !!}`
- }
- },
- methods: {
- getParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- },
-
-
- submitForm(formName) {
- let that = this;
- let json = {
- sequence:this.form.sequence,
- name:this.form.name,
- img:this.form.img,
- url:this.form.url,
- app_url:this.form.app_url,
- is_show:this.form.is_show,
- };
- if(this.id) {
- json.id = this.id
- }
- this.$refs[formName].validate((valid) => {
- if (valid) {
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.$http.post(this.submit_url,json).then(response => {
- if (response.data.result) {
- this.$message({type: 'success',message: '操作成功!'});
- this.goBack();
- } else {
- this.$message({message: response.data.msg,type: 'error'});
- }
- loading.close();
- },response => {
- loading.close();
- });
- }
- else {
- console.log('error submit!!');
- return false;
- }
- });
- },
-
- goBack() {
- history.go(-1)
- },
- openUpload(str) {
- this.chooseImgName = str;
- this.uploadShow = true;
- },
- changeProp(val) {
- if(val == true) {
- this.uploadShow = false;
- }
- else {
- this.uploadShow = true;
- }
- },
- sureImg(name,image,image_url) {
- this.form[name] = image;
- this.form['button_'+name] = image_url;
- },
- clearImg(str) {
- this.form[str] = "";
- this.form['button_'+str] = "";
- this.$forceUpdate();
- },
- //弹窗显示与隐藏的控制
- changeLink(item){
- this.show=item;
- },
- //当前链接的增加
- parHref(child,confirm){
- this.show=confirm;
- // this.form.link=child;
- this.form[this.chooseLink] = child;
- },
- changeprogram(item){
- this.pro=item;
- },
- parpro(child,confirm){
- this.pro=confirm;
- // this.form.prolink=child;
- this.form[this.chooseMiniLink] = child;
- },
- showLink(type,name) {
- if(type=="link") {
- this.chooseLink = name;
- this.show = true;
- }
- else {
- this.chooseMiniLink = name;
- this.pro = true;
- }
- },
-
- },
- })
- </script>
- @endsection
|