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}} - 支持7天无理由退货 顺丰发货 - - ¥{{Number(item.nowPrice) * item.num}} - ¥{{item.oldPrice*item.num}} - - - - - {{checkedCartLst[index].num}} - + - - - - - - 规格 - - {{item.sku_name}}/ - - - 使用人 - {{item.peopleName}} - - 配送方式 快递 - 买家留言 - - - - - - + + + + + + {{item.p_name}} + 支持7天无理由退货 顺丰发货 + + ¥{{Number(item.nowPrice) * item.num}} + ¥{{item.oldPrice*item.num}} + + + - + {{checkedCartLst[index].num}} + + + + + + + + 规格 + + {{item.sku_name}}/ + + + 使用人 + {{item.peopleName}} + + 配送方式 快递 + 买家留言 + + + + + + 实付金额: - ¥{{totalPrice}} - - + ¥{{totalPrice}} + + { - total += item.nowPrice*item.num + this.$store.state.cart.checkedCartLst.map(item => { + total += item.nowPrice * item.num }) - return total - }else{ - return this.buyItem.real_price* this.count + return total + } else { + return this.buyItem.real_price * this.count } }, - buyItem(){ + buyItem() { return this.$store.state.cart.buyItem }, // checkedCartLst(){ @@ -341,17 +348,17 @@ export default { }, }, methods: { - counter(isadd,index) { + counter(isadd, index) { if (isadd) { - if(this.isCart =='true'){ + if (this.isCart == 'true') { this.checkedCartLst[index].num++ - }else{ - this.count++ + } else { + this.count++ } } else { - if(this.isCart =='true'){ - this.checkedCartLst[index].num<= 1 ? (this.disabled = true) : this.checkedCartLst[index].num-- - }else{ + if (this.isCart == 'true') { + this.checkedCartLst[index].num <= 1 ? (this.disabled = true) : this.checkedCartLst[index].num-- + } else { this.count <= 1 ? (this.disabled = true) : this.count-- } } @@ -372,24 +379,24 @@ export default { uni.showLoading({ title: '支付中', }) - if(this.isCart == 'true'){ + if (this.isCart == 'true') { const checkedGoods = [] const sk_id_arr = [] - this.checkedCartLst.map(item=>{ + this.checkedCartLst.map(item => { checkedGoods.push(item.pid) sk_id_arr.push(item.sk_id) }) store.dispatch('order/build', { - uid: this.$store.state.user.userInfo.uid, + uid: this.$store.state.user.userInfo.uid, address: JSON.stringify(this.addressInfo), - checkedGoods:checkedGoods, + checkedGoods: checkedGoods, sk_id_arr: sk_id_arr, totalPrice: this.totalPrice, }).then((res) => { this.pay(res.data) }) } - if(this.isCart == 'false'){ + if (this.isCart == 'false') { const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param store.dispatch('order/buyNow', { pid: skId.pid, @@ -762,7 +769,7 @@ export default { width: 100%; align-items: center; padding-left: 126rpx; - box-sizing: border-box; + box-sizing: border-box; .name { display: flex; justify-content: space-between; @@ -817,7 +824,7 @@ export default { bottom: 104rpx; } } -.last_zhanwei{ +.last_zhanwei { background: #f2f2f2; height: 60px; }