wangguoyu 2 mesi fa
parent
commit
f96a269741

+ 2 - 2
androidPrivacy.json

@@ -2,7 +2,7 @@
     "version" : "1",
     "prompt" : "template",
     "title" : "服务协议和隐私政策",
-    "message" : "  请你务必审慎阅读、充分理解 “服务协议” 和 “隐私政策” 各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  进入应用前,你需先同意<a href=\"https:\/\/goosechampion.com/a/yhxy\">《服务协议》</a>和<a href=\"https:\/\/goosechampion.com/a/yszc\">
+    "message" : "  请你务必审慎阅读、充分理解 “服务协议” 和 “隐私政策” 各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  进入应用前,你需先同意<a href=\"https://goosechampion.com/a/yhxy\">《服务协议》</a>和<a href=\"https://goosechampion.com/a/yszc\">
 《隐私政策》</a>,否则将退出应用。",
     "buttonAccept" : "同意并接受",
     "buttonRefuse" : "暂不同意",
@@ -12,4 +12,4 @@
             "color" : "#999999"
         }
     }
-}
+}

+ 11 - 0
api/order.js

@@ -43,6 +43,17 @@ export function orderPayWx(data = {}) {
     timeout: 20000
   })
 }
+export function orderPayApple(data = {}) {
+  return request({
+    'url': '/app/order/pay/apple',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
 export function orderCheck(data = {}) {
   return request({
     'url': '/app/order/check',

+ 4 - 1
common/styles/global/pages.scss

@@ -1026,10 +1026,13 @@
 		}
 		.wx-radio{background-image: url("@/static/images/pay/svip-wx-icon.png");}
 		.zfb-radio{background-image: url("@/static/images/pay/svip-zfb-icon.png");}
-		.open-svip-btn{
+		.open-svip-btn,.open-svip-btn-hui{
 			width: 333rpx;height: 88rpx;line-height: 88rpx;text-align: center;color: #fff;margin: 10rpx auto;font-size: 36rpx;
 			@include ezy-no-repeat-cover;background-image: url("@/static/images/pay/svip-btn-bj.png");
 		}
+		.open-svip-btn-hui{
+			background-image: url("@/static/images/pay/svip-btn-bj-hui.png");
+		}
 	}
 	
 	@media (max-height: 800px) {

+ 1 - 8
manifest.json

@@ -70,14 +70,7 @@
                     }
                 },
                 "payment" : {
-                    "alipay" : {
-                        "__platform__" : [ "ios", "android" ]
-                    },
-                    "weixin" : {
-                        "__platform__" : [ "ios", "android" ],
-                        "appid" : "wxd6a8954fa7b0f8a0",
-                        "UniversalLinks" : "https://goosechampion.com/app/"
-                    }
+                    "appleiap" : {}
                 }
             },
             "splashscreen" : {

+ 1 - 1
pages/pay/order.vue

@@ -201,7 +201,7 @@
 
 	function handlePay(item) {
 		uni.redirectTo({
-			url: `/pages/pay/svip?cardId=${item.cardId}&formPage=my`
+			url: `/pages/pay/svip?cardId=${item.cardId}&formPage=my&orderId=${item.id}`
 		})
 		// uni.redirectTo({
 		// 	url: `/pages/pay/orderPay?id=${item.id}`

+ 209 - 15
pages/pay/svip.vue

@@ -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') {

BIN
static/images/pay/svip-btn-bj-hui.png