let orderInfo = res.get('data') as UTSJSONObject;
console.log('orderInfo: ', orderInfo)
const appid = orderInfo.get('appid') as string;
const noncestr = orderInfo.get('noncestr') as string;
const package2 = orderInfo.get('package') as string;
const partnerid = orderInfo.get('partnerid') as string;
const prepayid = orderInfo.get('prepayid') as string;
const timestamp = parseInt(orderInfo.get('timestamp') as string, 10);
const sign = orderInfo.get('sign') as string;
const payParams = {
appid,
noncestr,
package: package2,
partnerid,
prepayid,
timestamp,
sign
}
uni.requestPayment({
"provider": "wxpay",
"orderInfo": JSON.stringify(payParams),
fail: (res) => {
console.log(JSON.stringify(res))
if (res != null && res.errCode === 700601) {
uni.showToast({ title: "用户取消支付" })
} else {
uni.showToast({
icon: 'error',
title: '支付失败:'
});
}
},
success: (res) => {
console.log(JSON.stringify(res))
uni.showToast({
icon: 'success',
title: '支付成功'
});
}
})
这里一定要将时间戳转为数字类型,否则会报错
const timestamp = parseInt(orderInfo.get('timestamp') as string, 10);