course.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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
  8. v-else
  9. @click="jump(item, index)"
  10. v-for="(item, index) in courseList"
  11. :key="index"
  12. style="margin-bottom: 30rpx"
  13. >
  14. <view class="class_item">
  15. <image
  16. :src="$method.splitImgHost(item.coverUrl, true)"
  17. style="height: 316rpx; width: 100%; border-radius: 24rpx"
  18. ></image>
  19. <view style="color: #333333; font-weight: bold; font-size: 32rpx">{{
  20. item.courseName
  21. }}</view>
  22. </view>
  23. <view class="bottomBox">
  24. <view class=".content_box">
  25. <image src="/static/icon/wk_icon3.png" class="wk_icon"></image>
  26. 学习进度:{{ item.stuAllNum + item.recordNum }}/{{
  27. item.secAllNum + item.examNum
  28. }}
  29. </view>
  30. <view class="box_progress">
  31. <view style="width: 60%"
  32. ><u-line-progress
  33. height="22"
  34. :show-percent="false"
  35. active-color="#ff9900"
  36. :percent="((item.stuAllNum + item.recordNum) / (item.secAllNum + item.examNum)) * 100"
  37. ></u-line-progress
  38. ></view>
  39. <view
  40. ><u-button
  41. type="warning"
  42. size="mini"
  43. @click.stop="jump(item, index)"
  44. >进入学习</u-button
  45. ></view
  46. >
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. goodsId: 0,
  57. gradeId: 0,
  58. courseList: [],
  59. orderGoodsId: 0,
  60. param: {
  61. pageNum: 1,
  62. pageSize: 10,
  63. total: 0,
  64. },
  65. businessData: {},
  66. itemIndex: "",
  67. };
  68. },
  69. onLoad(option) {
  70. this.goodsId = Number(option.id);
  71. this.gradeId = Number(option.gid);
  72. this.orderGoodsId = Number(option.orderGoodsId);
  73. // uni.setStorageSync('courseGoodsId', this.goodsId);
  74. this.courseCourseList();
  75. this.$store.getters.dictObj;
  76. },
  77. onShow() {
  78. if (this.itemIndex !== "") {
  79. this.refreshByIndex();
  80. }
  81. },
  82. onReachBottom() {
  83. if (this.courseList.length < this.param.total) {
  84. this.param.pageNum++;
  85. this.courseCourseList();
  86. }
  87. },
  88. methods: {
  89. /**
  90. * 返回刷新之前进入的课程数据
  91. */
  92. refreshByIndex() {
  93. this.$api
  94. .courseCourseList({
  95. pageNum: this.itemIndex + 1,
  96. pageSize: 1,
  97. goodsId: this.goodsId,
  98. gradeId: this.gradeId,
  99. })
  100. .then((res) => {
  101. if (res.data.code == 200) {
  102. this.$set(this.courseList, this.itemIndex, res.data.rows[0]);
  103. }
  104. });
  105. },
  106. /**
  107. * 获取业务层次详情
  108. */
  109. courseBusiness(businessId) {
  110. this.$api.courseBusiness(businessId).then((res) => {
  111. this.businessData = res.data.data;
  112. });
  113. },
  114. jump(item, index) {
  115. this.itemIndex = index;
  116. if (index == 0) {
  117. if (item.rebuild === 0) {
  118. //未重修
  119. this.$navTo.togo("/pages2/learn/details", {
  120. id: item.courseId,
  121. gradeId: item.gradeId,
  122. goodsId: this.goodsId,
  123. orderGoodsId: this.orderGoodsId,
  124. });
  125. return;
  126. }
  127. this.$api.courseDetail(item.courseId).then((res) => {
  128. if (res.data.code == 200) {
  129. // if (res.data.data.educationName == "继续教育") {
  130. this.$api
  131. .lockLockStatus({
  132. action: "jxjy",
  133. uuid:this.$method.getUuid()
  134. })
  135. .then((res) => {
  136. if (res.data.code == 200) {
  137. //有其他端在操作,不能学习
  138. uni.showToast({
  139. icon: "none",
  140. title: res.data.msg,
  141. mask: true,
  142. duration: 3000,
  143. });
  144. } else if (res.data.code == 500) {
  145. //可以学习
  146. this.$navTo.togo("/pages3/polyv/detail", {
  147. id: item.courseId,
  148. goodsId: this.goodsId,
  149. orderGoodsId: this.orderGoodsId,
  150. });
  151. }
  152. });
  153. // websocket.sendMsg("doCourse");
  154. // } else {
  155. // this.$navTo.togo("/pages3/polyv/detail", {
  156. // id: item.courseId,
  157. // goodsId: this.goodsId,
  158. // orderGoodsId: this.orderGoodsId,
  159. // });
  160. // }
  161. }
  162. });
  163. } else {
  164. if (this.businessData.goodsLearningOrder == 2) {
  165. //学习顺序是从头到尾学习,没学完上一课不能学习下一课
  166. let prevItem = this.courseList[index - 1]; //上一课
  167. if (
  168. prevItem.stuAllNum + prevItem.recordNum ==
  169. prevItem.secAllNum + prevItem.examNum
  170. ) {
  171. if (item.rebuild === 0) {
  172. //未重修
  173. this.$navTo.togo("/pages2/learn/details", {
  174. id: item.courseId,
  175. gradeId: item.gradeId,
  176. goodsId: this.goodsId,
  177. orderGoodsId: this.orderGoodsId,
  178. });
  179. return;
  180. }
  181. this.$api.courseDetail(item.courseId).then((res) => {
  182. if (res.data.code == 200) {
  183. // if (res.data.data.educationName == "继续教育") {
  184. this.$api
  185. .lockLockStatus({
  186. action: "jxjy",
  187. uuid:this.$method.getUuid()
  188. })
  189. .then((res) => {
  190. if (res.data.code == 200) {
  191. //有其他端在操作,不能学习
  192. uni.showToast({
  193. icon: "none",
  194. title: res.data.msg,
  195. duration: 2000,
  196. });
  197. } else if (res.data.code == 500) {
  198. //可以学习
  199. this.$navTo.togo("/pages3/polyv/detail", {
  200. id: item.courseId,
  201. goodsId: this.goodsId,
  202. orderGoodsId: this.orderGoodsId,
  203. });
  204. }
  205. });
  206. // websocket.sendMsg("doCourse");
  207. // } else {
  208. // this.$navTo.togo("/pages3/polyv/detail", {
  209. // id: item.courseId,
  210. // goodsId: this.goodsId,
  211. // orderGoodsId: this.orderGoodsId,
  212. // });
  213. // }
  214. }
  215. });
  216. } else {
  217. uni.showToast({
  218. icon: "none",
  219. title: "请按顺序学完上一课再学习这一课",
  220. });
  221. }
  222. } else {
  223. if (item.rebuild === 0) {
  224. //未重修
  225. this.$navTo.togo("/pages2/learn/details", {
  226. id: item.courseId,
  227. gradeId: item.gradeId,
  228. goodsId: this.goodsId,
  229. orderGoodsId: this.orderGoodsId,
  230. });
  231. return;
  232. }
  233. this.$api.courseDetail(item.courseId).then((res) => {
  234. if (res.data.code == 200) {
  235. // if (res.data.data.educationName == "继续教育") {
  236. this.$api
  237. .lockLockStatus({
  238. action: "jxjy",
  239. uuid:this.$method.getUuid()
  240. })
  241. .then((res) => {
  242. if (res.data.code == 200) {
  243. //有其他端在操作,不能学习
  244. uni.showToast({
  245. icon: "none",
  246. title: res.data.msg,
  247. duration: 2000,
  248. });
  249. } else if (res.data.code == 500) {
  250. //可以学习
  251. this.$navTo.togo("/pages3/polyv/detail", {
  252. id: item.courseId,
  253. goodsId: this.goodsId,
  254. orderGoodsId: this.orderGoodsId,
  255. });
  256. }
  257. });
  258. // websocket.sendMsg("doCourse");
  259. // } else {
  260. // this.$navTo.togo("/pages3/polyv/detail", {
  261. // id: item.courseId,
  262. // goodsId: this.goodsId,
  263. // orderGoodsId: this.orderGoodsId,
  264. // });
  265. // }
  266. }
  267. });
  268. }
  269. }
  270. },
  271. courseCourseList() {
  272. let self = this;
  273. this.param.goodsId = this.goodsId;
  274. this.param.gradeId = this.gradeId;
  275. this.$api.courseCourseList(this.param).then((res) => {
  276. if (res.data.code == 200) {
  277. self.courseList.push.apply(self.courseList, res.data.rows);
  278. self.param.total = res.data.total;
  279. console.log(res.data.rows.length,'res.data.rows.length')
  280. if (res.data.rows.length) {
  281. this.courseBusiness(res.data.rows[0].businessId);
  282. }
  283. }
  284. });
  285. },
  286. appointment() {
  287. this.$navTo.togo("/pages2/appointment/index?orderGoodsId="+this.orderGoodsId);
  288. },
  289. },
  290. };
  291. </script>
  292. <style>
  293. page {
  294. background: #eaeef1;
  295. }
  296. </style>
  297. <style scope>
  298. .box_progress {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. margin-top: 20rpx;
  303. }
  304. .bottomBox {
  305. background: #ffffff;
  306. width: 94%;
  307. border-bottom-left-radius: 24rpx;
  308. border-bottom-right-radius: 24rpx;
  309. margin: 0 auto;
  310. padding: 20rpx;
  311. }
  312. .content_box {
  313. display: flex;
  314. align-items: center;
  315. color: #999999;
  316. margin-top: 8rpx;
  317. }
  318. .content {
  319. color: #000000;
  320. margin: 0 8rpx;
  321. }
  322. .wk_icon {
  323. width: 24rpx;
  324. height: 24rpx;
  325. margin-right: 8rpx;
  326. }
  327. .class_item {
  328. width: 100%;
  329. background: #ffffff;
  330. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  331. border-radius: 24rpx;
  332. padding: 20rpx;
  333. z-index: 999;
  334. position: relative;
  335. }
  336. </style>