|
|
@@ -4,13 +4,8 @@
|
|
|
<text class="nav-bar-title">学习</text>
|
|
|
</view>
|
|
|
<!-- 滚动区域 -->
|
|
|
- <scroll-view
|
|
|
- v-if="existData"
|
|
|
- class="ezy-page-body xuexi-page-body"
|
|
|
- scroll-y
|
|
|
- :scroll-top="scrollTop"
|
|
|
- @scroll="handleScroll"
|
|
|
- >
|
|
|
+ <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">
|
|
|
<!-- 显示内容 -->
|
|
|
@@ -30,7 +25,8 @@
|
|
|
<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>
|
|
|
+ <ezyActiveVue class="ezy-btn-active jxxx-btn" @aclick="handlePlay(banbenInfo,'jixu')">
|
|
|
+ </ezyActiveVue>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -40,20 +36,15 @@
|
|
|
|
|
|
<view v-for="(danyuanItem, index) in danyuanList" :key="danyuanItem.danyuanId">
|
|
|
<!-- 单元标题(带唯一ID,用于位置查询) -->
|
|
|
- <view class="xx-item-title" @click="handleClickDanyuan(danyuanItem.danyuanId)" :id="`title-${danyuanItem.danyuanId}`">
|
|
|
+ <view class="xx-item-title" @click="handleClickDanyuan(danyuanItem.danyuanId)"
|
|
|
+ :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>
|
|
|
+ <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>
|
|
|
@@ -68,7 +59,7 @@
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
<!-- 回到顶部 -->
|
|
|
- <view class="go-top-btn" @click="goTopBtn"></view>
|
|
|
+ <view v-show="showGoTop" class="go-top-btn" @click="goTopBtn"></view>
|
|
|
|
|
|
<!-- 无数据占位 -->
|
|
|
<view v-if="!existData" class="ezy-page-body">
|
|
|
@@ -104,7 +95,9 @@
|
|
|
import {
|
|
|
toast
|
|
|
} from '../../utils/common';
|
|
|
- import {updateXuexiProcess} from "./useNeirongShuxue"
|
|
|
+ import {
|
|
|
+ updateXuexiProcess
|
|
|
+ } from "./useNeirongShuxue"
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -124,10 +117,12 @@
|
|
|
stickyHeight: 0, // 吸顶栏高度(px)
|
|
|
currentStickyTitle: '', // 初始为空,不显示吸顶
|
|
|
currentStickyIntro: '',
|
|
|
- currentDanyuanId:'',
|
|
|
+ currentDanyuanId: '',
|
|
|
currentStickyDengjiId: '',
|
|
|
titlePositions: [],
|
|
|
scrollTop: 0,
|
|
|
+ showGoTop: false,
|
|
|
+ scrollThreshold: 300,
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
@@ -159,10 +154,13 @@
|
|
|
},
|
|
|
methods: {
|
|
|
goTopBtn() {
|
|
|
- this.scrollTop = -1; // 先设一个无效值(确保变化)
|
|
|
- this.$nextTick(() => {
|
|
|
- this.scrollTop = 0; // 再滚到顶部
|
|
|
+ uni.pageScrollTo({ // 添加平滑滚动效果
|
|
|
+ scrollTop: 0,
|
|
|
+ duration: 300
|
|
|
});
|
|
|
+
|
|
|
+ this.scrollTop = 0;
|
|
|
+ this.showGoTop = false; // 滚动到顶部后隐藏按钮
|
|
|
},
|
|
|
moreBtn() {
|
|
|
uni.switchTab({
|
|
|
@@ -184,7 +182,9 @@
|
|
|
const cacheData = cacheManager.get('xuexi-shuxue');
|
|
|
console.log('cacheData 从缓存更新数据方法', cacheData);
|
|
|
if (cacheData) {
|
|
|
- this.banbenInfo = { ...cacheData };
|
|
|
+ this.banbenInfo = {
|
|
|
+ ...cacheData
|
|
|
+ };
|
|
|
this.curProcess = cacheData.curProcess;
|
|
|
this.danyuanList = [...(cacheData.danyuanList || [])];
|
|
|
this.banbenId = cacheData.banbenId
|
|
|
@@ -205,11 +205,11 @@
|
|
|
if (res.code === 0) {
|
|
|
this.banbenInfo = res.data;
|
|
|
this.banbenInfo.danyuanId = res.data.curDanyuanId;
|
|
|
- this.curProcess =res.data.curProcess * 100;
|
|
|
+ this.curProcess = res.data.curProcess * 100;
|
|
|
this.danyuanList = res.data.danyuanList || [];
|
|
|
- if (this.danyuanList.length ==0) {
|
|
|
+ if (this.danyuanList.length == 0) {
|
|
|
this.existData = false
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.existData = true
|
|
|
}
|
|
|
// 保存到缓存(新增了参数保存)
|
|
|
@@ -243,17 +243,21 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+
|
|
|
handleScroll(e) {
|
|
|
const scrollTop = e.detail.scrollTop;
|
|
|
- console.log('scrollTop',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 {
|
|
|
+ danyuan,
|
|
|
+ jie
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -261,9 +265,9 @@
|
|
|
},
|
|
|
|
|
|
async saveAndNavigate(jieId, type, da, code) {
|
|
|
-
|
|
|
- console.log('this.banbenId',this.banbenId);
|
|
|
- console.log('this.danyuanIddanyuanId',da.danyuanId);
|
|
|
+
|
|
|
+ console.log('this.banbenId', this.banbenId);
|
|
|
+ console.log('this.danyuanIddanyuanId', da.danyuanId);
|
|
|
if (code == 'jixu') {
|
|
|
if (!this.banbenId || !da.danyuanId) {
|
|
|
toast("banbenId或者danyuanId 丢失")
|
|
|
@@ -276,7 +280,7 @@
|
|
|
"danyuanId": da.danyuanId,
|
|
|
"jieId": jieId
|
|
|
}
|
|
|
- console.log('req',req);
|
|
|
+ console.log('req', req);
|
|
|
try {
|
|
|
const res = await shuxueSave(req);
|
|
|
if (res.code == 0 && res.data) {
|
|
|
@@ -295,9 +299,13 @@
|
|
|
cacheManager.set('xuexi-shuxue', cacheData);
|
|
|
|
|
|
if (type == 1) {
|
|
|
- uni.navigateTo({ url: `/pages/xinshuxue/lookShipin?jieId=${jieId}` })
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
|
|
|
+ })
|
|
|
} else {
|
|
|
- uni.navigateTo({ url: `/pages/xinshuxue/unitTest?jieId=${jieId}` })
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
toast("保存位置出错");
|
|
|
@@ -317,7 +325,7 @@
|
|
|
this.saveAndNavigate(jieId, da.type, da, code);
|
|
|
},
|
|
|
handleClickDanyuan(danyuanId) {
|
|
|
-
|
|
|
+
|
|
|
if (!danyuanId) {
|
|
|
toast("danyuanId丢失")
|
|
|
return false
|
|
|
@@ -337,9 +345,8 @@
|
|
|
|
|
|
// 计算吸顶栏下方的偏移(确保内容不被遮挡)
|
|
|
computed: {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-</script>
|
|
|
-
|
|
|
+</script>
|