✨ 微信公众号支付:接入 100%
parent
f90096e20a
commit
b548999e89
|
@ -159,13 +159,14 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
//微信支付 TODO 芋艿:未测试
|
||||
// 微信支付
|
||||
wxpay(data, callback) {
|
||||
this.isReady(() => {
|
||||
debugger
|
||||
jweixin.chooseWXPay({
|
||||
timestamp: data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
||||
nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
|
||||
package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
|
||||
package: data.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
|
||||
signType: data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
|
||||
paySign: data.paySign, // 支付签名
|
||||
success: function (res) {
|
||||
|
|
|
@ -105,9 +105,12 @@ export default class SheepPay {
|
|||
// 成功时
|
||||
res.code === 0 && resolve(res);
|
||||
// 失败时
|
||||
// TODO 芋艿:这块需要在测试下哈;
|
||||
if (res.code !== 0 && res.msg === 'miss_openid') {
|
||||
this.bindWeixin();
|
||||
if (res.code !== 0 && res.msg.indexOf('无效的openid') >= 0) {
|
||||
// 特殊逻辑:微信公众号、小程序支付时,必须传入 openid 不正确的情况
|
||||
if (res.msg.indexOf('无效的openid') >= 0 // 获取的 openid 不正确时,或者随便输入了个 openid
|
||||
|| res.msg.indexOf('下单账号与支付账号不一致') >= 0) { // https://developers.weixin.qq.com/community/develop/doc/00008c53c347804beec82aed051c00
|
||||
this.bindWeixin();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -119,15 +122,19 @@ export default class SheepPay {
|
|||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
// let that = this;
|
||||
$wxsdk.wxpay(data, {
|
||||
const payConfig = JSON.parse(data.displayContent);
|
||||
$wxsdk.wxpay(payConfig, {
|
||||
success: () => {
|
||||
this.payResult('success');
|
||||
},
|
||||
cancel: () => {
|
||||
this.$helper.toast('支付已手动取消');
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
},
|
||||
fail: () => {
|
||||
fail: (error) => {
|
||||
if (error.errMsg.indexOf('chooseWXPay:没有此SDK或暂不支持此SDK模拟') >= 0) {
|
||||
sheep.$helper.toast('发起微信支付失败,原因:可能是微信开发者工具不支持,建议使用微信打开网页后支付');
|
||||
return
|
||||
}
|
||||
this.payResult('fail');
|
||||
},
|
||||
});
|
||||
|
|
|
@ -220,7 +220,8 @@ const request = (config) => {
|
|||
// TODO 芋艿:额外拼接
|
||||
if (config.url.indexOf('/app-api/') >= 0) {
|
||||
// config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
|
||||
config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
}
|
||||
return http.middleware(config);
|
||||
};
|
||||
|
|
|
@ -217,7 +217,8 @@ const request = (config) => {
|
|||
// 设置接口地址
|
||||
// config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
|
||||
// config.url = 'https://app.test.huizhizao.vip/prod-api' + config.url; // 调用【云端】
|
||||
config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
}
|
||||
return http.middleware(config);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue