// 仅作为参考,具体实现方法应与你们后端去沟通
uni.login({
provider: 'weixin', //使用微信登录获取code
success: function (loginRes) {
//使用微信code获取openid
that.request(`/feign/wxPay/queryOpenid/${loginRes.code}`,'GET').then((res)=>{
let json = {
price: 16,//支付金额
openid: res,
description: '商品描述'
}
// 调取后台支付接口创建订单
that.request('/feign/wxPay/createOrderV3',json,'POST').then((data)=>{
let qrCode = data.data.qrCode;
//调起微信支付
uni.requestPayment({
provider: 'wxpay',
timeStamp: qrCode.timeStamp,// 时间戳(单位:秒)
nonceStr: qrCode.nonceStr,// 随机字符串
package: qrCode.packageValue,// 统一下单接口返回的 prepay_id 参数值
signType: qrCode.signType,// 签名算法,应与后台下单时的值一致
paySign: qrCode.paySign,// 签名
success(res) {
//支付成功
},
uni-app微信小程序实现支付功能
最新推荐文章于 2024-05-19 14:58:37 发布