design.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * 热区
  3. */
  4. var hotAreaCarouselHtml = '<div style="display:none;"></div>';
  5. Vue.component("hot-area-carouse", {
  6. data: function () {
  7. return {
  8. data: this.$parent.data
  9. }
  10. },
  11. created: function () {
  12. this.$parent.data.ignore = ['textColor', 'elementBgColor', 'elementAngle'];//加载忽略内容 -- 其他设置中的属性设置
  13. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  14. // 组件所需的临时数据
  15. this.$parent.data.tempData = {
  16. swiperHeight: 0
  17. };
  18. if(this.data.imgWidth && this.data.imgHeight) {
  19. var radio = this.data.imgWidth / this.data.imgHeight;
  20. var swiperHeight = (370 / radio).toFixed(2);
  21. this.$parent.data.tempData.swiperHeight = swiperHeight;
  22. }
  23. },
  24. template: hotAreaCarouselHtml,
  25. watch: {
  26. data: {
  27. handler: function (val, oldVal) {
  28. // 计算图片高度
  29. var radio = (this.data.imgWidth / this.data.imgHeight) || 2;
  30. // 屏幕宽度
  31. var rootWidth = 370 - this.data.margin.both * 2;
  32. var swiperHeight = (rootWidth / radio).toFixed(2);
  33. this.$parent.data.tempData.swiperHeight = swiperHeight;
  34. },
  35. deep: true
  36. }
  37. },
  38. methods: {}
  39. });
  40. var hotAreaListHtml = '<div style="display:none;"></div>';
  41. Vue.component("hot-area-list", {
  42. template: hotAreaListHtml,
  43. data: function () {
  44. return {
  45. data: 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. // 组件所需的临时数据
  52. this.$parent.data.tempData = {
  53. ...this.$parent.data.tempData,
  54. methods: {
  55. setHeatMap:this.setHeatMap
  56. }
  57. };
  58. },
  59. methods: {
  60. //热区设置
  61. setHeatMap :function() {
  62. let that = this;
  63. if(!that.$parent.data.imageUrl){
  64. layer.msg('请先上传图片');
  65. return;
  66. }
  67. sessionStorage.setItem('imageData',JSON.stringify(that.$parent.data));
  68. ns.open_iframe({
  69. title: '热区设置',
  70. url:ns.url("shop/diy/heatmap"),
  71. area:['100%', '100%'],
  72. success: function(data){
  73. that.$parent.data.heatMapData = data.heatMapData;
  74. }
  75. })
  76. },
  77. verify: function (index) {
  78. var res = {code: true, message: ""};
  79. $(".draggable-element[data-index='" + index + "'] .hot-area").each(function (i) {
  80. if (vue.data[index].imageUrl === "") {
  81. res.code = false;
  82. res.message = "请添加图片";
  83. $(this).find(".error-msg").text("请添加图片").show();
  84. return res;
  85. } else {
  86. $(this).find(".error-msg").text("").hide();
  87. }
  88. });
  89. return res;
  90. }
  91. }
  92. });