From dc934dfd63fecff84d0bf996418e041b9bd4ea59 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 30 四月 2024 18:16:13 +0800 Subject: [PATCH] bug修改 --- pages/cart/paymentPage/index.js | 202 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 138 insertions(+), 64 deletions(-) diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index de51373..645549c 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -1,15 +1,20 @@ // pages/cart/paymentPage/index.js +import Toast from 'tdesign-miniprogram/toast/index'; + const app = getApp() import { getPublicImage } from '../../../assets/js/middleGround/tool'; -import drawQrcode from './js/weapp.qrcode' + Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + loading: true, + hidden: true, + myOrderOrderNumber: [], orderNumber: null, navBarHeight: '', barHeight: '', @@ -20,13 +25,21 @@ orderGoods: '', isPaySuccess: false, isPayComplete: false, - type: '' + type: '', + onNorderSaleMethod: '', + ImmediatelyReceive: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + + wx.setNavigationBarTitle({ + title: '鎻愪氦璁㈠崟' + }); + + const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -34,10 +47,12 @@ orderNumber: options.orderNumber, navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, - selectedIds: options.selectedIds + selectedIds: options.selectedIds, + onNorderSaleMethod: options.onNorderSaleMethod }) - console.log('鎺ユ敹鍒扮殑璁㈠崟鍙�:', this.data.orderNumber); + console.log(this.data.onNorderSaleMethod, 'options'); this.getOrderByOrderNumData() + this.getDataList() }, /** @@ -94,13 +109,12 @@ getOrderByOrderNumData() { + console.log(this.data.orderNumber, 'this.data.orderNumber'); let query = { orderNum: this.data.orderNumber, fields: { content: [], subtitle: [], - - } } app.MG.store.getOrderByOrderNum(query).then(res => { @@ -112,81 +126,141 @@ console.log(res.payPrice); this.setData({ - payPrice: res.payPrice.toFixed(2) + payPrice: res.payPrice.toFixed(2), + ImmediatelyReceive: res.payPrice }) + console.log(this.data.ImmediatelyReceive); res.saleMethodLinks.forEach(item => { + // console.log(item.type, 'item.type'); - const type = item.type == 'createProductItemSaleMethod' ? 'item' : 'product'; + const type = item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product'; item.type = type; // 灏唗ype璁剧疆涓篿tem瀵硅薄鐨勫睘鎬э紝鑰屼笉鏄娇鐢╯etData item.paymentIcon = getPublicImage(item.orderSaleMethod.product.icon) - console.log(item.type, 'item'); - - }) this.setData({ productList: res.saleMethodLinks, // type: item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' + loading: false, + hidden: false, + }) + + }) + }, + getDataList() { + let data = { + start: 0, + size: 999, + filterList: [{ + field: 'State', + value: 'WaitPay' + }], + sort: { + type: 'Desc', + field: 'CreateDate' + } + } + 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); }) }) }, confirmOrderGet() { - var that = this; + if (this.data.myOrderOrderNumber.includes(parseInt(this.data.onNorderSaleMethod))) { + Toast({ + context: this, + selector: '#t-toast', + message: '宸茬粡鍦ㄨ鍗曚腑', + theme: 'warning', + direction: 'column', + }); + } else { + var that = this; + let query = { + 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, + "nonceStr": payVal.nonceStr, + "package": payVal.package, + "signType": payVal.signType, + "paySign": payVal.paySign, + success: function (res) { + console.log('鏀粯鎴愬姛'); + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPaySuccess: true + }) + } + }, + fail: function (res) { + console.log('鏀粯澶辫触'); + }, + // 鏃犺鏀粯鎴愬姛澶辫触閮戒細璋冪敤 + "complete": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPayComplete: true + }) + } + if (that.data.isPaySuccess && that.data.isPayComplete) { + that.navToBack() + } + } + }); + } else { + Toast({ + context: this, + selector: '#t-toast', + message: '鏀粯澶辫触', + theme: 'warning', + direction: 'column', + }); + } + + }) + } + }) + } + + }, + // 椤甸潰杩斿洖 + navToBack() { + this.getOrderByOrderNumData() + // 杩斿洖 + wx.navigateBack() + }, + onReceive() { let query = { 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'); - const payVal = JSON.parse(payRes); - wx.requestPayment({ - "appId": payVal.appId, - "timeStamp": payVal.timeStamp, - "nonceStr": payVal.nonceStr, - "package": payVal.package, - "signType": payVal.signType, - "paySign": payVal.paySign, - success: function (res) { - console.log('鏀粯鎴愬姛'); - if (res.errMsg == 'requestPayment:ok') { - that.setData({ - isPaySuccess: true - }) - } - }, - fail: function (res) { - console.log('鏀粯澶辫触'); - }, - // 鏃犺鏀粯鎴愬姛澶辫触閮戒細璋冪敤 - "complete": function (res) { - if (res.errMsg == 'requestPayment:ok') { - that.setData({ - isPayComplete: true - }) - } - if (that.data.isPaySuccess && that.data.isPayComplete) { - that.navToBack() - } - } - }); - }) - } - + Toast({ + context: this, + selector: '#t-toast', + message: '棰嗗彇鎴愬姛', + theme: 'success', + direction: 'column', + }); + wx.navigateBack() }) - // 璋冨彇寰俊浜岀淮鐮佹敮浠� - }, - // 椤甸潰杩斿洖 - navToBack() { - - // 杩斿洖 - wx.navigateBack() - }, + } }) \ No newline at end of file -- Gitblit v1.9.1