wangxy 1 month ago
parent
commit
0557f7fd1c
1 changed files with 54 additions and 48 deletions
  1. 54 48
      pages/chanpinneirong/index2.vue

+ 54 - 48
pages/chanpinneirong/index2.vue

@@ -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 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>
+				<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>
 
 
@@ -118,18 +120,21 @@
 	import {
 		updateXuexiProcess
 	} from "./useNeirongShuxue"
-  import {nextTick} from "vue";
+	import {
+		nextTick
+	} from "vue";
+
 	export default {
 		data() {
 			return {
-				//-------------- start ---------------/ 
+				//-------------- start ---------------/
 				// 单元位置信息
 				unitPositions: [],
 				// 节流定时器
 				throttleTimer: null,
 				activeAAAIndex: 0,
 				defaultD: 0,
-				//-------------- end ---------------/ 
+				//-------------- end ---------------/
 
 
 				canExitApp: false,
@@ -459,16 +464,17 @@
 						this.unitPositions = [...rects]
 					})
 					.exec();
-        nextTick(() => {
-          uni
-              .createSelectorQuery()
-              .in(this)
-              .selectAll(".cccAAAB")
-              .boundingClientRect((rects) => {
-                this.defaultD = rects[0].top;
-              })
-              .exec();
-        })
+				setTimeout(() => {
+					uni
+						.createSelectorQuery()
+						.in(this)
+						.selectAll(".cccAAAB")
+						.boundingClientRect((rects) => {
+							console.log('cccccccccc', rects)
+							this.defaultD = rects[0].top;
+						})
+						.exec();
+				},500)
 			},
 			// 绑定滚动事件
 			bindScrollEvent() {
@@ -477,22 +483,22 @@
 					query.select('.cccAAA2').boundingClientRect()
 					query.exec((res) => {
 						let arr = []
-						this.unitPositions.forEach((item,index) => {
+						this.unitPositions.forEach((item, index) => {
 							if ((item.top + res[0].top) < this.defaultD) {
 								arr.push(index)
 							}
 						})
-						
+
 						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检查一次
 				}