style.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. * 公告·组件
  3. */
  4. var noticeConHtml = '<div class="goods-list-edit layui-form">';
  5. noticeConHtml += '<div class="layui-form-item ns-icon-radio">';
  6. noticeConHtml += '<label class="layui-form-label sm">公告图片</label>';
  7. noticeConHtml += '<div class="layui-input-block">';
  8. noticeConHtml += '<div class="search_logo">';
  9. noticeConHtml += '<div class="" ><img-sec-upload v-bind:data="{ data: data, field: \'leftImg\' }" v-bind:isShow="!1"></img-sec-upload></div>';
  10. noticeConHtml += '<div class="desc" >';
  11. noticeConHtml += '<div class="tip" >最多可添加一张图片</div>';
  12. noticeConHtml += '<div class="spec">40px*28px</div>';
  13. noticeConHtml += '</div>';
  14. noticeConHtml += '</div>';
  15. noticeConHtml += '</div>';
  16. noticeConHtml += '</div>';
  17. // noticeConHtml += '<div class="layui-form-item ns-icon-radio">';
  18. // noticeConHtml += '<label class="layui-form-label sm">数据来源</label>';
  19. // noticeConHtml += '<div class="layui-input-block">';
  20. // noticeConHtml += '<template v-for="(item, index) in goodsSources" v-bind:k="index">';
  21. // noticeConHtml += '<span :class="[item.value == data.sources ? \'\' : \'layui-hide\']">{{item.text}}</span>';
  22. // noticeConHtml += '</template>';
  23. // noticeConHtml += '<ul class="ns-icon">';
  24. // noticeConHtml += '<li v-for="(item, index) in goodsSources" v-bind:k="index" :class="[item.value == data.sources ? \'ns-text-color ns-border-color ns-bg-color-diaphaneity\' : \'\']" @click="data.sources=item.value">';
  25. // noticeConHtml += '<img v-if="item.value == data.sources" :src="item.selectedSrc" />'
  26. // noticeConHtml += '<img v-else :src="item.src" />'
  27. // noticeConHtml += '</li>';
  28. // noticeConHtml += '</ul>';
  29. // noticeConHtml += '</div>';
  30. // noticeConHtml += '</div>';
  31. noticeConHtml += '<div class="layui-form-item" v-if="data.sources == \'diy\'">';
  32. noticeConHtml += '<label class="layui-form-label sm">选择公告</label>';
  33. noticeConHtml += '<div class="layui-input-block">';
  34. noticeConHtml += '<div class="ns-input-text selected-style" v-on:click="addNotice">选择 <i class="layui-icon layui-icon-right"></i></div>';
  35. noticeConHtml += '</div>';
  36. noticeConHtml += '</div>';
  37. noticeConHtml += '</div>';
  38. Vue.component("notice-con", {
  39. template: noticeConHtml,
  40. data: function () {
  41. return {
  42. data: this.$parent.data,
  43. goodsSources: [{
  44. text: "手动添加公告",
  45. value: "default",
  46. src: noticeResourcePath + "/notice/img/manual.png",
  47. selectedSrc: noticeResourcePath + "/notice/img/manual_1.png"
  48. },
  49. {
  50. text: "选择系统公告",
  51. value: "diy",
  52. src: noticeResourcePath + "/notice/img/goods.png",
  53. selectedSrc: noticeResourcePath + "/notice/img/goods_1.png"
  54. }
  55. ],
  56. isShow: false,
  57. }
  58. },
  59. created: function () {
  60. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  61. this.$parent.data.verify.push(this.verify); //加载验证方法
  62. },
  63. methods: {
  64. verify: function () {
  65. var res = {
  66. code: true,
  67. message: ""
  68. };
  69. return res;
  70. },
  71. addNotice: function () {
  72. var self = this;
  73. self.noticeSelect(function (res) {
  74. self.$parent.data.noticeIds = [];
  75. self.$parent.data.list = [];
  76. for (var i = 0; i < res.length; i++) {
  77. self.$parent.data.noticeIds.push(res[i].id);
  78. self.$parent.data.list[i] = {
  79. title: res[i].title,
  80. link: {}
  81. };
  82. }
  83. }, self.$parent.data.noticeIds);
  84. },
  85. noticeSelect: function (callback, selectId) {
  86. var self = this;
  87. layui.use(['layer'], function () {
  88. var url = ns.url("shop/notice/noticeselect", {
  89. select_id: selectId.toString()
  90. });
  91. //iframe层-父子操作
  92. layer.open({
  93. title: "公告选择",
  94. type: 2,
  95. area: ['1000px', '600px'],
  96. fixed: false, //不固定
  97. btn: ['保存', '返回'],
  98. content: url,
  99. yes: function (index, layero) {
  100. var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
  101. iframeWin.selectGoods(function (obj) {
  102. if (typeof callback == "string") {
  103. try {
  104. eval(callback + '(obj)');
  105. layer.close(index);
  106. } catch (e) {
  107. console.error('回调函数' + callback + '未定义');
  108. }
  109. } else if (typeof callback == "function") {
  110. callback(obj);
  111. layer.close(index);
  112. }
  113. });
  114. }
  115. });
  116. });
  117. }
  118. }
  119. });
  120. var noticeEditHtml = '<div class="notice-config">';
  121. noticeEditHtml += '<div class="template-edit-wrap">';
  122. noticeEditHtml += '<ul v-if="data.sources == \'default\'">';
  123. noticeEditHtml += '<li v-for="(item,index) in list" v-bind:key="index">';
  124. noticeEditHtml += '<div class="content-block">';
  125. noticeEditHtml += '<div class="layui-form-item" >';
  126. noticeEditHtml += '<label class="layui-form-label sm">公告内容</label>';
  127. noticeEditHtml += '<div class="layui-input-block">';
  128. noticeEditHtml += '<input type="text" name=\'title\' v-model="item.title" class="layui-input" />';
  129. noticeEditHtml += '</div>';
  130. noticeEditHtml += '</div>';
  131. noticeEditHtml += '</div>';
  132. noticeEditHtml += '<i class="del" v-on:click="list.splice(index,1)" data-disabled="1">x</i>';
  133. noticeEditHtml += '<div class="error-msg"></div>';
  134. noticeEditHtml += '</li>';
  135. noticeEditHtml += '<div class="add-item ns-text-color" v-if="data.sources == \'default\'" v-on:click="list.push({ title:\'公告\',link:{} })">';
  136. noticeEditHtml += '<i>+</i>';
  137. noticeEditHtml += '<span>添加一条公告</span>';
  138. noticeEditHtml += '</div>';
  139. noticeEditHtml += '</ul>';
  140. noticeEditHtml += '</div>';
  141. noticeEditHtml += '</div>';
  142. Vue.component("notice-edit", {
  143. template: noticeEditHtml,
  144. data: function () {
  145. return {
  146. data: this.$parent.data,
  147. list: this.$parent.data.list,
  148. };
  149. },
  150. created: function () {
  151. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  152. this.$parent.data.verify.push(this.verify); //加载验证方法
  153. },
  154. methods: {
  155. verify: function () {
  156. var res = {
  157. code: true,
  158. message: ""
  159. };
  160. if (this.list.length > 0) {
  161. for (var i = 0; i < this.length; i++) {
  162. if (this.list[i].title == "") {
  163. res.code = false;
  164. res.message = "公告内容不能为空";
  165. break;
  166. }
  167. }
  168. } else {
  169. res.code = false;
  170. res.message = "请添加一条公告";
  171. }
  172. return res;
  173. }
  174. }
  175. });