ios 内购详情解决 二次支付 免费提示等问题
onShow(){
let platform = uni.getSystemInfoSync().platform
if (platform == 'ios') {
iosVip().then((res) => {
this.platform = 'ios'
this.vipList = res.data.rows
res.data.rows.map((item) => {
this.productIds.push(item.productDesc)
})
}).then(() => {
uni.showLoading({
title: "正在检测支付环境……" ,
})
this.iphonepay()
})
}
},
methods:{
iphonepay() {
let that = this
plus.payment.getChannels((res) => {
let channel = res.find(i => i.id === 'appleiap')
that.iapChannel = channel ? channel : null
console.log(channel, 'channel');
that.requestOrder()
})
},
requestOrder() {
let that = this
that.iapChannel.requestProduct(that.productIds, function(event) {
console.log(event, '检测完成');
uni.hideLoading()
}, function(erroemsg) {
uni.hideLoading()
uni.showToast({
title: "获取支付通道失败:" + errormsg.message,
icon: 'none'
})
})
},
iosPay(){
let that = this
that.iapChannel.restoreCompletedTransactions({
manualFinishTransaction: true,
username: ''
}, (res) => {
if (res.length > 0) {
that.iapChannel.finishTransaction(res[0], (reslut) => {
console.log(reslut, 'reslut');
})
}
}, (err) => {
console.log(err);
})
},
let orderInfo = {
manualFinishTransaction: false,
productid: result.data.productDesc,
}
uni.showLoading({
title: '充值中请勿离开',
})
uni.requestPayment({
provider: 'appleiap',
orderInfo: orderInfo,
success: (e) => {
let code = JSON.parse(JSON.stringify(e.payment.quantity))
if (code == 1) {
console.log(obj, 'result');
iosPayNotify(obj.data.orderNo).then((key) => {
if (key.code == 200) {
userInfo().then((reslut) => {
uni.setStorage({
key: 'userInfo',
data: reslut.data,
});
uni.hideLoading();
})
}
})
that.iapChannel.finishTransaction(e, (res) => {
console.log('成功关闭');
})
}
},
fail: (err) => {
uni.hideLoading();
console.log(err, 'err');
},
})
}