wangxy 5 mesiacov pred
rodič
commit
123f21993a

+ 3 - 4
components/catalogue/useCatalogue.js

@@ -6,12 +6,11 @@ import {
 	catchError
 } from "@/utils/common.js"
 import * as httpCatalogue from "@/api/catalogue.js"
-import {useXuekeNianji} from "@/utils/cacheManager.js"
+import cacheManager from "@/utils/cacheManager";
 
 export function useCatalogue() {
-	const {getXueke} = useXuekeNianji();
-	
-	const { cardId = null, nianji = null } = getXueke()
+	const auth = cacheManager.get('auth');
+	const { cardId = null, nianji = null } = auth
 	
 	const data = reactive({
 		xueke: null,

+ 1 - 3
pages/login/login.vue

@@ -32,9 +32,8 @@
 		sendCode
 	} from "@/api/login.js"
 	import sliderDialog from './sliderDialog.vue'
-	import cacheManager ,{useXuekeNianji}from "@/utils/cacheManager.js";
+	import cacheManager from "@/utils/cacheManager.js";
 
-	const {	updateXueke, getXueke} = useXuekeNianji();	
 	export default {
 		data() {
 			return {
@@ -98,7 +97,6 @@
 								url: `/pages/selectGradesTerms/index`
 							})
 						} else {
-							updateXueke(res.data.nianji,res.data.cardId)
 							uni.redirectTo({
 								url: `/pages/study/index`
 							})

+ 34 - 18
pages/selectGradesTerms/index.vue

@@ -31,26 +31,29 @@
 	import {
 		onLoad
 	} from "@dcloudio/uni-app";
-	
-	import {useXuekeNianji} from "@/utils/cacheManager.js"
+	import {getUserIdentity} from "@/utils/common.js"
+	import cacheManager from "@/utils/cacheManager.js"
 		
-	const {	updateXueke, getXueke} = useXuekeNianji();	
-
 	function useSelectGrade() {
-
+		const userCode = getUserIdentity();
 		const data = reactive({
 			activeNianji: null, // 当前年级
 			activeXueke: null, // 当前学期
 		});
 
-		onLoad(() => {
-			const {
-				nianji,
-				cardId
-			} = getXueke();
-			
-			data.activeNianji = nianji;
-			data.activeXueke = cardId;
+		onLoad((nianji,cardId) => {
+			if (userCode !== 'Visitor') {
+				const {
+					nianji: nianji_,
+					cardId: cardId_
+				} = cacheManager.get('auth');
+				data.activeNianji = nianji_;
+				data.activeXueke = cardId_;
+			} else {
+				data.activeNianji = nianji;
+				data.activeXueke = cardId;
+			}
+	
 		});
 
 		// 选择 年级+学期
@@ -76,11 +79,24 @@
 
 		// 跳转 岛 学习
 		function goDAOToStudy() {
-			updateXueke(data.activeNianji, data.activeXueke)
-			// 数序
-			uni.redirectTo({
-				url: `/pages/study/index?flag=selectGrades`
-			})
+			if (userCode !== 'Visitor') {
+				const auth = cacheManager.get('auth');
+				cacheManager.updateObject('auth', {
+					nianji: data.activeNianji,
+					zhangId: data.activeNianji == auth.nianji && data.activeXueke == auth.cardId ? auth.zhangId: 0,
+					cardId: data.activeXueke,
+				})
+				// 数序
+				uni.redirectTo({
+					url: `/pages/study/index?flag=selectGrades`
+				})
+			} else {
+				// 数序
+				uni.redirectTo({
+					url: `/pages/study/index?nianji=${data.activeNianji}&cardId=${data.activeXueke}&zhangId=0&flag=selectGrades`
+				})
+			}
+
 		}
 
 		return {

+ 36 - 32
pages/study/index.vue

@@ -35,14 +35,12 @@
 	} from '@/utils/emitEvents.js';
 	import eggDialog from './eggDialog.vue'
 	import {
-		toast
-	} from "../../utils/common";
-	import cacheManager ,{useXuekeNianji}from "@/utils/cacheManager.js";
-	const {
-		updateXueke,
-		getXueke
-	} = useXuekeNianji();
-	const eggDialogRef = ref(null);
+		toast,getUserIdentity
+	} from "@/utils/common";
+	import cacheManager from "@/utils/cacheManager.js";
+
+
+	const eggDialogRef = ref(null);
 	const catalogueRef = ref(null);
 	const selectZhang = ref(null);
 	let infoData = reactive({
@@ -57,29 +55,29 @@
 	});
 	onLoad(() => {
 		// 获取路由参数
-
+
 		init()
 
 	})
-
-	function init(){
-		if (cacheManager.get('auth')) {
-			//会员 取auth
-			selectZhang.value = cacheManager.get('auth');
-			
-			console.log(selectZhang.value);
-			// 已登录
-			// 选择年级进入调用此接口
-			//options.flag == 'selectGrades'
-			getZhangInfo()
-			// 蛋
-			// eggDialogRef.value.eggShow();
-		} else {
-			// 未登录 游客 
-			getCommonZhang()
-	
-		}
-	}
+
+	function init(){
+		if (cacheManager.get('auth')) {
+			//会员 取auth
+			selectZhang.value = cacheManager.get('auth');
+			
+			console.log(selectZhang.value);
+			// 已登录
+			// 选择年级进入调用此接口
+			//options.flag == 'selectGrades'
+			getZhangInfo()
+			// 蛋
+			// eggDialogRef.value.eggShow();
+		} else {
+			// 未登录 游客 
+			getCommonZhang()
+	
+		}
+	}
 	
 	function getZhangInfo(data) {
 		let req = {
@@ -108,11 +106,11 @@
 		})
 	}
 
-	function getCommonZhang(data) {
-		
+	function getCommonZhang(data) {
+    const auth = cacheManager.get('auth');
 		let req = {
-			nianji: getXueke().nianji,
-			cardId: getXueke().cardId,
+			nianji: auth.nianji,
+			cardId: auth.cardId,
 			zhangId: selectZhang.value? selectZhang.value.zhangId :0,
 		}
 		getCommonZhangInfo(req).then(res => {
@@ -196,6 +194,12 @@
 
 	function handleChangeZhang(data) {
 		selectZhang.value = data;
+    const authCode = getUserIdentity();
+    if (authCode !== 'Visitor') {
+      cacheManager.updateObject('auth', {
+        zhangId: data.zhangId
+      })
+    }
 		init()
 	}
 

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

@@ -35,11 +35,7 @@
 		getCurrentInstance,
 		onMounted
 	} from "vue";
-	import cacheManager ,{useXuekeNianji}from "@/utils/cacheManager.js";
-	const {
-		updateXueke,
-		getXueke
-	} = useXuekeNianji();
+	import cacheManager from "@/utils/cacheManager.js";
 	const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue'])
 	const props = defineProps({
 		options: {

+ 6 - 3
pages/unitTest/index.vue

@@ -52,6 +52,7 @@
 	import {
 		ref,
 	} from "vue";
+  import cacheManager from "@/utils/cacheManager";
 
 	const {
 		count,
@@ -89,9 +90,11 @@
 			cardId: xueke.value,
 			zhangId:  zhangId.value
 		}))
-		
+    cacheManager.updateObject('auth', {
+      zhangId: data.zhangId,
+    })
 		uni.redirectTo({
-			url: `/pages/study/index?zhangId=${data.zhangId}`
+			url: `/pages/study/index`
 		})
 	}
 	
@@ -100,7 +103,7 @@
 	function handleBack() {
 		// 数学
 		uni.redirectTo({
-			url: `/pages/study/index?zhangId=${zhangId.value}`
+			url: `/pages/study/index`
 		})
 	}
 	

+ 2 - 3
pages/unitTest/useUnit.js

@@ -15,7 +15,7 @@ import {
 	toast
 } from "@/utils/common.js"
 import * as httpUnit from "@/api/unitTest.js"
-import cacheManager, {useXuekeNianji,useUnitTestTishi} from "@/utils/cacheManager.js"
+import cacheManager, {useUnitTestTishi} from "@/utils/cacheManager.js"
 	
 
 function useJifen() {
@@ -40,7 +40,6 @@ function useJifen() {
 
 export function useExam() {
 	// 缓存
-	const {getXueke} = useXuekeNianji();
 
 	const {	showTishi, handleCloseTishi, handleShowTishi} = useTishiLeftRight()
 	const {rightAnswer,wrongAnswer,jifen, updateJifen} = useJifen();
@@ -57,7 +56,7 @@ export function useExam() {
 		xueke: null,
 	})
 	onLoad((options) => {
-		const { cardId } = getXueke();
+		const { cardId } = cacheManager.get('auth');
 		const {
 			jieId,zhangId,nianji
 		} = options;

+ 0 - 20
utils/cacheManager.js

@@ -98,26 +98,6 @@ export default cacheManager;
 
 // 单元测试 引导大鹅提示 缓存Key
 export const SHOW_UNIT_TEST_TISHI = 'SHOW_UNIT_TEST_TISHI';
-// 年级学科 缓存Key
-export const NIANJI_XUEKE = 'SHOW_UNIT_XUEKE';
-
-// 学科年级业务缓存
-export function useXuekeNianji() {
-	// 学科
-	function updateXueke(nianji, cardId) {
-		cacheManager.set(NIANJI_XUEKE, { nianji,cardId })
-	}
-	
-	// 获取学科年级
-	function getXueke() {
-		return cacheManager.get(NIANJI_XUEKE) || {}
-	}
-	
-	return {
-		updateXueke,
-		getXueke
-	}
-}
 
 // 单元测试大鹅提示缓存
 export function useUnitTestTishi() {