index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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">
  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. </view>
  50. </view>
  51. <!-- 底部占位 -->
  52. <view style="height: 100px;" v-if="currentIndex != dagangList.length - 1" class="xx-next-btn" @click="next">学习下一单元</view>
  53. <!-- <view class="xx-xw-text">课程已学完</view> -->
  54. <!-- <scroll-view scroll-y class="scroll-view" :scroll-top="scrollTop" @scroll="onScroll"> </scroll-view> -->
  55. <danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
  56. <CustomTabBar :currentTabNumber="1"></CustomTabBar>
  57. </view>
  58. </template>
  59. <script>
  60. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  61. import {
  62. shuxueChanpinDanyuanInfo
  63. } from "@/api/chanpinneirong.js"
  64. import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
  65. export default {
  66. data() {
  67. return {
  68. dagangList: [],
  69. currentUnitName: "",
  70. isShow: true,
  71. currentIndex: 0,
  72. danyuanInfo: {},
  73. banbenId: '',
  74. danyuanId: '',
  75. typeId: '',
  76. fontDanyuanId: '',
  77. nextDanyuanId: ''
  78. }
  79. },
  80. components: {
  81. CustomTabBar,
  82. danyuanInfoVue,
  83. },
  84. onShow() {
  85. console.log('学习页面显示,尝试恢复滚动位置')
  86. },
  87. onHide() {
  88. console.log('学习页面隐藏,保存滚动位置')
  89. },
  90. onLoad(options) {
  91. console.log('options', options);
  92. this.typeId = options.typeId
  93. this.danyuanId = options.danyuanId
  94. this.banbenId = options.banbenId
  95. this.loadDataFromApi()
  96. },
  97. methods: {
  98. loadDataFromApi() {
  99. const req = {
  100. banbenId: this.banbenId,
  101. danyuanId: this.danyuanId
  102. }
  103. shuxueChanpinDanyuanInfo(req).then(res => {
  104. this.danyuanInfo = res.data
  105. this.fontDanyuanId = res.data.fontDanyuanId
  106. this.nextDanyuanId = res.data.nextDanyuanId
  107. this.dagangList = res.data.dagangList || []
  108. // 初始化当前单元
  109. // if (this.danyuanList.length > 0) {
  110. // this.currentUnitName = this.danyuanList[0].danyuanName
  111. // }
  112. })
  113. },
  114. prev() {
  115. if (this.currentIndex > 0) {
  116. this.currentIndex--
  117. this.danyuanId = this.fontDanyuanId
  118. this.loadDataFromApi()
  119. }
  120. },
  121. next() {
  122. if (this.currentIndex < this.dagangList.length - 1) {
  123. this.currentIndex++
  124. this.danyuanId = this.nextDanyuanId
  125. this.loadDataFromApi()
  126. }
  127. },
  128. handlePlay(da, code) {
  129. let jieId = null;
  130. if (code == 'jixu') {
  131. jieId = da.curJieId;
  132. uni.navigateTo({
  133. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  134. })
  135. } else {
  136. jieId = da.jieId;
  137. if (da.type == 1) {
  138. uni.navigateTo({
  139. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  140. })
  141. } else {
  142. uni.navigateTo({
  143. url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
  144. })
  145. }
  146. }
  147. },
  148. handleClickDanyuan(item) {
  149. console.log('item', item)
  150. this.isShow = true;
  151. setTimeout(() => {
  152. this.$refs.dyRef.handleShow(item.danyuanId)
  153. }, 100)
  154. },
  155. // 滚动事件处理
  156. onScroll(e) {
  157. const scrollTop = e.detail.scrollTop;
  158. // 更新滚动位置
  159. this.scrollTop = scrollTop;
  160. }
  161. }
  162. }
  163. </script>