Browse Source

Merge remote-tracking branch 'origin/2025鹅状元数学' into 2025鹅状元数学

# Conflicts:
#	pages/chanpinMy/my.vue
wangxy 5 days ago
parent
commit
111aa55533

+ 5 - 0
common/styles/global/pages.scss

@@ -2474,4 +2474,9 @@
 	}
 	}
 	
 	
 		
 		
+}
+
+// 资料
+.ezy-ziliao-page{
+	width: 100%;height: 100vh;display: flex;flex-direction: column;
 }
 }

+ 2 - 2
components/custom-tabbar/custom-tabbar.vue

@@ -49,7 +49,7 @@
 					{
 					{
 						iconPath: 'static/images/tabbar/unselect/faxian-sj.png',
 						iconPath: 'static/images/tabbar/unselect/faxian-sj.png',
 						activePath: 'static/images/tabbar/select/faxian-sj.png',
 						activePath: 'static/images/tabbar/select/faxian-sj.png',
-						path: '/pages/game/index'
+						path: '/pages/chanpinZiliao/index'
 					},
 					},
 					{
 					{
 						iconPath: 'static/images/tabbar/unselect/wode-sj.png',
 						iconPath: 'static/images/tabbar/unselect/wode-sj.png',
@@ -92,7 +92,7 @@
 				const routeMap = {
 				const routeMap = {
 					0: 'pages/chanpinXuanze/index',
 					0: 'pages/chanpinXuanze/index',
 					1: 'pages/chanpinneirong/index',
 					1: 'pages/chanpinneirong/index',
-					2: 'pages/game/index',
+					2: 'pages/chanpinZiliao/index',
 					3: 'pages/chanpinMy/my'
 					3: 'pages/chanpinMy/my'
 				};
 				};
 				return route === routeMap[tabIndex];
 				return route === routeMap[tabIndex];

+ 1 - 9
components/custom-tabbar/index.vue

@@ -36,7 +36,7 @@
             selectedIconPath: 'static/images/tabbar/select/xuexi-sj.png'
             selectedIconPath: 'static/images/tabbar/select/xuexi-sj.png'
           },
           },
           {
           {
-            pagePath: '/pages/game/index',
+            pagePath: '/pages/chanpinZiliao/index',
             text: "游戏2",
             text: "游戏2",
             iconPath: 'static/images/tabbar/unselect/faxian-sj.png',
             iconPath: 'static/images/tabbar/unselect/faxian-sj.png',
             selectedIconPath: 'static/images/tabbar/select/faxian-sj.png'
             selectedIconPath: 'static/images/tabbar/select/faxian-sj.png'
@@ -113,12 +113,4 @@
     margin-bottom: 6rpx;
     margin-bottom: 6rpx;
   }
   }
 
 
-  .tab-text {
-    font-size: 20rpx;
-    color: #7A7E83;
-  }
-
-  .tab-text.active {
-    color: #007AFF;
-  }
 </style>
 </style>

+ 22 - 1
pages.json

@@ -20,6 +20,27 @@
 			}
 			}
 		},
 		},
 		{
 		{
+			"path" : "pages/chanpinMy/order",
+			"style" : 
+			{
+				"navigationStyle": "custom"
+			}
+		},
+		{
+			"path" : "pages/chanpinZiliao/index",
+			"style" : 
+			{
+				"navigationStyle": "custom"
+			}
+		},
+		{
+			"path" : "pages/chanpinZiliao/ziliaoInfo",
+			"style" : 
+			{
+				"navigationStyle": "custom"
+			}
+		},
+		{
 			"path": "pages/game/index",
 			"path": "pages/game/index",
 			"style": {
 			"style": {
 				"navigationStyle": "custom",
 				"navigationStyle": "custom",
@@ -210,7 +231,7 @@
 				"pagePath": "pages/chanpinneirong/index"
 				"pagePath": "pages/chanpinneirong/index"
 			},
 			},
 			{
 			{
-				"pagePath": "pages/game/index"
+				"pagePath": "pages/chanpinZiliao/index"
 
 
 			},
 			},
 			{
 			{

+ 16 - 0
pages/chanpinMy/my.vue

@@ -19,6 +19,10 @@
 
 
 			<!-- 设置 -->
 			<!-- 设置 -->
 			<view class="my-list-box">
 			<view class="my-list-box">
+				<view class="list-item" @click="ddBtn">
+					<icon class="list-icon yysz-icon"></icon>
+					<text>订单</text>
+				</view>
 				<view class="list-item" @click="yingyongshezhi">
 				<view class="list-item" @click="yingyongshezhi">
 					<icon class="list-icon yysz-icon"></icon>
 					<icon class="list-icon yysz-icon"></icon>
 					<text>应用设置</text>
 					<text>应用设置</text>
@@ -77,9 +81,13 @@
 		nickName: '',
 		nickName: '',
 		icon: '',
 		icon: '',
 	});
 	});
+	let pageFrom = ref(null)
 
 
 	onShow(() => {
 	onShow(() => {
 		currentTabIndex.value = 3
 		currentTabIndex.value = 3
+		if(pageFrom.value ==='myInfo'){
+			getMyInfo();
+		}
 	})
 	})
 	/***************** 测试 ******************/
 	/***************** 测试 ******************/
 	const testRef = ref(null)
 	const testRef = ref(null)
@@ -94,6 +102,7 @@
 		myInfo({}).then(res => {
 		myInfo({}).then(res => {
 			myInfoData.userName = res.data.userName;
 			myInfoData.userName = res.data.userName;
 			myInfoData.nickName = res.data.nickName;
 			myInfoData.nickName = res.data.nickName;
+			pageFrom.value = ''
 			appleCode.value = res.data.appleCode.toString()
 			appleCode.value = res.data.appleCode.toString()
 			if (res.data.nickName) {
 			if (res.data.nickName) {
 				myInfoData.nickName = res.data.nickName;
 				myInfoData.nickName = res.data.nickName;
@@ -131,11 +140,18 @@
 	}
 	}
 
 
 	function yingyongshezhi() {
 	function yingyongshezhi() {
+		pageFrom.value = 'myInfo'
 		uni.navigateTo({
 		uni.navigateTo({
 			url: '/pages/chanpinMy/myInfo'
 			url: '/pages/chanpinMy/myInfo'
 		})
 		})
 	}
 	}
 
 
+	function ddBtn(){
+		uni.navigateTo({
+			url: '/pages/chanpinMy/order'
+		})
+	}
+
 	function duihuamaDuihuan() {
 	function duihuamaDuihuan() {
 		// 兑换码兑换策略
 		// 兑换码兑换策略
 		if (currentPlatform.value == 'ios') {
 		if (currentPlatform.value == 'ios') {

+ 26 - 0
pages/chanpinMy/order.vue

@@ -0,0 +1,26 @@
+<template>
+	<view class="ezy-ziliao-page">
+		<view class="icon-title-navBar-box">
+			<view @click="handleBack" class="nav-bar-icon"></view>
+			<text class="nav-bar-title">订单</text>
+		</view>
+		<view class="ezy-page-body">
+			
+		</view>
+	</view>
+</template>
+
+<script setup>
+import {reactive, ref} from "vue";
+import {onLoad,onShow} from "@dcloudio/uni-app"
+function handleBack() {
+		uni.switchTab({
+			url: '/pages/chanpinMy/my'
+		})
+	}
+onLoad(() => {
+})
+</script>
+
+<style>
+</style>

+ 25 - 0
pages/chanpinZiliao/index.vue

@@ -0,0 +1,25 @@
+<template>
+	<view class="ezy-ziliao-page">
+		<view class="icon-title-navBar-box">
+			<text class="nav-bar-title">资料</text>
+		</view>
+		<view class="ezy-page-body">
+			
+		</view>
+	</view>
+	<custom-tab-bar :show="true" :current-index="currentTabIndex" />
+</template>
+
+<script setup>
+import {reactive, ref} from "vue";
+import {onLoad,onShow} from "@dcloudio/uni-app"
+import CustomTabBar from "@/components/custom-tabbar/index.vue";
+let currentTabIndex = ref(2);
+onLoad(() => {
+	// 隐藏默认系统导航栏显示自定义导航栏
+	uni.hideTabBar()
+})
+</script>
+
+<style>
+</style>

+ 26 - 0
pages/chanpinZiliao/ziliaoInfo.vue

@@ -0,0 +1,26 @@
+<template>
+	<view class="ezy-ziliao-page">
+		<view class="icon-title-navBar-box">
+			<view @click="handleBack" class="nav-bar-icon"></view>
+			<text class="nav-bar-title">资料详情</text>
+		</view>
+		<view class="ezy-page-body">
+			
+		</view>
+	</view>
+</template>
+
+<script setup>
+import {reactive, ref} from "vue";
+import {onLoad,onShow} from "@dcloudio/uni-app"
+function handleBack() {
+		uni.switchTab({
+			url: '/pages/chanpinZiliao/index'
+		})
+	}
+onLoad(() => {
+})
+</script>
+
+<style>
+</style>

+ 2 - 2
pages/chanpinneirong/index.vue

@@ -40,8 +40,8 @@
 						<view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
 						<view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
 						<view class="dy-right-box">
 						<view class="dy-right-box">
 							<view class="right-content">
 							<view class="right-content">
-								<view class="dy-name">{{danyuanItem.danyuanName}}</view>
-								<view>{{danyuanItem.danyuanIntro}}</view>
+								<view>{{danyuanItem.danyuanName}}</view>
+								<view class="dy-name">{{danyuanItem.danyuanIntro}}</view>
 							</view>
 							</view>
 						</view>
 						</view>
 					</ezyActiveVue>
 					</ezyActiveVue>

+ 427 - 0
pages/chanpinneirong/index4.vue

@@ -0,0 +1,427 @@
+<template>
+	<view class="ezy-xuexi-page3">
+		<view class="icon-title-navBar-box">
+			<text class="nav-bar-title">学习</text>
+		</view>
+		<!-- 吸顶单元标题 -->
+		<view
+			class="item-dy-box item-fixed"
+		>
+			<view class="dy-left-box">L{{ currentStickyDengjiId }}</view>
+			<view class="dy-right-box">
+				<view class="right-content" v-if="currentStickyTitle">
+					<view class="dy-name">{{ currentStickyTitle }}</view>
+					<view>{{ currentStickyIntro }}</view>
+				</view>
+				<view class="right-default" v-else><view>课程目录</view></view>
+			</view>
+		</view>
+
+		<!-- 滚动区域 -->
+		<scroll-view
+			v-if="existData"
+			class="ezy-page-body xuexi-page-body"
+			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,用于位置查询) -->
+					<view class="xx-item-title" :id="`title-${danyuanItem.danyuanId}`">
+						— {{ danyuanItem.danyuanName }} {{ danyuanItem.danyuanIntro }} —
+					</view>
+
+					<!-- 节列表 -->
+					<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 class="go-top-btn" @click="goTopBtn"></view>
+
+		<!-- 无数据占位 -->
+		<view v-if="!existData" class="ezy-page-body xuexi-page-body"></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: '',
+				currentStickyDengjiId: '',
+				titlePositions: [],
+				scrollTop: 0,
+			}
+		},
+		components: {
+			CustomTabBar,
+			danyuanInfoVue,
+			ezyActiveVue
+		},
+		onLoad(options) {
+			uni.hideTabBar()
+		},
+		onShow() {
+			this.currentTabIndex = 1
+			const cacheData = cacheManager.get('xuexi-shuxue');
+
+			if (cacheData) {
+				console.log('使用缓存数据');
+				this.updateFromCache();
+			} else {
+				console.log('重新请求数据');
+				const cacheDataAuth = cacheManager.get('auth');
+				this.initFromOptions(cacheDataAuth);
+			}
+		},
+		onHide() {
+			console.log('学习页面隐藏')
+		},
+		onUnload() {
+			// 页面卸载无需特殊处理
+		},
+		methods: {
+			goTopBtn() {
+				this.scrollTop = -1; // 先设一个无效值(确保变化)
+				this.$nextTick(() => {
+					this.scrollTop = 0; // 再滚到顶部
+				});
+			},
+			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('xuexi-shuxue');
+				console.log('cacheData 从缓存更新数据方法', cacheData);
+				if (cacheData) {
+					this.banbenInfo = { ...cacheData };
+					this.curProcess = cacheData.curProcess;
+					this.danyuanList = [...(cacheData.danyuanList || [])];
+
+					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.curProcess =res.data.curProcess * 100;
+						this.danyuanList = res.data.danyuanList || [];
+
+						if (!this.danyuanList.length) {
+							this.existData = false
+						}
+						// 保存到缓存(新增了参数保存)
+						const cacheData = {
+							...res.data,
+							banbenId: this.banbenId,
+							chanpinId: this.chanpinId,
+							danyuanId: this.danyuanId,
+							dengjiId: this.dengjiId
+						};
+						cacheManager.set('xuexi-shuxue', 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("xuexi-shuxue");
+					toast("加载失败,请重试");
+				});
+			},
+
+			updateStickyHeight() {
+					const query = uni.createSelectorQuery().in(this);
+					query.select('.item-fixed').boundingClientRect(res => {
+						if (res) {
+							this.stickyHeight = res.height; // 单位 px
+						} else {
+							this.stickyHeight = 100; // 默认 fallback(约 200rpx = 100px)
+						}
+					}).exec();
+				},
+
+			// 获取所有标题在 scroll-view 中的绝对位置
+			updateTitlePositions() {
+				this.titlePositions = [];
+				this.danyuanTitleRefs = [];
+
+				if (!this.danyuanList.length) return;
+
+				const query = uni.createSelectorQuery().in(this);
+				this.danyuanList.forEach(item => {
+					query.select(`#title-${item.danyuanId}`).boundingClientRect();
+					this.danyuanTitleRefs.push(item);
+				});
+
+				query.exec((rects) => {
+					rects.forEach((rect, index) => {
+						if (rect) {
+							// 在 scroll-view 初始未滚动时,rect.top 就是内容中的绝对 top
+							this.titlePositions.push({
+								danyuanId: this.danyuanTitleRefs[index].danyuanId,
+								name: this.danyuanTitleRefs[index].danyuanName,
+								intro: this.danyuanTitleRefs[index].danyuanIntro,
+								top: rect.top
+							});
+						}
+					});
+					this.titlePositions.sort((a, b) => a.top - b.top);
+					// 👇 新增:更新吸顶栏高度
+								this.updateStickyHeight();
+				});
+			},
+
+			handleScroll(e) {
+				const scrollTop = e.detail.scrollTop;
+				const firstTitle = this.titlePositions[0];
+
+				if (!firstTitle) {
+					this.currentStickyTitle = '';
+					return;
+				}
+
+				// 👇 关键修改:提前触发吸顶
+				const triggerOffset = scrollTop + this.stickyHeightPx;
+
+				// 如果还没滚到第一个标题的顶部(考虑吸顶高度),则隐藏
+				if (triggerOffset < firstTitle.top) {
+					this.currentStickyTitle = '';
+					return;
+				}
+
+				// 找出最后一个 top <= triggerOffset 的标题(即刚进入吸顶区的单元)
+				let matched = null;
+				for (let i = this.titlePositions.length - 1; i >= 0; i--) {
+					if (this.titlePositions[i].top <= triggerOffset) {
+						matched = this.titlePositions[i];
+						break;
+					}
+				}
+
+				if (matched) {
+					this.currentStickyTitle = matched.name;
+					this.currentStickyIntro = matched.intro;
+					this.currentStickyDengjiId = this.banbenInfo.dengjiId || 1;
+				} else {
+					this.currentStickyTitle = '';
+				}
+			},
+
+			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) {
+				if (code == 'jixu') {
+					if (!this.banbenId || !this.danyuanId) {
+						toast("banbenId或者danyuanId 丢失")
+						return false
+					}
+				}
+
+				let req = {
+					"banbenId": this.banbenId,
+					"danyuanId": da.danyuanId,
+					"jieId": jieId
+				}
+
+				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('xuexi-shuxue') || {};
+						cacheData.curDanyuanName = curJieAndDanyuan.danyuan.danyuanName;
+						cacheData.curKechengName = curJieAndDanyuan.jie.jieIntro;
+						cacheData.curJieId = jieId;
+						cacheData.type = curJieAndDanyuan.jie.type;
+						cacheManager.set('xuexi-shuxue', 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(item) {
+				if (!item.danyuanId) {
+					toast("danyuanId丢失")
+					return false
+				}
+				this.isShow = true;
+				setTimeout(() => {
+					// 更新为点击的动态单元Id [临时]
+					this.$refs.dyRef.handleShow(item.danyuanId)
+				}, 100)
+			},
+			handleBack() {
+				uni.navigateTo({
+					url: `/pages/chanpinXuanze/banben?dengjiId=` + this.dengjiId
+				})
+			},
+		},
+
+		// 计算吸顶栏下方的偏移(确保内容不被遮挡)
+		computed: {
+			stickyHeightPx() {
+					// 175rpx ≈ 87.5px,取整 90px 足够安全
+					return 90;
+				},
+			topOffset() {
+					// 只有当吸顶栏显示时,才增加上边距避免内容被遮挡
+					return this.currentStickyTitle ? '80rpx' : '0rpx';
+				}
+
+		}
+	}
+</script>
+