diy-share.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template id="diy-share">
  2. <diy-style-contain title="分享配置">
  3. <diy-operation-list v-model="shareList" @on-change="shareChange" :gutter="20" :label-width="labelWidth">
  4. <template v-slot:wxtext="{ item }">
  5. <div class="flex">
  6. <div class="diy-operation-name" :style="{width: labelWidth + 'px'}"></div>
  7. <div class="upload-img-tips">{{item.value}}</div>
  8. </div>
  9. </template>
  10. <template v-slot:h5text="{ item }">
  11. <div class="flex">
  12. <div class="diy-operation-name" :style="{width: labelWidth + 'px'}"></div>
  13. <div class="upload-img-tips">{{item.value}}</div>
  14. </div>
  15. </template>
  16. <template v-slot:previewimg="{ item,index }">
  17. <div class="item-row">
  18. <div class="diy-operation-name" :style="{width: labelWidth + 'px'}">{{ item.label }}</div>
  19. <diy-tab v-model="item.list" :default-index="item.previewImgIndex" @change="onShopCartStyle">
  20. <template v-slot="{item, isSelect}">
  21. <div flex="cross:center" :class="{'preview-img-item': true,'preview-img-item-active': isSelect}">
  22. {{item.label}}
  23. </div>
  24. </template>
  25. </diy-tab>
  26. </div>
  27. <div v-if="item.previewImgIndex == 0">
  28. <div class="item-row">
  29. <div class="diy-operation-name" :style="{width: labelWidth + 'px'}"></div>
  30. <div class="prev-img-contain-mp WeChat">
  31. <img style="width: 207px;" src="resources/img/decorate/nav/share1.png" alt="">
  32. </div>
  33. </div>
  34. </div>
  35. <div v-else>
  36. <div class="item-row">
  37. <div class="diy-operation-name" :style="{width: labelWidth + 'px'}"></div>
  38. <div class="prev-img-contain-h5">
  39. <div class="title">朋友圈</div>
  40. <div style="padding: 20px; background: #EDEDED">
  41. <img style="width: 100%;" src="resources/img/decorate/nav/share2.png" alt="">
  42. </div>
  43. <div class="title">发送给朋友</div>
  44. <div>
  45. <img style="width: 100%;" src="resources/img/decorate/nav/share.png" alt="">
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. </diy-operation-list>
  52. </diy-style-contain>
  53. </template>
  54. <script>
  55. /**
  56. * 分享组件
  57. */
  58. Vue.component('diy-share', {
  59. name: "diy-share",
  60. template: '#diy-share',
  61. props: {
  62. defaultData: {
  63. type: Object,
  64. default () {
  65. return null
  66. }
  67. }
  68. },
  69. data() {
  70. return {
  71. labelWidth: 100,
  72. shareList: [{
  73. type: "input",
  74. label: "分享标题",
  75. value: "",
  76. placeholder: "请输入分享标题",
  77. max: 15,
  78. showLimit: true
  79. },
  80. {
  81. type: "textarea",
  82. label: "分享描述",
  83. value: "",
  84. placeholder: "请输入分享描述",
  85. max: 30,
  86. showLimit: true
  87. },
  88. {
  89. type: "image",
  90. label: "小程序分享图片",
  91. value: "",
  92. },
  93. {
  94. value: "小程序:建议尺寸5:4",
  95. slot: "wxtext"
  96. },
  97. {
  98. type: "image",
  99. label: "公众号分享图片",
  100. value: "",
  101. },
  102. {
  103. value: "H5:建议尺寸1:1",
  104. slot: "h5text"
  105. },
  106. {
  107. label: "分享预览图片",
  108. value: "",
  109. slot: "previewimg",
  110. list: [{
  111. label: "小程序"
  112. }, {
  113. label: "h5"
  114. }],
  115. previewImgIndex: 0,
  116. }
  117. ],
  118. }
  119. },
  120. mounted() {
  121. const e = this.shareList
  122. e[0].value = this.defaultData.title
  123. e[1].value = this.defaultData.desc
  124. e[2].value = this.defaultData.appletImg
  125. e[4].value = this.defaultData.officialAccountImg
  126. },
  127. methods: {
  128. onShopCartStyle(item, index) {
  129. const i = this.shareList[6];
  130. i.previewImgIndex = index;
  131. },
  132. shareChange(e) {
  133. this.$emit("change", e)
  134. },
  135. }
  136. });
  137. </script>
  138. <style>
  139. .preview-img-item {
  140. width: 78px;
  141. height: 32px;
  142. background: #EEF0F4;
  143. border-radius: 2px;
  144. color: #999999;
  145. justify-content: center;
  146. margin-right: 10px;
  147. }
  148. .preview-img-item-active {
  149. background: #E5F7FF;
  150. color: #2D8CF0;
  151. }
  152. .prev-img-contain-mp {
  153. box-sizing: border-box;
  154. width: 252px;
  155. padding: 8px 6px;
  156. margin-top: 14px;
  157. }
  158. .prev-img-contain-h5 {
  159. box-sizing: border-box;
  160. width: 252px;
  161. padding: 0 6px;
  162. }
  163. .prev-img-contain-h5 .title {
  164. margin: 20px 0;
  165. font-size: 14px;
  166. font-family: PingFang SC;
  167. font-weight: bold;
  168. line-height: 0px;
  169. color: #999999;
  170. }
  171. .upload-img-tips {
  172. margin-top: -10px;
  173. color: #999999;
  174. }
  175. .WeChat {
  176. background-color: #eee;
  177. display: flex;
  178. justify-content: flex-end;
  179. }
  180. </style>