index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="ezy-xuexi-page">
  3. <view class="icon-title-navBar-box">
  4. <!-- <view @click="handleBack" class="nav-bar-icon"></view> -->
  5. <text class="nav-bar-title">学习</text>
  6. </view>
  7. <view class="ezy-page-body xuexi-page-body">
  8. <view class="change-dy-box">
  9. <view class="arrow-icon left-icon" :class="{ 'disabled': currentIndex == 0 }" @click="prev"> </view>
  10. <!-- 显示内容 -->
  11. <view class="change-dy-content">
  12. <view>{{ danyuanInfo.danyuanName }}</view>
  13. <view>{{ danyuanInfo.danyuanIntro }}</view>
  14. </view>
  15. <view class="arrow-icon right-icon" @click="next"
  16. :class="{ 'disabled': currentIndex == dagangList.length - 1 }"> </view>
  17. </view>
  18. <view class="xx-scroll-body">
  19. <view class="xx-jd-box">
  20. <view class="xx-progress-btn-box">
  21. <view class="xx-progress-box">
  22. <view>当前学习进度</view>
  23. <progress :percent="20" class="xx-progress" stroke-width="10" backgroundColor="#3c7dfd"
  24. activeColor="#ffd11c" />
  25. </view>
  26. <view class="jxxx-btn" @click="handlePlay(subjectDetail,'jixu')"></view>
  27. </view>
  28. <view class="jd-item-box">
  29. <view class="jd-item-btn">
  30. <icon class="dydg-icon"></icon>单元大纲
  31. </view>
  32. <view class="jd-item-btn">
  33. <icon class="dyml-icon"></icon>单元目录
  34. </view>
  35. </view>
  36. </view>
  37. <view class="xx-item-list">
  38. <view class="xx-item-box" v-for="section in dagangList" :key="section.jieId">
  39. <view class="xx-item-status"
  40. :class="section.wanchengFlag == 1 ? 'completed-status' : 'uncompleted-status'"> </view>
  41. <img :src="section.cover" />
  42. <view class="xx-text-box">
  43. <view>{{ section.jieName }}</view>
  44. <view>{{ section.jieIntro }}</view>
  45. </view>
  46. <view @click="handlePlay(section,'play')" class="xx-item-btn"></view>
  47. </view>
  48. </view>
  49. <!-- 底部占位 -->
  50. <view v-if="currentIndex != dagangList.length - 1" class="xx-next-btn" @click="next">
  51. 学习下一单元</view>
  52. <!-- <view class="xx-xw-text">课程已学完</view> -->
  53. </view>
  54. </view>
  55. <!-- <scroll-view scroll-y class="scroll-view" :scroll-top="scrollTop" @scroll="onScroll"> </scroll-view> -->
  56. <danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
  57. <CustomTabBar :currentTabNumber="1"></CustomTabBar>
  58. </view>
  59. </template>
  60. <script>
  61. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  62. import cacheManager from "@/utils/cacheManager.js";
  63. import {
  64. shuxueChanpinDanyuanInfo
  65. } from "@/api/chanpinneirong.js"
  66. import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
  67. export default {
  68. data() {
  69. return {
  70. dagangList: [],
  71. currentUnitName: "",
  72. isShow: true,
  73. currentIndex: 0,
  74. danyuanInfo: {},
  75. banbenId: '',
  76. danyuanId: '',
  77. typeId: '',
  78. fontDanyuanId: '',
  79. nextDanyuanId: '',
  80. customType: '',
  81. cacheManagerLocal:null
  82. }
  83. },
  84. components: {
  85. CustomTabBar,
  86. danyuanInfoVue,
  87. },
  88. onShow() {
  89. console.log('学习页面显示,尝试恢复滚动位置')
  90. },
  91. onHide() {
  92. console.log('学习页面隐藏,保存滚动位置')
  93. },
  94. onLoad(options) {
  95. console.log('options', options);
  96. this.customType = options.customType
  97. if (this.customType) {
  98. this.typeId = options.typeId
  99. this.danyuanId = options.danyuanId
  100. this.banbenId = options.banbenId
  101. this.loadDataFromApi()
  102. } else {
  103. this.typeId = cacheManager.get('auth').typeId
  104. this.cacheManagerLocal = cacheManager.get('xuexi-'+this.typeId)
  105. // 使用缓存
  106. this.danyuanInfo = this.cacheManagerLocal.data
  107. this.fontDanyuanId = this.cacheManagerLocal.data.fontDanyuanId
  108. this.nextDanyuanId = this.cacheManagerLocal.data.nextDanyuanId
  109. this.dagangList = this.cacheManagerLocal.data.dagangList || []
  110. }
  111. },
  112. methods: {
  113. loadDataFromApi() {
  114. const req = {
  115. banbenId: this.banbenId,
  116. danyuanId: this.danyuanId
  117. }
  118. shuxueChanpinDanyuanInfo(req).then(res => {
  119. this.danyuanInfo = res.data
  120. this.fontDanyuanId = res.data.fontDanyuanId
  121. this.nextDanyuanId = res.data.nextDanyuanId
  122. this.dagangList = res.data.dagangList || []
  123. cacheManager.set('xuexi-' + this.typeId, res.data)
  124. cacheManager.updateObject('auth', {
  125. typeId: this.typeId,
  126. banbenId: this.banbenId,
  127. danyuanId: this.danyuanId
  128. })
  129. // 初始化当前单元
  130. // if (this.danyuanList.length > 0) {
  131. // this.currentUnitName = this.danyuanList[0].danyuanName
  132. // }
  133. })
  134. },
  135. prev() {
  136. if (this.currentIndex > 0) {
  137. this.currentIndex--
  138. this.danyuanId = this.fontDanyuanId
  139. this.loadDataFromApi()
  140. }
  141. },
  142. next() {
  143. if (this.currentIndex < this.dagangList.length - 1) {
  144. this.currentIndex++
  145. this.danyuanId = this.nextDanyuanId
  146. this.loadDataFromApi()
  147. }
  148. },
  149. handlePlay(da, code) {
  150. let jieId = null;
  151. if (code == 'jixu') {
  152. jieId = da.curJieId;
  153. uni.navigateTo({
  154. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  155. })
  156. } else {
  157. jieId = da.jieId;
  158. if (da.type == 1) {
  159. uni.navigateTo({
  160. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  161. })
  162. } else {
  163. uni.navigateTo({
  164. url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
  165. })
  166. }
  167. }
  168. },
  169. handleClickDanyuan(item) {
  170. console.log('item', item)
  171. this.isShow = true;
  172. setTimeout(() => {
  173. this.$refs.dyRef.handleShow(item.danyuanId)
  174. }, 100)
  175. },
  176. // 滚动事件处理
  177. onScroll(e) {
  178. const scrollTop = e.detail.scrollTop;
  179. // 更新滚动位置
  180. this.scrollTop = scrollTop;
  181. }
  182. }
  183. }
  184. </script>