This commit is contained in:
@fawn-nine
2024-07-15 17:04:49 +08:00
parent 2c7bd95cc1
commit 7487f74259
5 changed files with 39 additions and 15 deletions

10
App.vue
View File

@@ -32,8 +32,8 @@
// #ifdef APP-PLUS
updata();
// 检测是否有未关闭苹果内购订单
iap.getChannels();
console.log('引入了?');
// iap.getChannels();
// console.log('引入了?');
// #endif
uni.getSystemInfo({
@@ -153,6 +153,12 @@
},
onShow: function(e) {
// #ifdef APP-PLUS
// updata();
// 检测是否有未关闭苹果内购订单
iap.getChannels();
// console.log('引入了?');
// #endif
// console.log(plus.runtime.arguments, 'plus.runtime.arguments-----')
// #ifdef MP-WEIXIN
//获取二维码携带的参数

View File

@@ -6,8 +6,8 @@ if (process.env.NODE_ENV === 'development') {
// socketUrl = "ws://localhost:6001/";
// baseUrl = "https://twin-ui.com/demo/";
// baseUrl = "https://testapi.nuttyreading.com/"; // 线上测试环境
baseUrl = "https://api.nuttyreading.com/"; // 线上正式
// baseUrl = "http://192.168.110.100:9200/pb/"; // 开发用电脑
// baseUrl = "https://api.nuttyreading.com/"; // 线上正式
baseUrl = "http://192.168.110.100:9200/pb/"; // 开发用电脑
// baseUrl = "http://59.110.212.44:9200/pb/";
// baseUrl = "http://192.168.110.100:9100/pb/"; // 开发用电脑
// baseUrl = "http://192.168.110.110:9200/pb/";

View File

@@ -266,12 +266,13 @@
}
})
}, 1000)
}else{
uni.showToast({
title:'支付环境不支持IAP',
icon:'none'
})
}
// else{
// uni.showToast({
// title:'支付环境不支持IAP',
// icon:'none'
// })
// }
}
})
@@ -329,7 +330,8 @@
// 支付成功result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证
that.iapCheck(result)
}, function(e) {
console.log('错误回调', e)
uni.hideLoading()
console.log('错误回调', e)
if (e.code == 2) {
uni.showToast({
title:'取消支付,内购订单即将关闭',
@@ -342,6 +344,7 @@
})
console.log('其他支付错误',e);
}
that.restoreComplateRequest()
});
},
iapCheck(result) {
@@ -367,14 +370,15 @@
'Content-Type': 'application/json'
},
}).then(res => {
console.log(JSON.stringify(res))
// console.log(JSON.stringify(res))
if (res.code == 0) {
uni.hideLoading()
uni.showToast({
title:'充值成功!',
icon:'success'
})
console.log("充值订单已处理,请留意账户金额变动....");
console.log("充值订单已处理,请留意账户金额变动....",res);
that.finishTransaction(result);
}
}).catch(e => {

Binary file not shown.

View File

@@ -17,14 +17,13 @@ var iap = {
console.log('检测支付通道')
plus.payment.getChannels(async (channels) => {
for (var i in channels) {
console.log("channels",channels, );
// 判断是否苹果支付1
if (channels[i].id === "appleiap") {
console.log("存在苹果内购channels",channels, );
that.iapChannel = channels[i];
// 先检测有没有未完成的订单
that.restoreComplateRequest()
}else{
console.log('安卓客户端');
}
}
});
@@ -50,7 +49,7 @@ var iap = {
// return false
// 已经支付,但是没有走逻辑的内购订单 就发给后台做验证
that.iapCheck(item, index)
// that.finishTransaction(item)
// that.finishTransaction(item)
} else {
// 其他状态的内购订单
that.finishTransaction(item)
@@ -110,6 +109,21 @@ var iap = {
})
.catch((e) => {
console.log('后台验证失败=>',e);
uni.showModal({
title: "提示",
cancelColor:'#0081ff',
content: `您的账户下存在验证异常的订单(订单编号为:${e.data.orderId})可尝试稍后重启app如不能解决您的问题可联系官方客服`,
cancelText:'已验证关闭订单',
confirmText:'知道了',
success: function(res) {
if (res.confirm) {
console.log("用户点击确定");
}else{
console.log('点了取消')
that.finishTransaction(result);
}
},
});
// that.finishTransaction(result);
});
},