|
@@ -26,7 +26,7 @@
|
|
|
<view>原价:<text class="original-price">¥399</text></view>
|
|
|
<view class="discount-price">活动价:¥199</view>
|
|
|
</view>
|
|
|
- <radio-group @change="radioChange" class="pay-type-box">
|
|
|
+ <radio-group v-if="currentPlatform =='android'" @change="radioChange" class="pay-type-box">
|
|
|
<view class="type-radio-title">支付方式</view>
|
|
|
<view class="type-radio-content">
|
|
|
<view class="type-radio-box">
|
|
@@ -43,7 +43,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</radio-group>
|
|
|
- <view class="open-svip-btn" @touchstart="creatOrder">立即开通</view>
|
|
|
+ <view v-if="currentPlatform =='android'" class="open-svip-btn" @touchstart="creatOrder">立即开通</view>
|
|
|
+ <view v-if="currentPlatform =='ios'&&!disabled" style="margin-top: 20rpx;" class="open-svip-btn"
|
|
|
+ @touchstart="creatOrderIos">立即开通</view>
|
|
|
+ <view v-if="currentPlatform =='ios'&&disabled" style="margin-top: 20rpx;" class="open-svip-btn-hui"
|
|
|
+ >立即开通</view>
|
|
|
</view>
|
|
|
<CustomTabBar></CustomTabBar>
|
|
|
<!-- 蛋破壳 -->
|
|
@@ -60,6 +64,7 @@
|
|
|
orderAdd,
|
|
|
orderPayAli,
|
|
|
orderPayWx,
|
|
|
+ orderPayApple,
|
|
|
orderCheck
|
|
|
} from "@/api/order.js"
|
|
|
import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
|
|
@@ -84,6 +89,13 @@
|
|
|
const daoPokeRef = ref(null);
|
|
|
const daoPokeAllRef = ref(null);
|
|
|
let orderId = ref('');
|
|
|
+ let productId = ref(null)
|
|
|
+ let iapChannel = ref(null)
|
|
|
+ let quantity = ref(1)
|
|
|
+ let channel = ref('')
|
|
|
+ let disabled = ref(false)
|
|
|
+ let appleFlag = ref('')
|
|
|
+ let currentPlatform = ref('')
|
|
|
const isVip = getUserIdentity();
|
|
|
const svipArr = [{
|
|
|
iconPath: 'static/images/pay/svip-list-icon1.png',
|
|
@@ -107,11 +119,32 @@
|
|
|
}
|
|
|
];
|
|
|
onLoad((options) => {
|
|
|
- console.log('jinruaaaaaaaaaaaaa');
|
|
|
+ isIOSorAndroid()
|
|
|
+ appleFlag.value = cacheManager.get("auth").appleFlag
|
|
|
+ console.log('appleFlag', appleFlag.value);
|
|
|
cardId.value = options.cardId
|
|
|
formPage.value = options.formPage
|
|
|
+ if (options.orderId) {
|
|
|
+ orderId.value = options.orderId
|
|
|
+ } else {
|
|
|
+ orderId.value = ''
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
+ const isIOSorAndroid = () => {
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+
|
|
|
+ console.log('systemInfo', systemInfo);
|
|
|
+
|
|
|
+ if (systemInfo.platform == 'ios') {
|
|
|
+
|
|
|
+ return currentPlatform.value = 'ios'
|
|
|
+ } else {
|
|
|
+ return systemInfo.platform = 'android'
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function radioChange(data) {
|
|
|
payType.value = data.detail.value;
|
|
|
}
|
|
@@ -123,6 +156,7 @@
|
|
|
cacheManager.updateObject('auth', {
|
|
|
growthType: 1
|
|
|
})
|
|
|
+ console.log('isVip', isVip);
|
|
|
if (isVip != 'VIP') {
|
|
|
daoPokeRef.value.handleShow();
|
|
|
} else {
|
|
@@ -143,10 +177,160 @@
|
|
|
}, 3000)
|
|
|
}
|
|
|
|
|
|
+ const creatOrderIos = debounce((data => {
|
|
|
+ disabled.value = true
|
|
|
+ uni.showLoading({
|
|
|
+ title: '',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ if (appleFlag.value.toString() == 'true') {
|
|
|
+ productId.value = 'llisoftEzhuangyuanceshi'
|
|
|
+ } else {
|
|
|
+ if (cardId.value == 1) {
|
|
|
+ productId.value = 'llisoftEzhuangyuan'
|
|
|
+ } else {
|
|
|
+ productId.value = 'llisoftEzhuangyuanYingyu'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (orderId.value) {
|
|
|
+ uni.hideLoading();
|
|
|
+ applePay()
|
|
|
+ } else {
|
|
|
+ let req = {
|
|
|
+ cardId: cardId.value
|
|
|
+ }
|
|
|
+ orderAdd(req).then(res => {
|
|
|
+ console.log('res', res);
|
|
|
+ if (res.code == 0) {
|
|
|
+ uni.hideLoading();
|
|
|
+ orderId.value = res.data.id
|
|
|
+ // 测试ios 1元
|
|
|
+ applePay()
|
|
|
+ } else {
|
|
|
+ uni.hideLoading();
|
|
|
+ disabled.value = false
|
|
|
+ return false
|
|
|
+ console.log('请求失败');
|
|
|
+ }
|
|
|
+ }).catch((e) => {
|
|
|
+ uni.hideLoading();
|
|
|
+ disabled.value = false
|
|
|
+ console.log('创建订单失败');
|
|
|
+ return false
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }), 500)
|
|
|
+
|
|
|
+ function applePaySuccess(data) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '会员开通中',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ let req = {
|
|
|
+ "id": orderId.value,
|
|
|
+ "paynum": data.transactionIdentifier,
|
|
|
+ "receipt": data.transactionReceipt
|
|
|
+ }
|
|
|
+ console.log('reqreq', req);
|
|
|
+ orderPayApple(req).then(res => {
|
|
|
+ if (res.code == 0 && res.data) {
|
|
|
+ iapChannel.finishTransaction(data.transactionIdentifier)
|
|
|
+ console.log('resiapChanneliapChanneliapChannel', res);
|
|
|
+ genggaiVip()
|
|
|
+ } else {
|
|
|
+ disabled.value = false
|
|
|
+ iapChannel.finishTransaction(data.transactionIdentifier)
|
|
|
+ uni.hideLoading();
|
|
|
+ toast("苹果内购失败")
|
|
|
+ console.log('orderPayApple失败');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function applePay() {
|
|
|
+ console.log('123123');
|
|
|
+ if (!productId.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '苹果内购ID缺失,请选择其它支付方式或联系客服',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在支付中...'
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ plus.payment.getChannels(function(channels) { //判读项目支付通道开通情况
|
|
|
+ for (var i in channels) {
|
|
|
+ iapChannel = channels[i];
|
|
|
+ // 获取 id 为 'appleiap' 的 channel
|
|
|
+ console.info("支付通道", iapChannel)
|
|
|
+ if (iapChannel.id === 'appleiap') { //开通了app应用内支付,在manifest.josn中设置,开通后需打自定议基座
|
|
|
+ console.info("苹果支付通道", iapChannel)
|
|
|
+ // ids 数组中的项为 App Store Connect 配置的内购买项目产品ID(productId)
|
|
|
+ var ids = [productId.value];
|
|
|
+ // iap 为应用内支付对象
|
|
|
+ iapChannel.requestOrder(ids, function(e) {
|
|
|
+ // 获取订单信息成功回调方法
|
|
|
+ console.log('requestOrder success: ' + JSON.stringify(e));
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'appleiap',
|
|
|
+ orderInfo: {
|
|
|
+ productid: productId.value, //产品id,来自于苹果
|
|
|
+ quantity: quantity.value, //产品数量
|
|
|
+ manualFinishTransaction: true
|
|
|
+ },
|
|
|
+ success: (e) => {
|
|
|
+ uni.hideLoading();
|
|
|
+
|
|
|
+ // toast("苹果内购成功")
|
|
|
+ console.info("苹果内购成功", e)
|
|
|
+ applePaySuccess(e)
|
|
|
+ //e.payment.orderNo = that.orderNo
|
|
|
+ //支付成功回调,前端调用后台接口
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ disabled.value = false
|
|
|
+ uni.hideLoading();
|
|
|
+ toast("苹果内购失败")
|
|
|
+ console.info("苹果内购失败", e)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ function(e) {
|
|
|
+ // 获取订单信息失败回调方法
|
|
|
+ console.log('requestOrder failed: ' + JSON.stringify(e));
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('不支持苹果支付')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ function(e) {
|
|
|
+ console.log("获取iap支付通道失败:" + e.message);
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (e) {
|
|
|
+ uni.showModal({
|
|
|
+ title: "init",
|
|
|
+ content: e.message,
|
|
|
+ showCancel: false
|
|
|
+ });
|
|
|
+ disabled.value = false
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ const creatOrder = debounce((data) => {
|
|
|
|
|
|
- const creatOrder= debounce((data)=> {
|
|
|
-
|
|
|
console.log('123123123123');
|
|
|
if (isLoading.value) {
|
|
|
return
|
|
@@ -203,12 +387,16 @@
|
|
|
orderCheck({
|
|
|
id: orderId.value
|
|
|
}).then(res4 => {
|
|
|
- if (res4.code == 0 && res4
|
|
|
+ if (res4.code ==
|
|
|
+ 0 && res4
|
|
|
.data) {
|
|
|
genggaiVip()
|
|
|
} else {
|
|
|
- toast("开通失败,请联系管理员!")
|
|
|
- uni.hideLoading();
|
|
|
+ toast(
|
|
|
+ "开通失败,请联系管理员!"
|
|
|
+ )
|
|
|
+ uni
|
|
|
+ .hideLoading();
|
|
|
return false
|
|
|
}
|
|
|
}).catch(() => {
|
|
@@ -278,18 +466,24 @@
|
|
|
orderCheck({
|
|
|
id: orderId.value
|
|
|
}).then(res4 => {
|
|
|
- if (res4.code == 0 && res4
|
|
|
+ if (res4.code ==
|
|
|
+ 0 && res4
|
|
|
.data) {
|
|
|
genggaiVip()
|
|
|
} else {
|
|
|
- isLoading.value =
|
|
|
- false;
|
|
|
- toast("开通失败,请联系管理员!")
|
|
|
- uni.hideLoading();
|
|
|
+ isLoading
|
|
|
+ .value =
|
|
|
+ false;
|
|
|
+ toast(
|
|
|
+ "开通失败,请联系管理员!"
|
|
|
+ )
|
|
|
+ uni
|
|
|
+ .hideLoading();
|
|
|
return false
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
- isLoading.value = false;
|
|
|
+ isLoading.value =
|
|
|
+ false;
|
|
|
uni.hideLoading();
|
|
|
toast("check接口报错")
|
|
|
return false
|
|
@@ -319,7 +513,7 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- },500)
|
|
|
+ }, 500)
|
|
|
|
|
|
function goBack(data) {
|
|
|
if (formPage.value == 'my') {
|