| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- @extends('layouts.base')
- @section('title', '添加广告')
- @section('content')
- <link rel="stylesheet" href="{{resource_get('plugins/pc-terminal/views/admin/index.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>
- <div class="vue-crumbs">
- <a @click="goParent(1)">PC端</a>
- >
- <a @click="goParent(2)">广告管理</a>
- >
- 添加广告
- </div>
- <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="sort">
- <el-input v-model="form.sort" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="广告名称" prop="title">
- <el-input v-model="form.title" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="广告图片" prop="img">
- <div class="upload-box" @click="openUpload('img')" v-if="!form.img_src">
- <i class="el-icon-plus" style="font-size:32px"></i>
- </div>
- <div @click="openUpload('img')" class="upload-boxed" v-if="form.img_src" style="height:82px">
- <img :src="form.img_src" alt="" style="width:150px;height:82px;border-radius: 5px;cursor: pointer;">
- <i class="el-icon-close" @click.stop="clearImg('img')" title="点击清除图片"></i>
- <div class="upload-boxed-text">点击重新上传</div>
- </div>
- <div class="tip">
- 建议尺寸: [[advert_type==2?'390*360':'590* 370']]
- </div>
- </el-form-item>
- <el-form-item label="跳转链接" prop="url">
- <el-input v-model="form.url" style="width:70%;" placeholder=" 请填写指向的链接 (请以https://开头)"></el-input>
- <div class="tip">请以https://开头</div>
- </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')" :disabled="btnChangeEnable">提交</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>
- var app = new Vue({
- el:"#app",
- delimiters: ['[[', ']]'],
- name: 'test',
- data() {
- return{
- show:false,//是否开启公众号弹窗
- pro:false ,//是否开启小程序弹窗
- chooseLink:'',
- chooseMiniLink:'',
- id:0,
- advert_type:{{$_REQUEST['advert_type']?:1}},
- form:{
- sort:"0",
- title:"",
- img:"",
- img_src:"",
- url:"",
- is_show:0,
- },
- uploadShow:false,
- chooseImgName:'',
- submit_url:'',
- showVisible:false,
- btnChangeEnable:false,
- loading: false,
- uploadImg1:'',
-
- rules:{
- sort:{ required: true, message: '请输入排序'},
- title:{ required: true, message: '请输入广告名称'},
- img:{ required: true, message: '请选择广告图片'},
- // url:{ required: true, message: '请选择广告链接'},
- },
- }
- },
- created() {
-
- },
- mounted() {
- },
- 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;
- },
- goParent(level) {
- if(level==1) {
- window.location.href = `{!! yzWebFullUrl('plugin.pc-terminal.admin.set.basic') !!}`;
- }
- else if(level==2) {
- window.location.href = `{!! yzWebFullUrl('plugin.pc-terminal.admin.slide.slide-list') !!}`;
- }
- },
-
- submitForm(formName) {
- this.btnChangeEnable = true;
- let that = this;
- let json = {
- sort:this.form.sort,
- title:this.form.title,
- img:this.form.img,
- url:this.form.url,
- is_show:this.form.is_show || 0,
- advert_type:this.advert_type,
- };
- this.$refs[formName].validate((valid) => {
- if (valid) {
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.$http.post('{!! yzWebFullUrl('plugin.pc-terminal.admin.advert.advert-add') !!}',{advert: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();
- window.location.reload(1);
- },response => {
- loading.close();
- });
- }
- else {
- console.log('error submit!!');
- return false;
- }
- });
- this.btnChangeEnable = 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[name+'_src'] = image_url;
- },
- clearImg(str) {
- this.form[str] = "";
- this.form[str+'_src'] = "";
- 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
|