Browse Source

Merge branch '2025鹅状元数学' of https://gogs.mtavip.com/wangguoyu/uniProject into 2025鹅状元数学

tanxue 1 month ago
parent
commit
bfd3cfa3b4
1 changed files with 66 additions and 43 deletions
  1. 66 43
      pages/chanpinneirong/index2.vue

+ 66 - 43
pages/chanpinneirong/index2.vue

@@ -3,7 +3,7 @@
 		<view class="icon-title-navBar-box">
 			<text class="nav-bar-title">学习</text>
 		</view>
-		<view v-if="existData" class="ezy-page-body xuexi-page-body">
+		<view v-if="existData" class="ezy-page-body xuexi-page-body" ref="containerRef">
 			<view class="xxjl-card-box-padding">
 				<view class="xxjl-card-box">
 					<!-- 显示内容 -->
@@ -11,10 +11,10 @@
 						<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>等级:{{ banbenInfo.dengjiName }}</view>
+							<view>版本:{{ banbenInfo.name }}</view>
+							<view>单元:{{ banbenInfo.curDanyuanName }}</view>
+							<view>课程:{{ banbenInfo.curKechengName }}</view>
 						</view>
 					</view>
 					<view class="card-progress-box">
@@ -31,36 +31,38 @@
 			<view class="xx-item-list">
 				<view class="xx-item-title cccAAA2">— 以下为当前等级课程目录 —</view>
 
-        <template v-if="unitPositions.length">
-          <ezyActiveVue  class="ezy-list-item-active item-dy-box item-fixed cccAAA"
-                         @aclick="handleClickDanyuan(danyuanList[activeAAAIndex])" :id="`unit-title-${danyuanList[activeAAAIndex].danyuanId}`">
-            <view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
-            <view class="dy-right-box">
-              <view class="right-content">
-                <view class="dy-name">{{danyuanList[activeAAAIndex].danyuanName}}</view>
-                <view>{{danyuanList[activeAAAIndex].danyuanIntro}}</view>
-              </view>
-            </view>
-          </ezyActiveVue>
-        </template>
+				<template v-if="unitPositions.length">
+					<ezyActiveVue class="ezy-list-item-active item-dy-box item-fixed cccAAAB"
+						@aclick="handleClickDanyuan(danyuanList[activeAAAIndex])"
+						:id="`unit-title-${danyuanList[activeAAAIndex].danyuanId}`">
+						<view class="dy-left-box">L{{ banbenInfo.dengjiId }}</view>
+						<view class="dy-right-box">
+							<view class="right-content">
+								<view class="dy-name">{{ danyuanList[activeAAAIndex].danyuanName }}</view>
+								<view>{{ danyuanList[activeAAAIndex].danyuanIntro }}</view>
+							</view>
+						</view>
+					</ezyActiveVue>
+				</template>
 
 
 				<view v-for="(danyuanItem,index) in danyuanList" :key="danyuanItem.danyuanId">
 					<!-- 第一单元 -->
-            <ezyActiveVue v-show="false"  v-if="index ==0" class="ezy-list-item-active item-dy-box item-fixed cccAAA"
-                          @aclick="handleClickDanyuan(danyuanItem)" :id="`unit-title-${danyuanItem.danyuanId}`">
-              <view class="dy-left-box">L{{banbenInfo.dengjiId}}</view>
-              <view class="dy-right-box">
-                <view class="right-content">
-                  <view class="dy-name">{{danyuanItem.danyuanName}}</view>
-                  <view>{{danyuanItem.danyuanIntro}}</view>
-                </view>
-              </view>
-            </ezyActiveVue>
+					<ezyActiveVue v-show="false" v-if="index ==0"
+						class="ezy-list-item-active item-dy-box item-fixed cccAAA"
+						@aclick="handleClickDanyuan(danyuanItem)" :id="`unit-title-${danyuanItem.danyuanId}`">
+						<view class="dy-left-box">L{{ banbenInfo.dengjiId }}</view>
+						<view class="dy-right-box">
+							<view class="right-content">
+								<view class="dy-name">{{ danyuanItem.danyuanName }}</view>
+								<view>{{ danyuanItem.danyuanIntro }}</view>
+							</view>
+						</view>
+					</ezyActiveVue>
 					<!-- 其他单元 -->
 					<view v-if="index !=0" class="xx-item-title cccAAA" :id="`unit-title-${danyuanItem.danyuanId}`">—
-						{{danyuanItem.danyuanName}}
-						{{danyuanItem.danyuanIntro}} —
+						{{ danyuanItem.danyuanName }}
+						{{ danyuanItem.danyuanIntro }} —
 					</view>
 
 
@@ -84,7 +86,7 @@
 			</view>
 
 			<!-- 回到顶部 -->
-			<view class="go-top-btn" v-if="false"></view>
+			<view class="go-top-btn" v-if="showTop" @click="handleTop"></view>
 
 		</view>
 		<view v-if="!existData">
@@ -118,17 +120,22 @@
 	import {
 		updateXuexiProcess
 	} from "./useNeirongShuxue"
+	import {
+		nextTick
+	} from "vue";
+
 	export default {
 		data() {
 			return {
-				//-------------- start ---------------/ 
+				//-------------- start ---------------/
 				// 单元位置信息
 				unitPositions: [],
 				// 节流定时器
 				throttleTimer: null,
 				activeAAAIndex: 0,
 				defaultD: 0,
-				//-------------- end ---------------/ 
+        showTop: false,
+				//-------------- end ---------------/
 
 
 				canExitApp: false,
@@ -455,11 +462,19 @@
 					.in(this)
 					.selectAll(".cccAAA")
 					.boundingClientRect((rects) => {
-            console.log('cccAAA', rects)
 						this.unitPositions = [...rects]
-						this.defaultD = rects[0].top;
 					})
 					.exec();
+				setTimeout(() => {
+					uni
+						.createSelectorQuery()
+						.in(this)
+						.selectAll(".cccAAAB")
+						.boundingClientRect((rects) => {
+							this.defaultD = rects[0].top;
+						})
+						.exec();
+				},500)
 			},
 			// 绑定滚动事件
 			bindScrollEvent() {
@@ -468,22 +483,26 @@
 					query.select('.cccAAA2').boundingClientRect()
 					query.exec((res) => {
 						let arr = []
-						this.unitPositions.forEach((item,index) => {
-							if ((item.top + res[0].top) < this.defaultD) {
+						this.unitPositions.forEach((item, index) => {
+							if ((item.top + res[0].top) < this.defaultD+20) {
 								arr.push(index)
 							}
+              if (res[0].top< 0) {
+                this.showTop = true
+              } else {
+                this.showTop = false
+              }
 						})
-						
 						if (arr.length) {
-							if (this.activeAAAIndex != arr[arr.length-1]) {
-								console.log('当前数据', this.danyuanList[arr[arr.length-1]])
-								this.activeAAAIndex = arr[arr.length-1];
+							if (this.activeAAAIndex != arr[arr.length - 1]) {
+								// console.log('当前数据', this.danyuanList[arr[arr.length - 1]])
+								this.activeAAAIndex = arr[arr.length - 1];
 							}
 						}
 					})
 
-          clearTimeout(this.scrollTimer)
-          this.scrollTimer = null;
+					clearTimeout(this.scrollTimer)
+					this.scrollTimer = null;
 					this.scrollTimer = setTimeout(checkScroll, 200) // 每200ms检查一次
 				}
 
@@ -498,7 +517,11 @@
 					// 添加初始调试信息
 					console.log("页面初始化完成,单元位置:", this.unitPositions);
 				});
-			}
+			},
+      handleTop() {
+        console.log('ccc', this.$refs.containerRef.$el.scrollTop)
+        this.$refs.containerRef.$el.scrollTop = 0;
+      }
 		},
 	}
 </script>