wangguoyu 1 month ago
parent
commit
a098beb0cb
2 changed files with 44 additions and 43 deletions
  1. 40 39
      pages/chanpinneirong/index.vue
  2. 4 4
      pages/xinshuxue/lookShipin.vue

+ 40 - 39
pages/chanpinneirong/index.vue

@@ -16,22 +16,22 @@
 					<view>
 						<text>版本</text>
 						<text>{{banbenInfo.name}}</text>
-					</view>	
+					</view>
 					<view>
 						<text>单元</text>
 						<text>{{banbenInfo.curDanyuanName}}</text>
-					</view>	
+					</view>
 					<view>
 						<text>课程</text>
 						<text>{{banbenInfo.curKechengName}}</text>
-					</view>	
-					<view>
-					<view class="xx-progress-box">
-						<view>当前学习进度</view>
-						<progress :percent="curProcess" class="xx-progress" stroke-width="10"
-							backgroundColor="#3c7dfd" activeColor="#ffd11c" />
 					</view>
-					<view class="jxxx-btn" @click="handlePlay(banbenInfo,'jixu')"></view>
+					<view>
+						<view class="xx-progress-box">
+							<view>当前学习进度</view>
+							<progress :percent="curProcess" class="xx-progress" stroke-width="10"
+								backgroundColor="#3c7dfd" activeColor="#ffd11c" />
+						</view>
+						<view class="jxxx-btn" @click="handlePlay(banbenInfo,'jixu')"></view>
 					</view>
 				</view>
 			</view>
@@ -43,7 +43,8 @@
 							<view>{{danyuanItem.danyuanName}}</view>
 							<view>{{danyuanItem.danyuanIntro}}</view>
 						</view>
-						<view class="xx-item-box" v-for="jieItem in danyuanItem.jieList" :key="jieItem.jieId" @click="handlePlay(jieItem,'play')" >
+						<view class="xx-item-box" v-for="jieItem in danyuanItem.jieList" :key="jieItem.jieId"
+							@click="handlePlay(jieItem,'play')">
 							<view class="xx-item-status"
 								:class="jieItem.wanchengFlag == 1 ? 'completed-status' : 'uncompleted-status'"> </view>
 							<img :src="jieItem.cover" />
@@ -55,7 +56,7 @@
 						</view>
 					</view>
 				</view>
-		
+
 			</view>
 
 		</view>
@@ -81,18 +82,14 @@
 				danyuanList: [],
 				currentUnitName: "",
 				isShow: true,
-				currentIndex: 0,
 				banbenInfo: {},
 				banbenId: '',
 				danyuanId: '',
 				chanpinId: '',
-				fontDanyuanId: '',
-				nextDanyuanId: '',
 				dengjiId: '',
-				customType: '',
 				curProcess: '',
 				cacheManagerLocal: null,
-				curJieObject: null
+				isFirstFlag: false
 			}
 		},
 		components: {
@@ -101,41 +98,41 @@
 		},
 		onShow() {
 			console.log('学习页面显示,尝试恢复滚动位置')
+				console.log('this.isFirstFlag', this.isFirstFlag);
+			if (!this.isFirstFlag) {
+				return false
+			}
+			this.chanpinId = cacheManager.get('auth').chanpinId
+			this.danyuanId = cacheManager.get('auth').danyuanId
+			this.banbenId = cacheManager.get('auth').banbenId
+			//用于返回
+			this.dengjiId = cacheManager.get('auth').dengjiId
+			this.cacheManagerLocal = cacheManager.get('xuexi-shuxue') || {}
+			// 使用缓存
+			this.banbenInfo = this.cacheManagerLocal
+			this.curProcess = this.cacheManagerLocal.curProcess
+			this.danyuanList = this.cacheManagerLocal.danyuanList || []
 		},
 		onHide() {
-
 			console.log('学习页面隐藏,保存滚动位置')
+			this.isFirstFlag  = true
+		
 		},
 		onLoad(options) {
+			if (this.isFirstFlag) {
+				return false
+			}
 			console.log('options', options);
 			if (!cacheManager.get('xuexi-shuxue')) {
 				console.log('没有缓存');
-				this.customType = options.customType
 				this.chanpinId = options.chanpinId
 				this.danyuanId = options.danyuanId
 				this.banbenId = options.banbenId
 				this.dengjiId = options.dengjiId
 				this.loadDataFromApi()
 			} else {
-				console.log('使用缓存');
-				this.chanpinId = cacheManager.get('auth').chanpinId
-				this.danyuanId = cacheManager.get('auth').danyuanId
-				this.banbenId = cacheManager.get('auth').banbenId
-				//用于返回
-				this.dengjiId = cacheManager.get('auth').dengjiId
-				this.cacheManagerLocal = cacheManager.get('xuexi-shuxue') || {}
-				// 使用缓存
-				this.banbenInfo = this.cacheManagerLocal
-				this.curProcess = this.cacheManagerLocal.curProcess
-				this.danyuanList = this.cacheManagerLocal.danyuanList || []
-				// const result = this.jisuanWanchengStatus(this.danyuanList);
-				// if (result.allCompleted) {
-				// 	console.log('全部完成');
-				// } else {
-				// 	this.banbenInfo.curJieId = result.firstUncompleted.jieId
-				// 	console.log('未完成项目:', result.firstUncompleted);
-				// 	console.log('未完成项目jieId:', result.firstUncompleted.jieId);
-				// }
+				toast("使用xuexi-shuxue缓存,并且this.isFirstFlag 为false")
+				return false
 			}
 		},
 
@@ -168,8 +165,6 @@
 				shuxueChanpinBanbenInfo(req).then(res => {
 					this.banbenInfo = res.data
 					this.curProcess = res.data.curProcess
-					this.fontDanyuanId = res.data.fontDanyuanId
-					this.nextDanyuanId = res.data.nextDanyuanId
 					this.danyuanList = res.data.danyuanList || []
 					cacheManager.set('xuexi-shuxue', res.data)
 					cacheManager.updateObject('auth', {
@@ -178,6 +173,12 @@
 						danyuanId: this.danyuanId,
 						dengjiId: this.dengjiId
 					})
+					this.isFirstFlag = true
+				}).catch(res => {
+					this.isFirstFlag = false
+					cacheManager.remove("xuexi-shuxue")
+					toast("shuxueChanpinBanbenInfo接口错误重置isFirstFlag,清除xuexi-shuxue缓存")
+					return false
 				})
 			},
 

+ 4 - 4
pages/xinshuxue/lookShipin.vue

@@ -246,10 +246,10 @@
 				});
 			},
 			goUpPage() {
-				// uni.navigateBack()
-				uni.redirectTo({
-					url: "/pages/chanpinneirong/index"
-				})
+				 uni.navigateBack()
+				// uni.redirectTo({
+				// 	url: "/pages/chanpinneirong/index"
+				// })
 			},
 		},
 	}