From cb15c57d0ff984f5a100cf25d560fb0a69c00984 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期二, 16 四月 2024 18:21:05 +0800 Subject: [PATCH] 音频bug4 --- pages/cart/paymentPage/index.js | 198 ++++++++++++++++++++++++++++--------------------- 1 files changed, 113 insertions(+), 85 deletions(-) diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index fcad534..06298eb 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -1,6 +1,9 @@ // pages/cart/paymentPage/index.js +import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp() -import { getPublicImage } from '../../../assets/js/middleGround/tool'; +import { + getPublicImage +} from '../../../assets/js/middleGround/tool'; import drawQrcode from './js/weapp.qrcode' Page({ @@ -8,6 +11,9 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + loading: true, + hidden: true, + myOrderOrderNumber: [], orderNumber: null, navBarHeight: '', barHeight: '', @@ -15,20 +21,17 @@ purchasedIds: [], productList: [], payPrice: '', - drawQrcodeText: 'https://www.baidu.com/', orderGoods: '', - - - confirmBtn: { content: '纭畾', variant: 'base' }, - dialogKey: 'false', - + isPaySuccess: false, + isPayComplete: false, + type: '', + onNorderSaleMethod: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { - const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -36,47 +39,12 @@ orderNumber: options.orderNumber, navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, - selectedIds: options.selectedIds + selectedIds: options.selectedIds, + onNorderSaleMethod: options.onNorderSaleMethod }) - console.log('鎺ユ敹鍒扮殑璁㈠崟鍙�:', this.data.orderNumber); - - - this.getOrderByOrderNum() - - - - - drawQrcode({ - - width: 200, // 蹇呴』锛屼簩缁寸爜瀹藉害锛屼笌canvas鐨剋idth淇濇寔涓�鑷� - - height: 200, // 蹇呴』锛屼簩缁寸爜楂樺害锛屼笌canvas鐨刪eight淇濇寔涓�鑷� - - canvasId: 'myQrcode', - - background: '#ffffff', // 闈炲繀椤伙紝浜岀淮鐮佽儗鏅鑹诧紝榛樿鍊肩櫧鑹� - - foreground: '#2bb15e', // 闈炲繀椤伙紝浜岀淮鐮佸墠鏅壊锛岄粯璁ゅ�奸粦鑹� '#000000' - - // ctx: wx.createCanvasContext('myQrcode'), // 闈炲繀椤伙紝缁樺浘涓婁笅鏂囷紝鍙�氳繃 wx.createCanvasContext('canvasId') 鑾峰彇锛寁1.0.0+鐗堟湰鏀寔 - - text: this.data.drawQrcodeText, // 蹇呴』锛屼簩缁寸爜鍐呭 - // v1.0.0+鐗堟湰鏀寔鍦ㄤ簩缁寸爜涓婄粯鍒跺浘鐗� - - image: { - // imageResource: '../../images/icon.png', // 鎸囧畾浜岀淮鐮佸皬鍥炬爣 - dx: 70, - dy: 70, - dWidth: 60, - dHeight: 60 - } - }) - - - - - - + console.log(this.data.onNorderSaleMethod, 'options'); + this.getOrderByOrderNumData() + this.getDataList() }, /** @@ -132,7 +100,8 @@ }, - getOrderByOrderNum() { + getOrderByOrderNumData() { + console.log(this.data.orderNumber, 'this.data.orderNumber'); let query = { orderNum: this.data.orderNumber, fields: { @@ -154,49 +123,108 @@ payPrice: res.payPrice.toFixed(2) }) res.saleMethodLinks.forEach(item => { + console.log(item.type, 'item.type'); + const type = item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product'; + item.type = type; // 灏唗ype璁剧疆涓篿tem瀵硅薄鐨勫睘鎬э紝鑰屼笉鏄娇鐢╯etData item.paymentIcon = getPublicImage(item.orderSaleMethod.product.icon) - console.log(item.orderSaleMethod.type); + console.log(item.type, 'item'); + }) + this.setData({ + productList: res.saleMethodLinks, + // type: item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' + loading: false, + hidden: false, + }) - this.setData({ - productList: res.saleMethodLinks, - type: item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' - }) - + }) + }, + 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() { - let query = { - orderNum: this.data.orderGoods - } - app.MG.store.confirmOrder(query).then(res => { - this.makeWeChatQrPayGet() - }) - // 璋冨彇寰俊浜岀淮鐮佹敮浠� - - }, - // 璋冨彇寰俊浜岀淮鐮佹敮浠� - makeWeChatQrPayGet() { - let query = { - orderNum: this.data.orderGoods - } - app.MG.store.makeWeChatQrPay(query).then((res) => { - - this.setData({ - drawQrcodeText: res + 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'); + 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() + } + } + }); + }) + } }) - this.data.dialogKey = true - console.log(this.data.drawQrcodeText, 'drawQrcodeText'); - }) - }, - showDialog(e) { - const { key } = e.currentTarget.dataset; - this.setData({ [key]: true, dialogKey: key }); - }, - closeDialog() { - const { dialogKey } = this.data; - this.setData({ [dialogKey]: false }); - }, + } + }, + // 椤甸潰杩斿洖 + navToBack() { + + // 杩斿洖 + wx.navigateBack() + }, }) \ No newline at end of file -- Gitblit v1.9.1