/** * 公告·组件 */ var noticeConHtml = '
'; noticeConHtml += '
'; noticeConHtml += ''; noticeConHtml += '
'; noticeConHtml += ''; noticeConHtml += '
'; noticeConHtml += '
'; // noticeConHtml += '
'; // noticeConHtml += ''; // noticeConHtml += '
'; // noticeConHtml += ''; // noticeConHtml += '
    '; // noticeConHtml += '
  • '; // noticeConHtml += '' // noticeConHtml += '' // noticeConHtml += '
  • '; // noticeConHtml += '
'; // noticeConHtml += '
'; // noticeConHtml += '
'; noticeConHtml += '
'; noticeConHtml += ''; noticeConHtml += '
'; noticeConHtml += '
选择
'; noticeConHtml += '
'; noticeConHtml += '
'; noticeConHtml += '
'; Vue.component("notice-con", { template: noticeConHtml, data: function () { return { data: this.$parent.data, goodsSources: [{ text: "手动添加公告", value: "default", src: noticeResourcePath + "/notice/img/manual.png", selectedSrc: noticeResourcePath + "/notice/img/manual_1.png" }, { text: "选择系统公告", value: "diy", src: noticeResourcePath + "/notice/img/goods.png", selectedSrc: noticeResourcePath + "/notice/img/goods_1.png" } ], isShow: false, } }, created: function () { if (!this.$parent.data.verify) this.$parent.data.verify = []; this.$parent.data.verify.push(this.verify); //加载验证方法 }, methods: { verify: function () { var res = { code: true, message: "" }; return res; }, addNotice: function () { var self = this; self.noticeSelect(function (res) { self.$parent.data.noticeIds = []; self.$parent.data.list = []; for (var i = 0; i < res.length; i++) { self.$parent.data.noticeIds.push(res[i].id); self.$parent.data.list[i] = { title: res[i].title, link: {} }; } }, self.$parent.data.noticeIds); }, noticeSelect: function (callback, selectId) { var self = this; layui.use(['layer'], function () { var url = ns.url("shop/notice/noticeselect", { select_id: selectId.toString() }); //iframe层-父子操作 layer.open({ title: "公告选择", type: 2, area: ['1000px', '600px'], fixed: false, //不固定 btn: ['保存', '返回'], content: url, yes: function (index, layero) { var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法: iframeWin.selectGoods(function (obj) { if (typeof callback == "string") { try { eval(callback + '(obj)'); layer.close(index); } catch (e) { console.error('回调函数' + callback + '未定义'); } } else if (typeof callback == "function") { callback(obj); layer.close(index); } }); } }); }); } } }); var noticeEditHtml = '
'; noticeEditHtml += '
'; noticeEditHtml += ''; noticeEditHtml += '
'; noticeEditHtml += '
'; Vue.component("notice-edit", { template: noticeEditHtml, data: function () { return { data: this.$parent.data, list: this.$parent.data.list, }; }, created: function () { if (!this.$parent.data.verify) this.$parent.data.verify = []; this.$parent.data.verify.push(this.verify); //加载验证方法 }, methods: { verify: function () { var res = { code: true, message: "" }; if (this.list.length > 0) { for (var i = 0; i < this.length; i++) { if (this.list[i].title == "") { res.code = false; res.message = "公告内容不能为空"; break; } } } else { res.code = false; res.message = "请添加一条公告"; } return res; } } });