design.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. var styleHtml = '<div class="layui-form-item">';
  2. styleHtml += '<label class="layui-form-label sm">风格选择</label>';
  3. styleHtml += '<div class="layui-input-block">';
  4. styleHtml += '<div v-if="data.styleName" class="text-color selected-style" @click="selectStyle()">{{data.styleName}} <i class="layui-icon layui-icon-right"></i></div>';
  5. styleHtml += '</div>';
  6. styleHtml += '</div>';
  7. Vue.component("text-style", {
  8. template: styleHtml,
  9. data: function () {
  10. return {
  11. data: this.$parent.data,
  12. styleList: {
  13. "style-0": {
  14. "text": "标题栏",
  15. "subTitle": {"isElementShow": false},
  16. "more": {"isElementShow": false}
  17. },
  18. "style-1": {
  19. "text": "标题栏",
  20. "subTitle": {"isElementShow": false},
  21. "more": {"isElementShow": false}
  22. },
  23. "style-2": {
  24. "text": "标题栏",
  25. "subTitle": {"isElementShow": false},
  26. "more": {"isElementShow": false}
  27. },
  28. "style-3": {
  29. "text": "标题栏",
  30. "subTitle": {"isElementShow": false},
  31. "more": {"isElementShow": false}
  32. },
  33. "style-4": {
  34. "text": "标题栏",
  35. "subTitle": {"isElementShow": false},
  36. "more": {"isElementShow": false}
  37. },
  38. "style-5": {
  39. "text": "标题栏",
  40. "subTitle": {"isElementShow": false},
  41. "more": {"isElementShow": false}
  42. },
  43. "style-6": {
  44. "text": "标题栏",
  45. "subTitle": {"isElementShow": false},
  46. "more": {"isElementShow": false}
  47. },
  48. "style-7": {
  49. "text": "标题栏",
  50. "subTitle": {"isElementShow": false},
  51. "more": {"isElementShow": false}
  52. },
  53. "style-8": {
  54. "text": "标题栏",
  55. "subTitle": {"isElementShow": false},
  56. "more": {"isElementShow": false}
  57. },
  58. "style-9": {
  59. "text": "为您推荐",
  60. "textColor": "#3b2ce7",
  61. "fontSize": 16,
  62. "fontWeight": 'bold',
  63. "subTitle": {
  64. "fontSize": 14,
  65. "text": "夏日清爽出行必备",
  66. "isElementShow": true,
  67. "color": "#b7bcd2"
  68. },
  69. "more": {"isElementShow": false}
  70. },
  71. "style-10": {
  72. "text": "为您推荐",
  73. "textColor": "#FF95AC",
  74. "fontSize": 16,
  75. "fontWeight": 'bold',
  76. "subTitle": {
  77. "fontSize": 14,
  78. "text": "夏日清爽出行必备",
  79. "isElementShow": true,
  80. "color": "#B7BCD2"
  81. },
  82. "more": {"isElementShow": false}
  83. },
  84. "style-11": {
  85. "text": "为您推荐",
  86. "textColor": "#FF3B3B",
  87. "fontSize": 16,
  88. "fontWeight": 'bold',
  89. "subTitle": {
  90. "fontSize": 14,
  91. "text": "夏日清爽出行必备",
  92. "isElementShow": true,
  93. "color": "#FFB2B2"
  94. },
  95. "more": {
  96. "text": "查看更多",
  97. "link": {"name": ""},
  98. "isShow": true,
  99. "isElementShow": true,
  100. "color": "#999999"
  101. }
  102. },
  103. "style-12": {
  104. "text": "标题栏",
  105. "textColor": "#303133",
  106. "fontSize": 16,
  107. "fontWeight": 'bold',
  108. "subTitle": {
  109. "fontSize": 14,
  110. "text": "副标题",
  111. "isElementShow": true,
  112. "color": "#999999"
  113. },
  114. "more": {
  115. "text": "更多",
  116. "link": {"name": ""},
  117. "isShow": true,
  118. "isElementShow": true,
  119. "color": "#999999"
  120. }
  121. },
  122. "style-13": {
  123. "text": "夏日纳凉精选",
  124. "textColor": "#FFC425",
  125. "fontSize": 16,
  126. "fontWeight": 'bold',
  127. "subTitle": {"isElementShow": false},
  128. "more": {"isElementShow": false}
  129. },
  130. "style-14": {
  131. "text": "标题",
  132. "textColor": "#9849FF",
  133. "fontSize": 16,
  134. "fontWeight": 'bold',
  135. "subTitle": {
  136. "fontSize": 14,
  137. "text": "TITLE ZONE",
  138. "isElementShow": true,
  139. "color": "#9849FF"
  140. },
  141. "more": {
  142. "text": "更多",
  143. "link": {"name": ""},
  144. "isShow": true,
  145. "isElementShow": true,
  146. "color": "#999999"
  147. }
  148. },
  149. "style-15": {
  150. "text": "标题专区",
  151. "textColor": "#9849FF",
  152. "fontSize": 16,
  153. "fontWeight": 'bold',
  154. "subTitle": {
  155. "fontSize": 14,
  156. "text": "TITLE ZONE",
  157. "isElementShow": true,
  158. "color": "#9849FF"
  159. },
  160. "more": {"isElementShow": false}
  161. },
  162. "style-16": {
  163. "text": "标题专区",
  164. "textColor": "#303133",
  165. "fontSize": 16,
  166. "fontWeight": 'bold',
  167. "subTitle": {
  168. "fontSize": 14,
  169. "text": "副标题",
  170. "isElementShow": true,
  171. "color": "#FFFFFF",
  172. "bgColor": "#FC0F85",
  173. "icon": "icondiy icon-system-bargain-one",
  174. "fontWeight": 'bold',
  175. },
  176. "more": {
  177. "text": "更多",
  178. "link": {"name": ""},
  179. "isShow": true,
  180. "isElementShow": true,
  181. "color": "#999999"
  182. }
  183. }
  184. },
  185. list: {},
  186. }
  187. },
  188. created: function () {
  189. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  190. this.$parent.data.verify.push(this.verify);//加载验证方法
  191. this.$parent.data.ignore = ['elementAngle', 'elementBgColor']; //加载忽略内容 -- 其他设置中的属性设置
  192. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  193. // this.$parent.data.hidden = ['textColor'];// 隐藏公共属性编辑
  194. // 组件所需的临时数据
  195. this.$parent.data.tempData = {
  196. styleList: this.styleList
  197. };
  198. },
  199. methods: {
  200. verify: function (index) {
  201. var res = {code: true, message: ""};
  202. return res;
  203. },
  204. selectStyle: function () {
  205. var self = this;
  206. layer.open({
  207. type: 1,
  208. title: '风格选择',
  209. area: ['930px', '630px'],
  210. btn: ['确定', '返回'],
  211. content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .style-list-box-text").html(),
  212. success: function (layero, index) {
  213. $(".layui-layer-content input[name='style']").val(self.data.style);
  214. $(".layui-layer-content input[name='style_name']").val(self.data.styleName);
  215. $("body").on("click", ".layui-layer-content .style-list-con-text .style-li-text", function () {
  216. $(this).addClass("selected border-color").siblings().removeClass("selected border-color bg-color-after");
  217. $(".layui-layer-content input[name='style']").val($(this).attr("data_key"));
  218. $(".layui-layer-content input[name='style_name']").val($(this).find("span").text());
  219. });
  220. },
  221. yes: function (index, layero) {
  222. self.data.style = $(".layui-layer-content input[name='style']").val();
  223. self.data.styleName = $(".layui-layer-content input[name='style_name']").val();
  224. var data = self.styleList[self.data.style];
  225. self.data.text = data.text;
  226. if (data.fontSize) self.data.fontSize = data.fontSize;
  227. else self.data.fontSize = 16;
  228. if (data.fontWeight) self.data.fontWeight = data.fontWeight;
  229. else self.data.fontWeight = 'normal';
  230. if (data.subTitle.text) self.data.subTitle.text = data.subTitle.text;
  231. else self.data.subTitle.text = '副标题';
  232. if (data.subTitle.color) self.data.subTitle.color = data.subTitle.color;
  233. else self.data.subTitle.color = '#999999';
  234. if (data.subTitle.fontSize) self.data.subTitle.fontSize = data.subTitle.fontSize;
  235. else self.data.subTitle.fontSize = 14;
  236. if (data.subTitle.isElementShow) self.data.subTitle.isElementShow = data.subTitle.isElementShow;
  237. else self.data.subTitle.isElementShow = false;
  238. if (data.subTitle.bgColor) self.data.subTitle.bgColor = data.subTitle.bgColor;
  239. else self.data.subTitle.bgColor = '';
  240. if (data.subTitle.icon) self.data.subTitle.icon = data.subTitle.icon;
  241. else self.data.subTitle.icon = '';
  242. if (data.subTitle.fontWeight) self.data.subTitle.fontWeight = data.subTitle.fontWeight;
  243. else self.data.subTitle.fontWeight = 'normal';
  244. if (data.more.text) self.data.more.text = data.more.text;
  245. else self.data.more.text = '查看更多';
  246. if (data.more.isElementShow) self.data.more.isElementShow = data.more.isElementShow;
  247. else self.data.more.isElementShow = false;
  248. if (data.more.isShow) self.data.more.isShow = data.more.isShow;
  249. else self.data.more.isShow = false;
  250. if (data.more.color) self.data.more.color = data.more.color;
  251. else self.data.more.color = '#999999';
  252. layer.closeAll()
  253. }
  254. });
  255. }
  256. }
  257. });
  258. // 主标题文字粗细
  259. var fontWeightHtml = '<div class="layui-form-item icon-radio">';
  260. fontWeightHtml += '<label class="layui-form-label sm">文字粗细</label>';
  261. fontWeightHtml += '<div class="layui-input-block">';
  262. fontWeightHtml += '<template v-for="(item, index) in thicknessList">';
  263. fontWeightHtml += '<span :class="[item.value == data.fontWeight ? \'\' : \'layui-hide\']">{{item.name}}</span>';
  264. fontWeightHtml += '</template>';
  265. fontWeightHtml += '<ul class="icon-wrap">';
  266. fontWeightHtml += '<li v-for="(item, index) in thicknessList" :class="[item.value == data.fontWeight ? \'text-color border-color\' : \'\']" @click="change(item)">';
  267. fontWeightHtml += '<i class="iconfont" :class="[{\'text-color\': item.value == data.fontWeight}, item.src]"></i>';
  268. fontWeightHtml += '</li>';
  269. fontWeightHtml += '</ul>';
  270. fontWeightHtml += '</div>';
  271. fontWeightHtml += '</div>';
  272. Vue.component("text-font-weight", {
  273. props: {
  274. weightData: {
  275. type: Object,
  276. default: function () {
  277. return {};
  278. }
  279. }
  280. },
  281. template: fontWeightHtml,
  282. data: function () {
  283. return {
  284. data: this.$parent.data,
  285. thicknessList: [
  286. {name: "加粗", src: "iconbold", value: "bold"},
  287. {name: "常规", src: "iconbold-copy", value: "normal"}
  288. ]
  289. };
  290. },
  291. created: function () {
  292. if (this.weightData.parent !== undefined) this.data = this.$parent.data[this.weightData.parent];
  293. },
  294. methods: {
  295. change: function (item) {
  296. this.data.fontWeight = item.value;
  297. }
  298. },
  299. });