index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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(danyuanInfo,'jixu')"></view>
  27. </view>
  28. <view class="jd-item-box">
  29. <view class="jd-item-btn" @click="handleClickDanyuan">
  30. <icon class="dydg-icon"></icon>单元大纲
  31. </view>
  32. <view class="jd-item-btn" @click="handleClickMulu">
  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. <danyuanMuluVue ref="dyMlRef" @select="handleSelectDanyuan"></danyuanMuluVue>
  58. <CustomTabBar :currentTabNumber="1"></CustomTabBar>
  59. </view>
  60. </template>
  61. <script>
  62. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  63. import cacheManager from "@/utils/cacheManager.js";
  64. import {
  65. shuxueChanpinDanyuanInfo
  66. } from "@/api/chanpinneirong.js"
  67. import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
  68. import danyuanMuluVue from '@/pages/xinshuxue/components/danyuanMulu.vue';
  69. export default {
  70. data() {
  71. return {
  72. dagangList: [],
  73. currentUnitName: "",
  74. isShow: true,
  75. currentIndex: 0,
  76. danyuanInfo: {},
  77. banbenId: '',
  78. danyuanId: '',
  79. chanpinId: '',
  80. fontDanyuanId: '',
  81. nextDanyuanId: '',
  82. customType: '',
  83. cacheManagerLocal: null
  84. }
  85. },
  86. components: {
  87. CustomTabBar,
  88. danyuanInfoVue,
  89. danyuanMuluVue
  90. },
  91. onShow() {
  92. console.log('学习页面显示,尝试恢复滚动位置')
  93. },
  94. onHide() {
  95. console.log('学习页面隐藏,保存滚动位置')
  96. },
  97. onLoad(options) {
  98. console.log('options', options);
  99. this.customType = options.customType
  100. if (this.customType) {
  101. this.chanpinId = options.chanpinId
  102. this.danyuanId = options.danyuanId
  103. this.banbenId = options.banbenId
  104. this.loadDataFromApi()
  105. } else {
  106. console.log('使用缓存');
  107. this.chanpinId = cacheManager.get('auth').chanpinId
  108. this.danyuanId = cacheManager.get('auth').danyuanId
  109. this.banbenId = cacheManager.get('auth').banbenId
  110. this.cacheManagerLocal = cacheManager.get('xuexi-' + this.chanpinId)
  111. // 使用缓存
  112. this.danyuanInfo = this.cacheManagerLocal
  113. this.fontDanyuanId = this.cacheManagerLocal.fontDanyuanId
  114. this.nextDanyuanId = this.cacheManagerLocal.nextDanyuanId
  115. this.dagangList = this.cacheManagerLocal.dagangList || []
  116. }
  117. },
  118. methods: {
  119. handleSelectDanyuan(item) {
  120. console.log('点击单元', item)
  121. },
  122. handleClickMulu() {
  123. this.$refs.dyMlRef.showPopup(this.banbenId)
  124. },
  125. handleBack() {
  126. },
  127. loadDataFromApi() {
  128. const req = {
  129. banbenId: this.banbenId,
  130. danyuanId: this.danyuanId
  131. }
  132. shuxueChanpinDanyuanInfo(req).then(res => {
  133. this.danyuanInfo = res.data
  134. this.fontDanyuanId = res.data.fontDanyuanId
  135. this.nextDanyuanId = res.data.nextDanyuanId
  136. this.dagangList = res.data.dagangList || []
  137. cacheManager.set('xuexi-' + this.chanpinId, res.data)
  138. cacheManager.updateObject('auth', {
  139. chanpinId: this.chanpinId,
  140. banbenId: this.banbenId,
  141. danyuanId: this.danyuanId
  142. })
  143. // 初始化当前单元
  144. // if (this.danyuanList.length > 0) {
  145. // this.currentUnitName = this.danyuanList[0].danyuanName
  146. // }
  147. })
  148. },
  149. prev() {
  150. if (this.currentIndex > 0) {
  151. this.currentIndex--
  152. this.danyuanId = this.fontDanyuanId
  153. this.loadDataFromApi()
  154. }
  155. },
  156. next() {
  157. if (this.currentIndex < this.dagangList.length - 1) {
  158. this.currentIndex++
  159. this.danyuanId = this.nextDanyuanId
  160. this.loadDataFromApi()
  161. }
  162. },
  163. handlePlay(da, code) {
  164. console.log('da', da)
  165. let jieId = null;
  166. if (code == 'jixu') {
  167. jieId = da.curJieId;
  168. uni.navigateTo({
  169. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  170. })
  171. } else {
  172. jieId = da.jieId;
  173. if (da.type == 1) {
  174. uni.navigateTo({
  175. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  176. })
  177. } else {
  178. uni.navigateTo({
  179. url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
  180. })
  181. }
  182. }
  183. },
  184. handleClickDanyuan() {
  185. this.isShow = true;
  186. setTimeout(() => {
  187. this.$refs.dyRef.handleShow(this.danyuanId)
  188. }, 100)
  189. },
  190. // 滚动事件处理
  191. onScroll(e) {
  192. const scrollTop = e.detail.scrollTop;
  193. // 更新滚动位置
  194. this.scrollTop = scrollTop;
  195. }
  196. }
  197. }
  198. </script>