wangxy преди 2 месеца
родител
ревизия
1f1d3b7de3
променени са 1 файла, в които са добавени 20 реда и са изтрити 19 реда
  1. 20 19
      pages/wordList/wordList.vue

+ 20 - 19
pages/wordList/wordList.vue

@@ -10,7 +10,7 @@
 				<scroll-view scroll-x="true" :scroll-left='wordLeft' class="word-title-box"
 					v-if="listData.jieNumberList && listData.jieNumberList.length >0">
 					<view :id="'item-' + item.jieId" class="title-item" v-for="(item,index) in listData.jieNumberList"
-						:key="item.jieId" @click="handleTitleClick(item)"
+						:key="item.jieId"
 						:class="{active: listData.activeIndex == index}">Unit{{item.number}}</view>
 				</scroll-view>
 
@@ -61,7 +61,8 @@
 		ref
 	} from "vue";
 	import {
-		toast
+		toast,
+		getDataFromStr
 	} from "@/utils/common";
 	import {
 		onLoad
@@ -83,26 +84,25 @@
 	let routerOpt = ref(false);
 	let wordLeft = ref(0);
 	const youkeDialogRef = ref(null);
-	const currentIndex = ref(null)
 	const unitList = ref([])
-	const info= reactive({
+	const info = reactive({
 		levelId: null,
 		zhangId: null,
 	})
 
 	onLoad((options) => {
 		routerOpt = options;
-		info.levelId = routerOpt.levelId;
-		info.zhangId = routerOpt.zhangId;
-		// 获取缓存
-		console.log(cacheManager.get('auth').levelId,'cacheManager.get');
-		
 		if (!cacheManager.get('auth')) {
+			info.levelId = routerOpt.levelId;
+			info.zhangId = routerOpt.zhangId;
 			// 游客
 			const youkeData = JSON.parse(routerOpt.youkePageData)
 			wordJieId = youkeData.jieId
 			getWordListDataYk();
 		} else {
+			// 获取缓存
+			[info.levelId, info.zhangId ] = getDataFromStr(cacheManager.get('auth').levelId)
+
 			// 非游客
 			wordJieId = routerOpt.jieId
 			getWordListData();
@@ -110,12 +110,13 @@
 	});
 
 	function handleSwiperChange(e) {
-		currentIndex.value = e.detail.current + 1;
+		listData.activeIndex = e.detail.current;
 		// unit滚动到指定位置
-		findWordLeft(e.detail.current)
-		// 修改缓存zid  用于定位岛
-		// updataCache(item.zhangZid)
+		findWordLeft(listData.activeIndex)
+		handleTitleClick(listData.jieNumberList[listData.activeIndex])
 	}
+	
+
 
 	// 游客弹窗---确定
 	function ykConfirm() {
@@ -165,9 +166,9 @@
 		findWordLeft(findIndex)
 		return findIndex;
 	}
-	
+
 	// 获取滚动距离
-	function findWordLeft(data){
+	function findWordLeft(data) {
 		wordLeft.value = data * 40;
 		return wordLeft.value;
 	}
@@ -188,7 +189,7 @@
     }).catch(err => {
         toast("获取单词列表数据失败");
     }); */
-		
+
 		const opt = {
 			levelId: info.levelId,
 			zhangId: info.zhangId,
@@ -199,10 +200,10 @@
 				unitList.value = res.data;
 				unitList.value.forEach(item => {
 					if (item.jieId == wordJieId.value) {
-						listData.activeIndex = findIndexByJieId(listData.jieNumberList,wordJieId);
+						listData.activeIndex = findIndexByJieId(listData.jieNumberList, wordJieId);
 					}
 				})
-				
+
 			}
 		}).catch(err => {
 			toast("获取单词列表数据失败");
@@ -224,7 +225,7 @@
 				unitList.value = res.data;
 				unitList.value.forEach(item => {
 					if (item.jieId == wordJieId.value) {
-						listData.activeIndex = findIndexByJieId(listData.jieNumberList,wordJieId);
+						listData.activeIndex = findIndexByJieId(listData.jieNumberList, wordJieId);
 					}
 				})
 			}