From 36e5592037888e5b54ebfd4874c987d8f671e68f Mon Sep 17 00:00:00 2001 From: BigBoss <2280520255@qq.com> Date: Mon, 8 Jun 2020 18:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BottomSheet/BottomSheet.vue | 7 +- src/pages.json | 8 ++ src/pages/cart/cart.vue | 13 +-- src/pages/confirmOrder/confirmOrder.vue | 4 +- src/pages/details/details.vue | 17 ++-- src/pages/myOrder/components/OrderCard.vue | 75 +--------------- src/pages/myOrderPaying/myOrderPaying.vue | 132 ++++++++++++++++++++++++----- src/store/modules/orderRead.js | 6 +- 8 files changed, 149 insertions(+), 113 deletions(-) diff --git a/src/components/BottomSheet/BottomSheet.vue b/src/components/BottomSheet/BottomSheet.vue index f03f608..dae83cd 100644 --- a/src/components/BottomSheet/BottomSheet.vue +++ b/src/components/BottomSheet/BottomSheet.vue @@ -492,10 +492,11 @@ import store from '@/store' j += this.current[i] } } + const price = this.skuList.filter(item=>item.sk_id == this.skuList[j].sk_id)[0].real_price let sk_id = this.skuList[j].sk_id - console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU) - console.log('mp_id',this.mp_id,'数量',this.count) - this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id)//添加购物车 + // console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU) + // console.log('mp_id',this.mp_id,'数量',this.count) + this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id,price)//添加购物车 this.$emit("closeBottom")//关闭弹窗 }, onClickLoveItem(index,name){ diff --git a/src/pages.json b/src/pages.json index 1e1cc69..8bc07a1 100644 --- a/src/pages.json +++ b/src/pages.json @@ -153,6 +153,14 @@ "pages/address/addAddress", "pages/address/addressList" ] + }, + { + "root": "pages/myOrder", + "name": "pack3", + "pages": [ + "pages/myOrder/myOrder", + "pages/myOrderPaying/myOrderPaying" + ] } ], "globalStyle": { diff --git a/src/pages/cart/cart.vue b/src/pages/cart/cart.vue index 04d345d..21f4b19 100644 --- a/src/pages/cart/cart.vue +++ b/src/pages/cart/cart.vue @@ -180,13 +180,14 @@ export default { args: { index: index, }, + }) + this.$nextTick(function(){ + store.dispatch('cart/getCartList', { + uid: this.$store.state.user.userInfo.uid, // 用户id + }).then(()=>{ + this.cartList = this.$store.state.cart.cartList; + }) }) - store.dispatch('cart/getCartList', { - uid: this.$store.state.user.userInfo.uid, // 用户id - }) - - this.$forceUpdate() - // console.log('21212121212',this.cartList) }, //底部弹窗开关 showBottom(isCart,pid,skId,mp_id,cart_id,index){ diff --git a/src/pages/confirmOrder/confirmOrder.vue b/src/pages/confirmOrder/confirmOrder.vue index 9985847..f553122 100644 --- a/src/pages/confirmOrder/confirmOrder.vue +++ b/src/pages/confirmOrder/confirmOrder.vue @@ -451,7 +451,7 @@ export default { }) // 跳转订单详情页->状态 待收货 uni.reLaunch({ - url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=1&isPay=1`, + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`, }) }, fail: (res) => { @@ -462,7 +462,7 @@ export default { }) // 跳转订单详情页->状态 待付款 uni.reLaunch({ - url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=0&isPay=1`, + url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`, }) }, complete: () => { diff --git a/src/pages/details/details.vue b/src/pages/details/details.vue index 21343af..b55cb88 100644 --- a/src/pages/details/details.vue +++ b/src/pages/details/details.vue @@ -420,13 +420,16 @@ export default { }) }, // 加入购物车 - addCart (mpId, num, checkedSKU, skId) { - this.addCartList.mp_id = mpId - this.addCartList.sk_id = skId - this.addCartList.num = num - this.addCartList.checkedSKU = checkedSKU - console.log('添加购物车的参数', this.addCartList) - store.dispatch('cart/addCart', this.addCartList).then((res) => { + addCart (mpId, num, checkedSKU, skId,price) { + const addCartList = {} + addCartList.mp_id = mpId + addCartList.sk_id = skId + addCartList.num = num + addCartList.checkedSKU = checkedSKU + addCartList.pid = this.pid + addCartList.price = price + console.log('添加购物车的参数', addCartList) + store.dispatch('cart/addCart', addCartList).then((res) => { if (res.code === 1) { uni.showToast({ title: '添加成功~', diff --git a/src/pages/myOrder/components/OrderCard.vue b/src/pages/myOrder/components/OrderCard.vue index 44c25d3..29d5ada 100644 --- a/src/pages/myOrder/components/OrderCard.vue +++ b/src/pages/myOrder/components/OrderCard.vue @@ -30,7 +30,7 @@ 已完成 - + {{orderInfo.p_name}} @@ -116,74 +116,7 @@ /** * 订单数据 */ - order: { - // orderId: Number, - // img: String, - // name: String, - // originCost:String, - // price: String, - // orderType:Number, - // buyNum:Number, - finished_time: null, - is_refound: String, - mch_id: String, - money_of_dcw: String, - money_of_partner: String, - money_of_shop: String, - orderJudge: Boolean, - order_info: { - address:{ - cityName: String, - countyName: String, - detailInfo: String, - errMsg: String, - nationalCode: String, - postalCode: String, - provinceName: String, - telNumber: String, - userName: String, - }, - cartinfo: ["127"], - keyname: "330_1588911391", - lefttime: Number, - list:[ - { - cart_id: "127", - imgUrl: String, - img_index_url: null, - memo: String, - mp_id: String, - nowPrice: String, - num: String, - oldPrice: Number, - p_discount: String, - p_name: String, - p_root_index: String, - p_sale_price: String, - peopleName: String, - pics: ["79_0_D122D2.jpg","79_1_E0A1ED.jpg","79_2_B00B3D.jpg","79_3_B2CF21.jpg","79_4_33AD1B.jpg"], - pid: String, - sk_id: String, - } - ], - orderDesc: String, - total_fee: Number, - }, - partner_uid: String, - pay_cate: String, - pay_id: String, - pay_time: String, - pay_wood_desc: String, - pay_wood_id: String, - prepay_id: String, - re_check_staus: String, - shopid: String, - split_userid: String, - status: String, - // status0待付款 1已付款 待收货 2 已收货待评价 3 已评价 - total_fee: String, - uid: String, - }, + order: {}, /** * 当前选择 */ @@ -200,7 +133,7 @@ return this.order.status }, orderInfoList(){ - console.log('this.order.order_info', this.order) + console.log('orderInfoList', this.order.order_info) return this.order.order_info } }, diff --git a/src/pages/myOrderPaying/myOrderPaying.vue b/src/pages/myOrderPaying/myOrderPaying.vue index 67623c1..f049325 100644 --- a/src/pages/myOrderPaying/myOrderPaying.vue +++ b/src/pages/myOrderPaying/myOrderPaying.vue @@ -139,24 +139,26 @@ export default { uid: "", openid: "", lefttime: 0, - isPay: 0 + isPay: 0, + orderInfo:Object }; }, - onLoad: function ({payId,state,isPay}) { - console.log('++++++++++++++++++',payId,state,isPay) + onLoad:async function ({payId,status,isPay}) { + // console.log('++++++++++++++++++',payId,status,isPay) this.payId = payId - this.status = state + this.status = status this.isPay = isPay const openid = uni.getStorageSync('openid') - const uid = this.$store.state.user.uid + const uid = this.$store.state.user.userInfo.uid this.uid = uid this.openid = openid - store.dispatch('orderRead/getOrderInfo', { + await store.dispatch('orderRead/getOrderInfo', { pay_id: this.payId, - uid: "1", + uid: uid, openid: openid - }); - // this.orderInfo = this.$store.state.orderRead.orderInfo + }); + console.log(this.$store.state.orderRead.orderInfo) + this.orderInfo = this.$store.state.orderRead.orderInfo }, // 若从支付页面跳转过来,返回直接返回到首页 onBackPress(option) { @@ -168,14 +170,8 @@ export default { } }, computed: { - // 获取订单详细信息 - orderInfo() { - console.log("orderInfo", this.$store.state.orderRead.orderInfo); - return this.$store.state.orderRead.orderInfo || {}; - }, orderInfoList () { - const orderInfoList = this.$store.state.orderRead.orderInfo.order_info.list - return orderInfoList + return this.orderInfo.order_info.list }, // 获取订单地址信息 orderAddressInfo () { @@ -206,25 +202,119 @@ export default { }, cancleOrder() { const uid = this.uid; - const openid = this.openid; + const openid = this.openid; + const keyname = this.orderInfo.keyname + console.log(this.orderInfo) uni.showModal({ title: "提示", content: "现在取消,订单不可恢复哦,确认取消吗?", success: function(res) { if (res.confirm) { store.dispatch("cancelOrder/cancel", { - keyname: "1", + keyname: keyname, uid: uid, openid: openid - }); + }); + uni.navigateBack({ + delta:1 + }) } else if (res.cancel) { console.log("用户点击取消"); } } }); }, - paylog() {}, - confirmOrder() { + paylog() { + console.log('pay',this.orderInfo) + // const { data, exKeyName: keyName } = res + // const uid = uni.getStorageSync('uid') + // const timeStamp = new Date().getTime().toString() + // const nonceStr = 'asfafasfasfasfasf' + // // 支付参数 + // const fieldSet = { + // openid: this.$store.state.user.userInfo.openid, + // uid: this.$store.state.user.userInfo.uid, + // shopid: 0, + // payCate: 2020, + // payMoney: this.totalPrice, + // payWoodId: `fcdj-${uid}-${keyName}`, + // payWoodDesc: '在【非常戴镜】的微信付款凭证', + // nonceStr, + // signType: 'MD5', + // app_uid: 2020, + // timeStamp, + // keyname: keyName, + // billInfo: JSON.stringify(data), + // } + // // 请求后台支付接口 + // store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => { + // if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') { + // const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}` + // const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789' + + // // 微信支付接口 + // uni.requestPayment({ + // appId: data.appid, + // timeStamp, + // nonceStr, + // total_fee: this.totalPrice, + // package: `prepay_id=${data.prepay_id}`, + // signType: 'MD5', + // paySign: MD5Util.MD5(stringSignTemp).toUpperCase(), + // success: (res) => { + // // 支付成功 + // uni.showModal({ + // content: '支付成功', + // showCancel: false, + // }) + // // 跳转订单详情页->状态 待收货 + // uni.reLaunch({ + // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`, + // }) + // }, + // fail: (res) => { + // // 支付失败 + // uni.showModal({ + // content: '支付失败', + // showCancel: false, + // }) + // // 跳转订单详情页->状态 待付款 + // uni.reLaunch({ + // url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`, + // }) + // }, + // complete: () => { + // uni.hideLoading() + // }, + // }) + // } else { + // uni.showModal({ + // content: '支付失败', + // showCancel: false, + // }) + // console.log('支付失败') + // uni.hideLoading() + // } + // }) + + //修改订单状态 待付款==>待收货 + store.dispatch("statusConfirm/confirm", { + uid: this.uid, + openid: this.openid, + oldway: "0", + way: "1", + pay_id: this.payId, + judgeContent: "", + orderInfo: this.orderInfo.order_info + }) + .then( + setTimeout(() => { + uni.navigateBack(); + }, 1500) + ); + }, + confirmOrder() { + //确认收货 way1 ==>way2 store .dispatch("statusConfirm/confirm", { uid: this.uid, diff --git a/src/store/modules/orderRead.js b/src/store/modules/orderRead.js index 095302d..9de17af 100644 --- a/src/store/modules/orderRead.js +++ b/src/store/modules/orderRead.js @@ -17,14 +17,14 @@ const mutations = { const actions = { getOrderInfo({ commit }, param) { - request({ + return new Promise ((resolve) => request({ url: orderRead, data: param, success: (res) => { commit("INIT", res.data.data) - console.log('res',res) + resolve(res.data.data) } - }) + })) } } -- 2.0.0