wangguoyu пре 5 дана
родитељ
комит
5da42c4d4d

+ 322 - 0
pages/chanpinneirong/chanpin1.vue

@@ -0,0 +1,322 @@
+<template>
+	<view>
+		<!-- 滚动区域 -->
+		<scroll-view v-if="existData" class="ezy-page-body xuexi-page-body" :scroll-with-animation="true" scroll-y
+			:scroll-top="scrollTop" @scroll="handleScroll">
+			<view class="xxjl-card-box-padding">
+				<view class="xxjl-card-box">
+					<!-- 显示内容 -->
+					<view class="card-body-box">
+						<img :src="banbenInfo.cover" />
+						<view class="body-right">
+							<view class="right-name">{{ banbenInfo.chanpinName }}</view>
+							<view>等级:{{banbenInfo.dengjiName}}</view>
+							<view>版本:{{banbenInfo.name}}</view>
+							<view>单元:{{banbenInfo.curDanyuanName}}</view>
+							<view>课程:{{banbenInfo.curKechengName}}</view>
+						</view>
+					</view>
+					<view class="card-progress-box">
+						<view class="xx-progress-box">
+							<view>学习进度</view>
+							<progress :percent="curProcess" class="xx-progress" stroke-width="20"
+								backgroundColor="#3c7dfd" activeColor="#ffd11c" />
+						</view>
+						<ezyActiveVue class="ezy-btn-active jxxx-btn" @aclick="handlePlay(banbenInfo,'jixu')">
+						</ezyActiveVue>
+					</view>
+				</view>
+			</view>
+
+			<view class="xx-item-list">
+				<view class="xx-item-title">— 以下为当前等级课程目录 —</view>
+
+				<view v-for="(danyuanItem, index) in danyuanList" :key="danyuanItem.danyuanId">
+					<!-- 单元标题(带唯一ID,用于位置查询) -->
+					<ezyActiveVue class="ezy-list-item-active item-dy-box" @aclick="handleClickDanyuan(danyuanItem.danyuanId)" :id="`unit-title-${danyuanItem.danyuanId}`">
+						<view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
+						<view class="dy-right-box">
+							<view class="right-content">
+								<view>{{danyuanItem.danyuanName}}</view>
+								<view class="dy-name">{{danyuanItem.danyuanIntro}}</view>
+							</view>
+						</view>
+					</ezyActiveVue>
+					<!-- 节列表 -->
+					<ezyActiveVue class="ezy-list-item-active xx-item-box" v-for="jieItem in danyuanItem.jieList"
+						:key="jieItem.jieId" @aclick="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>
+					</ezyActiveVue>
+				</view>
+
+				<view class="xx-item-title">本级别最后一单元啦~</view>
+				<view class="xx-more-btn" @click="moreBtn"></view>
+			</view>
+		</scroll-view>
+		<!-- 回到顶部 -->
+		<view v-show="showGoTop" class="go-top-btn" @click="goTopBtn"></view>
+
+		<!-- 无数据占位 -->
+		<view v-if="!existData" class="ezy-page-body">
+			<view class="ezy-no-sj">
+				<icon></icon>
+				<text>暂无数据</text>
+			</view>
+		</view>
+		<!-- 弹窗组件 -->
+		<danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow = false"></danyuanInfoVue>
+	</view>
+</template>
+
+<script>
+	import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+	import CustomTabBar from '@/components/custom-tabbar/index.vue';
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		shuxueChanpinBanbenInfo,
+		shuxueSave
+	} from "@/api/chanpinneirong.js"
+	import {
+		onLoad,
+		onShow,
+		onHide,
+		onUnload
+	} from "@dcloudio/uni-app"
+	import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
+	import {
+		toast
+	} from '../../utils/common';
+	import {
+		updateChanpin1Process
+	} from "./useNeirongChanpin1"
+	export default {
+		data() {
+			return {
+				canExitApp: false,
+
+				danyuanList: [],
+				banbenInfo: {},
+				banbenId: '',
+				danyuanId: '',
+				chanpinId: '',
+				dengjiId: '',
+				curProcess: '',
+				currentTabIndex: 1,
+				existData: true,
+				isShow: false,
+
+				stickyHeight: 0, // 吸顶栏高度(px)
+				currentStickyTitle: '', // 初始为空,不显示吸顶
+				currentStickyIntro: '',
+				currentDanyuanId: '',
+				currentStickyDengjiId: '',
+				titlePositions: [],
+				scrollTop: 0,
+				showGoTop: false,
+				scrollThreshold: 300,
+			}
+		},
+		components: {
+			CustomTabBar,
+			danyuanInfoVue,
+			ezyActiveVue
+		},
+	
+		onHide() {
+			console.log('学习页面隐藏')
+		},
+		onUnload() {
+			// 页面卸载无需特殊处理
+		},
+		methods: {
+			initData(banbenId) {
+				console.log('123111');
+				this.currentTabIndex = 1
+				const cacheData = cacheManager.get('contentInfo');
+			
+				if (cacheData) {
+					console.log('使用缓存数据');
+					this.updateFromCache();
+				} else {
+					console.log('重新请求数据');
+					const cacheDataAuth = cacheManager.get('auth');
+					this.initFromOptions(banbenId);
+				}
+			},
+			goTopBtn() {
+				// 替换原来的 uni.pageScrollTo
+				this.scrollTop = Math.random(); // 先设置一个随机值
+				this.$nextTick(() => {
+					this.scrollTop = 0; // 再设置回0
+				});
+
+				this.showGoTop = false;
+			},
+			moreBtn() {
+				uni.switchTab({
+					url: '/pages/chanpinXuanze/index'
+				})
+			},
+
+			initFromOptions(banbenId) {
+			
+				this.loadDataFromApi(banbenId);
+			},
+			// 从缓存更新数据方法
+			updateFromCache() {
+				updateChanpin1Process()
+				const cacheData = cacheManager.get('contentInfo');
+				console.log('cacheData 从缓存更新数据方法', cacheData);
+				if (cacheData) {
+					this.banbenInfo = {
+						...cacheData
+					};
+					this.curProcess = cacheData.curProcess;
+					this.danyuanList = [...(cacheData.danyuanList || [])];
+					this.banbenId = cacheData.banbenId
+					// this.$nextTick(() => {
+					// 	this.updateTitlePositions();
+					// });
+				}
+			},
+
+			loadDataFromApi(banbenId) {
+				this.banbenInfo = {}
+				this.curProcess = ''
+				this.danyuanList = []
+				const req = {
+					banbenId: banbenId
+				}
+				shuxueChanpinBanbenInfo(req).then(res => {
+					if (res.code === 0) {
+						this.banbenInfo = res.data;
+						this.banbenInfo.danyuanId = res.data.curDanyuanId;
+						this.curProcess = res.data.curProcess * 100;
+						this.danyuanList = res.data.danyuanList || [];
+						if (this.danyuanList.length == 0) {
+							this.existData = false
+						} else {
+							this.existData = true
+						}
+						cacheManager.set('contentInfo', res.data);
+					}
+				}).catch(res => {
+					cacheManager.remove("contentInfo");
+					toast("加载失败,请重试");
+				});
+			},
+
+
+			handleScroll(e) {
+				const scrollTop = e.detail.scrollTop;
+				console.log('scrollTop', scrollTop);
+				this.showGoTop = scrollTop > this.scrollThreshold;
+			},
+
+			getJieAndDanyuan(data, jieId) {
+				for (let danyuan of data.danyuanList) {
+					for (let jie of danyuan.jieList) {
+						if (jie.jieId == jieId) {
+							return {
+								danyuan,
+								jie
+							}
+						}
+					}
+				}
+				return null;
+			},
+
+			async saveAndNavigate(jieId, type, da, code) {
+
+				console.log('this.banbenId', this.banbenId);
+				console.log('this.danyuanIddanyuanId', da.danyuanId);
+				if (code == 'jixu') {
+					if (!this.banbenId || !da.danyuanId) {
+						toast("banbenId或者danyuanId 丢失")
+						return false
+					}
+				}
+
+				let req = {
+					"banbenId": this.banbenId,
+					"danyuanId": da.danyuanId,
+					"jieId": jieId
+				}
+				console.log('req', req);
+				try {
+					const res = await shuxueSave(req);
+					if (res.code == 0 && res.data) {
+						let curJieAndDanyuan = this.getJieAndDanyuan(this.banbenInfo, jieId);
+						if (!curJieAndDanyuan) {
+							toast("未找到课程信息");
+							return false;
+						}
+
+						const cacheData = cacheManager.get('contentInfo') || {};
+						cacheData.curDanyuanName = curJieAndDanyuan.danyuan.danyuanName;
+						cacheData.curKechengName = curJieAndDanyuan.jie.jieIntro;
+						cacheData.danyuanId = curJieAndDanyuan.jie.danyuanId;
+						cacheData.curJieId = jieId;
+						cacheData.type = curJieAndDanyuan.jie.type;
+						cacheManager.set('contentInfo', cacheData);
+
+						if (type == 1) {
+							uni.navigateTo({
+								url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
+							})
+						} else {
+							uni.navigateTo({
+								url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
+							})
+						}
+					} else {
+						toast("保存位置出错");
+						return false;
+					}
+				} catch (error) {
+					toast("保存失败");
+					return false;
+				}
+			},
+			handlePlay(da, code) {
+				let jieId = code === 'jixu' ? da.curJieId : da.jieId;
+				if (!jieId) {
+					toast("无课程ID");
+					return;
+				}
+				this.saveAndNavigate(jieId, da.type, da, code);
+			},
+			handleClickDanyuan(danyuanId) {
+
+				if (!danyuanId) {
+					toast("danyuanId丢失")
+					return false
+				}
+				this.isShow = true;
+				setTimeout(() => {
+					// 更新为点击的动态单元Id [临时]
+					this.$refs.dyRef.handleShow(danyuanId)
+				}, 100)
+			},
+			handleBack() {
+				uni.navigateTo({
+					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
+				})
+			},
+		},
+
+		// 计算吸顶栏下方的偏移(确保内容不被遮挡)
+		computed: {
+
+
+		}
+	}
+</script>

+ 357 - 0
pages/chanpinneirong/index copy.vue

@@ -0,0 +1,357 @@
+<template>
+	<view class="ezy-xuexi-page">
+		<view class="icon-title-navBar-box">
+			<text class="nav-bar-title">学习</text>
+		</view>
+		<!-- 滚动区域 -->
+		<scroll-view v-if="existData" class="ezy-page-body xuexi-page-body" :scroll-with-animation="true" scroll-y
+			:scroll-top="scrollTop" @scroll="handleScroll">
+			<view class="xxjl-card-box-padding">
+				<view class="xxjl-card-box">
+					<!-- 显示内容 -->
+					<view class="card-body-box">
+						<img :src="banbenInfo.cover" />
+						<view class="body-right">
+							<view class="right-name">{{ banbenInfo.chanpinName }}</view>
+							<view>等级:{{banbenInfo.dengjiName}}</view>
+							<view>版本:{{banbenInfo.name}}</view>
+							<view>单元:{{banbenInfo.curDanyuanName}}</view>
+							<view>课程:{{banbenInfo.curKechengName}}</view>
+						</view>
+					</view>
+					<view class="card-progress-box">
+						<view class="xx-progress-box">
+							<view>学习进度</view>
+							<progress :percent="curProcess" class="xx-progress" stroke-width="20"
+								backgroundColor="#3c7dfd" activeColor="#ffd11c" />
+						</view>
+						<ezyActiveVue class="ezy-btn-active jxxx-btn" @aclick="handlePlay(banbenInfo,'jixu')">
+						</ezyActiveVue>
+					</view>
+				</view>
+			</view>
+
+			<view class="xx-item-list">
+				<view class="xx-item-title">— 以下为当前等级课程目录 —</view>
+
+				<view v-for="(danyuanItem, index) in danyuanList" :key="danyuanItem.danyuanId">
+					<!-- 单元标题(带唯一ID,用于位置查询) -->
+					<ezyActiveVue class="ezy-list-item-active item-dy-box" @aclick="handleClickDanyuan(danyuanItem.danyuanId)" :id="`unit-title-${danyuanItem.danyuanId}`">
+						<view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
+						<view class="dy-right-box">
+							<view class="right-content">
+								<view>{{danyuanItem.danyuanName}}</view>
+								<view class="dy-name">{{danyuanItem.danyuanIntro}}</view>
+							</view>
+						</view>
+					</ezyActiveVue>
+					<!-- 节列表 -->
+					<ezyActiveVue class="ezy-list-item-active xx-item-box" v-for="jieItem in danyuanItem.jieList"
+						:key="jieItem.jieId" @aclick="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>
+					</ezyActiveVue>
+				</view>
+
+				<view class="xx-item-title">本级别最后一单元啦~</view>
+				<view class="xx-more-btn" @click="moreBtn"></view>
+			</view>
+		</scroll-view>
+		<!-- 回到顶部 -->
+		<view v-show="showGoTop" class="go-top-btn" @click="goTopBtn"></view>
+
+		<!-- 无数据占位 -->
+		<view v-if="!existData" class="ezy-page-body">
+			<view class="ezy-no-sj">
+				<icon></icon>
+				<text>暂无数据</text>
+			</view>
+		</view>
+
+		<!-- 弹窗组件 -->
+		<danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow = false"></danyuanInfoVue>
+
+		<!-- 底部 tabBar -->
+		<custom-tab-bar :show="true" :current-index="currentTabIndex" />
+	</view>
+</template>
+
+<script>
+	import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+	import CustomTabBar from '@/components/custom-tabbar/index.vue';
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		shuxueChanpinBanbenInfo,
+		shuxueSave
+	} from "@/api/chanpinneirong.js"
+	import {
+		onLoad,
+		onShow,
+		onHide,
+		onUnload
+	} from "@dcloudio/uni-app"
+	import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
+	import {
+		toast
+	} from '../../utils/common';
+	import {
+		updateXuexiProcess
+	} from "./useNeirongShuxue"
+	export default {
+		data() {
+			return {
+				canExitApp: false,
+
+				danyuanList: [],
+				banbenInfo: {},
+				banbenId: '',
+				danyuanId: '',
+				chanpinId: '',
+				dengjiId: '',
+				curProcess: '',
+				currentTabIndex: 1,
+				existData: true,
+				isShow: false,
+
+				stickyHeight: 0, // 吸顶栏高度(px)
+				currentStickyTitle: '', // 初始为空,不显示吸顶
+				currentStickyIntro: '',
+				currentDanyuanId: '',
+				currentStickyDengjiId: '',
+				titlePositions: [],
+				scrollTop: 0,
+				showGoTop: false,
+				scrollThreshold: 300,
+			}
+		},
+		components: {
+			CustomTabBar,
+			danyuanInfoVue,
+			ezyActiveVue
+		},
+		onLoad(options) {
+			uni.hideTabBar()
+		},
+		onShow() {
+			this.currentTabIndex = 1
+			const cacheData = cacheManager.get('contentInfo');
+
+			if (cacheData) {
+				console.log('使用缓存数据');
+				this.updateFromCache();
+			} else {
+				console.log('重新请求数据');
+				const cacheDataAuth = cacheManager.get('auth');
+				this.initFromOptions(cacheDataAuth);
+			}
+		},
+		onHide() {
+			console.log('学习页面隐藏')
+		},
+		onUnload() {
+			// 页面卸载无需特殊处理
+		},
+		methods: {
+			goTopBtn() {
+				// 替换原来的 uni.pageScrollTo
+				this.scrollTop = Math.random(); // 先设置一个随机值
+				this.$nextTick(() => {
+					this.scrollTop = 0; // 再设置回0
+				});
+
+				this.showGoTop = false;
+			},
+			moreBtn() {
+				uni.switchTab({
+					url: '/pages/chanpinXuanze/index'
+				})
+			},
+
+			initFromOptions(options) {
+				//console.log('options', options);
+				this.chanpinId = options.chanpinId;
+				this.danyuanId = options.danyuanId;
+				this.banbenId = options.banbenId;
+				this.dengjiId = options.dengjiId;
+				this.loadDataFromApi();
+			},
+			// 从缓存更新数据方法
+			updateFromCache() {
+				updateXuexiProcess()
+				const cacheData = cacheManager.get('contentInfo');
+				console.log('cacheData 从缓存更新数据方法', cacheData);
+				if (cacheData) {
+					this.banbenInfo = {
+						...cacheData
+					};
+					this.curProcess = cacheData.curProcess;
+					this.danyuanList = [...(cacheData.danyuanList || [])];
+					this.banbenId = cacheData.banbenId
+					// this.$nextTick(() => {
+					// 	this.updateTitlePositions();
+					// });
+				}
+			},
+
+			loadDataFromApi() {
+				this.banbenInfo = {}
+				this.curProcess = ''
+				this.danyuanList = []
+				const req = {
+					banbenId: this.banbenId
+				}
+				shuxueChanpinBanbenInfo(req).then(res => {
+					if (res.code === 0) {
+						this.banbenInfo = res.data;
+						this.banbenInfo.danyuanId = res.data.curDanyuanId;
+						this.curProcess = res.data.curProcess * 100;
+						this.danyuanList = res.data.danyuanList || [];
+						if (this.danyuanList.length == 0) {
+							this.existData = false
+						} else {
+							this.existData = true
+						}
+						// 保存到缓存(新增了参数保存)
+						const cacheData = {
+							...res.data,
+							banbenId: this.banbenId,
+							chanpinId: this.chanpinId,
+							danyuanId: this.danyuanId,
+							dengjiId: this.dengjiId
+						};
+						cacheManager.set('contentInfo', cacheData);
+
+						// 更新全局auth信息
+						cacheManager.updateObject('auth', {
+							chanpinId: res.data.chanpinId,
+							banbenId: this.banbenId,
+							danyuanId: res.data.curDanyuanId,
+							dengjiId: res.data.dengjiId
+						});
+						this.danyuanId = res.data.curDanyuanId
+						this.dengjiId = res.data.dengjiId
+						this.chanpinId = res.data.chanpinId
+						// 数据加载完成后初始化观察器
+						// this.$nextTick(() => {
+						// 	this.updateTitlePositions();
+						// });
+					}
+				}).catch(res => {
+					cacheManager.remove("contentInfo");
+					toast("加载失败,请重试");
+				});
+			},
+
+
+			handleScroll(e) {
+				const scrollTop = e.detail.scrollTop;
+				console.log('scrollTop', scrollTop);
+				this.showGoTop = scrollTop > this.scrollThreshold;
+			},
+
+			getJieAndDanyuan(data, jieId) {
+				for (let danyuan of data.danyuanList) {
+					for (let jie of danyuan.jieList) {
+						if (jie.jieId == jieId) {
+							return {
+								danyuan,
+								jie
+							}
+						}
+					}
+				}
+				return null;
+			},
+
+			async saveAndNavigate(jieId, type, da, code) {
+
+				console.log('this.banbenId', this.banbenId);
+				console.log('this.danyuanIddanyuanId', da.danyuanId);
+				if (code == 'jixu') {
+					if (!this.banbenId || !da.danyuanId) {
+						toast("banbenId或者danyuanId 丢失")
+						return false
+					}
+				}
+
+				let req = {
+					"banbenId": this.banbenId,
+					"danyuanId": da.danyuanId,
+					"jieId": jieId
+				}
+				console.log('req', req);
+				try {
+					const res = await shuxueSave(req);
+					if (res.code == 0 && res.data) {
+						let curJieAndDanyuan = this.getJieAndDanyuan(this.banbenInfo, jieId);
+						if (!curJieAndDanyuan) {
+							toast("未找到课程信息");
+							return false;
+						}
+
+						const cacheData = cacheManager.get('contentInfo') || {};
+						cacheData.curDanyuanName = curJieAndDanyuan.danyuan.danyuanName;
+						cacheData.curKechengName = curJieAndDanyuan.jie.jieIntro;
+						cacheData.danyuanId = curJieAndDanyuan.jie.danyuanId;
+						cacheData.curJieId = jieId;
+						cacheData.type = curJieAndDanyuan.jie.type;
+						cacheManager.set('contentInfo', cacheData);
+
+						if (type == 1) {
+							uni.navigateTo({
+								url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
+							})
+						} else {
+							uni.navigateTo({
+								url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
+							})
+						}
+					} else {
+						toast("保存位置出错");
+						return false;
+					}
+				} catch (error) {
+					toast("保存失败");
+					return false;
+				}
+			},
+			handlePlay(da, code) {
+				let jieId = code === 'jixu' ? da.curJieId : da.jieId;
+				if (!jieId) {
+					toast("无课程ID");
+					return;
+				}
+				this.saveAndNavigate(jieId, da.type, da, code);
+			},
+			handleClickDanyuan(danyuanId) {
+
+				if (!danyuanId) {
+					toast("danyuanId丢失")
+					return false
+				}
+				this.isShow = true;
+				setTimeout(() => {
+					// 更新为点击的动态单元Id [临时]
+					this.$refs.dyRef.handleShow(danyuanId)
+				}, 100)
+			},
+			handleBack() {
+				uni.navigateTo({
+					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
+				})
+			},
+		},
+
+		// 计算吸顶栏下方的偏移(确保内容不被遮挡)
+		computed: {
+
+
+		}
+	}
+</script>

+ 45 - 295
pages/chanpinneirong/index.vue

@@ -3,137 +3,39 @@
 		<view class="icon-title-navBar-box">
 		<view class="icon-title-navBar-box">
 			<text class="nav-bar-title">学习</text>
 			<text class="nav-bar-title">学习</text>
 		</view>
 		</view>
-		<!-- 滚动区域 -->
-		<scroll-view v-if="existData" class="ezy-page-body xuexi-page-body" :scroll-with-animation="true" scroll-y
-			:scroll-top="scrollTop" @scroll="handleScroll">
-			<view class="xxjl-card-box-padding">
-				<view class="xxjl-card-box">
-					<!-- 显示内容 -->
-					<view class="card-body-box">
-						<img :src="banbenInfo.cover" />
-						<view class="body-right">
-							<view class="right-name">{{ banbenInfo.chanpinName }}</view>
-							<view>等级:{{banbenInfo.dengjiName}}</view>
-							<view>版本:{{banbenInfo.name}}</view>
-							<view>单元:{{banbenInfo.curDanyuanName}}</view>
-							<view>课程:{{banbenInfo.curKechengName}}</view>
-						</view>
-					</view>
-					<view class="card-progress-box">
-						<view class="xx-progress-box">
-							<view>学习进度</view>
-							<progress :percent="curProcess" class="xx-progress" stroke-width="20"
-								backgroundColor="#3c7dfd" activeColor="#ffd11c" />
-						</view>
-						<ezyActiveVue class="ezy-btn-active jxxx-btn" @aclick="handlePlay(banbenInfo,'jixu')">
-						</ezyActiveVue>
-					</view>
-				</view>
-			</view>
-
-			<view class="xx-item-list">
-				<view class="xx-item-title">— 以下为当前等级课程目录 —</view>
-
-				<view v-for="(danyuanItem, index) in danyuanList" :key="danyuanItem.danyuanId">
-					<!-- 单元标题(带唯一ID,用于位置查询) -->
-					<ezyActiveVue class="ezy-list-item-active item-dy-box" @aclick="handleClickDanyuan(danyuanItem.danyuanId)" :id="`unit-title-${danyuanItem.danyuanId}`">
-						<view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
-						<view class="dy-right-box">
-							<view class="right-content">
-								<view>{{danyuanItem.danyuanName}}</view>
-								<view class="dy-name">{{danyuanItem.danyuanIntro}}</view>
-							</view>
-						</view>
-					</ezyActiveVue>
-					<!-- 节列表 -->
-					<ezyActiveVue class="ezy-list-item-active xx-item-box" v-for="jieItem in danyuanItem.jieList"
-						:key="jieItem.jieId" @aclick="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>
-					</ezyActiveVue>
-				</view>
-
-				<view class="xx-item-title">本级别最后一单元啦~</view>
-				<view class="xx-more-btn" @click="moreBtn"></view>
-			</view>
-		</scroll-view>
-		<!-- 回到顶部 -->
-		<view v-show="showGoTop" class="go-top-btn" @click="goTopBtn"></view>
-
-		<!-- 无数据占位 -->
-		<view v-if="!existData" class="ezy-page-body">
-			<view class="ezy-no-sj">
-				<icon></icon>
-				<text>暂无数据</text>
-			</view>
-		</view>
-
-		<!-- 弹窗组件 -->
-		<danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow = false"></danyuanInfoVue>
-
+		<chanpin1 v-if="chanpinId==1" ref="chanpin1Ref"></chanpin1>
 		<!-- 底部 tabBar -->
 		<!-- 底部 tabBar -->
 		<custom-tab-bar :show="true" :current-index="currentTabIndex" />
 		<custom-tab-bar :show="true" :current-index="currentTabIndex" />
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script>
 <script>
-	import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
 	import CustomTabBar from '@/components/custom-tabbar/index.vue';
 	import CustomTabBar from '@/components/custom-tabbar/index.vue';
 	import cacheManager from "@/utils/cacheManager.js";
 	import cacheManager from "@/utils/cacheManager.js";
 	import {
 	import {
-		shuxueChanpinBanbenInfo,
-		shuxueSave
-	} from "@/api/chanpinneirong.js"
-	import {
 		onLoad,
 		onLoad,
 		onShow,
 		onShow,
 		onHide,
 		onHide,
 		onUnload
 		onUnload
 	} from "@dcloudio/uni-app"
 	} from "@dcloudio/uni-app"
-	import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
 	import {
 	import {
 		toast
 		toast
 	} from '../../utils/common';
 	} from '../../utils/common';
+	import chanpin1 from './chanpin1'
 	import {
 	import {
-		updateXuexiProcess
-	} from "./useNeirongShuxue"
+		banbenImpinfo
+	} from "@/api/login.js"
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				canExitApp: false,
-
-				danyuanList: [],
-				banbenInfo: {},
-				banbenId: '',
-				danyuanId: '',
-				chanpinId: '',
-				dengjiId: '',
-				curProcess: '',
 				currentTabIndex: 1,
 				currentTabIndex: 1,
-				existData: true,
-				isShow: false,
-
-				stickyHeight: 0, // 吸顶栏高度(px)
-				currentStickyTitle: '', // 初始为空,不显示吸顶
-				currentStickyIntro: '',
-				currentDanyuanId: '',
-				currentStickyDengjiId: '',
-				titlePositions: [],
-				scrollTop: 0,
-				showGoTop: false,
-				scrollThreshold: 300,
+				banbenId: '',
+				chanpinId: ''
 			}
 			}
 		},
 		},
 		components: {
 		components: {
 			CustomTabBar,
 			CustomTabBar,
-			danyuanInfoVue,
-			ezyActiveVue
+			chanpin1
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
 			uni.hideTabBar()
 			uni.hideTabBar()
@@ -141,14 +43,12 @@
 		onShow() {
 		onShow() {
 			this.currentTabIndex = 1
 			this.currentTabIndex = 1
 			const cacheData = cacheManager.get('contentInfo');
 			const cacheData = cacheManager.get('contentInfo');
-
 			if (cacheData) {
 			if (cacheData) {
 				console.log('使用缓存数据');
 				console.log('使用缓存数据');
-				this.updateFromCache();
+			this.switchUseCache(cacheData)
 			} else {
 			} else {
-				console.log('重新请求数据');
-				const cacheDataAuth = cacheManager.get('auth');
-				this.initFromOptions(cacheDataAuth);
+				console.log('重新请求数据,请求版本内容详情接口');
+				this.getBanbenInfo();
 			}
 			}
 		},
 		},
 		onHide() {
 		onHide() {
@@ -158,200 +58,50 @@
 			// 页面卸载无需特殊处理
 			// 页面卸载无需特殊处理
 		},
 		},
 		methods: {
 		methods: {
-			goTopBtn() {
-				// 替换原来的 uni.pageScrollTo
-				this.scrollTop = Math.random(); // 先设置一个随机值
-				this.$nextTick(() => {
-					this.scrollTop = 0; // 再设置回0
-				});
-
-				this.showGoTop = false;
-			},
-			moreBtn() {
-				uni.switchTab({
-					url: '/pages/chanpinXuanze/index'
-				})
-			},
-
-			initFromOptions(options) {
-				//console.log('options', options);
-				this.chanpinId = options.chanpinId;
-				this.danyuanId = options.danyuanId;
-				this.banbenId = options.banbenId;
-				this.dengjiId = options.dengjiId;
-				this.loadDataFromApi();
-			},
-			// 从缓存更新数据方法
-			updateFromCache() {
-				updateXuexiProcess()
-				const cacheData = cacheManager.get('contentInfo');
-				console.log('cacheData 从缓存更新数据方法', cacheData);
-				if (cacheData) {
-					this.banbenInfo = {
-						...cacheData
-					};
-					this.curProcess = cacheData.curProcess;
-					this.danyuanList = [...(cacheData.danyuanList || [])];
-					this.banbenId = cacheData.banbenId
-					// this.$nextTick(() => {
-					// 	this.updateTitlePositions();
-					// });
-				}
-			},
-
-			loadDataFromApi() {
-				this.banbenInfo = {}
-				this.curProcess = ''
-				this.danyuanList = []
-				const req = {
-					banbenId: this.banbenId
+			switchUseCache(data){
+				switch (Number(data.chanpinId)) {
+					case 1:
+						this.$nextTick(() => {
+							this.$refs.chanpin1Ref.initData()
+						})
+						break;
+					case 2:
+				
+						break;
+					default:
+				
 				}
 				}
-				shuxueChanpinBanbenInfo(req).then(res => {
-					if (res.code === 0) {
-						this.banbenInfo = res.data;
-						this.banbenInfo.danyuanId = res.data.curDanyuanId;
-						this.curProcess = res.data.curProcess * 100;
-						this.danyuanList = res.data.danyuanList || [];
-						if (this.danyuanList.length == 0) {
-							this.existData = false
-						} else {
-							this.existData = true
-						}
-						// 保存到缓存(新增了参数保存)
-						const cacheData = {
-							...res.data,
-							banbenId: this.banbenId,
-							chanpinId: this.chanpinId,
-							danyuanId: this.danyuanId,
-							dengjiId: this.dengjiId
-						};
-						cacheManager.set('contentInfo', cacheData);
-
-						// 更新全局auth信息
-						cacheManager.updateObject('auth', {
-							chanpinId: res.data.chanpinId,
-							banbenId: this.banbenId,
-							danyuanId: res.data.curDanyuanId,
-							dengjiId: res.data.dengjiId
-						});
-						this.danyuanId = res.data.curDanyuanId
-						this.dengjiId = res.data.dengjiId
-						this.chanpinId = res.data.chanpinId
-						// 数据加载完成后初始化观察器
-						// this.$nextTick(() => {
-						// 	this.updateTitlePositions();
-						// });
-					}
-				}).catch(res => {
-					cacheManager.remove("contentInfo");
-					toast("加载失败,请重试");
-				});
-			},
-
-
-			handleScroll(e) {
-				const scrollTop = e.detail.scrollTop;
-				console.log('scrollTop', scrollTop);
-				this.showGoTop = scrollTop > this.scrollThreshold;
 			},
 			},
+			switchGetNeiRongInfo(data) {
+				switch (Number(data.chanpinId)) {
+					case 1:
+						const banbenId = data.banbenId
+						this.$nextTick(() => {
+							this.$refs.chanpin1Ref.initData(banbenId)
+						})
+						break;
+					case 2:
+
+						break;
+					default:
 
 
-			getJieAndDanyuan(data, jieId) {
-				for (let danyuan of data.danyuanList) {
-					for (let jie of danyuan.jieList) {
-						if (jie.jieId == jieId) {
-							return {
-								danyuan,
-								jie
-							}
-						}
-					}
 				}
 				}
-				return null;
 			},
 			},
-
-			async saveAndNavigate(jieId, type, da, code) {
-
-				console.log('this.banbenId', this.banbenId);
-				console.log('this.danyuanIddanyuanId', da.danyuanId);
-				if (code == 'jixu') {
-					if (!this.banbenId || !da.danyuanId) {
-						toast("banbenId或者danyuanId 丢失")
-						return false
-					}
-				}
-
-				let req = {
-					"banbenId": this.banbenId,
-					"danyuanId": da.danyuanId,
-					"jieId": jieId
-				}
-				console.log('req', req);
-				try {
-					const res = await shuxueSave(req);
-					if (res.code == 0 && res.data) {
-						let curJieAndDanyuan = this.getJieAndDanyuan(this.banbenInfo, jieId);
-						if (!curJieAndDanyuan) {
-							toast("未找到课程信息");
-							return false;
-						}
-
-						const cacheData = cacheManager.get('contentInfo') || {};
-						cacheData.curDanyuanName = curJieAndDanyuan.danyuan.danyuanName;
-						cacheData.curKechengName = curJieAndDanyuan.jie.jieIntro;
-						cacheData.danyuanId = curJieAndDanyuan.jie.danyuanId;
-						cacheData.curJieId = jieId;
-						cacheData.type = curJieAndDanyuan.jie.type;
-						cacheManager.set('contentInfo', cacheData);
-
-						if (type == 1) {
-							uni.navigateTo({
-								url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
-							})
-						} else {
-							uni.navigateTo({
-								url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
-							})
-						}
+			getBanbenInfo() {
+				banbenImpinfo({}).then(res => {
+					if (res.code == 0) {
+						this.chanpinId = res.data.chanpinId
+						this.switchGetNeiRongInfo(res.data)
 					} else {
 					} else {
-						toast("保存位置出错");
-						return false;
+						toast('请求版本内容详情接口数据异常')
+						return
 					}
 					}
-				} catch (error) {
-					toast("保存失败");
-					return false;
-				}
-			},
-			handlePlay(da, code) {
-				let jieId = code === 'jixu' ? da.curJieId : da.jieId;
-				if (!jieId) {
-					toast("无课程ID");
-					return;
-				}
-				this.saveAndNavigate(jieId, da.type, da, code);
-			},
-			handleClickDanyuan(danyuanId) {
-
-				if (!danyuanId) {
-					toast("danyuanId丢失")
+				}).catch(() => {
+					toast('请求版本内容详情接口数据异常')
 					return false
 					return false
-				}
-				this.isShow = true;
-				setTimeout(() => {
-					// 更新为点击的动态单元Id [临时]
-					this.$refs.dyRef.handleShow(danyuanId)
-				}, 100)
-			},
-			handleBack() {
-				uni.navigateTo({
-					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
 				})
 				})
 			},
 			},
 		},
 		},
-
-		// 计算吸顶栏下方的偏移(确保内容不被遮挡)
-		computed: {
-
-
-		}
+		computed: {}
 	}
 	}
-</script>
+</script>

+ 16 - 0
pages/chanpinneirong/useNeirongChanpin1.js

@@ -0,0 +1,16 @@
+import cacheManager from "@/utils/cacheManager.js";
+
+export function updateChanpin1Process() {
+	const cacheData = cacheManager.get('contentInfo');
+	console.log('cacheData333333', cacheData)
+	const list = cacheData.danyuanList;
+	const defaultCurProcess = cacheData.curProcess;
+	let mList = [];
+	list.forEach(item => {
+		mList = [...mList, ...item.jieList]
+	})
+
+	const process = mList.filter(item => item.wanchengFlag).length/mList.length * 100 || 0;
+	cacheData.curProcess = defaultCurProcess > process ? defaultCurProcess: process;
+	cacheManager.set('contentInfo', cacheData);
+}