course.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <nav-bar title="所有课程"></nav-bar>
  4. <view v-if="!courseList.length">
  5. <u-empty text="暂无课程" mode="list"></u-empty>
  6. </view>
  7. <view v-else @click="jump(item,index)" v-for="(item, index) in courseList" :key="index" style="margin-bottom: 30rpx;">
  8. <view class="class_item">
  9. <image :src="$method.splitImgHost(item.coverUrl, true)" style="height: 316rpx;width: 100%;border-radius: 24rpx;"></image>
  10. <view style="color: #333333;font-weight: bold;font-size: 32rpx;">{{ item.courseName }}</view>
  11. </view>
  12. <view class="bottomBox">
  13. <view class=".content_box">
  14. <image src="/static/icon/wk_icon3.png" class="wk_icon"></image>
  15. 学习进度:{{ item.stuAllNum+item.recordNum }}/{{ item.secAllNum+item.examNum }}
  16. </view>
  17. <view class="box_progress">
  18. <view style="width: 60%;"><u-line-progress height="22" :show-percent="false" active-color="#ff9900" :percent="(item.stuAllNum / item.secAllNum) * 100"></u-line-progress></view>
  19. <view><u-button type="warning" size="mini">进入学习</u-button></view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. goodsId: 0,
  30. gradeId:0,
  31. courseList: [],
  32. orderGoodsId:0,
  33. param:{
  34. pageNum: 1,
  35. pageSize: 10,
  36. total: 0
  37. },
  38. businessData:{},
  39. itemIndex:''
  40. };
  41. },
  42. onLoad(option) {
  43. this.goodsId = Number(option.id);
  44. this.gradeId = Number(option.gid)
  45. this.orderGoodsId = Number(option.orderGoodsId)
  46. // uni.setStorageSync('courseGoodsId', this.goodsId);
  47. this.courseCourseList();
  48. this.$store.getters.dictObj
  49. },
  50. onShow(){
  51. if(this.itemIndex !== '') {
  52. this.refreshByIndex();
  53. }
  54. },
  55. onReachBottom() {
  56. if (this.courseList.length < this.param.total) {
  57. this.param.pageNum++;
  58. this.courseCourseList();
  59. }
  60. },
  61. methods: {
  62. /**
  63. * 返回刷新之前进入的课程数据
  64. */
  65. refreshByIndex() {
  66. this.$api.courseCourseList({
  67. pageNum: this.itemIndex+1,
  68. pageSize: 1,
  69. goodsId:this.goodsId,
  70. gradeId:this.gradeId
  71. }).then(res => {
  72. if (res.data.code == 200) {
  73. this.$set(this.courseList,this.itemIndex,res.data.rows[0])
  74. }
  75. });
  76. },
  77. /**
  78. * 获取业务层次详情
  79. */
  80. courseBusiness(businessId){
  81. this.$api.courseBusiness(businessId).then(res => {
  82. this.businessData = res.data.data;
  83. })
  84. },
  85. jump(item,index) {
  86. this.itemIndex = index;
  87. if(index == 0) {
  88. if(item.rebuild === 0) { //未重修
  89. this.$navTo.togo('/pages2/learn/details', {
  90. id: item.courseId,
  91. gradeId:item.gradeId,
  92. goodsId: this.goodsId
  93. });
  94. return;
  95. }
  96. this.$navTo.togo('/pages3/polyv/detail', {
  97. id: item.courseId,
  98. goodsId: this.goodsId,
  99. orderGoodsId:this.orderGoodsId
  100. });
  101. } else {
  102. if(this.businessData.goodsLearningOrder == 2) { //学习顺序是从头到尾学习,没学完上一课不能学习下一课
  103. let prevItem = this.courseList[index-1]; //上一课
  104. if( (prevItem.stuAllNum+prevItem.recordNum) == (prevItem.secAllNum+prevItem.examNum) ) {
  105. if(item.rebuild === 0) { //未重修
  106. this.$navTo.togo('/pages2/learn/details', {
  107. id: item.courseId,
  108. gradeId:item.gradeId,
  109. goodsId: this.goodsId
  110. });
  111. return;
  112. }
  113. this.$navTo.togo('/pages3/polyv/detail', {
  114. id: item.courseId,
  115. goodsId: this.goodsId,
  116. orderGoodsId:this.orderGoodsId
  117. });
  118. } else {
  119. uni.showToast({
  120. icon:'none',
  121. title:'请按顺序学完上一课再学习这一课'
  122. })
  123. }
  124. } else {
  125. if(item.rebuild === 0) { //未重修
  126. this.$navTo.togo('/pages2/learn/details', {
  127. id: item.courseId,
  128. gradeId:item.gradeId,
  129. goodsId: this.goodsId
  130. });
  131. return;
  132. }
  133. this.$navTo.togo('/pages3/polyv/detail', {
  134. id: item.courseId,
  135. goodsId: this.goodsId,
  136. orderGoodsId:this.orderGoodsId
  137. });
  138. }
  139. }
  140. },
  141. courseCourseList() {
  142. let self = this;
  143. this.param.goodsId =this.goodsId
  144. this.param.gradeId = this.gradeId
  145. this.$api.courseCourseList(this.param).then(res => {
  146. if (res.data.code == 200) {
  147. self.courseList.push.apply(self.courseList, res.data.rows);
  148. self.param.total = res.data.total;
  149. if(res.data.rows.length) {
  150. this.courseBusiness(res.data.rows[0].businessId)
  151. }
  152. }
  153. });
  154. },
  155. appointment() {
  156. this.$navTo.togo('/pages2/appointment/index');
  157. }
  158. }
  159. };
  160. </script>
  161. <style>
  162. page {
  163. background: #eaeef1;
  164. }
  165. </style>
  166. <style scope>
  167. .box_progress {
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: center;
  171. margin-top: 20rpx;
  172. }
  173. .bottomBox {
  174. background: #ffffff;
  175. width: 94%;
  176. border-bottom-left-radius: 24rpx;
  177. border-bottom-right-radius: 24rpx;
  178. margin: 0 auto;
  179. padding: 20rpx;
  180. }
  181. .content_box {
  182. display: flex;
  183. align-items: center;
  184. color: #999999;
  185. margin-top: 8rpx;
  186. }
  187. .content {
  188. color: #000000;
  189. margin: 0 8rpx;
  190. }
  191. .wk_icon {
  192. width: 24rpx;
  193. height: 24rpx;
  194. margin-right: 8rpx;
  195. }
  196. .class_item {
  197. width: 100%;
  198. background: #ffffff;
  199. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  200. border-radius: 24rpx;
  201. padding: 20rpx;
  202. z-index: 999;
  203. position: relative;
  204. }
  205. </style>