Browse Source

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

tanxue 4 months ago
parent
commit
673226c042
7 changed files with 117 additions and 63 deletions
  1. 18 1
      App.vue
  2. 68 37
      pages/pay/svip.vue
  3. 1 1
      pages/study/index.vue
  4. 1 1
      pages/study/lookShipin.vue
  5. 1 0
      pages/study/product/shuxue.vue
  6. 27 22
      utils/cacheManager.js
  7. 1 1
      utils/common.js

+ 18 - 1
App.vue

@@ -10,7 +10,24 @@
 	export default {
 		// creat by wgy 0619  生命周期 钩子  
 		onLaunch: function() {
-			//console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			if (cacheManager.get('auth')) {
+				uni.reLaunch({
+					url: `/pages/study/index`
+				})
+			}else if(!(cacheManager.get('wxLogin').bind)){
+					console.log('asdfadsfadsfasd')
+				// 微信登录且未绑定 
+			} else {
+				cacheManager.clearAll()
+				uni.redirectTo({
+					url: '/pages/login/index' 
+				});
+			}
 			
 		},
 		onShow: function() {

+ 68 - 37
pages/pay/svip.vue

@@ -22,65 +22,96 @@
 				<view>原价:<text class="original-price">¥598</text></view>
 				<view class="discount-price">活动价:¥198</view>
 			</view>
-			<radio-group @change="radioChange" class="pay-type-box" >
+			<radio-group @change="radioChange" class="pay-type-box">
 				<view class="type-radio-title">支付方式</view>
 				<view class="type-radio-content">
 					<view class="type-radio-box">
 						<icon class="wx-radio"></icon>
 						<text>微信</text>
 						<radio value="weixin" :checked="payType==='weixin'" activeBackgroundColor="transparent"
-						:class="{'radio-checked': payType==='weixin'}"/>
+							:class="{'radio-checked': payType==='weixin'}" />
 					</view>
 					<view class="type-radio-box">
 						<icon class="zfb-radio"></icon>
 						<text>支付宝</text>
 						<radio value="zhifubao" :checked="payType==='zhifubao'" activeBackgroundColor="transparent"
-						:class="{'radio-checked': payType==='zhifubao'}" style="margin-right: 0;"/>
+							:class="{'radio-checked': payType==='zhifubao'}" style="margin-right: 0;" />
 					</view>
 				</view>
 			</radio-group>
-			<view class="open-svip-btn">立即开通</view>
+			<view class="open-svip-btn" @click="creatOrder">立即开通</view>
 		</view>
 		<CustomTabBar></CustomTabBar>
 	</view>
 </template>
 
 <script setup>
-import {ref} from "vue";
-import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
-let payType = ref('weixin')
-const svipArr = [
-    {
-        iconPath: 'static/images/pay/svip-list-icon1.png',
-		title:'学习资源,随心畅学',
-        content: `解锁全年级数学优质学习资源,满足多样<br/>学习需求`
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon2.png',
-        title:'名师打造,优质路径',
-        content: '资深名师精心规划学习路径,引领高效提升方向'
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon3.png',
-        title:'进度分析,个性贴心',
-        content: '优先参与丰富真题测试,精准洞察学习状况'
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon4.png',
-        title:'真题测试,优先体验',
-        content: '成为会员,即刻畅享专属权益,开启无忧学习之旅'
-    }
-];
-function radioChange(data){
-	payType.value = data.detail.value;
-}
-
-function goBack(data){
-	uni.redirectTo({
-		url: '/pages/study/index'
+	import {
+		ref
+	} from "vue";
+	import {
+		orderAdd
+	} from "@/api/order.js"
+	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		onLoad,
+		onReady
+	} from '@dcloudio/uni-app';
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	let payType = ref('weixin')
+	let cardId = ref('')
+	const svipArr = [{
+			iconPath: 'static/images/pay/svip-list-icon1.png',
+			title: '学习资源,随心畅学',
+			content: `解锁全年级数学优质学习资源,满足多样<br/>学习需求`
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon2.png',
+			title: '名师打造,优质路径',
+			content: '资深名师精心规划学习路径,引领高效提升方向'
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon3.png',
+			title: '进度分析,个性贴心',
+			content: '优先参与丰富真题测试,精准洞察学习状况'
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon4.png',
+			title: '真题测试,优先体验',
+			content: '成为会员,即刻畅享专属权益,开启无忧学习之旅'
+		}
+	];
+	onLoad((options) => {
+		cardId.value = options.cardId
 	})
-}
 
+	function radioChange(data) {
+		payType.value = data.detail.value;
+	}
+
+	function creatOrder(data) {
+		let req = {
+			cardId:cardId.value
+		}
+		orderAdd(req).then(res=>{
+			console.log('res');
+			cacheManager.updateVipStatus('auth',cardId.value)
+			toast('开通成功!')
+			uni.redirectTo({
+				url: '/pages/study/index'
+			})
+		})
+	}
+
+	function goBack(data) {
+		uni.redirectTo({
+			url: '/pages/study/index'
+		})
+	}
 </script>
 
 <style>

+ 1 - 1
pages/study/index.vue

@@ -213,7 +213,7 @@
 
 	function goPayPage() {
 		uni.redirectTo({
-			url: '/pages/pay/svip'
+			url: '/pages/pay/svip?cardId='+currentProduct.value
 		})
 	}
 

+ 1 - 1
pages/study/lookShipin.vue

@@ -256,7 +256,7 @@
 			},
 			svipConfirm() {
 				uni.redirectTo({
-					url: '/pages/pay/svip'
+					url: '/pages/pay/svip?cardId='+cacheManager.get('auth').cardId
 				})
 			},
 			ykConfirm() {

+ 1 - 0
pages/study/product/shuxue.vue

@@ -65,6 +65,7 @@
 		},
 	})
 	const isVip = getUserIdentity();
+	console.log('isVip',isVip);
 	const gradeMapping = {
 		1: '一年级',
 		2: '二年级',

+ 27 - 22
utils/cacheManager.js

@@ -1,5 +1,6 @@
 const cacheManager = (function() {
 	const STORAGE_PREFIX = 'App_cache_';
+
 	function set(key, value) {
 		const fullKey = STORAGE_PREFIX + key;
 		if (typeof value === 'object' && value !== null) {
@@ -32,44 +33,47 @@ const cacheManager = (function() {
 		let obj = get(key) || {};
 		// 合并更新到对象中
 		//Object.assign(obj, updates);
-		 for (let [keyToUpdate, value] of Object.entries(updates)) {
-		    if (value === null || value === undefined) {
-		      // 如果值为 null 或 undefined,则删除属性
-		      delete obj[keyToUpdate];
-		    } else {
-		      obj[keyToUpdate] = value;
-		    }
-		  }
+		for (let [keyToUpdate, value] of Object.entries(updates)) {
+			if (value === null || value === undefined) {
+				// 如果值为 null 或 undefined,则删除属性
+				delete obj[keyToUpdate];
+			} else {
+				obj[keyToUpdate] = value;
+			}
+		}
 		set(key, obj);
 	}
 	// 用于视频已经看完 修改状态
-	function updateJieStatus(key, index,currentJieId) {
+	function updateJieStatus(key, index, currentJieId) {
 		let obj = get(key) || {};
-		// console.log('obj',obj);
-		// console.log('index',index);
-		// console.log('currentJieId',currentJieId);
-		for(let jie of obj.zhangList[index].jieList){
-			if(jie.jieId ==currentJieId){
-		//		console.log('jie',jie);
+		for (let jie of obj.zhangList[index].jieList) {
+			if (jie.jieId == currentJieId) {
+				//		console.log('jie',jie);
 				jie.studyFlag = 1
 				break
 			}
 		}
 		set(key, obj);
 	}
+	// 更新会员
+	function updateVipStatus(key, cardId) {
+		let obj = get(key) || {};
+		if (!obj.cardList.includes(cardId)) {
+			obj.cardList.push(cardId);
+		}
+		set(key, obj);
+	}
 	// 获得当前jie参数
-	function getCurrentJieData(key, index,currentJieId) {
+	function getCurrentJieData(key, index, currentJieId) {
 		let obj = get(key) || {};
-		// console.log('obj',obj);
-		// console.log('index',index);
-		// console.log('currentJieId',currentJieId);
-		for(let jie of obj.zhangList[index].jieList){
-			if(jie.jieId ==currentJieId){
+		for (let jie of obj.zhangList[index].jieList) {
+			if (jie.jieId == currentJieId) {
 				return jie
 				break
 			}
 		}
 	}
+
 	function clearAll() {
 		const keys = uni.getStorageInfoSync().keys;
 		keys.forEach(key => {
@@ -119,6 +123,7 @@ const cacheManager = (function() {
 		updateJieStatus,
 		getCurrentJieData,
 		updateObject,
+		updateVipStatus,
 		findArrayInObject,
 		clearAll
 	};
@@ -132,7 +137,7 @@ export const SHOW_UNIT_TEST_TISHI = 'SHOW_UNIT_TEST_TISHI';
 // 单元测试大鹅提示缓存
 export function useUnitTestTishi() {
 	return {
-		updateTishi:() => cacheManager.set(SHOW_UNIT_TEST_TISHI,'has'),
+		updateTishi: () => cacheManager.set(SHOW_UNIT_TEST_TISHI, 'has'),
 		getTishi: () => cacheManager.get(SHOW_UNIT_TEST_TISHI)
 	}
 }

+ 1 - 1
utils/common.js

@@ -57,7 +57,7 @@ export function catchError(promise) {
 export function getUserIdentity() {
 	const auth = cacheManager.get('auth');
 	if (auth) {
-		if (auth.cardList.some(item => item === auth.cardId)) {
+		if (auth.cardList.some(item => item == auth.cardId)) {
 			// VIP
 			return 'VIP'
 		}