index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. }
  81. },
  82. components: {
  83. CustomTabBar,
  84. danyuanInfoVue,
  85. },
  86. onShow() {
  87. console.log('学习页面显示,尝试恢复滚动位置')
  88. },
  89. onHide() {
  90. console.log('学习页面隐藏,保存滚动位置')
  91. },
  92. onLoad(options) {
  93. console.log('options', options);
  94. this.typeId = options.typeId
  95. this.danyuanId = options.danyuanId
  96. this.banbenId = options.banbenId
  97. this.loadDataFromApi()
  98. },
  99. methods: {
  100. loadDataFromApi() {
  101. const req = {
  102. banbenId: this.banbenId,
  103. danyuanId: this.danyuanId
  104. }
  105. shuxueChanpinDanyuanInfo(req).then(res => {
  106. this.danyuanInfo = res.data
  107. this.fontDanyuanId = res.data.fontDanyuanId
  108. this.nextDanyuanId = res.data.nextDanyuanId
  109. this.dagangList = res.data.dagangList || []
  110. cacheManager.set('xuexi-' + this.typeId, res.data)
  111. cacheManager.updateObject('auth', {
  112. typeId: this.typeId,
  113. banbenId:this.banbenId,
  114. danyuanId:this.danyuanId
  115. })
  116. // 初始化当前单元
  117. // if (this.danyuanList.length > 0) {
  118. // this.currentUnitName = this.danyuanList[0].danyuanName
  119. // }
  120. })
  121. },
  122. prev() {
  123. if (this.currentIndex > 0) {
  124. this.currentIndex--
  125. this.danyuanId = this.fontDanyuanId
  126. this.loadDataFromApi()
  127. }
  128. },
  129. next() {
  130. if (this.currentIndex < this.dagangList.length - 1) {
  131. this.currentIndex++
  132. this.danyuanId = this.nextDanyuanId
  133. this.loadDataFromApi()
  134. }
  135. },
  136. handlePlay(da, code) {
  137. let jieId = null;
  138. if (code == 'jixu') {
  139. jieId = da.curJieId;
  140. uni.navigateTo({
  141. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  142. })
  143. } else {
  144. jieId = da.jieId;
  145. if (da.type == 1) {
  146. uni.navigateTo({
  147. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  148. })
  149. } else {
  150. uni.navigateTo({
  151. url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
  152. })
  153. }
  154. }
  155. },
  156. handleClickDanyuan(item) {
  157. console.log('item', item)
  158. this.isShow = true;
  159. setTimeout(() => {
  160. this.$refs.dyRef.handleShow(item.danyuanId)
  161. }, 100)
  162. },
  163. // 滚动事件处理
  164. onScroll(e) {
  165. const scrollTop = e.detail.scrollTop;
  166. // 更新滚动位置
  167. this.scrollTop = scrollTop;
  168. }
  169. }
  170. }
  171. </script>