소스 검색

代码优化

tanxue 2 달 전
부모
커밋
fae95e470e
1개의 변경된 파일18개의 추가작업 그리고 9개의 파일을 삭제
  1. 18 9
      pages/wordList/wordList.vue

+ 18 - 9
pages/wordList/wordList.vue

@@ -9,7 +9,7 @@
 			<view class="ezy-border-body">
 				<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"
+					<view :id="'item-' + item.jieId" class="title-item" v-for="(item,index) in listData.jieNumberList" @click="handleTitleClick(item)"
 						:key="item.jieId" :class="{active: listData.activeIndex == index}">Unit{{item.number}}</view>
 				</scroll-view>
 
@@ -125,6 +125,7 @@
 		}
 	});
 
+	// Swiper 切换
 	function handleSwiperChange(e) {
 		listData.activeIndex = e.detail.current;
 		if (!swiperData.isAllowed) {
@@ -136,12 +137,10 @@
 		}
 		if (userCode == 'VIP') {
 		  findWordLeft(listData.activeIndex)
-		  handleTitleClick(listData.jieNumberList[listData.activeIndex])
+		  updataShuju(listData.jieNumberList[listData.activeIndex])
 		}
 	}
 
-
-
 	// 游客弹窗---确定
 	function ykConfirm() {
 		uni.redirectTo({
@@ -165,6 +164,7 @@
 		}
 
 	}
+	
 	// 修改缓存zid  用于定位岛
 	function updataCache(data) {
 		cacheManager.updateObject('zhangInfo', {
@@ -172,18 +172,25 @@
 		})
 	}
 
+	//tab click
 	function handleTitleClick(item) {
 		if (!cacheManager.get('auth')) {
 			youkeDialogRef.value.handleShow();
 		} else {
-			// 非游客
-			wordJieId = item.jieId;
-			// 修改缓存zid  用于定位岛
-			updataCache(item.zhangZid)
-			getWordListData();
+			updataShuju(item)
 		}
 	}
 
+	// 修改数据 &&定位岛
+	function updataShuju(data){
+		// 非游客
+		wordJieId = data.jieId;
+		// 修改缓存zid  用于定位岛
+		updataCache(data.zhangZid)
+		getWordListData();
+	}
+	
+	// 返回节index
 	function findIndexByJieId(list, jieId) {
 		const findIndex = list.findIndex(item => item.jieId == jieId)
 		// unit滚动到指定位置
@@ -197,6 +204,7 @@
 		return wordLeft.value;
 	}
 
+	// 非游客接口数据
 	function getWordListData() {
 		const opt = {
 			levelId: info.levelId,
@@ -220,6 +228,7 @@
 		});
 	}
 
+	// 游客接口数据
 	function getWordListDataYk() {
 		const opt = {
 			levelId: info.levelId,