course.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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" @click.stop="jump(item,index)">进入学习</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.$api.courseDetail(item.courseId).then((res) => {
  97. if (res.data.code == 200) {
  98. if (res.data.data.educationName == "继续教育") {
  99. this.$api.lockLockStatus({
  100. action:'jxjy'
  101. }).then(res => {
  102. if(res.data.code == 200) { //有其他端在操作,不能学习
  103. uni.showToast({
  104. icon:'none',
  105. title:res.data.msg,
  106. mask:true,
  107. duration:3000
  108. })
  109. } else if(res.data.code == 500) { //可以学习
  110. this.$navTo.togo('/pages3/polyv/detail', {
  111. id: item.courseId,
  112. goodsId: this.goodsId,
  113. orderGoodsId:this.orderGoodsId
  114. });
  115. }
  116. })
  117. // websocket.sendMsg("doCourse");
  118. } else {
  119. this.$navTo.togo('/pages3/polyv/detail', {
  120. id: item.courseId,
  121. goodsId: this.goodsId,
  122. orderGoodsId:this.orderGoodsId
  123. });
  124. }
  125. }
  126. });
  127. } else {
  128. if(this.businessData.goodsLearningOrder == 2) { //学习顺序是从头到尾学习,没学完上一课不能学习下一课
  129. let prevItem = this.courseList[index-1]; //上一课
  130. if( (prevItem.stuAllNum+prevItem.recordNum) == (prevItem.secAllNum+prevItem.examNum) ) {
  131. if(item.rebuild === 0) { //未重修
  132. this.$navTo.togo('/pages2/learn/details', {
  133. id: item.courseId,
  134. gradeId:item.gradeId,
  135. goodsId: this.goodsId
  136. });
  137. return;
  138. }
  139. this.$api.courseDetail(item.courseId).then((res) => {
  140. if (res.data.code == 200) {
  141. if (res.data.data.educationName == "继续教育") {
  142. this.$api.lockLockStatus({
  143. action:'jxjy'
  144. }).then(res => {
  145. if(res.data.code == 200) { //有其他端在操作,不能学习
  146. uni.showToast({
  147. icon:'none',
  148. title:res.data.msg,
  149. duration:2000
  150. })
  151. } else if(res.data.code == 500) { //可以学习
  152. this.$navTo.togo('/pages3/polyv/detail', {
  153. id: item.courseId,
  154. goodsId: this.goodsId,
  155. orderGoodsId:this.orderGoodsId
  156. });
  157. }
  158. })
  159. // websocket.sendMsg("doCourse");
  160. } else {
  161. this.$navTo.togo('/pages3/polyv/detail', {
  162. id: item.courseId,
  163. goodsId: this.goodsId,
  164. orderGoodsId:this.orderGoodsId
  165. });
  166. }
  167. }
  168. });
  169. } else {
  170. uni.showToast({
  171. icon:'none',
  172. title:'请按顺序学完上一课再学习这一课'
  173. })
  174. }
  175. } else {
  176. if(item.rebuild === 0) { //未重修
  177. this.$navTo.togo('/pages2/learn/details', {
  178. id: item.courseId,
  179. gradeId:item.gradeId,
  180. goodsId: this.goodsId
  181. });
  182. return;
  183. }
  184. this.$api.courseDetail(item.courseId).then((res) => {
  185. if (res.data.code == 200) {
  186. if (res.data.data.educationName == "继续教育") {
  187. this.$api.lockLockStatus({
  188. action:'jxjy'
  189. }).then(res => {
  190. if(res.data.code == 200) { //有其他端在操作,不能学习
  191. uni.showToast({
  192. icon:'none',
  193. title:res.data.msg,
  194. duration:2000
  195. })
  196. } else if(res.data.code == 500) { //可以学习
  197. this.$navTo.togo('/pages3/polyv/detail', {
  198. id: item.courseId,
  199. goodsId: this.goodsId,
  200. orderGoodsId:this.orderGoodsId
  201. });
  202. }
  203. })
  204. // websocket.sendMsg("doCourse");
  205. }
  206. }
  207. });
  208. }
  209. }
  210. },
  211. courseCourseList() {
  212. let self = this;
  213. this.param.goodsId =this.goodsId
  214. this.param.gradeId = this.gradeId
  215. this.$api.courseCourseList(this.param).then(res => {
  216. if (res.data.code == 200) {
  217. self.courseList.push.apply(self.courseList, res.data.rows);
  218. self.param.total = res.data.total;
  219. if(res.data.rows.length) {
  220. this.courseBusiness(res.data.rows[0].businessId)
  221. }
  222. }
  223. });
  224. },
  225. appointment() {
  226. this.$navTo.togo('/pages2/appointment/index');
  227. }
  228. }
  229. };
  230. </script>
  231. <style>
  232. page {
  233. background: #eaeef1;
  234. }
  235. </style>
  236. <style scope>
  237. .box_progress {
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. margin-top: 20rpx;
  242. }
  243. .bottomBox {
  244. background: #ffffff;
  245. width: 94%;
  246. border-bottom-left-radius: 24rpx;
  247. border-bottom-right-radius: 24rpx;
  248. margin: 0 auto;
  249. padding: 20rpx;
  250. }
  251. .content_box {
  252. display: flex;
  253. align-items: center;
  254. color: #999999;
  255. margin-top: 8rpx;
  256. }
  257. .content {
  258. color: #000000;
  259. margin: 0 8rpx;
  260. }
  261. .wk_icon {
  262. width: 24rpx;
  263. height: 24rpx;
  264. margin-right: 8rpx;
  265. }
  266. .class_item {
  267. width: 100%;
  268. background: #ffffff;
  269. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  270. border-radius: 24rpx;
  271. padding: 20rpx;
  272. z-index: 999;
  273. position: relative;
  274. }
  275. </style>