初始化提交
This commit is contained in:
37
src/hooks/usePay.ts
Normal file
37
src/hooks/usePay.ts
Normal file
@ -0,0 +1,37 @@
|
||||
export function wxPay(opt) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let params;
|
||||
// #ifdef MP-WEIXIN
|
||||
params = {
|
||||
timeStamp: opt.timeStamp,
|
||||
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
||||
nonceStr: opt.nonceStr,
|
||||
// 支付签名随机串,不长于 32 位
|
||||
package: opt.package,
|
||||
// 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
|
||||
signType: opt.signType,
|
||||
// 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
|
||||
paySign: opt.paySign,
|
||||
}
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
params = {
|
||||
orderInfo: opt
|
||||
}
|
||||
// #endif
|
||||
console.log(params)
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
...params,
|
||||
success: res => {
|
||||
resolve('success');
|
||||
},
|
||||
cancel: res => {
|
||||
resolve('fail');
|
||||
},
|
||||
fail: res => {
|
||||
resolve('fail');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user