style.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // 幻灯片·组件
  2. var singleImgPreviewHtml = '<div v-bind:id="id" v-bind:style="{paddingLeft: data.paddingLeftRight+\'px\',paddingRight: data.paddingLeftRight+\'px\'}">';
  3. singleImgPreviewHtml += ' <div class="single-img-item" v-for="(item,index) in data.list" v-bind:style="{marginTop: index?data.imageGap+\'px\':0}">';
  4. singleImgPreviewHtml += ' <img :src="item.imageUrl?item.imageUrl:\'/static/images/diy/crack_figure.png\'" :style="\'border-radius:\'+data.topRadius+\'px \'+data.topRadius+\'px \'+data.bottomRadius+\'px \'+data.bottomRadius+\'px\'" />';
  5. singleImgPreviewHtml += ' </div>';
  6. singleImgPreviewHtml += '</div>';
  7. Vue.component("single-img", {
  8. data: function () {
  9. return {
  10. id: "slider_" + get_math_rant(10),
  11. data: this.$parent.data
  12. }
  13. },
  14. created: function () {
  15. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  16. this.$parent.data.verify.push(this.verify); //加载验证方法
  17. },
  18. methods: {
  19. verify: function () {
  20. var res = {
  21. code: true,
  22. message: ""
  23. };
  24. return res;
  25. }
  26. },
  27. template: singleImgPreviewHtml
  28. });
  29. /**
  30. * [图片导航的图片]·组件
  31. */
  32. var singleImgListHtml = '<div class="single-img-list">';
  33. singleImgListHtml += '<div class="template-edit-wrap">';
  34. singleImgListHtml += '<ul>';
  35. singleImgListHtml += '<p class="hint">建议图片宽度750px</p>';
  36. singleImgListHtml += '<li v-for="(item,index) in list" v-bind:key="index">';
  37. singleImgListHtml += '<img-sec-upload v-bind:data="{ data: item }"></img-sec-upload>';
  38. singleImgListHtml += '<div class="content-block" v-bind:class="$parent.data.selectedTemplate">';
  39. singleImgListHtml += '<sel-link v-bind:data="{ field : $parent.data.list[index].link }"></sel-link>';
  40. singleImgListHtml += '</div>';
  41. singleImgListHtml += '<i class="del" v-on:click="list.splice(index, 1)" data-disabled="1">x</i>';
  42. singleImgListHtml += '<div class="error-msg"></div>';
  43. singleImgListHtml += '</li>';
  44. singleImgListHtml += '<div v-if="showAddItem" class="add-item ns-text-color" v-on:click="list.push({ imageUrl : \'\', title : \'\', link : {} })">';
  45. singleImgListHtml += ' <i>+</i>';
  46. singleImgListHtml += ' <span>添加一张图片</span>';
  47. singleImgListHtml += '</div>';
  48. singleImgListHtml += '</ul>';
  49. singleImgListHtml += '</div>';
  50. singleImgListHtml += '<div class="template-edit-title">';
  51. singleImgListHtml += '<h3>其他设置</h3>';
  52. singleImgListHtml += '<i class="layui-icon layui-icon-down" onclick="closeBox(this)"></i>';
  53. singleImgListHtml += '</div>';
  54. singleImgListHtml += '<div class="template-edit-wrap">';
  55. singleImgListHtml += ' <div class="text-slide">';
  56. singleImgListHtml += ' <slide v-bind:data="{ field : \'marginTop\', label : \'页面间距\' }"></slide>';
  57. singleImgListHtml += ' </div>';
  58. singleImgListHtml += ' <div class="text-slide">';
  59. singleImgListHtml += ' <slide v-bind:data="{ field : \'paddingLeftRight\', label : \'左右间距\' }"></slide>';
  60. singleImgListHtml += ' </div>';
  61. singleImgListHtml += ' <div class="text-slide">';
  62. singleImgListHtml += ' <slide v-bind:data="{ field : \'imageGap\', label : \'图片间距\' }"></slide>';
  63. singleImgListHtml += ' </div>';
  64. singleImgListHtml += ' <div class="text-slide">';
  65. singleImgListHtml += ' <slide v-bind:data="{ field : \'topRadius\', label : \'上边角\' }"></slide>';
  66. singleImgListHtml += ' </div>';
  67. singleImgListHtml += ' <div class="text-slide">';
  68. singleImgListHtml += ' <slide v-bind:data="{ field : \'bottomRadius\', label : \'下边角\' }"></slide>';
  69. singleImgListHtml += ' </div>';
  70. singleImgListHtml += '</div>';
  71. singleImgListHtml += '</div>';
  72. Vue.component("single-img-list", {
  73. data: function () {
  74. return {
  75. data: this.$parent.data,
  76. showAddItem: true,
  77. list: this.$parent.data.list,
  78. maxTip: 5, //最大上传数量提示
  79. };
  80. },
  81. created: function () {
  82. this.changeShowAddItem();
  83. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  84. this.$parent.data.verify.push(this.verify); //加载验证方法
  85. },
  86. watch: {
  87. list: function () {
  88. this.changeShowAddItem();
  89. }
  90. },
  91. methods: {
  92. //改变按钮的显示隐藏
  93. changeShowAddItem: function () {
  94. this.showAddItem = (this.list.length >= this.maxTip) ? false : true;
  95. },
  96. verify: function () {
  97. var res = {
  98. code: true,
  99. message: ""
  100. };
  101. var _self = this;
  102. $(".draggable-element[data-index='" + this.data.index + "'] .single_img .single-img-list .template-edit-wrap>ul>li").each(function (index) {
  103. $(this).find("input[name='title']").removeAttr("style"); //清空输入框的样式
  104. //检测是否有未上传的图片
  105. if (_self.list[index].imageUrl == "") {
  106. res.code = false;
  107. res.message = "请选择一张图片";
  108. $(this).find(".error-msg").text("请选择一张图片").show();
  109. return res;
  110. } else {
  111. $(this).find(".error-msg").text("").hide();
  112. }
  113. });
  114. return res;
  115. }
  116. },
  117. template: singleImgListHtml
  118. });