From 1dd20a03809bda9114ca5667efd8bae62c29fc91 Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Tue, 19 Mar 2024 11:17:53 +0800 Subject: [PATCH] 1 --- miniprogram/api/pay/pay.js | 12 +++++ .../pages/meeting/pay/waitPay/waitPay.js | 45 ++++++++++++------- 2 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 miniprogram/api/pay/pay.js diff --git a/miniprogram/api/pay/pay.js b/miniprogram/api/pay/pay.js new file mode 100644 index 0000000..3ebf39f --- /dev/null +++ b/miniprogram/api/pay/pay.js @@ -0,0 +1,12 @@ +import { + request +} from '../selfRequest'; + +// 唤起支付需要的参数 +export function wxPaySignRq(data) { + return request({ + url: '/meeting/wxPay/paySign', + method: "post", + data + }); +} diff --git a/miniprogram/pages/meeting/pay/waitPay/waitPay.js b/miniprogram/pages/meeting/pay/waitPay/waitPay.js index a2480ea..f78887d 100644 --- a/miniprogram/pages/meeting/pay/waitPay/waitPay.js +++ b/miniprogram/pages/meeting/pay/waitPay/waitPay.js @@ -5,6 +5,10 @@ import { selectReservationByIdRq, } from "../../../../api/meeting/meetingRoom.js" +import { + wxPaySignRq +} from "../../../../api/pay/pay.js" + Page({ /** @@ -83,22 +87,33 @@ Page({ // 确认支付 payComplete() { let _this = this; - meetingRoomPayOrderRq({ - id: _this.data.id + wxPaySignRq({ + prepayId: _this.data.detail.prepayId }).then(res => { - console.log('meetingRoomPayOrderRq', res); - if (res.code == 0) { - wx.reLaunch({ - url: '/pages/meeting/pay/waitComplete/waitComplete', - }) - } else { - // 消息提示 - Notify({ - message: res.msg, - color: '#FB4B4B', - background: '#FBE9E9', - duration: 3000, - }); + console.log('wxPaySignRq', res); + // 唤起支付 + _this.callPay(res.data) + }) + }, + + // 唤起支付 + callPay(data) { + wx.requestPayment({ + timeStamp: data.timeStamp, + nonceStr: data.nonceStr, + package: data.prepayId, + signType: data.signType, + paySign: data.paySign, + success(res) { + console.log('success' ,res ); + + }, + fail(res) { + console.log('fail' ,res ); + + }, + complete(res) { + console.log('complete' , res); } }) },