index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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" :class="{ 'disabled': currentIndex == list.length - 1 }"> </view>
  16. </view>
  17. <view class="xx-scroll-body">
  18. <view class="xx-jd-box">
  19. <view class="xx-progress-btn-box">
  20. <view class="xx-progress-box">
  21. <view>当前学习进度</view>
  22. <progress :percent="20" class="xx-progress" stroke-width="10" backgroundColor="#3c7dfd"
  23. activeColor="#ffd11c" />
  24. </view>
  25. <view class="jxxx-btn" @click="handlePlay(subjectDetail,'jixu')"></view>
  26. </view>
  27. <view class="jd-item-box">
  28. <view class="jd-item-btn"><icon class="dydg-icon"></icon>单元大纲</view>
  29. <view class="jd-item-btn"><icon class="dyml-icon"></icon>单元目录</view>
  30. </view>
  31. </view>
  32. <view class="xx-item-list">
  33. <view class="xx-item-box" v-for="section in dagangList" :key="section.jieId" >
  34. <view class="xx-item-status" :class="section.wanchengFlag === 1 ? 'completed-status' : 'uncompleted-status'"> </view>
  35. <img :src="section.cover"/>
  36. <view class="xx-text-box">
  37. <view>{{ section.jieName }}</view>
  38. <view>{{ section.jieIntro }}</view>
  39. </view>
  40. <view @click="handlePlay(section,'play')" class="xx-item-btn"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 底部占位 -->
  46. <view class="xx-next-btn">学习下一单元</view>
  47. <view class="xx-xw-text">课程已学完</view>
  48. <!-- <scroll-view scroll-y class="scroll-view" :scroll-top="scrollTop" @scroll="onScroll"> </scroll-view> -->
  49. <danyuanInfoVue ref="dyRef" v-if="isShow" @close="isShow= false"></danyuanInfoVue>
  50. <CustomTabBar :currentTabNumber="1"></CustomTabBar>
  51. </view>
  52. </template>
  53. <script>
  54. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  55. import {
  56. shuxueChanpinDanyuanInfo
  57. } from "@/api/chanpinneirong.js"
  58. import danyuanInfoVue from '@/pages/xinshuxue/components/danyuanInfo.vue';
  59. export default {
  60. data() {
  61. return {
  62. dagangList: [],
  63. currentUnitName: "",
  64. isShow: true,
  65. currentIndex: 0,
  66. danyuanInfo:{}
  67. }
  68. },
  69. components: {
  70. CustomTabBar,
  71. danyuanInfoVue,
  72. },
  73. onShow() {
  74. console.log('学习页面显示,尝试恢复滚动位置')
  75. },
  76. onHide() {
  77. console.log('学习页面隐藏,保存滚动位置')
  78. },
  79. onLoad() {
  80. this.loadDataFromApi()
  81. },
  82. methods: {
  83. prev() {
  84. if (this.currentIndex > 0) {
  85. this.currentIndex--
  86. }
  87. },
  88. next() {
  89. if (this.currentIndex < this.list.length - 1) {
  90. this.currentIndex++
  91. }
  92. },
  93. handlePlay(da, code) {
  94. let jieId = null;
  95. if (code == 'jixu') {
  96. jieId = da.curJieId;
  97. uni.navigateTo({
  98. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  99. })
  100. } else {
  101. jieId = da.jieId;
  102. if (da.type == 1) {
  103. uni.navigateTo({
  104. url: `/pages/xinshuxue/lookShipin?jieId=${jieId}`
  105. })
  106. } else {
  107. uni.navigateTo({
  108. url: `/pages/xinshuxue/unitTest?jieId=${jieId}`
  109. })
  110. }
  111. }
  112. },
  113. handleClickDanyuan(item) {
  114. console.log('item', item)
  115. this.isShow = true;
  116. setTimeout(() => {
  117. this.$refs.dyRef.handleShow(item.danyuanId)
  118. }, 100)
  119. },
  120. loadDataFromApi() {
  121. const req = {
  122. banbenId: 7,
  123. danyuanId:2
  124. }
  125. shuxueChanpinDanyuanInfo(req).then(res => {
  126. this.danyuanInfo = res.data
  127. this.dagangList = res.data.dagangList || []
  128. // 初始化当前单元
  129. // if (this.danyuanList.length > 0) {
  130. // this.currentUnitName = this.danyuanList[0].danyuanName
  131. // }
  132. })
  133. },
  134. // 滚动事件处理
  135. onScroll(e) {
  136. const scrollTop = e.detail.scrollTop;
  137. // 更新滚动位置
  138. this.scrollTop = scrollTop;
  139. }
  140. }
  141. }
  142. </script>