浏览代码

Merge branch '2024鹅状元' of https://gogs.mtavip.com/wangguoyu/uniProject into 2024鹅状元

# Conflicts:
#	pages/login/index.vue
tanxue 3 月之前
父节点
当前提交
2ea98ce4b4
共有 2 个文件被更改,包括 112 次插入53 次删除
  1. 11 0
      api/order.js
  2. 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
+  })
 }

+ 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));