From 678d6b48aaed6062bd4e9d050ebcaf689484f806 Mon Sep 17 00:00:00 2001
From: mullins <476823686@qq.com>
Date: Wed, 10 Jun 2020 00:10:02 +0800
Subject: [PATCH] =?UTF-8?q?async=E5=87=BD=E6=95=B0=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/cart/cart.vue | 142 +++++++++++------------
src/pages/confirmOrder/confirmOrder.vue | 197 +++++++++++++++++---------------
2 files changed, 173 insertions(+), 166 deletions(-)
diff --git a/src/pages/cart/cart.vue b/src/pages/cart/cart.vue
index 95f0c9f..f3f1e12 100644
--- a/src/pages/cart/cart.vue
+++ b/src/pages/cart/cart.vue
@@ -130,7 +130,7 @@ export default {
isCart: Number,
sk_id: String,
mp_id: String,
- isShowBottom: false, // 底部弹窗开关
+ isShowBottom: false, // 底部弹窗开关
cart_id: Number,
maxCount: 20,
cartIndex: Number,
@@ -145,88 +145,88 @@ export default {
return false
},
goodInfo () {
- return this.$store.state.read.goodInfo
+ return this.$store.state.read.goodInfo
},
totalPrice() {
let totalPrice = 0
this.cartList.forEach((item) => {
- if (item.isChecked) {
+ if (item.isChecked) {
totalPrice += item.nowPrice * item.num
- }
+ }
})
return totalPrice
},
},
- onShow() {
+ onShow: async function() {
await this.$store.dispatch('cart/getCartList', {
uid: this.$store.state.user.userInfo.uid, // 用户id
})
this.cartList = this.$store.state.cart.cartList
this.cartList.forEach((item) => {
- item.isChecked = false
+ item.isChecked = false
})
},
onLoad: async function() {
},
methods: {
- // 全选按钮
- pClick() {
- const pStatus = !this.cartList.find(item => !item.isChecked)
- const oldList = this.cartList
- oldList.forEach((item, index) => {
- item.isChecked = !pStatus
- this.cartList.splice(index, 1, item)
- })
- },
- // 单选按钮
- childClick(type, index) {
- this.cartList[index].isChecked = !this.cartList[index].isChecked
- // vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发
- this.cartList.splice(index, 1, this.cartList[index])
- },
- // 修改购物车
- chooseCartModi(mp_id, sk_id, price, pid, num, cart_id, index) {
- // console.log('modi',mp_id,sk_id,price,pid,num,cart_id)
- store.dispatch('cart/modiCart', {
- uid: this.$store.state.user.userInfo.uid,
- openid: this.$store.state.user.userInfo.openid,
- mp_id: mp_id,
- sk_id: sk_id,
- price: price,
- pid: pid,
- num: num,
- cart_id: cart_id,
+ // 全选按钮
+ pClick() {
+ const pStatus = !this.cartList.find(item => !item.isChecked)
+ const oldList = this.cartList
+ oldList.forEach((item, index) => {
+ item.isChecked = !pStatus
+ this.cartList.splice(index, 1, item)
+ })
+ },
+ // 单选按钮
+ childClick(type, index) {
+ this.cartList[index].isChecked = !this.cartList[index].isChecked
+ // vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发
+ this.cartList.splice(index, 1, this.cartList[index])
+ },
+ // 修改购物车
+ chooseCartModi(mp_id, sk_id, price, pid, num, cart_id, index) {
+ // console.log('modi',mp_id,sk_id,price,pid,num,cart_id)
+ store.dispatch('cart/modiCart', {
+ uid: this.$store.state.user.userInfo.uid,
+ openid: this.$store.state.user.userInfo.openid,
+ mp_id: mp_id,
+ sk_id: sk_id,
+ price: price,
+ pid: pid,
+ num: num,
+ cart_id: cart_id,
args: {
- index: index,
+ index: index,
},
- })
- this.$nextTick(function() {
- store.dispatch('cart/getCartList', {
- uid: this.$store.state.user.userInfo.uid, // 用户id
- }).then(() => {
+ })
+ this.$nextTick(function() {
+ store.dispatch('cart/getCartList', {
+ uid: this.$store.state.user.userInfo.uid, // 用户id
+ }).then(() => {
this.cartList = this.$store.state.cart.cartList
})
- })
- },
- // 底部弹窗开关
- showBottom(isCart, pid, skId, mp_id, cart_id, index) {
- store.dispatch('read/fetch', {
+ })
+ },
+ // 底部弹窗开关
+ showBottom(isCart, pid, skId, mp_id, cart_id, index) {
+ store.dispatch('read/fetch', {
pid,
sk_id: skId,
- }).then(() => {
- this.cartIndex = index
- this.sk_id = skId
- this.pid = pid
- this.mp_id = mp_id
- this.isCart = isCart
- this.cart_id = cart_id
- this.isShowBottom = true
- })
- },
- closeBottom() {
- this.isShowBottom = false
- },
+ }).then(() => {
+ this.cartIndex = index
+ this.sk_id = skId
+ this.pid = pid
+ this.mp_id = mp_id
+ this.isCart = isCart
+ this.cart_id = cart_id
+ this.isShowBottom = true
+ })
+ },
+ closeBottom() {
+ this.isShowBottom = false
+ },
toGoods(id, skId) {
uni.navigateTo({
url: '../details/details?pid=' + id + '&sk_id=' + skId,
@@ -300,20 +300,20 @@ export default {
},
delCart(cart_id, index) {
cart_id = parseInt(cart_id)
- uni.showModal({
- title: '是否删除该商品',
- success: function (res) {
- if (res.confirm) {
- store.dispatch('cart/delCart', {
- uid: this.$store.state.user.userInfo.uid,
- openid: this.$store.state.user.userInfo.openid,
- cart_id: cart_id, // 要修改的购物车id
- arg: index, // 由于action 传参是能接收两参数,因此将index放入对象
- })
- }
- }.bind(this),
- })
- // this.cartList.splice(index,1)
+ uni.showModal({
+ title: '是否删除该商品',
+ success: function (res) {
+ if (res.confirm) {
+ store.dispatch('cart/delCart', {
+ uid: this.$store.state.user.userInfo.uid,
+ openid: this.$store.state.user.userInfo.openid,
+ cart_id: cart_id, // 要修改的购物车id
+ arg: index, // 由于action 传参是能接收两参数,因此将index放入对象
+ })
+ }
+ }.bind(this),
+ })
+ // this.cartList.splice(index,1)
},
},
}
diff --git a/src/pages/confirmOrder/confirmOrder.vue b/src/pages/confirmOrder/confirmOrder.vue
index f553122..f7522fa 100644
--- a/src/pages/confirmOrder/confirmOrder.vue
+++ b/src/pages/confirmOrder/confirmOrder.vue
@@ -52,58 +52,66 @@
>
非常戴镜
-
-
-
-
-
- {{item.p_name}}
-
-
- ¥{{Number(item.nowPrice) * item.num}}
- ¥{{item.oldPrice*item.num}}
-
-
- -
- {{checkedCartLst[index].num}}
- +
-
-
-
-
-
- 规格
-
- {{item.sku_name}}/
-
-
- 使用人
- {{item.peopleName}}
-
- 配送方式 快递
- 买家留言
-
-
-
-
-
-
+
+
+
+
+
+ {{item.p_name}}
+
+
+ ¥{{Number(item.nowPrice) * item.num}}
+ ¥{{item.oldPrice*item.num}}
+
+
+ -
+ {{checkedCartLst[index].num}}
+ +
+
+
+
+
+
+ 规格
+
+ {{item.sku_name}}/
+
+
+ 使用人
+ {{item.peopleName}}
+
+ 配送方式 快递
+ 买家留言
+
+
+
+
+
+