design.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var brandHtml = '<div></div>';
  2. Vue.component("goods-brand-sources", {
  3. template: brandHtml,
  4. data: function () {
  5. return {
  6. data: this.$parent.data,
  7. goodsSources: {
  8. initial: {
  9. text: "默认",
  10. icon: "iconmofang"
  11. },
  12. diy: {
  13. text: "手动选择",
  14. icon: "iconshoudongxuanze"
  15. },
  16. },
  17. ornamentList: [
  18. {
  19. type: 'default',
  20. text: '默认',
  21. },
  22. {
  23. type: 'shadow',
  24. text: '投影',
  25. },
  26. {
  27. type: 'stroke',
  28. text: '描边',
  29. },
  30. ],
  31. };
  32. },
  33. created: function () {
  34. this.$parent.data.ignore = ['elementBgColor'];//加载忽略内容 -- 其他设置中的属性设置
  35. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  36. if(Object.keys(this.$parent.data.previewList).length == 0) {
  37. for (var i = 1; i < 5; i++) {
  38. this.$parent.data.previewList["brand_id_" + ns.gen_non_duplicate(i)] = {
  39. image_url: "",
  40. };
  41. }
  42. }
  43. // 组件所需的临时数据
  44. this.$parent.data.tempData = {
  45. goodsSources: this.goodsSources,
  46. ornamentList: this.ornamentList,
  47. methods: {
  48. addBrand: this.addBrand,
  49. },
  50. };
  51. },
  52. methods: {
  53. verify: function (index) {
  54. var res = {code: true, message: ""};
  55. if (vue.data[index].sources === 'diy' && vue.data[index].brandIds.length === 0) {
  56. res.code = false;
  57. res.message = "请选择文章";
  58. }
  59. return res;
  60. },
  61. addBrand: function () {
  62. var self = this;
  63. goodsBrandSelect(function (res) {
  64. self.$parent.data.brandIds = res.brandIds;
  65. self.$parent.data.previewList = res.list;
  66. }, {select_id: self.$parent.data.brandIds.toString()});
  67. },
  68. }
  69. });