course.vue 10.0 KB

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