style.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // 幻灯片·组件
  2. var videoPreviewHtml = '<div v-bind:id="id" class="videobox" :class="{fillet: data.sliderRadius==\'fillet\'}">';
  3. videoPreviewHtml += ' <div v-for="(item,index) in list">';
  4. videoPreviewHtml += ' <video :src="item.videoUrl" controls v-if="item.videoUrl" />';
  5. videoPreviewHtml += ' <img src="/static/images/diy/crack_figure.png" style="height: 150px;" v-else >';
  6. videoPreviewHtml += ' </div>';
  7. videoPreviewHtml += '</div>';
  8. Vue.component("szy-video", {
  9. data: function () {
  10. return {
  11. id: "video_" + get_math_rant(10),
  12. data: this.$parent.data,
  13. list: this.$parent.data.list,
  14. videoWidth: 710
  15. }
  16. },
  17. created: function () {
  18. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  19. this.$parent.data.verify.push(this.verify); //加载验证方法
  20. },
  21. watch: {
  22. list : function(val, oldval){
  23. console.log(val)
  24. console.log(oldval)
  25. },
  26. },
  27. methods: {
  28. verify: function () {
  29. var res = {
  30. code: true,
  31. message: ""
  32. };
  33. return res;
  34. },
  35. },
  36. template: videoPreviewHtml
  37. });
  38. /**
  39. * [视频的图片]·组件
  40. */
  41. var videoListHtml = '<div class="video-list">';
  42. videoListHtml += '<div class="template-edit-wrap">';
  43. videoListHtml += '<ul>';
  44. videoListHtml += '<li v-for="(item,index) in list" v-bind:key="index">';
  45. videoListHtml += '<video-upload v-bind:data="{ data: item }"></video-upload>';
  46. videoListHtml += '<div class="content-block">';
  47. // videoListHtml += '<sel-link v-bind:data="{ field : $parent.data.list[index].link }"></sel-link>';
  48. videoListHtml += '</div>';
  49. videoListHtml += '<i class="del" v-on:click="list.splice(index,1)" data-disabled="1">x</i>';
  50. videoListHtml += '<div class="error-msg"></div>';
  51. videoListHtml += '</li>';
  52. videoListHtml += '</ul>';
  53. videoListHtml += '</div>';
  54. videoListHtml += '<div class="template-edit-wrap">';
  55. videoListHtml += '<video-radius></video-radius>';
  56. videoListHtml += '</div>';
  57. videoListHtml += '<div class="template-edit-title">';
  58. videoListHtml += '<h3>其他设置</h3>';
  59. videoListHtml += '<i class="layui-icon layui-icon-down" onclick="closeBox(this)"></i>';
  60. videoListHtml += '</div>';
  61. videoListHtml += '<div class="template-edit-wrap">';
  62. videoListHtml += '<color v-bind:data="{ field : \'backgroundColor\', label : \'背景颜色\' }"></color>';
  63. videoListHtml += '<div class="text-slide">';
  64. videoListHtml += '<slide v-bind:data="{ field : \'marginTop\', label : \'页面间距\' }"></slide>';
  65. videoListHtml += '</div>';
  66. videoListHtml += '</div>';
  67. videoListHtml += '</div>';
  68. Vue.component("video-list", {
  69. data: function () {
  70. return {
  71. data: this.$parent.data,
  72. showAddItem: true,
  73. list: this.$parent.data.list,
  74. imageScale: this.$parent.data.imageScale,
  75. padding: this.$parent.data.padding,
  76. maxTip: 5, //最大上传数量提示
  77. scrollSettingList: [{
  78. name: "固定",
  79. value: "fixed",
  80. max: 5
  81. }],
  82. };
  83. },
  84. created: function () {
  85. this.changeShowAddItem();
  86. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  87. this.$parent.data.verify.push(this.verify); //加载验证方法
  88. },
  89. watch: {
  90. list: function () {
  91. this.changeShowAddItem();
  92. }
  93. },
  94. methods: {
  95. //改变图文导航按钮的显示隐藏
  96. changeShowAddItem: function () {
  97. if (this.list.length >= this.scrollSettingList[0].max) this.showAddItem = false;
  98. else this.showAddItem = true;
  99. this.maxTip = this.scrollSettingList[0].max;
  100. },
  101. //改变上下边距
  102. changePadding: function (event) {
  103. var v = event.target.value;
  104. if (v != "") {
  105. if (v >= 0 && v <= 100) {
  106. this.padding = v;
  107. this.$parent.data.padding = this.padding; //更新父级对象
  108. } else {
  109. layer.msg("请输入合法数字0~100");
  110. }
  111. } else {
  112. layer.msg("请输入合法数字0~100");
  113. }
  114. },
  115. verify: function () {
  116. var res = {
  117. code: true,
  118. message: ""
  119. };
  120. var _self = this;
  121. $(".draggable-element[data-index='" + this.data.index + "'] .slider .slider-list .template-edit-wrap>ul>li").each(function (index) {
  122. $(this).find("input[name='title']").removeAttr("style"); //清空输入框的样式
  123. //检测是否有未上传的视频
  124. if (_self.list[index].videoUrl == "") {
  125. res.code = false;
  126. res.message = "请选择视频";
  127. $(this).find(".error-msg").text("请选择视频").show();
  128. return res;
  129. } else {
  130. $(this).find(".error-msg").text("").hide();
  131. }
  132. });
  133. return res;
  134. }
  135. },
  136. template: videoListHtml
  137. });
  138. var videoRadiusHtml = '<div class="layui-form-item ns-icon-radio">';
  139. videoRadiusHtml += '<label class="layui-form-label sm">圆角展示</label>';
  140. videoRadiusHtml += '<div class="layui-input-block">';
  141. videoRadiusHtml += '<template v-for="(item, index) in sliderRadius" v-bind:k="index">';
  142. videoRadiusHtml += '<span :class="[item.value == data.sliderRadius ? \'\' : \'layui-hide\']">{{item.text}}</span>';
  143. videoRadiusHtml += '</template>';
  144. videoRadiusHtml += '<ul class="ns-icon">';
  145. videoRadiusHtml += '<li v-for="(item, index) in sliderRadius" v-bind:k="index" :class="[item.value == data.sliderRadius ? \'ns-text-color ns-border-color ns-bg-color-diaphaneity\' : \'\']" @click="data.sliderRadius=item.value">';
  146. videoRadiusHtml += '<img v-if="item.value == data.sliderRadius" :src="item.selectedSrc" />'
  147. videoRadiusHtml += '<img v-else :src="item.src" />'
  148. videoRadiusHtml += '</li>';
  149. videoRadiusHtml += '</ul>';
  150. videoRadiusHtml += '</div>';
  151. videoRadiusHtml += '</div>';
  152. Vue.component("video-radius", {
  153. template: videoRadiusHtml,
  154. data: function () {
  155. return {
  156. data: this.$parent.data,
  157. sliderRadius: [{
  158. text: "直角",
  159. value: "right-angle",
  160. src: sliderResourcePath + "/graphic_nav/img/right-angle.png",
  161. selectedSrc: sliderResourcePath + "/graphic_nav/img/right-angle_1.png"
  162. },
  163. {
  164. text: "圆角",
  165. value: "fillet",
  166. src: sliderResourcePath + "/graphic_nav/img/fillet.png",
  167. selectedSrc: sliderResourcePath + "/graphic_nav/img/fillet_1.png"
  168. }
  169. ],
  170. }
  171. },
  172. created: function () {
  173. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  174. this.$parent.data.verify.push(this.verify); //加载验证方法
  175. },
  176. methods: {
  177. verify: function () {
  178. var res = {
  179. code: true,
  180. message: ""
  181. };
  182. return res;
  183. },
  184. },
  185. });