From dce885689d308043450f199981722b5c80360fe7 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 28 十一月 2024 10:21:29 +0800 Subject: [PATCH] 题库购买 --- pages/cart/paymentPage/index.js | 81 ++++++++++++++++++++++++---------------- 1 files changed, 48 insertions(+), 33 deletions(-) diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index 2b42ac5..8a28a08 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -28,7 +28,6 @@ isPayComplete: false, type: '', onNorderSaleMethod: '', - ImmediatelyReceive: '', integral: 0, defaultVal: false, deductioRate: 0, @@ -54,7 +53,6 @@ selectedIds: options.selectedIds, onNorderSaleMethod: options.onNorderSaleMethod }) - console.log(this.data.onNorderSaleMethod, 'options'); this.getIntegral() this.getOrderByOrderNumData() this.getDataList() @@ -144,7 +142,6 @@ return intPartFormat + floatPart; }, getOrderByOrderNumData() { - console.log(this.data.orderNumber, 'this.data.orderNumber'); let query = { orderNum: this.data.orderNumber, fields: { @@ -154,25 +151,43 @@ } app.MG.store.getOrderByOrderNum(query).then(res => { this.setData({ - orderGoods: res.orderNumber - }) - this.setData({ - price: res.payPrice, + orderGoods: res.orderNumber, + price: res.totalPrice.toFixed(2), payPrice: res.payPrice.toFixed(2), - ImmediatelyReceive: res.payPrice }) + if (Number(this.data.payPrice) < Number(this.data.price)) { + this.handleChange() + } + console.log(res, "res") res.saleMethodLinks.forEach(item => { const type = item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product'; item.type = type; // 灏唗ype璁剧疆涓篿tem瀵硅薄鐨勫睘鎬э紝鑰屼笉鏄娇鐢╯etData item.paymentIcon = getPublicImage(item.orderSaleMethod.product.icon) - item.payPrice = this.numFormat(item.payPrice) + item.price = item.orderSaleMethod.price.toFixed(2) + if (item.orderSaleMethod.product.cmsTypeRefCode == 'jsek_digitalTextbooks') { + item.typeTxt = '鏁板瓧鏁欐潗' + item.productType = "鏁板瓧鏁欐潗" + } else if (item.orderSaleMethod.product.cmsTypeRefCode == 'jsek_digitalCourses') { + item.typeTxt = '鏁板瓧璇剧▼' + item.productType = "鏁板瓧璇剧▼" + } else { + item.typeTxt = '鐢靛瓙涔�' + item.productType = "鍥句功鏈嶅姟-鐢靛瓙涔�" + if (item.orderSaleMethod.type == 'createProductItemSaleMethod') { + item.typeTxt = '浜戝涔�' + item.productType = "鍥句功鏈嶅姟-浜戝涔�" + } + if (item.orderSaleMethod.cmsItemList.length && item.orderSaleMethod.cmsItemList[0].type == "questionBankFolder") { + item.typeTxt = '棰樺簱' + item.productType = "鍥句功鏈嶅姟-浜戞祴璇�" + } + } }) this.setData({ productList: res.saleMethodLinks, loading: false, hidden: false, }) - }) }, getDataList() { @@ -189,21 +204,25 @@ } } app.MG.store.getUserOrderList(data).then((res) => { - res.datas.forEach((item) => { this.data.myOrderOrderNumber.push(item.saleMethodLinks[0].orderSaleMethod.id) - console.log(this.data.myOrderOrderNumber); }) }) }, handleChange(e) { - this.setData({ - defaultVal: e.detail.value, - }); - console.log(this.data.defaultVal) + if (e) { + this.setData({ + defaultVal: e.detail.value, + }); + } else { + this.setData({ + defaultVal: true, + }); + } + if (this.data.defaultVal) { - let useBalance = Math.floor(this.data.payPrice * this.data.deductioRate); + let useBalance = Math.round(Number(this.data.payPrice) * Number(this.data.deductioRate)); if (useBalance >= this.data.integral) { this.setData({ currentBalance: this.data.integral, @@ -223,8 +242,8 @@ if (res) { this.setData({ payId: res.payList[0].id, - payPrice: res.payPrice, - deduct: (this.data.price - this.data.payPrice).toFixed(2), + payPrice: res.payPrice.toFixed(2), + deduct: (this.data.currentBalance / 100).toFixed(2), integral: this.data.integral - this.data.currentBalance, showIntegral: true }); @@ -236,10 +255,9 @@ payId: this.data.payId, } app.MG.store.delOrderPay(data).then(res => { - console.log(res, "鍙栨秷鐢ㄧН鍒�") if (res) { this.setData({ - payPrice: res.payPrice, + payPrice: res.payPrice.toFixed(2), showIntegral: false }); this.getIntegral() @@ -264,19 +282,15 @@ orderNum: this.data.orderGoods } app.MG.store.confirmOrder(query).then(res => { - console.log(res.orderNumber, 'res'); if (res.orderNumber) { let resOrderNum = { orderNum: res.orderNumber, platform: "WeChatAppCustom" }; - console.log(resOrderNum, 'resOrderNum'); // 鐢ㄦ埛鏈粦瀹氬井淇� 鎶�500 app.MG.store.makeWeChatPay(resOrderNum).then(payRes => { - console.log(payRes, 'payRes'); if (payRes) { const payVal = JSON.parse(payRes); - console.log(payVal); wx.requestPayment({ "appId": payVal.appId, "timeStamp": payVal.timeStamp, @@ -285,7 +299,6 @@ "signType": payVal.signType, "paySign": payVal.paySign, success: function (res) { - console.log('鏀粯鎴愬姛'); if (res.errMsg == 'requestPayment:ok') { that.setData({ isPaySuccess: true @@ -334,14 +347,16 @@ orderNum: this.data.orderGoods } app.MG.store.confirmOrder(query).then(res => { - Toast({ - context: this, - selector: '#t-toast', - message: '棰嗗彇鎴愬姛', - theme: 'success', - direction: 'column', + wx.showToast({ + title: '棰嗗彇鎴愬姛', + icon: 'success', + complete: res => { + setTimeout(() => { + wx.navigateBack() + }, 1000); + } }); - wx.navigateBack() + }) } }) \ No newline at end of file -- Gitblit v1.9.1