From c96612e8a63ecef9590be0f8b5199277ec94e5b9 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 18 九月 2024 18:43:12 +0800 Subject: [PATCH] 云学习购买目录,修改bug --- pages/cart/paymentPage/index.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 94 insertions(+), 4 deletions(-) diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index 9e747a2..8bece7c 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -21,13 +21,20 @@ selectedIds: '', purchasedIds: [], productList: [], + price: '', payPrice: '', orderGoods: '', isPaySuccess: false, isPayComplete: false, type: '', onNorderSaleMethod: '', - ImmediatelyReceive: '' + ImmediatelyReceive: '', + integral: 0, + defaultVal: false, + deductioRate: 0, + currentBalance: 0, + showIntegral: false + }, /** @@ -48,10 +55,22 @@ onNorderSaleMethod: options.onNorderSaleMethod }) console.log(this.data.onNorderSaleMethod, 'options'); + this.getIntegral() this.getOrderByOrderNumData() this.getDataList() }, - + getIntegral() { + app.MG.store + .getUserWallet({ + type: 'integral' + }) + .then((res) => { + this.setData({ + integral: res.balance, + deductioRate: res.exchangeRate + }); + }) + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ @@ -138,16 +157,33 @@ orderGoods: res.orderNumber }) this.setData({ + price: res.payPrice.toFixed(2), payPrice: res.payPrice.toFixed(2), ImmediatelyReceive: res.payPrice }) - console.log(this.data.ImmediatelyReceive); + console.log(1, res.saleMethodLinks); 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) - console.log(item, 'item'); + item.orderSaleMethod.price = this.numFormat(item.orderSaleMethod.price) + // + 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 = "鍥句功鏈嶅姟-浜戝涔�" + } + } }) this.setData({ productList: res.saleMethodLinks, @@ -178,6 +214,60 @@ }) }) }, + + handleChange(e) { + this.setData({ + defaultVal: e.detail.value, + }); + console.log(this.data.defaultVal) + if (this.data.defaultVal) { + let useBalance = Math.floor(this.data.payPrice * this.data.deductioRate); + if (useBalance >= this.data.integral) { + this.setData({ + currentBalance: this.data.integral, + }); + } else { + this.setData({ + currentBalance: useBalance, + }); + } + const data = { + orderNumber: this.data.orderNumber, + payMethod: "Wallet", + type: "integral", + payValue: this.data.currentBalance + } + app.MG.store.newOrderPay(data).then(res => { + if (res) { + this.setData({ + payId: res.payList[0].id, + payPrice: res.payPrice.toFixed(2), + deduct: (this.data.currentBalance / 100).toFixed(2), + integral: this.data.integral - this.data.currentBalance, + showIntegral: true + }); + console.log(this.data.price, this.data.payPrice, 123) + } + }) + } else { + const data = { + orderNumber: this.data.orderNumber, + payId: this.data.payId, + } + app.MG.store.delOrderPay(data).then(res => { + console.log(res, "鍙栨秷鐢ㄧН鍒�") + if (res) { + this.setData({ + payPrice: res.payPrice.toFixed(2), + showIntegral: false + }); + this.getIntegral() + } + }) + } + }, + + confirmOrderGet() { if (this.data.myOrderOrderNumber.includes(parseInt(this.data.onNorderSaleMethod))) { Toast({ -- Gitblit v1.9.1