feat:修改微信,支付宝,华为支付在微信小程序,H5,华为快应用端的支付规范
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'wx_pay',
|
||||
data() {
|
||||
@@ -21,10 +20,32 @@ export default {
|
||||
onLoad(options) {
|
||||
this.wx_alipay = options.wx_alipay || '';
|
||||
this.out_trade_no = options.out_trade_no || '';
|
||||
|
||||
// ========== 核心修改:用条件编译隔离H5/小程序环境 ==========
|
||||
// H5环境:保留原有跳转逻辑(不改动)
|
||||
// #ifdef H5
|
||||
if(!this.$util.isWeiXin() && this.wx_alipay){
|
||||
this.show = false;
|
||||
location.href = this.wx_alipay;
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 小程序环境:禁用location,仅提示+清除定时器(避免报错)
|
||||
// #ifdef MP
|
||||
if(this.wx_alipay){
|
||||
// 友好提示用户
|
||||
this.$util.showToast({
|
||||
title: '该支付方式需在浏览器打开',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
// 可选:返回上一页(支付选择页),取消下面注释即可
|
||||
// setTimeout(() => {
|
||||
// uni.navigateBack({ delta: 1 });
|
||||
// }, 1500);
|
||||
}
|
||||
// #endif
|
||||
|
||||
this.checkPayStatus();
|
||||
},
|
||||
methods: {
|
||||
@@ -56,6 +77,10 @@ export default {
|
||||
} else {
|
||||
clearInterval(timer);
|
||||
}
|
||||
},
|
||||
// 新增:请求失败时清除定时器,避免内存泄漏
|
||||
fail: () => {
|
||||
clearInterval(timer);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
@@ -91,4 +116,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user