shopTop.vue 12 KB

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