bannerTool.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div class="shopTopTool">
  3. <h3 class="toolTit">轮播图</h3>
  4. <div class="tabBox">
  5. <div class="toolBox">
  6. <div class="numberGroup">
  7. <div class="title">
  8. <span>图片高度</span>
  9. </div>
  10. <div class="itemBox">
  11. <div class="block">
  12. <el-slider
  13. :show-input-controls=false
  14. input-size="mini"
  15. :max="1000"
  16. v-model="activeComponent.componentContent.height"
  17. show-input>
  18. </el-slider>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="imgListBox">
  23. <draggable v-model="activeComponent.componentContent.bannerData">
  24. <div v-for="(item, index) in activeComponent.componentContent.bannerData" :key="index" class="item">
  25. <div class="listItemBox">
  26. <div class="addImgTit" @click="openAddImg(item, index)">
  27. <div class="titLeft">
  28. <span class="iconfont">&#xe703;</span>
  29. <span class="iconfont">&#xe64a;</span>
  30. <span>图片</span>
  31. </div>
  32. <div class="titRight">
  33. <span class="iconfont" @click.stop="deleteItem(item, index)">&#xe633;</span>
  34. <span v-html="imgCurrent === index ? '&#xe660;' : '&#xe695;'" class="iconfont"></span>
  35. </div>
  36. </div>
  37. <div class="addBox" v-show="imgCurrent === index">
  38. <div class="addContent">
  39. <tool-single-img :imageUrl.sync='item.bannerUrl' :tip="terminal == 4?'建议尺寸: 宽度1920px':'建议尺寸: 宽度750px'"></tool-single-img>
  40. <tool-select-link :linkObj.sync='item.linkObj' title="图片链接"></tool-select-link>
  41. </div>
  42. <div @click="deleteItem(item, index)" class="deleteItem"><span class="iconfont">&#xe633;</span>删除内容</div>
  43. </div>
  44. </div>
  45. </div>
  46. </draggable>
  47. </div>
  48. <div class="addImgBtn" @click="addImgText"><span class="iconfont">&#xe64a;</span>添加图片</div>
  49. </div>
  50. </div>
  51. <el-dialog :visible.sync="dialogImageVisible">
  52. <img width="100%" :src="dialogImageUrl" alt="">
  53. </el-dialog>
  54. </div>
  55. </template>
  56. <script>
  57. import Draggable from 'vuedraggable'
  58. import {toolMixin} from '@@/config/mixin'
  59. import { mapGetters } from 'vuex'
  60. import ToolSelectLink from '../toolModule/tool-select-link'
  61. import ToolSelectCategory from '../toolModule/tool-select-category'
  62. import ToolSingleImg from '../toolModule/tool-single-img'
  63. export default {
  64. name: 'bannerTool',
  65. mixins: [toolMixin],
  66. components: {
  67. ToolSingleImg,
  68. ToolSelectCategory,
  69. ToolSelectLink,
  70. Draggable
  71. },
  72. data () {
  73. return {
  74. dialogImageVisible: false,
  75. dialogImageUrl: '',
  76. alignList: [
  77. {
  78. id: 1,
  79. label: '居左',
  80. value: 'left'
  81. },
  82. {
  83. id: 2,
  84. label: '居中',
  85. value: 'center'
  86. },
  87. {
  88. id: 3,
  89. label: '居右',
  90. value: 'right'
  91. }
  92. ],
  93. textAlign: 'left',
  94. imgCurrent: null,
  95. labelCurrent: null
  96. }
  97. },
  98. computed: {
  99. ...mapGetters([
  100. 'terminal'
  101. ])
  102. },
  103. methods: {
  104. // 添加类别
  105. addCategory () {
  106. },
  107. openAddImg (item, index) {
  108. if (this.imgCurrent === index) {
  109. this.imgCurrent = null
  110. return false
  111. }
  112. this.imgCurrent = index
  113. },
  114. openAddLabel (item, index) {
  115. if (this.labelCurrent === index) {
  116. this.labelCurrent = null
  117. return false
  118. }
  119. this.labelCurrent = index
  120. },
  121. // 添加图文
  122. addImgText () {
  123. this.activeComponent.componentContent.bannerData.push({
  124. title: '',
  125. imgData: '',
  126. url: ''
  127. })
  128. },
  129. // 删除内容
  130. deleteItem (item, index) {
  131. this.$confirm('确定删除此项?')
  132. .then(_ => {
  133. this.activeComponent.componentContent.bannerData.splice(index, 1)
  134. })
  135. .catch(_ => {})
  136. },
  137. // 添加标签
  138. addLabel () {
  139. this.activeComponent.componentContent.labelList.push({
  140. name: '',
  141. url: ''
  142. })
  143. },
  144. // 删除标签
  145. deleteLabelItem (item, index) {
  146. this.$confirm('确定删除此项?')
  147. .then(_ => {
  148. this.activeComponent.componentContent.labelList.splice(index, 1)
  149. })
  150. .catch(_ => {})
  151. },
  152. imgChange (file, index, key) {
  153. this.activeComponent.componentContent.bannerData[index][key] = URL.createObjectURL(file.raw)
  154. },
  155. showImage (imgData) {
  156. this.dialogImageUrl = imgData
  157. this.dialogImageVisible = true
  158. },
  159. delImage (index, key) {
  160. this.activeComponent.componentContent.bannerData[index][key] = ''
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .shopTopTool {
  167. padding: 20px 20px 0px 20px;
  168. .topTit {
  169. display: flex;
  170. justify-content: space-between;
  171. border-bottom: 1px solid #eeeeee;
  172. margin-bottom: 20px;
  173. span {
  174. height: 35px;
  175. line-height: 35px;
  176. font-size: 14px;
  177. color: #333333;
  178. }
  179. span:last-child {
  180. font-weight: bold;
  181. width: 100px;
  182. text-align: center;
  183. cursor: pointer;
  184. &:hover {
  185. color: $mainColor;
  186. }
  187. }
  188. }
  189. h3 {
  190. font-size: 18px;
  191. font-weight: 500;
  192. height: 35px;
  193. line-height: 35px;
  194. color: #333333;
  195. margin-bottom: 20px;
  196. }
  197. .titleBox{
  198. display: flex;
  199. justify-content: space-between;
  200. }
  201. .btnSelect{
  202. margin-top: 30px;
  203. }
  204. .toolBox {
  205. padding-bottom: 10px;
  206. .modelTit {
  207. font-size: 14px;
  208. color: #333333;
  209. margin-top: 10px;
  210. }
  211. .itemBox {
  212. label {
  213. font-size: 14px;
  214. color: #666666;
  215. height: 40px;
  216. line-height: 40px;
  217. }
  218. margin-bottom: 15px;
  219. }
  220. .imgListBox {
  221. .item {
  222. border: 1px solid #E8EAEC;
  223. border-radius: 4px;
  224. margin-bottom: 10px;
  225. }
  226. .listItemBox {
  227. .addImgTit {
  228. padding: 10px;
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. background: #F6F7F9;
  233. cursor: pointer;
  234. .titLeft {
  235. display: flex;
  236. align-items: center;
  237. span {
  238. color: #7D7E80;
  239. }
  240. span:nth-child(1) {
  241. font-size: 28px;
  242. }
  243. span:nth-child(2) {
  244. font-size: 25px;
  245. margin: 0 6px;
  246. }
  247. span:nth-child(3) {
  248. font-size: 14px;
  249. }
  250. }
  251. .titRight {
  252. display: flex;
  253. align-items: center;
  254. span:nth-child(1) {
  255. width: 40px;
  256. text-align: center;
  257. display: block;
  258. height: 30px;
  259. line-height: 30px;
  260. }
  261. }
  262. }
  263. .addContent {
  264. padding: 5px 13px;
  265. .imgIsShow {
  266. display: flex;
  267. justify-content: space-between;
  268. margin: 18px 0 22px 0;
  269. span {
  270. font-size: 14px;
  271. color: #666666;
  272. }
  273. }
  274. .deleteItem {
  275. border-radius: 4px;
  276. background: $mainColor;
  277. text-align: center;
  278. height: 36px;
  279. color: #ffffff;
  280. font-size: 14px;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. cursor: pointer;
  285. margin-bottom: 10px;
  286. span {
  287. font-size: 18px;
  288. color: #ffffff;
  289. margin-right: 5px;
  290. }
  291. }
  292. }
  293. .deleteItem {
  294. padding: 10px;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. background: #F6F7F9;
  299. cursor: pointer;
  300. color: $mainColor;
  301. font-size: 14px;
  302. span {
  303. font-size: 16px;
  304. margin-right: 5px;
  305. }
  306. }
  307. }
  308. }
  309. .textTit {
  310. height: 35px;
  311. line-height: 35px;
  312. font-size: 16px;
  313. color: #333333;
  314. font-weight: bold;
  315. }
  316. }
  317. ::v-deep .el-select {
  318. width: 100%;
  319. }
  320. .addImgBtn {
  321. border-radius: 4px;
  322. background: $mainColor;
  323. text-align: center;
  324. height: 36px;
  325. color: #ffffff;
  326. font-size: 14px;
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. cursor: pointer;
  331. margin-bottom: 30px;
  332. span {
  333. font-size: 20px;
  334. margin-right: 5px;
  335. }
  336. }
  337. .labelList {
  338. .addLabelBox {
  339. padding: 10px;
  340. }
  341. }
  342. }
  343. .numberGroup {
  344. .title{
  345. display: flex;
  346. justify-content: space-between;
  347. }
  348. ::v-deep .el-slider__input {
  349. width: 50px;
  350. }
  351. ::v-deep .el-slider__runway {
  352. height: 4px;
  353. margin: 18px 65px 18px 0;
  354. }
  355. ::v-deep .el-slider__bar {
  356. height: 4px;
  357. }
  358. ::v-deep .el-slider__button-wrapper {
  359. top: -17px;
  360. }
  361. ::v-deep .el-slider__button {
  362. width: 12px;
  363. height: 12px;
  364. }
  365. ::v-deep .el-input-number.is-without-controls .el-input__inner {
  366. padding: 10px;
  367. }
  368. }
  369. </style>