wangxy 4 місяців тому
батько
коміт
2ced14efe8
2 змінених файлів з 19 додано та 3 видалено
  1. 4 3
      pages/pay/svip.vue
  2. 15 0
      utils/common.js

+ 4 - 3
pages/pay/svip.vue

@@ -65,7 +65,8 @@
 	} from '@dcloudio/uni-app';
 	import {
 		toast,
-		getUserIdentity
+		getUserIdentity,
+		hasUserIdentity
 	} from "@/utils/common";
 	let payType = ref('weixin')
 	let cardId = ref('')
@@ -73,7 +74,7 @@
 	const daoPokeRef = ref(null);
 	const daoPokeAllRef = ref(null);
 	const selectZhangId = ref(null);//来自岛目录选择的章Id,支付后需要修改章id缓存记录,方便返回时定位到选中章的岛
-	const isVip = getUserIdentity();
+	const isAlreadyVip = hasUserIdentity();
 	const svipArr = [{
 			iconPath: 'static/images/pay/svip-list-icon1.png',
 			title: '学习资源,随心畅学',
@@ -115,7 +116,7 @@
 			cacheManager.updateObject('auth', {
 				growthType: 1
 			})
-			if (isVip != 'VIP') {
+			if (isAlreadyVip != 'VIP') {
 				daoPokeRef.value.handleShow();
 			} else {
 				daoPokeAllRef.value.handleShow();

+ 15 - 0
utils/common.js

@@ -67,4 +67,19 @@ export function getUserIdentity() {
 		// 游客
 		return 'Visitor';
 	}
+}
+
+export function hasUserIdentity() {
+	const auth = cacheManager.get('auth');
+	if (auth) {
+		if (auth.cardList.length) {
+			// VIP
+			return 'VIP'
+		}
+		// 非VIP
+		return 'Not-Vip';
+	} else {
+		// 游客
+		return 'Visitor';
+	}
 }