Commit b38a27f3ec7a7674bc160f7f760bcfd0b3b28794
1 parent
42375342ff
Exists in
master
详情页样式修改
Showing
5 changed files
with
54 additions
and
27 deletions
Show diff stats
src/pages/frameDetail/frameDetail.vue
... | ... | @@ -308,7 +308,10 @@ |
308 | 308 | @tap="toCart()" |
309 | 309 | class="botton_1" |
310 | 310 | > |
311 | - <image v-bind:src="imgShop.img"></image> | |
311 | + <view class="cart_icon"> | |
312 | + <image v-bind:src="imgShop.img"/> | |
313 | + <text>{{cartNumber}}</text> | |
314 | + </view> | |
312 | 315 | <view class="botton_image">购物车</view> |
313 | 316 | </view> |
314 | 317 | <view class="botton_2"> |
... | ... | @@ -396,12 +399,13 @@ export default { |
396 | 399 | this.parameter[5].slength = `${this.goodInfo.weight}mm` |
397 | 400 | this.tag = this.goodInfo.tag |
398 | 401 | this.test = this.goodInfo.prodIntro1 |
399 | - this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto"') | |
402 | + this.test = this.test.replace('/\<img/gi', '<img style="max-width:100%;height:auto"') | |
400 | 403 | // addCart |
401 | 404 | this.addCartList.price = this.goodInfo.priceArea.Min_Price |
402 | 405 | this.addCartList.sk_id = this.goodInfo.skuList[0].sk_id |
403 | 406 | this.addCartList.mp_id = this.goodInfo.glassData.mp_id |
404 | 407 | }) |
408 | + store.dispatch('cart/getCartList') | |
405 | 409 | // console.log(this.$store.state.user.userInfo.uid + 'ssss') |
406 | 410 | }, |
407 | 411 | computed: { |
... | ... | @@ -412,6 +416,9 @@ export default { |
412 | 416 | console.log(this.$store.state.read.goodInfo) |
413 | 417 | return this.$store.state.read.goodInfo |
414 | 418 | }, |
419 | + cartNumber() { | |
420 | + return this.$store.state.cart.cartList.length || 0 | |
421 | + }, | |
415 | 422 | }, |
416 | 423 | methods: { |
417 | 424 | // 前往购物车 |
... | ... | @@ -770,6 +777,26 @@ export default { |
770 | 777 | height: 100%; |
771 | 778 | text-align: center; |
772 | 779 | color: #989898; |
780 | + .cart_icon { | |
781 | + position: relative; | |
782 | + image { | |
783 | + | |
784 | + } | |
785 | + text { | |
786 | + position: absolute; | |
787 | + color: white; | |
788 | + font-size: 17px; | |
789 | + background-color: red; | |
790 | + min-height: 24px; | |
791 | + min-width:24px; | |
792 | + line-height: 24px; | |
793 | + right: -12%; | |
794 | + top: -12px; | |
795 | + text-align: center; | |
796 | + border-radius: 24px; | |
797 | + padding:2px; | |
798 | + } | |
799 | + } | |
773 | 800 | } |
774 | 801 | image { |
775 | 802 | width: 60%; | ... | ... |
src/static/tab-cart.png
src/store/modules/address.js
... | ... | @@ -14,7 +14,7 @@ const mutations = { |
14 | 14 | }, |
15 | 15 | DEFAULT: (state, data) => { |
16 | 16 | state.defaultInfo = data |
17 | - } | |
17 | + }, | |
18 | 18 | } |
19 | 19 | |
20 | 20 | const actions = { |
... | ... | @@ -28,12 +28,12 @@ const actions = { |
28 | 28 | fail: () => { |
29 | 29 | uni.showModal({ |
30 | 30 | content: '编辑失败', |
31 | - showCancel: false | |
31 | + showCancel: false, | |
32 | 32 | }) |
33 | 33 | }, |
34 | 34 | complete: (res) => { |
35 | 35 | console.log('complete status === > ', res) |
36 | - } | |
36 | + }, | |
37 | 37 | })) |
38 | 38 | }, |
39 | 39 | list({ commit }) { |
... | ... | @@ -45,9 +45,9 @@ const actions = { |
45 | 45 | fail: () => { |
46 | 46 | uni.showModal({ |
47 | 47 | content: '获取地址列表失败', |
48 | - showCancel: false | |
48 | + showCancel: false, | |
49 | 49 | }) |
50 | - } | |
50 | + }, | |
51 | 51 | }) |
52 | 52 | }, |
53 | 53 | details({ commit }, param) { |
... | ... | @@ -58,15 +58,15 @@ const actions = { |
58 | 58 | commit('DETAILS', res.data.data) |
59 | 59 | resolve({ |
60 | 60 | code: res.data.code, |
61 | - data: res.data.data | |
61 | + data: res.data.data, | |
62 | 62 | }) |
63 | 63 | }, |
64 | 64 | fail: () => { |
65 | 65 | uni.showModal({ |
66 | 66 | content: '获取地址信息失败', |
67 | - showCancel: false | |
67 | + showCancel: false, | |
68 | 68 | }) |
69 | - } | |
69 | + }, | |
70 | 70 | })) |
71 | 71 | }, |
72 | 72 | default({ commit }, param) { |
... | ... | @@ -76,22 +76,22 @@ const actions = { |
76 | 76 | success: (res) => { |
77 | 77 | resolve({ |
78 | 78 | code: res.data.code, |
79 | - data: res.data.data | |
79 | + data: res.data.data, | |
80 | 80 | }) |
81 | 81 | }, |
82 | 82 | fail: () => { |
83 | 83 | uni.showModal({ |
84 | 84 | content: '获取默认地址信息失败', |
85 | - showCancel: false | |
85 | + showCancel: false, | |
86 | 86 | }) |
87 | - } | |
87 | + }, | |
88 | 88 | })) |
89 | - } | |
89 | + }, | |
90 | 90 | } |
91 | 91 | |
92 | 92 | export default { |
93 | 93 | namespaced: true, |
94 | 94 | state, |
95 | 95 | mutations, |
96 | - actions | |
96 | + actions, | |
97 | 97 | } | ... | ... |
src/store/modules/cart.js
... | ... | @@ -4,7 +4,7 @@ import request from '../request' |
4 | 4 | const { cartList, cartModi, cartDel, cartAdd } = urlAlias |
5 | 5 | |
6 | 6 | const state = { |
7 | - cartList: [] | |
7 | + cartList: [], | |
8 | 8 | } |
9 | 9 | |
10 | 10 | const mutations = { |
... | ... | @@ -22,11 +22,12 @@ const mutations = { |
22 | 22 | console.log('mutations====>isadd', args) |
23 | 23 | state.cartList[args.index].num = args.num |
24 | 24 | console.log('the num', state.cartList[args.index].num) |
25 | - } | |
25 | + }, | |
26 | 26 | |
27 | 27 | } |
28 | 28 | |
29 | 29 | const actions = { |
30 | + // 获取购物车列表 | |
30 | 31 | getCartList({ commit }, param) { |
31 | 32 | request({ |
32 | 33 | url: cartList, |
... | ... | @@ -40,10 +41,10 @@ const actions = { |
40 | 41 | }, |
41 | 42 | complete: (res) => { |
42 | 43 | console.log('complete status === > ', res) |
43 | - } | |
44 | + }, | |
44 | 45 | }) |
45 | 46 | }, |
46 | - | |
47 | + // 修改购物车数量 | |
47 | 48 | modiCart({ commit }, param) { |
48 | 49 | const arg = Object.assign({ num: param.num }, param.args) |
49 | 50 | delete param.args |
... | ... | @@ -60,10 +61,10 @@ const actions = { |
60 | 61 | }, |
61 | 62 | complete: (res) => { |
62 | 63 | console.log('complete status === > ', res) |
63 | - } | |
64 | + }, | |
64 | 65 | }) |
65 | 66 | }, |
66 | - | |
67 | + // 删除购物车商品 | |
67 | 68 | delCart({ commit }, param) { |
68 | 69 | const arg = param.arg |
69 | 70 | delete param.arg |
... | ... | @@ -80,10 +81,10 @@ const actions = { |
80 | 81 | }, |
81 | 82 | complete: (res) => { |
82 | 83 | console.log('complete status === > ', res) |
83 | - } | |
84 | + }, | |
84 | 85 | }) |
85 | 86 | }, |
86 | - | |
87 | + // 添加到购物车 | |
87 | 88 | addCart({ commit }, param) { |
88 | 89 | console.log('请求接口开始') |
89 | 90 | request({ |
... | ... | @@ -99,15 +100,14 @@ const actions = { |
99 | 100 | }, |
100 | 101 | complete: (res) => { |
101 | 102 | console.log('complete status === > ', res) |
102 | - } | |
103 | + }, | |
103 | 104 | }) |
104 | - } | |
105 | - | |
105 | + }, | |
106 | 106 | } |
107 | 107 | |
108 | 108 | export default { |
109 | 109 | namespaced: true, |
110 | 110 | state, |
111 | 111 | mutations, |
112 | - actions | |
112 | + actions, | |
113 | 113 | } | ... | ... |
src/tab-cart.png
2.85 KB