parent
e814e1aa0c
commit
ec932a429b
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-04-29 14:26:10
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-06-29 17:25:38
|
||||
* @Description: file content
|
||||
*/
|
||||
|
||||
import { ApiPostAliH5Pay, ApiPostAliAppPay } from '@/common/api/pay';
|
||||
import ENV from '@/common/config/env';
|
||||
export const Alipay = async ({orderId})=>{
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
const {error, result} = await ApiPostAliAppPay({orderId});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
const par = result.payDataInfo;
|
||||
uni.requestPayment({
|
||||
provider: 'alipay',
|
||||
orderInfo :{
|
||||
"appid": par.appId, // 微信开放平台 - 应用 - AppId
|
||||
"noncestr": par.nonceStr, // 随机字符串
|
||||
"package": par.packageValue, // 固定值
|
||||
"partnerid": par.partnerId, // 微信支付商户号
|
||||
"prepayid": par.prepayId, // 统一下单订单号
|
||||
"timestamp": par.timeStamp ,// 时间戳(单位:秒)
|
||||
"sign": par.sign // 签名,这里用的 MD5 签名
|
||||
},
|
||||
success(res) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
},
|
||||
fail(e) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('res',res);
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const { error, result } = await ApiPostAliH5Pay({
|
||||
orderId,
|
||||
returnUrl : decodeURIComponent(`${ENV.staticUrl}/payResult?orderId=${orderId}&payType=alih5`)
|
||||
});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
window.location.href = result.payDataInfo.payUrl;
|
||||
// #endif
|
||||
|
||||
}
|
Loading…
Reference in new issue