Commit 37f3387c9a521db64ac886200ccb0aa1aae1cfda
1 parent
7f3de0e04f
Exists in
master
购物车支付
Showing
2 changed files
with
42 additions
and
22 deletions
Show diff stats
src/components/CommodityCard/CommodityCard.vue
src/pages/confirmOrder/confirmOrder.vue
... | ... | @@ -73,7 +73,7 @@ |
73 | 73 | type="default" |
74 | 74 | @click="counter(false,index)" |
75 | 75 | >-</view> |
76 | - <text>{{count}}</text> | |
76 | + <text>{{checkedCartLst[index].num}}</text> | |
77 | 77 | <view |
78 | 78 | class="btn" |
79 | 79 | type="default" |
... | ... | @@ -270,13 +270,16 @@ export default { |
270 | 270 | } |
271 | 271 | }, |
272 | 272 | onLoad({ pid, addressId,isCart ,count,name}) { |
273 | - this.pid = pid; | |
273 | + if(isCart == 'false'){ | |
274 | + | |
275 | + this.pid = pid; | |
276 | + store.dispatch('read/fetch', { | |
277 | + pid, | |
278 | + }) | |
279 | + } | |
274 | 280 | this.count = count; |
275 | 281 | this.name = name; |
276 | 282 | this.isCart = isCart; |
277 | - store.dispatch('read/fetch', { | |
278 | - pid, | |
279 | - }) | |
280 | 283 | |
281 | 284 | console.log('++++++++++++'+pid,addressId,isCart) |
282 | 285 | this.checkedCartLst = this.$store.state.cart.checkedCartLst |
... | ... | @@ -306,7 +309,6 @@ export default { |
306 | 309 | }, |
307 | 310 | computed: { |
308 | 311 | totalPrice(){ |
309 | - // console.log('isCart',this.isCart) | |
310 | 312 | if(this.isCart == 'true'){ |
311 | 313 | let total = 0 |
312 | 314 | this.$store.state.cart.checkedCartLst.map(item =>{ |
... | ... | @@ -360,7 +362,7 @@ export default { |
360 | 362 | url: `../address/addressList?edit=${1}`, |
361 | 363 | success: res => {}, |
362 | 364 | fail: error => { |
363 | - // console.log('跳转到地址列表页面失败====>', error) | |
365 | + console.log('跳转到地址列表页面失败====>', error) | |
364 | 366 | }, |
365 | 367 | complete: () => {}, |
366 | 368 | }) |
... | ... | @@ -370,20 +372,38 @@ export default { |
370 | 372 | uni.showLoading({ |
371 | 373 | title: '支付中', |
372 | 374 | }) |
373 | - // console.log('this', this.$store.state) | |
374 | - const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param | |
375 | - store.dispatch('order/buyNow', { | |
376 | - pid: skId.pid, | |
377 | - sk_id: skId.sk_id, | |
378 | - number: this.count, | |
379 | - mp_id: mpId, | |
380 | - address: JSON.stringify(this.addressInfo), | |
381 | - totalPrice: this.totalPrice, | |
382 | - liuyan: this.note, | |
383 | - dir: 1, | |
384 | - }).then((res) => { | |
385 | - this.pay(res.data) | |
386 | - }) | |
375 | + if(this.isCart == 'true'){ | |
376 | + const checkedGoods = [] | |
377 | + const sk_id_arr = [] | |
378 | + this.checkedCartLst.map(item=>{ | |
379 | + checkedGoods.push(item.pid) | |
380 | + sk_id_arr.push(item.sk_id) | |
381 | + }) | |
382 | + store.dispatch('order/build', { | |
383 | + uid: this.$store.state.user.userInfo.uid, | |
384 | + address: JSON.stringify(this.addressInfo), | |
385 | + checkedGoods:checkedGoods, | |
386 | + sk_id_arr: sk_id_arr, | |
387 | + totalPrice: this.totalPrice, | |
388 | + }).then((res) => { | |
389 | + this.pay(res.data) | |
390 | + }) | |
391 | + } | |
392 | + if(this.isCart == 'false'){ | |
393 | + const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param | |
394 | + store.dispatch('order/buyNow', { | |
395 | + pid: skId.pid, | |
396 | + sk_id: skId.sk_id, | |
397 | + number: this.count, | |
398 | + mp_id: mpId, | |
399 | + address: JSON.stringify(this.addressInfo), | |
400 | + totalPrice: this.totalPrice, | |
401 | + liuyan: this.note, | |
402 | + dir: 1, | |
403 | + }).then((res) => { | |
404 | + this.pay(res.data) | |
405 | + }) | |
406 | + } | |
387 | 407 | }, |
388 | 408 | // 支付 |
389 | 409 | pay(res) { | ... | ... |