design.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. var articleHtml = '<div></div>';
  2. Vue.component("article-sources", {
  3. template: articleHtml,
  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 = [];//加载忽略内容 -- 其他设置中的属性设置
  35. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  36. if(Object.keys(this.$parent.data.previewList).length == 0) {
  37. for (var i = 1; i < 3; i++) {
  38. this.$parent.data.previewList["brand_id_" + ns.gen_non_duplicate(i)] = {
  39. article_title: "文章标题",
  40. article_abstract: '这里是文章内容',
  41. read_num: (i + 1) * 12,
  42. category_name: '文章分类',
  43. create_time: 1662202804
  44. };
  45. }
  46. }
  47. // 组件所需的临时数据
  48. this.$parent.data.tempData = {
  49. goodsSources: this.goodsSources,
  50. ornamentList: this.ornamentList,
  51. methods: {
  52. addArticle: this.addArticle,
  53. timeFormat: this.timeFormat
  54. },
  55. };
  56. },
  57. methods: {
  58. verify: function (index) {
  59. var res = {code: true, message: ""};
  60. if (vue.data[index].sources === 'diy' && vue.data[index].articleIds.length === 0) {
  61. res.code = false;
  62. res.message = "请选择文章";
  63. }
  64. return res;
  65. },
  66. addArticle: function () {
  67. var self = this;
  68. articleSelect(function (res) {
  69. self.$parent.data.articleIds = res.articleIds;
  70. self.$parent.data.previewList = res.list;
  71. }, {select_id: self.$parent.data.articleIds.toString()});
  72. },
  73. timeFormat(time, format){
  74. return ns.time_to_date(time, format)
  75. }
  76. }
  77. });