shopTool.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="brandListTool">
  3. <h3 class="toolTit">每日好店</h3>
  4. <div class="toolBox">
  5. <div class="imgListBox">
  6. <draggable v-model="activeComponent.componentContent.imgTextData">
  7. <div v-for="(item, index) in activeComponent.componentContent.imgTextData" :key="index" class="item">
  8. <div class="listItemBox">
  9. <div class="addImgTit" @click="openAddImg(item, index)">
  10. <div class="titLeft">
  11. <span class="iconfont">&#xe703;</span>
  12. <span class="iconfont">&#xe64a;</span>
  13. <span>图片</span>
  14. </div>
  15. <div class="titRight">
  16. <span class="iconfont" @click.stop="deleteItem(item, index)">&#xe633;</span>
  17. <span v-html="imgCurrent === index ? '&#xe660;' : '&#xe695;'" class="iconfont"></span>
  18. </div>
  19. </div>
  20. <div class="addBox" v-show="imgCurrent === index">
  21. <div class="addContent">
  22. <tool-single-img :imageUrl.sync='item.img' tip="建议尺寸: 710*420px"></tool-single-img>
  23. <tool-select-link :linkObj.sync='item.linkObj'></tool-select-link>
  24. </div>
  25. <div @click="deleteItem(item, index)" class="deleteItem"><span class="iconfont">&#xe633;</span>删除图片</div>
  26. </div>
  27. </div>
  28. </div>
  29. </draggable>
  30. </div>
  31. </div>
  32. <div class="addImgBtn" v-if="activeComponent.componentContent.imgTextData.length < 5" @click="addImgText"><span class="iconfont">&#xe64a;</span>添加图片</div>
  33. <div class="addImgBtn" v-else><span class="iconfont">&#xe608;</span>最多只能添加5个</div>
  34. </div>
  35. </template>
  36. <script>
  37. import Draggable from 'vuedraggable'
  38. import {toolMixin} from '@@/config/mixin'
  39. import ToolSingleImg from '../toolModule/tool-single-img'
  40. import ToolSelectLink from '../toolModule/tool-select-link'
  41. export default {
  42. mixins: [toolMixin],
  43. name: 'imageTextNavTool',
  44. components: {
  45. ToolSelectLink,
  46. ToolSingleImg,
  47. Draggable
  48. },
  49. data () {
  50. return {
  51. title: '', // 标题内容
  52. textInfo: '', // 文本
  53. dialogImageUrl: '',
  54. imgTextData: [
  55. {
  56. title: '',
  57. isShow: true,
  58. imgData: '',
  59. describe: '',
  60. url: ''
  61. }
  62. ],
  63. textAlign: 'left',
  64. imgCurrent: null,
  65. }
  66. },
  67. computed: {
  68. },
  69. methods: {
  70. openAddImg (item, index) {
  71. if (this.imgCurrent === index) {
  72. this.imgCurrent = null
  73. return false
  74. }
  75. this.imgCurrent = index
  76. },
  77. // 添加图文
  78. addImgText () {
  79. this.activeComponent.componentContent.imgTextData.push({
  80. title: '',
  81. isShow: true,
  82. imgData: '',
  83. linkObj: {
  84. selsectValue: '',
  85. selectName: '',
  86. typeText: '',
  87. url: ''
  88. }
  89. })
  90. },
  91. // 删除内容
  92. deleteItem (item, index) {
  93. this.$confirm('确定删除此项?')
  94. .then(_ => {
  95. this.activeComponent.componentContent.imgTextData.splice(index, 1)
  96. })
  97. .catch(_ => {})
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .brandListTool {
  104. padding: 20px 20px 0px 20px;
  105. h3 {
  106. font-size: 18px;
  107. font-weight: 500;
  108. height: 35px;
  109. line-height: 35px;
  110. color: #333333;
  111. margin-bottom: 20px;
  112. }
  113. .toolBox {
  114. padding-bottom: 10px;
  115. .itemBox {
  116. label {
  117. font-size: 14px;
  118. color: #666666;
  119. height: 40px;
  120. line-height: 40px;
  121. }
  122. margin-bottom: 15px;
  123. }
  124. .imgListBox {
  125. margin-top: 30px;
  126. .item {
  127. border: 1px solid #E8EAEC;
  128. border-radius: 4px;
  129. margin-bottom: 10px;
  130. }
  131. .listItemBox {
  132. .addImgTit {
  133. padding: 10px;
  134. display: flex;
  135. justify-content: space-between;
  136. align-items: center;
  137. background: #F6F7F9;
  138. cursor: pointer;
  139. .titLeft {
  140. display: flex;
  141. align-items: center;
  142. span {
  143. color: #7D7E80;
  144. }
  145. span:nth-child(1) {
  146. font-size: 28px;
  147. }
  148. span:nth-child(2) {
  149. font-size: 25px;
  150. margin: 0 6px;
  151. }
  152. span:nth-child(3) {
  153. font-size: 14px;
  154. }
  155. }
  156. .titRight {
  157. display: flex;
  158. align-items: center;
  159. span:nth-child(1) {
  160. width: 40px;
  161. text-align: center;
  162. display: block;
  163. height: 30px;
  164. line-height: 30px;
  165. }
  166. }
  167. }
  168. .addContent {
  169. padding: 5px 13px;
  170. .imgIsShow {
  171. display: flex;
  172. justify-content: space-between;
  173. margin: 18px 0 22px 0;
  174. span {
  175. font-size: 14px;
  176. color: #666666;
  177. }
  178. }
  179. .deleteItem {
  180. border-radius: 4px;
  181. background: $mainColor;
  182. text-align: center;
  183. height: 36px;
  184. color: #ffffff;
  185. font-size: 14px;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. cursor: pointer;
  190. margin-bottom: 10px;
  191. span {
  192. font-size: 18px;
  193. color: #ffffff;
  194. margin-right: 5px;
  195. }
  196. }
  197. }
  198. .deleteItem {
  199. padding: 10px;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. background: #F6F7F9;
  204. cursor: pointer;
  205. color: $mainColor;
  206. font-size: 14px;
  207. span {
  208. font-size: 16px;
  209. margin-right: 5px;
  210. }
  211. }
  212. }
  213. }
  214. .textTit {
  215. height: 35px;
  216. line-height: 35px;
  217. font-size: 16px;
  218. color: #333333;
  219. font-weight: bold;
  220. }
  221. }
  222. ::v-deep .el-select {
  223. width: 100%;
  224. }
  225. .addImgBtn {
  226. border-radius: 4px;
  227. background: $mainColor;
  228. text-align: center;
  229. height: 36px;
  230. color: #ffffff;
  231. font-size: 14px;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. cursor: pointer;
  236. span {
  237. font-size: 20px;
  238. margin-right: 5px;
  239. }
  240. }
  241. }
  242. </style>