wangguoyu 4 ヶ月 前
コミット
9207609137
3 ファイル変更122 行追加56 行削除
  1. 11 0
      api/order.js
  2. 10 3
      pages/login/index.vue
  3. 101 53
      pages/pay/svip.vue

+ 11 - 0
api/order.js

@@ -42,4 +42,15 @@ export function orderPayWx(data = {}) {
     data,
     timeout: 20000
   })
+}
+export function orderCheck(data = {}) {
+  return request({
+    'url': '/app/order/check',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 10 - 3
pages/login/index.vue

@@ -26,7 +26,7 @@
 			</view>
 			<view class="bottom-btn-box">
 				<view class="yk-btn" @click="ykBtn"></view>
-				<view class="wx-btn" @click="wxLoginClick"></view>
+				<view v-if="wxFlag" class="wx-btn" @click="wxLoginClick"></view>
 				<view class="apple-btn" v-if="showAppleLogin" @click="appleLoginClick"></view>
 			</view>
 		</view>
@@ -74,10 +74,17 @@
 	const agreeYkDialog = ref(null);
 	const telDialogRef = ref(null);
 	let telDialogFlag = ref(false);
-	let showAppleLogin = ref(false);
+	let showAppleLogin = ref(false);
+	let wxFlag = ref(true);
 
 	onLoad((options) => {
 		showAppleLogin.value = isIOS13OrAbove();
+		if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
+				console.log('111',"已安装微信");
+					wxFlag.value = true
+		}else{
+			wxFlag.value = false
+		}
 		console.log('showAppleLogin.value',showAppleLogin.value);
 	})
 
@@ -308,7 +315,7 @@
 			}
 		})
 		} else {
-			toast("未安装微信,请安装微信进行登录!")
+			toast("请重启应用重试")
 			return false
 		}
 	}

+ 101 - 53
pages/pay/svip.vue

@@ -56,6 +56,7 @@
 		orderAdd,
 		orderPayAli,
 		orderPayWx,
+		orderCheck
 	} from "@/api/order.js"
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import cacheManager from "@/utils/cacheManager.js";
@@ -74,6 +75,7 @@
 	let formPage = ref('')
 	const daoPokeRef = ref(null);
 	const daoPokeAllRef = ref(null);
+	let orderId = ref('');
 	const isVip = getUserIdentity();
 	const svipArr = [{
 			iconPath: 'static/images/pay/svip-list-icon1.png',
@@ -105,6 +107,32 @@
 		payType.value = data.detail.value;
 	}
 
+	function genggaiVip() {
+		uni.hideLoading();
+		cacheManager.updateVipStatus('auth', cardId.value)
+		cacheManager.updateObject('auth', {
+			growthType: 1
+		})
+		if (isVip != 'VIP') {
+			daoPokeRef.value.handleShow();
+		} else {
+			daoPokeAllRef.value.handleShow();
+		}
+		setTimeout(() => {
+			daoPokeRef.value.handleClose();
+			daoPokeAllRef.value.handleClose();
+			if (formPage.value == 'my') {
+				uni.redirectTo({
+					url: '/pages/my/index'
+				})
+			} else {
+				uni.redirectTo({
+					url: '/pages/study/index'
+				})
+			}
+		}, 3000)
+	}
+
 	function creatOrder(data) {
 
 		if (payType.value == 'weixin') {
@@ -113,7 +141,8 @@
 			}
 			orderAdd(req).then(res => {
 				console.log('res', res);
-				console.log(' res.data.id',  res.data.id);
+				console.log(' res.data.id', res.data.id);
+				orderId.value = res.data.id
 				orderPayWx({
 					id: res.data.id
 				}).then(res2 => {
@@ -121,41 +150,52 @@
 					uni.requestPayment({
 						"provider": "wxpay",
 						"orderInfo": {
-							  "appid": res2.data.appid,  // 应用ID(AppID)
-							  "partnerid":  res2.data.partnerId,      // 商户号(PartnerID)
-							  "prepayid": res2.data.prepayId, // 预支付交易会话ID
-							  "package": res2.data.packageVal,        // 固定值
-							  "noncestr":  res2.data.nonceStr, // 随机字符串
-							  "timestamp":  res2.data.timestamp,        // 时间戳(单位:秒)
-							  "sign":  res2.data.sign // 签名,这里用的 MD5 签名
+							"appid": res2.data.appid, // 应用ID(AppID)
+							"partnerid": res2.data.partnerId, // 商户号(PartnerID)
+							"prepayid": res2.data.prepayId, // 预支付交易会话ID
+							"package": res2.data.packageVal, // 固定值
+							"noncestr": res2.data.nonceStr, // 随机字符串
+							"timestamp": res2.data.timestamp, // 时间戳(单位:秒)
+							"sign": res2.data.sign // 签名,这里用的 MD5 签名
 						}, //此处为服务器返回的订单信息字符串
 						success: function(res) {
 							var rawdata = JSON.parse(res.rawdata);
 							console.log('支付成功');
 							console.log('rawdata', rawdata);
-							// toast("支付成功");
-							cacheManager.updateVipStatus('auth', cardId.value)
-							cacheManager.updateObject('auth', {
-								growthType: 1
-							})
-							if (isVip != 'VIP') {
-								daoPokeRef.value.handleShow();
-							} else {
-								daoPokeAllRef.value.handleShow();
-							}
-							setTimeout(() => {
-								daoPokeRef.value.handleClose();
-								daoPokeAllRef.value.handleClose();
-								if (formPage.value == 'my') {
-									uni.redirectTo({
-										url: '/pages/my/index'
-									})
+							uni.showLoading({
+								title: '会员开通中,请稍后...'
+							});
+							orderCheck({
+								id: orderId.value
+							}).then(res3 => {
+								console.log('res3',res3);
+								if (res3.code == 0 && res3.data) {
+									
+									genggaiVip()
 								} else {
-									uni.redirectTo({
-										url: '/pages/study/index'
-									})
+									setTimeout(() => {
+										orderCheck({id:orderId.value}).then(res4 => {
+											if (res4.code == 0 && res4
+												.data) {
+												genggaiVip()
+											} else {
+												toast("开通失败,请联系管理员!")
+												uni.hideLoading();
+												return false
+											}
+										}).catch(() => {
+											uni.hideLoading();
+											toast("check接口报错")
+											return false
+										})
+									}, 5000)
 								}
-							}, 3000)
+							}).catch(() => {
+								uni.hideLoading();
+								toast("check接口报错")
+								return false
+							})
+
 						},
 						fail: function(err) {
 							//  toast('支付失败:' + JSON.stringify(err));
@@ -163,8 +203,8 @@
 						}
 					});
 				}).catch((error) => {
-				console.log(error);
-			})
+					console.log(error);
+				})
 
 
 			})
@@ -174,11 +214,11 @@
 			}
 			orderAdd(req).then(res => {
 				console.log('res', res);
+					orderId.value = res.data.id
 				orderPayAli({
 					id: res.data.id
 				}).then(res2 => {
 					console.log('res2', res2);
-
 					uni.requestPayment({
 						"provider": "alipay",
 						"orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
@@ -186,29 +226,37 @@
 							var rawdata = JSON.parse(res.rawdata);
 							console.log('支付成功');
 							console.log('rawdata', rawdata);
-							// toast("支付成功");
-							cacheManager.updateVipStatus('auth', cardId.value)
-							cacheManager.updateObject('auth', {
-								growthType: 1
-							})
-							if (isVip != 'VIP') {
-								daoPokeRef.value.handleShow();
-							} else {
-								daoPokeAllRef.value.handleShow();
-							}
-							setTimeout(() => {
-								daoPokeRef.value.handleClose();
-								daoPokeAllRef.value.handleClose();
-								if (formPage.value == 'my') {
-									uni.redirectTo({
-										url: '/pages/my/index'
-									})
+							uni.showLoading({
+								title: '会员开通中,请稍后...'
+							});
+							orderCheck({
+								id: orderId.value
+							}).then(res3 => {
+								if (res3.code == 0 && res3.data) {
+									genggaiVip()
 								} else {
-									uni.redirectTo({
-										url: '/pages/study/index'
-									})
+									setTimeout(() => {
+										orderCheck({id:orderId.value}).then(res4 => {
+											if (res4.code == 0 && res4
+												.data) {
+												genggaiVip()
+											} else {
+												toast("开通失败,请联系管理员!")
+												uni.hideLoading();
+												return false
+											}
+										}).catch(() => {
+											uni.hideLoading();
+											toast("check接口报错")
+											return false
+										})
+									}, 5000)
 								}
-							}, 3000)
+							}).catch(() => {
+								uni.hideLoading();
+								toast("check接口报错")
+								return false
+							})
 						},
 						fail: function(err) {
 							//  toast('支付失败:' + JSON.stringify(err));