| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <template>
- <view class="ezy-xuexi-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 xuexi-page-body">
- <view class="change-dy-box">
- <view class="arrow-icon left-icon" :class="{ 'disabled': currentIndex == 0 }" @click="prev"> </view>
- <!-- 显示内容 -->
- <view class="change-dy-content">
- <view>{{ danyuanInfo.danyuanName }}</view>
- <view>{{ danyuanInfo.danyuanIntro }}</view>
- </view>
- <view class="arrow-icon right-icon" @click="next"
- :class="{ 'disabled': currentIndex == dagangList.length - 1 }"> </view>
- </view>
- <view class="xx-scroll-body">
- <view class="xx-jd-box">
- <view class="xx-progress-btn-box">
- <view class="xx-progress-box">
- <view>当前学习进度</view>
- <progress :percent="20" class="xx-progress" stroke-width="10" backgroundColor="#3c7dfd"
- activeColor="#ffd11c" />
- </view>
- <view class="jxxx-btn" @click="handlePlay(subjectDetail,'jixu')"></view>
- </view>
- <view class="jd-item-box">
- <view class="jd-item-btn">
- <icon class="dydg-icon"></icon>单元大纲
- </view>
- <view class="jd-item-btn">
- <icon class="dyml-icon"></icon>单元目录
- </view>
- </view>
- </view>
- <view class="xx-item-list">
- <view class="xx-item-box" v-for="section in dagangList" :key="section.jieId">
- <view class="xx-item-status"
- :class="section.wanchengFlag == 1 ? 'completed-status' : 'uncompleted-status'"> </view>
- <img :src="section.cover" />
- <view class="xx-text-box">
- <view>{{ section.jieName }}</view>
- <view>{{ section.jieIntro }}</view>
- </view>
- <view @click="handlePlay(section,'play')" class="xx-item-btn"></view>
- </view>
- </view>
- <!-- 底部占位 -->
- <view v-if="currentIndex != dagangList.length - 1" class="xx-next-btn" @click="next">
- 学习下一单元</view>
- <!-- <view class="xx-xw-text">课程已学完</view> -->
- </view>
- </view>
- <!-- <scroll-view scroll-y class="scroll-view" :scroll-top="scrollTop" @scroll="onScroll"> </scroll-view> -->
- <danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
- <CustomTabBar :currentTabNumber="1"></CustomTabBar>
- </view>
- </template>
- <script>
- import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
- import cacheManager from "@/utils/cacheManager.js";
- import {
- shuxueChanpinDanyuanInfo
- } from "@/api/chanpinneirong.js"
- import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
- export default {
- data() {
- return {
- dagangList: [],
- currentUnitName: "",
- isShow: true,
- currentIndex: 0,
- danyuanInfo: {},
- banbenId: '',
- danyuanId: '',
- typeId: '',
- fontDanyuanId: '',
- nextDanyuanId: '',
- customType: '',
- cacheManagerLocal:null
- }
- },
- components: {
- CustomTabBar,
- danyuanInfoVue,
- },
- onShow() {
- console.log('学习页面显示,尝试恢复滚动位置')
- },
- onHide() {
- console.log('学习页面隐藏,保存滚动位置')
- },
- onLoad(options) {
- console.log('options', options);
- this.customType = options.customType
- if (this.customType) {
- this.typeId = options.typeId
- this.danyuanId = options.danyuanId
- this.banbenId = options.banbenId
- this.loadDataFromApi()
- } else {
- this.typeId = cacheManager.get('auth').typeId
- this.cacheManagerLocal = cacheManager.get('xuexi-'+this.typeId)
- // 使用缓存
- this.danyuanInfo = this.cacheManagerLocal.data
- this.fontDanyuanId = this.cacheManagerLocal.data.fontDanyuanId
- this.nextDanyuanId = this.cacheManagerLocal.data.nextDanyuanId
- this.dagangList = this.cacheManagerLocal.data.dagangList || []
- }
- },
- methods: {
- loadDataFromApi() {
- const req = {
- banbenId: this.banbenId,
- danyuanId: this.danyuanId
- }
- shuxueChanpinDanyuanInfo(req).then(res => {
- this.danyuanInfo = res.data
- this.fontDanyuanId = res.data.fontDanyuanId
- this.nextDanyuanId = res.data.nextDanyuanId
- this.dagangList = res.data.dagangList || []
- cacheManager.set('xuexi-' + this.typeId, res.data)
- cacheManager.updateObject('auth', {
- typeId: this.typeId,
- banbenId: this.banbenId,
- danyuanId: this.danyuanId
- })
- // 初始化当前单元
- // if (this.danyuanList.length > 0) {
- // this.currentUnitName = this.danyuanList[0].danyuanName
- // }
- })
- },
- prev() {
- if (this.currentIndex > 0) {
- this.currentIndex--
- this.danyuanId = this.fontDanyuanId
- this.loadDataFromApi()
- }
- },
- next() {
- if (this.currentIndex < this.dagangList.length - 1) {
- this.currentIndex++
- this.danyuanId = this.nextDanyuanId
- this.loadDataFromApi()
- }
- },
- handlePlay(da, code) {
- let jieId = null;
- if (code == 'jixu') {
- jieId = da.curJieId;
- uni.navigateTo({
- url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
- })
- } else {
- jieId = da.jieId;
- if (da.type == 1) {
- uni.navigateTo({
- url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
- })
- } else {
- uni.navigateTo({
- url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
- })
- }
- }
- },
- handleClickDanyuan(item) {
- console.log('item', item)
- this.isShow = true;
- setTimeout(() => {
- this.$refs.dyRef.handleShow(item.danyuanId)
- }, 100)
- },
- // 滚动事件处理
- onScroll(e) {
- const scrollTop = e.detail.scrollTop;
- // 更新滚动位置
- this.scrollTop = scrollTop;
- }
- }
- }
- </script>
|