wangguoyu 1 month ago
parent
commit
7ed5044e23
3 changed files with 85 additions and 102 deletions
  1. 12 0
      api/chanpinneirong.js
  2. 58 85
      pages/chanpinneirong/index.vue
  3. 15 17
      utils/cacheManager.js

+ 12 - 0
api/chanpinneirong.js

@@ -10,3 +10,15 @@ export function shuxueChanpinDanyuanInfo(data = {}) {
     timeout: 20000
     timeout: 20000
   })
   })
 }
 }
+
+export function shuxueChanpinBanbenInfo(data = {}) {
+  return request({
+    'url': '/app/shuxue/chanpin/banben/info',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 58 - 85
pages/chanpinneirong/index.vue

@@ -6,59 +6,60 @@
 		</view>
 		</view>
 		<view class="ezy-page-body xuexi-page-body">
 		<view class="ezy-page-body xuexi-page-body">
 			<view class="change-dy-box">
 			<view class="change-dy-box">
-				<view class="arrow-icon left-icon" :class="{ 'disabled': fontDanyuanId == 0 }" @click="prev"> </view>
 				<!-- 显示内容 -->
 				<!-- 显示内容 -->
 				<view class="change-dy-content">
 				<view class="change-dy-content">
-					<view>{{ danyuanInfo.danyuanName }}</view>
-					<view>{{ danyuanInfo.danyuanIntro }}</view>
-				</view>
-				<view class="arrow-icon right-icon" @click="next" :class="{ 'disabled': nextDanyuanId == 0 }"> </view>
-			</view>
-			<view class="xx-scroll-body">
-				<view class="xx-jd-box">
-					<view class="xx-progress-btn-box">
-						<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(danyuanInfo,'jixu')"></view>
+					<view>{{ banbenInfo.chanpinName }}</view>
+					<view>
+						<text>等级</text>
+						<text>{{banbenInfo.dengjiName}}</text>
 					</view>
 					</view>
-					<view class="jd-item-box">
-						<view class="jd-item-btn" @click="handleClickDanyuan">
-							<icon class="dydg-icon"></icon>单元大纲
-						</view>
-						<view class="jd-item-btn" @click="handleClickMulu">
-							<icon class="dyml-icon"></icon>单元目录
-						</view>
+					<view>
+						<text>版本</text>
+						<text>{{banbenInfo.name}}</text>
+					</view>	
+					<view>
+						<text>单元</text>
+						<text>{{banbenInfo.curDanyuanName}}</text>
+					</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>
-
 				</view>
 				</view>
+			</view>
+			<view class="xx-scroll-body">
 				<view class="xx-item-list">
 				<view class="xx-item-list">
-					<view class="xx-item-box" v-for="section in dagangList" :key="section.jieId" @click="handlePlay(section,'play')" >
-						<view class="xx-item-status"
-							:class="section.wanchengFlag == 1 ? 'completed-status' : 'uncompleted-status'"> </view>
-						<img :src="section.cover" />
-						<view class="xx-text-box">
-							<view>{{ section.jieName }}</view>
-							<view>{{ section.jieIntro }}</view>
+					<view v-for="danyuanItem in danyuanList" :key="danyuanItem.danyuanId">
+						<view @click="handleClickDanyuan">
+							<view>L{{danyuanItem.danyuanId}}</view>
+							<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-status"
+								:class="jieItem.wanchengFlag == 1 ? 'completed-status' : 'uncompleted-status'"> </view>
+							<img :src="jieItem.cover" />
+							<view class="xx-text-box">
+								<view>{{ jieItem.jieName }}</view>
+								<view>{{ jieItem.jieIntro }}</view>
+							</view>
+							<view class="xx-item-btn"></view>
 						</view>
 						</view>
-						<view class="xx-item-btn"></view>
 					</view>
 					</view>
 				</view>
 				</view>
-				<!-- 底部占位 -->
-				<view v-if="nextDanyuanId!=0" class="xx-next-btn" @click="next">
-					学习下一单元</view>
-				<!-- 	<view class="xx-xw-text">课程已学完</view> -->
+		
 			</view>
 			</view>
 
 
 		</view>
 		</view>
-
-
-		<!-- <scroll-view scroll-y class="scroll-view" :scroll-top="scrollTop" @scroll="onScroll"> </scroll-view> -->
-
 		<danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
 		<danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
-		<danyuanMuluVue ref="dyMlRef" @select="handleSelectDanyuan"></danyuanMuluVue>
 		<CustomTabBar :currentTabNumber="1"></CustomTabBar>
 		<CustomTabBar :currentTabNumber="1"></CustomTabBar>
 	</view>
 	</view>
 </template>
 </template>
@@ -67,10 +68,9 @@
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import cacheManager from "@/utils/cacheManager.js";
 	import cacheManager from "@/utils/cacheManager.js";
 	import {
 	import {
-		shuxueChanpinDanyuanInfo
+		shuxueChanpinBanbenInfo
 	} from "@/api/chanpinneirong.js"
 	} from "@/api/chanpinneirong.js"
 	import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
 	import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
-	import danyuanMuluVue from '@/pages/xinshuxue/components/danyuanMulu.vue';
 	import {
 	import {
 		toast
 		toast
 	} from '../../utils/common';
 	} from '../../utils/common';
@@ -78,11 +78,11 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				dagangList: [],
+				danyuanList: [],
 				currentUnitName: "",
 				currentUnitName: "",
 				isShow: true,
 				isShow: true,
 				currentIndex: 0,
 				currentIndex: 0,
-				danyuanInfo: {},
+				banbenInfo: {},
 				banbenId: '',
 				banbenId: '',
 				danyuanId: '',
 				danyuanId: '',
 				chanpinId: '',
 				chanpinId: '',
@@ -93,15 +93,12 @@
 				curProcess: '',
 				curProcess: '',
 				cacheManagerLocal: null,
 				cacheManagerLocal: null,
 				curJieObject: null
 				curJieObject: null
-
-
-
 			}
 			}
 		},
 		},
 		components: {
 		components: {
 			CustomTabBar,
 			CustomTabBar,
-			danyuanInfoVue,
-			danyuanMuluVue
+			danyuanInfoVue
+		
 		},
 		},
 		onShow() {
 		onShow() {
 			console.log('学习页面显示,尝试恢复滚动位置')
 			console.log('学习页面显示,尝试恢复滚动位置')
@@ -132,17 +129,17 @@
 				//用于返回
 				//用于返回
 				this.dengjiId = cacheManager.get('auth').dengjiId
 				this.dengjiId = cacheManager.get('auth').dengjiId
 				this.cacheManagerLocal = cacheManager.get('xuexi-shuxue') || {}
 				this.cacheManagerLocal = cacheManager.get('xuexi-shuxue') || {}
-				// 使用缓存A@
-				this.danyuanInfo = this.cacheManagerLocal
+				// 使用缓存
+				this.banbenInfo = this.cacheManagerLocal
 				this.curProcess = this.cacheManagerLocal.curProcess
 				this.curProcess = this.cacheManagerLocal.curProcess
 				this.fontDanyuanId = this.cacheManagerLocal.fontDanyuanId
 				this.fontDanyuanId = this.cacheManagerLocal.fontDanyuanId
 				this.nextDanyuanId = this.cacheManagerLocal.nextDanyuanId
 				this.nextDanyuanId = this.cacheManagerLocal.nextDanyuanId
-				this.dagangList = this.cacheManagerLocal.dagangList || []
-				const result = this.jisuanWanchengStatus(this.dagangList);
+				this.danyuanList = this.cacheManagerLocal.danyuanList || []
+				const result = this.jisuanWanchengStatus(this.danyuanList);
 				if (result.allCompleted) {
 				if (result.allCompleted) {
 					console.log('全部完成');
 					console.log('全部完成');
 				} else {
 				} else {
-					this.danyuanInfo.curJieId = result.firstUncompleted.jieId
+					this.banbenInfo.curJieId = result.firstUncompleted.jieId
 					console.log('未完成项目:', result.firstUncompleted);
 					console.log('未完成项目:', result.firstUncompleted);
 					console.log('未完成项目jieId:', result.firstUncompleted.jieId);
 					console.log('未完成项目jieId:', result.firstUncompleted.jieId);
 				}
 				}
@@ -156,7 +153,7 @@
 			// 继续学习按钮是否可以点击
 			// 继续学习按钮是否可以点击
 			jisuanWanchengStatus(dagangList) {
 			jisuanWanchengStatus(dagangList) {
 				// 查找第一个未完成的项目
 				// 查找第一个未完成的项目
-				const firstUncompleted = dagangList.find(item => item.wanchengFlag == 0);
+				const firstUncompleted = danyuanList.find(item => item.wanchengFlag == 0);
 				if (firstUncompleted) {
 				if (firstUncompleted) {
 					return {
 					return {
 						allCompleted: false,
 						allCompleted: false,
@@ -176,9 +173,7 @@
 				this.danyuanId = item.danyuanId
 				this.danyuanId = item.danyuanId
 				this.loadDataFromApi()
 				this.loadDataFromApi()
 			},
 			},
-			handleClickMulu() {
-				this.$refs.dyMlRef.showPopup(this.banbenId)
-			},
+		
 			handleBack() {
 			handleBack() {
 				uni.navigateTo({
 				uni.navigateTo({
 					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
 					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
@@ -186,15 +181,14 @@
 			},
 			},
 			loadDataFromApi() {
 			loadDataFromApi() {
 				const req = {
 				const req = {
-					banbenId: this.banbenId,
-					danyuanId: this.danyuanId
+					banbenId: this.banbenId
 				}
 				}
-				shuxueChanpinDanyuanInfo(req).then(res => {
-					this.danyuanInfo = res.data
+				shuxueChanpinBanbenInfo(req).then(res => {
+					this.banbenInfo = res.data
 					this.curProcess = res.data.curProcess
 					this.curProcess = res.data.curProcess
 					this.fontDanyuanId = res.data.fontDanyuanId
 					this.fontDanyuanId = res.data.fontDanyuanId
 					this.nextDanyuanId = res.data.nextDanyuanId
 					this.nextDanyuanId = res.data.nextDanyuanId
-					this.dagangList = res.data.dagangList || []
+					this.danyuanList = res.data.danyuanList || []
 					cacheManager.set('xuexi-shuxue', res.data)
 					cacheManager.set('xuexi-shuxue', res.data)
 					cacheManager.updateObject('auth', {
 					cacheManager.updateObject('auth', {
 						chanpinId: this.chanpinId,
 						chanpinId: this.chanpinId,
@@ -205,37 +199,16 @@
 				})
 				})
 			},
 			},
 
 
-			prev() {
-				if (this.fontDanyuanId != 0) {
-					this.danyuanId = this.fontDanyuanId
-					this.loadDataFromApi()
-				}
-
-
-			},
-			next() {
-				if (this.nextDanyuanId != 0) {
-					this.danyuanId = this.nextDanyuanId
-					this.loadDataFromApi()
-				}
-
-			},
 
 
 			handlePlay(da, code) {
 			handlePlay(da, code) {
 				let jieId = null;
 				let jieId = null;
 				if (code == 'jixu') {
 				if (code == 'jixu') {
-					if (da.curProcess >= 100) {
-						toast("当前单元节内容全部学习完毕,请切换下一单元!")
-						return
-					}
 					if (!da.curJieId) {
 					if (!da.curJieId) {
 						toast("无jieId");
 						toast("无jieId");
 						return;
 						return;
 					}
 					}
-					const firstUncompleted = this.dagangList.find(item => item.jieId == da.curJieId);
-						console.log(firstUncompleted)
 					jieId = da.curJieId;
 					jieId = da.curJieId;
-					if (firstUncompleted.type == 1) {
+					if (da.type == 1) {
 						uni.navigateTo({
 						uni.navigateTo({
 							url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
 							url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
 						})
 						})

+ 15 - 17
utils/cacheManager.js

@@ -108,30 +108,28 @@ const cacheManager = (function() {
 			}
 			}
 		}, obj);
 		}, obj);
 	}
 	}
-	// 用于新数学产品当前单元节视频看完了 更新完成状态和计算当前单元的进度
-	// currentJieId:当前jieId
-	function updateStatusAndProess(currentJieId) {
-		let obj = get('xuexi-shuxue') || {};
-		// 标记完成
-		for (let jie of obj.dagangList) {
-			if (jie.jieId == currentJieId) {
-				jie.wanchengFlag = 1;
-				break;
-			}
-		}
-		// 计算新进度
-		let newProgress = (parseFloat(obj.curProcess) || 0) + (100 / obj.dagangList.length);
-		if (newProgress > 100) newProgress = 100;
-		obj.curProcess = newProgress.toFixed(2);
-		set('xuexi-shuxue', obj);
+	function updateShuxueWanchengStatus(currentJieId) {
+	    let obj = get('xuexi-shuxue') || {};
+	    if (obj.data && obj.data.danyuanList) {
+	        obj.data.danyuanList.forEach(danyuan => {
+	            if (danyuan.jieList) {
+	                const jie = danyuan.jieList.find(j => j.jieId == currentJieId);
+	                if (jie) {
+	                    jie.wanchengFlag = 1;
+	                }
+	            }
+	        });
+	    }
+	    set('xuexi-shuxue', obj);
 	}
 	}
+	
 	return {
 	return {
 		set,
 		set,
 		get,
 		get,
 		remove,
 		remove,
 		updateJieStatus,
 		updateJieStatus,
 		getCurrentJieData,
 		getCurrentJieData,
-		updateStatusAndProess,
+		updateShuxueWanchengStatus,
 		updateObject,
 		updateObject,
 		findArrayInObject,
 		findArrayInObject,
 		clearAll
 		clearAll