style.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. var searchHtml = '<div class="layui-form-item ns-icon-radio">';
  2. searchHtml += '<label class="layui-form-label sm">{{data.label}}</label>';
  3. searchHtml += '<div class="layui-input-block">';
  4. searchHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  5. searchHtml += '<span v-if="parent[data.field]==item.value">{{item.label}}</span>';
  6. searchHtml += '</template>';
  7. searchHtml += '<ul class="ns-icon">';
  8. searchHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  9. searchHtml += '<li v-on:click="parent[data.field]=item.value" :class="{\'ns-text-color ns-border-color ns-bg-color-diaphaneity\':parent[data.field]==item.value}">';
  10. searchHtml += '<img :src="item.icon_img_active" v-if="parent[data.field]==item.value"/>';
  11. searchHtml += '<img :src="item.icon_img" v-else />';
  12. searchHtml += '</li>';
  13. searchHtml += '</template>';
  14. searchHtml += '</ul>';
  15. searchHtml += '</div>';
  16. searchHtml += '</div>';
  17. Vue.component("goods-search", {
  18. props: {
  19. data: {
  20. type: Object,
  21. default: function () {
  22. return {
  23. field: "textAlign",
  24. label: "文本位置"
  25. };
  26. }
  27. }
  28. },
  29. data: function () {
  30. return {
  31. list: [
  32. {
  33. label: "居左",
  34. value: "left",
  35. icon_img:searchResourcePath + "/search/img/text_left.png",
  36. icon_img_active:searchResourcePath + "/search/img/text_left_hover.png"
  37. },
  38. {
  39. label: "居中",
  40. value: "center",
  41. icon_img:searchResourcePath + "/search/img/text_right.png",
  42. icon_img_active:searchResourcePath + "/search/img/text_right_hover.png"
  43. },
  44. ],
  45. parent: this.$parent.data,
  46. };
  47. },
  48. created: function () {
  49. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  50. this.$parent.data.verify.push(this.verify);//加载验证方法
  51. if (this.data.label == undefined) this.data.label = "文本位置";
  52. if (this.data.field == undefined) this.data.field = "textAlign";
  53. var self = this;
  54. setTimeout(function () {
  55. layui.use(['form'], function() {
  56. self.form = layui.form;
  57. self.form.render();
  58. });
  59. },10);
  60. //设置默认logo
  61. var error_img = $('input[name="d_elem"]').val()
  62. if(!this.parent.searchImg){this.parent.searchImg = error_img;}
  63. },
  64. watch: {
  65. data: function (val, oldVal) {
  66. if (val.field == undefined) val.field = oldVal.field;
  67. if (val.label == undefined) val.label = "文本位置";
  68. },
  69. },
  70. methods: {
  71. verify : function () {
  72. var res = { code : true, message : "" };
  73. return res;
  74. }
  75. },
  76. template: searchHtml
  77. });
  78. var borderHtml = '<div class="layui-form-item ns-icon-radio">';
  79. borderHtml += '<label class="layui-form-label sm">{{data.label}}</label>';
  80. borderHtml += '<div class="layui-input-block">';
  81. borderHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  82. borderHtml += '<span v-if="parent[data.field]==item.value">{{item.label}}</span>';
  83. borderHtml += '</template>';
  84. borderHtml += '<ul class="ns-icon">';
  85. borderHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  86. borderHtml += '<li v-on:click="parent[data.field]=item.value" :class="{\'ns-text-color ns-border-color ns-bg-color-diaphaneity\':parent[data.field]==item.value}">';
  87. borderHtml += '<img :src="item.icon_img_active" v-if="parent[data.field]==item.value"/>';
  88. borderHtml += '<img :src="item.icon_img" v-else />';
  89. borderHtml += '</li>';
  90. borderHtml += '</template>';
  91. borderHtml += '</ul>';
  92. borderHtml += '</div>';
  93. borderHtml += '</div>';
  94. Vue.component("search-border", {
  95. props: {
  96. data: {
  97. type: Object,
  98. default: function () {
  99. return {
  100. field: "borderType",
  101. label: "框体样式"
  102. };
  103. }
  104. }
  105. },
  106. data: function () {
  107. return {
  108. list: [
  109. {
  110. label: "方形",
  111. value: 1,
  112. icon_img:searchResourcePath + "/search/img/border1.png",
  113. icon_img_active:searchResourcePath + "/search/img/border1_hover.png"
  114. },
  115. {
  116. label: "圆形",
  117. value: 2,
  118. icon_img:searchResourcePath + "/search/img/border2.png",
  119. icon_img_active:searchResourcePath + "/search/img/border2_hover.png"
  120. },
  121. ],
  122. parent: this.$parent.data,
  123. };
  124. },
  125. created: function () {
  126. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  127. this.$parent.data.verify.push(this.verify);//加载验证方法
  128. if (this.data.label == undefined) this.data.label = "框体样式";
  129. if (this.data.field == undefined) this.data.field = "borderType";
  130. var self = this;
  131. setTimeout(function () {
  132. layui.use(['form'], function() {
  133. self.form = layui.form;
  134. self.form.render();
  135. });
  136. },10);
  137. },
  138. watch: {
  139. data: function (val, oldVal) {
  140. if (val.field == undefined) val.field = oldVal.field;
  141. if (val.label == undefined) val.label = "框体样式";
  142. },
  143. },
  144. methods: {
  145. verify : function () {
  146. var res = { code : true, message : "" };
  147. return res;
  148. },
  149. },
  150. template: borderHtml
  151. });
  152. var typeHtml = '<div class="layui-form-item">';
  153. typeHtml += '<label class="layui-form-label sm">{{data.label}}</label>';
  154. typeHtml += '<div class="layui-input-block">';
  155. typeHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  156. typeHtml += '<div v-on:click="parent[data.field]=item.value" v-if="parent[data.field]==item.value"><div>{{item.label}}</div></div>';
  157. typeHtml += '</template>';
  158. typeHtml += '</div>';
  159. typeHtml += '<div class="search_type">';
  160. typeHtml += '<template v-for="(item,index) in list" v-bind:k="index">';
  161. typeHtml += '<div class="search_type_left" v-on:click="parent[data.field]=item.value,parent.searchStyle=1" :class="{\'active\':parent[data.field]==item.value}">';
  162. typeHtml += '<img :src="item.icon_img_active" v-if="parent[data.field]==item.value"/>';
  163. typeHtml += '<img :src="item.icon_img" v-else />';
  164. typeHtml += '</div>';
  165. typeHtml += '</template>';
  166. typeHtml += '</div>';
  167. typeHtml += '<div class="search_logo" v-if="parent[data.field] == 2">';
  168. typeHtml += '<div class="" ><img-upload v-bind:data="{ data : parent, field : \'searchImg\' }" v-bind:isShow="!1"></img-upload></div>';
  169. typeHtml += '<div class="desc" >';
  170. typeHtml += '<div class="tip" >最多可添加一张图片</div>';
  171. typeHtml += '<div class="spec">85px*30px</div>';
  172. typeHtml += '</div>';
  173. typeHtml += '</div>';
  174. typeHtml += '</div>';