chunk-451b.db9f0281.js 14 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-451b"],{A3TM:function(t,e,a){},"Va4+":function(t,e,a){"use strict";a.r(e);var i=a("FyfS"),n=a.n(i),r=a("P2sY"),o=a.n(r),s=a("QbLZ"),l=a.n(s),d=a("t3Un"),u=a("Qyje"),c=a.n(u);var m=a("xA6U"),p=a("rs3x"),f=a("X4fA"),g=a("7Qib"),h=a("Mz3J"),v=[{value:1,unionType:3,name:"轮播"},{value:2,unionType:1,name:"分类精选"},{value:3,unionType:3,name:"横幅"},{value:4,unionType:1,name:"首页轮播下5按钮"},{value:"",name:"全部"}],y=[{value:0,name:"冻结"},{value:1,name:"激活"},{value:"",name:"全部"}],b={name:"Ad",components:{ElOption:a("KFLd").a,Pagination:h.a},filters:{adTypeFilter:function(t){return v[t-1].name},adStatusFilter:function(t){return y[t].name}},data:function(){return{uploadPath:p.b,options:[],value:[],list:[],total:0,listLoading:!0,linkUnion:void 0,adTypeMap:v,adStatusMap:y,listQuery:{pageNo:1,limit:20,status:void 0,adType:void 0},dataForm:{id:void 0,adType:void 0,title:void 0,url:"",imgUrl:void 0,status:void 0,color:void 0},dialogFormVisible:!1,dialogStatus:"",textMap:{update:"编辑",create:"创建"},rules:{title:[{required:!0,message:"广告标题不能为空",trigger:"blur"}],imgUrl:[{required:!0,message:"广告图片不能为空",trigger:"blur"}],adType:[{required:!0,message:"请选择广告类型",trigger:"blur"}],status:[{required:!0,message:"请选择广告状态",trigger:"blur"}]},downloadLoading:!1}},computed:{headers:function(){return{accessToken:Object(f.a)()}}},created:function(){this.getList()},methods:{getList:function(){var t=this;this.listLoading=!0,function(t){return Object(d.a)({method:"get",params:l()({_gp:"admin.advertisement",_mt:"queryAdvertisement"},t)})}(this.listQuery).then(function(e){t.list=e.data.data.items,t.total=e.data.data.total,t.listLoading=!1}).catch(function(){t.list=[],t.total=0,t.listLoading=!1})},handleLink:function(t){if(void 0!==t&&null!==t){var e="";if(t[t.length-1].startsWith("C")){if(t.length<3)return void this.$notify.error({title:"提示",message:"请关联第三级类目或者商品"});e="/pages/product/list?tid="+t[2].substring(2)}else e="/pages/product/detail?id="+t[3].substring(2);this.dataForm.url=e}},handleFilter:function(){this.listQuery.page=1,this.getList()},resetForm:function(){this.dataForm={id:void 0,adType:void 0,title:void 0,url:"",imgUrl:void 0,status:void 0,color:void 0},this.linkUnion=void 0},refreshOptions:function(){var t=this;0===this.options.length&&Object(m.g)().then(function(e){t.options=Object(g.a)(e.data.data)})},handleCreate:function(){var t=this;this.resetForm(),this.refreshOptions(),this.dialogStatus="create",this.dialogFormVisible=!0,this.$nextTick(function(){t.$refs.dataForm.clearValidate()})},uploadUrl:function(t){this.dataForm.imgUrl=t.url},createData:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.checkAdType()&&function(t){return Object(d.a)({method:"post",data:c.a.stringify(l()({_gp:"admin.advertisement",_mt:"addAdvertisement"},t))})}(t.dataForm).then(function(e){t.getList(),t.dialogFormVisible=!1,t.$notify.success({title:"成功",message:"创建成功"})}).catch(function(e){t.$notify.error({title:"失败",message:e.data.errmsg})})})},checkAdType:function(){if(void 0===this.linkUnion||null===this.linkUnion||this.linkUnion.length<3)return this.$notify.error({title:"失败",message:"请关联三级目录或者商品"}),!1;for(var t=0;t<this.adTypeMap.length;t++){var e=this.adTypeMap[t];if(e.value===this.dataForm.adType){if(1===e.unionType&&4===this.linkUnion.length)return this.$notify.error({title:"失败",message:"此类广告只能关联三级类目"}),!1;if(2===this.unionType&&3===this.linkUnion.length)return this.$notify.error({title:"失败",message:"此类广告只能关联商品"}),!1}}return!0},handleUpdate:function(t){var e=this;this.dataForm=o()({},t),this.refreshOptions(),this.dialogStatus="update",this.dataForm.url.indexOf("tid")>=0?this.linkUnion="C_"+this.dataForm.url.replace(/[^0-9]/gi,""):this.linkUnion="G_"+this.dataForm.url.replace(/[^0-9]/gi,""),this.dialogFormVisible=!0,this.$nextTick(function(){e.$refs.dataForm.clearValidate()})},updateData:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.checkAdType()&&function(t){return Object(d.a)({method:"post",data:c.a.stringify(l()({_gp:"admin.advertisement",_mt:"updateAdvertisement"},t,{adId:t.id}))})}(t.dataForm).then(function(){var e=!0,a=!1,i=void 0;try{for(var r,o=n()(t.list);!(e=(r=o.next()).done);e=!0){var s=r.value;if(s.id===t.dataForm.id){var l=t.list.indexOf(s);t.list.splice(l,1,t.dataForm);break}}}catch(t){a=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(a)throw i}}t.dialogFormVisible=!1,t.$notify.success({title:"成功",message:"更新广告成功"})}).catch(function(e){t.$notify.error({title:"失败",message:e.data.errmsg})})})},handleDelete:function(t){var e=this;this.$confirm("此操作将永久删除该广告--"+t.title+"--, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){(function(t,e){return Object(d.a)({method:"post",params:{_gp:"admin.advertisement",_mt:"deleteAdvertisement",adId:t,adType:e}})})(t.id,t.adType).then(function(a){e.$notify.success({title:"成功",message:"删除成功"});var i=e.list.indexOf(t);e.list.splice(i,1)}).catch(function(t){e.$notify.error({title:"失败",message:t.data.errmsg})})}).catch(function(){return!1})},uploadSuccessHandle:function(t,e){var a=this;this.dataForm.imgUrl=t.url,this.dialogFormVisible=!1,this.dialogFormVisible=!0;var i=new Image;i.src=t.url,i.setAttribute("crossOrigin","anonymous"),i.src=t.url+"?time="+(new Date).valueOf(),i.onload=function(t){var e=a.$refs.canvas;a.dataForm.color=function(t,e){t.width=e.width,t.height=e.height;var a=t.getContext("2d");a.drawImage(e,0,0);var i,n,r,o=a.getImageData(0,0,e.width,e.height).data;i=n=r=0;for(var s=0;s<e.height;s++)for(var l=0;l<e.width;l++)i+=o[4*(e.width*s+l)],n+=o[4*(e.width*s+l)+1],r+=o[4*(e.width*s+l)+2];return i/=e.width*e.height,n/=e.width*e.height,r/=e.width*e.height,"rgb("+(i=Math.round(i))+","+(n=Math.round(n))+","+(r=Math.round(r))+")"}(e,i)}},onBeforeUpload:function(t){var e="image/jpeg"===t.type||"image/gif",a=t.size/1024/1024<1;return e||this.$message.error("上传文件只能是图片格式!"),a||this.$message.error("上传文件大小不能超过 1MB!"),e&&a}}},_=(a("wke7"),a("KHd+")),F=Object(_.a)(b,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"app-container"},[a("div",{staticClass:"filter-container"},[a("el-select",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{placeholder:"请选择广告状态"},model:{value:t.listQuery.status,callback:function(e){t.$set(t.listQuery,"status",e)},expression:"listQuery.status"}},t._l(t.adStatusMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})})),t._v(" "),a("el-select",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{placeholder:"请选择广告类型"},model:{value:t.listQuery.adType,callback:function(e){t.$set(t.listQuery,"adType",e)},expression:"listQuery.adType"}},t._l(t.adTypeMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})})),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:advertisement:query"],expression:"['promote:advertisement:query']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.handleFilter}},[t._v("查找")]),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:advertisement:create"],expression:"['promote:advertisement:create']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-edit"},on:{click:t.handleCreate}},[t._v("添加")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],attrs:{data:t.list,size:"small","element-loading-text":"正在查询中。。。",border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{align:"center",label:"广告ID",prop:"id",sortable:""}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"广告标题",prop:"title"}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"广告类型",prop:"adType"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-tag",[t._v(t._s(t._f("adTypeFilter")(e.row.adType)))])]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"广告状态",prop:"status"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-tag",[t._v(t._s(t._f("adStatusFilter")(e.row.status)))])]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"广告图片",prop:"imgUrl"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.imgUrl?a("img",{attrs:{src:e.row.imgUrl,width:"80"}}):t._e()]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"活动链接",prop:"url"}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"操作",width:"200","class-name":"small-padding fixed-width"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:advertisement:update"],expression:"['promote:advertisement:update']"}],attrs:{type:"primary",size:"mini"},on:{click:function(a){t.handleUpdate(e.row)}}},[t._v("编辑")]),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:advertisement:delete"],expression:"['promote:advertisement:delete']"}],attrs:{type:"danger",size:"mini"},on:{click:function(a){t.handleDelete(e.row)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("pagination",{directives:[{name:"show",rawName:"v-show",value:t.total>0,expression:"total>0"}],attrs:{total:t.total,page:t.listQuery.pageNo,limit:t.listQuery.limit},on:{"update:page":function(e){t.$set(t.listQuery,"pageNo",e)},"update:limit":function(e){t.$set(t.listQuery,"limit",e)},pagination:t.getList}}),t._v(" "),a("el-dialog",{attrs:{title:t.textMap[t.dialogStatus],visible:t.dialogFormVisible},on:{"update:visible":function(e){t.dialogFormVisible=e}}},[a("el-form",{ref:"dataForm",staticStyle:{width:"400px","margin-left":"50px"},attrs:{rules:t.rules,model:t.dataForm,"status-icon":"","label-position":"left","label-width":"100px"}},[a("el-form-item",{attrs:{label:"隐藏的广告id",prop:"id",hidden:""}},[a("el-input",{model:{value:t.dataForm.id,callback:function(e){t.$set(t.dataForm,"id",e)},expression:"dataForm.id"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"广告标题",prop:"title"}},[a("el-input",{model:{value:t.dataForm.title,callback:function(e){t.$set(t.dataForm,"title",e)},expression:"dataForm.title"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"广告图片",prop:"imgUrl"}},[a("el-upload",{staticClass:"avatar-uploader",attrs:{headers:t.headers,action:t.uploadPath,"show-file-list":!1,"on-success":t.uploadSuccessHandle,"before-upload":t.onBeforeUpload,accept:".jpg, .jpeg, .png, .gif"}},[t.dataForm.imgUrl?a("img",{ref:"adImg",staticClass:"avatar",attrs:{src:t.dataForm.imgUrl}}):a("i",{staticClass:"el-icon-plus avatar-uploader-icon"})])],1),t._v(" "),a("el-form-item",{attrs:{label:"广告类型",prop:"adType"}},[a("el-select",{attrs:{placeholder:"请选择"},model:{value:t.dataForm.adType,callback:function(e){t.$set(t.dataForm,"adType",e)},expression:"dataForm.adType"}},t._l(t.adTypeMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"广告状态",prop:"status"}},[a("el-select",{attrs:{placeholder:"请选择"},model:{value:t.dataForm.status,callback:function(e){t.$set(t.dataForm,"status",e)},expression:"dataForm.status"}},t._l(t.adStatusMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"活动链接"}},[a("el-cascader",{attrs:{options:t.options,props:{checkStrictly:!0},placeholder:"关联类目、商品",filterable:""},on:{change:t.handleLink},model:{value:t.linkUnion,callback:function(e){t.linkUnion=e},expression:"linkUnion"}})],1)],1),t._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(e){t.dialogFormVisible=!1}}},[t._v("取消")]),t._v(" "),"create"==t.dialogStatus?a("el-button",{attrs:{type:"primary"},on:{click:t.createData}},[t._v("确定")]):a("el-button",{attrs:{type:"primary"},on:{click:t.updateData}},[t._v("确定")])],1)],1),t._v(" "),a("canvas",{ref:"canvas",attrs:{hidden:""}})],1)},[],!1,null,null,null);F.options.__file="merchantad.vue";e.default=F.exports},"gDS+":function(t,e,a){t.exports={default:a("oh+g"),__esModule:!0}},"oh+g":function(t,e,a){var i=a("WEpk"),n=i.JSON||(i.JSON={stringify:JSON.stringify});t.exports=function(t){return n.stringify.apply(n,arguments)}},rs3x:function(t,e,a){"use strict";a.d(e,"b",function(){return n}),a.d(e,"a",function(){return r});var i=a("t3Un"),n="https://shiyaopinche.cspc.cn:10443/upload/admin";function r(t){return Object(i.a)({url:n,method:"post",data:t})}},wke7:function(t,e,a){"use strict";var i=a("A3TM");a.n(i).a},xA6U:function(t,e,a){"use strict";a.d(e,"g",function(){return u}),a.d(e,"f",function(){return c}),a.d(e,"d",function(){return m}),a.d(e,"b",function(){return p}),a.d(e,"a",function(){return f}),a.d(e,"c",function(){return g}),a.d(e,"e",function(){return h});var i=a("gDS+"),n=a.n(i),r=a("QbLZ"),o=a.n(r),s=a("t3Un"),l=a("Qyje"),d=a.n(l);function u(){return Object(s.a)({method:"get",params:{_gp:"admin.goods",_mt:"getSpuBigTree"}})}function c(t){return Object(s.a)({method:"get",params:o()({_gp:"admin.goods",_mt:"list"},t)})}function m(t){return Object(s.a)({method:"post",data:d.a.stringify({_gp:"admin.goods",_mt:"edit",spuDTO:n()(t)})})}function p(t){return Object(s.a)({method:"post",params:{_gp:"admin.goods",_mt:"delete",spuId:t}})}function f(t){return Object(s.a)({method:"post",data:d.a.stringify({_gp:"admin.goods",_mt:"create",spuDTO:n()(t)})})}function g(t){return Object(s.a)({method:"get",params:{_gp:"admin.goods",_mt:"detail",spuId:t}})}function h(t,e){return Object(s.a)({method:"post",params:{_gp:"admin.goods",_mt:"freezeOrActivation",spuId:t,status:e}})}}}]);