course.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view style="padding: 24rpx">
  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="32"
  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 class="learing_bt" @click.stop="jump(item, index)">
  44. 进入学习
  45. <!-- <u-button
  46. type="warning"
  47. size="mini"
  48. @click.stop="jump(item, index)"
  49. >进入学习</u-button> -->
  50. </view>
  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. console.log('00000000')
  120. this.itemIndex = index;
  121. if (index == 0) {
  122. if (item.rebuild === 0) {
  123. //未重修
  124. this.$navTo.togo("/pages2/learn/details", {
  125. id: item.courseId,
  126. gradeId: item.gradeId,
  127. goodsId: this.goodsId,
  128. orderGoodsId: this.orderGoodsId,
  129. });
  130. return;
  131. }
  132. this.$api.courseDetail(item.courseId).then((res) => {
  133. if (res.data.code == 200) {
  134. // if (res.data.data.educationName == "继续教育") {
  135. this.$api
  136. .lockLockStatus({
  137. action: "jxjy",
  138. uuid: this.$method.getUuid(),
  139. })
  140. .then((res) => {
  141. if (res.data.code == 200) {
  142. //有其他端在操作,不能学习
  143. uni.showToast({
  144. icon: "none",
  145. title: res.data.msg,
  146. mask: true,
  147. duration: 3000,
  148. });
  149. } else if (res.data.code == 500) {
  150. //可以学习
  151. this.$navTo.togo("/pages3/polyv/detail", {
  152. id: item.courseId,
  153. goodsId: this.goodsId,
  154. orderGoodsId: this.orderGoodsId,
  155. });
  156. }
  157. });
  158. // websocket.sendMsg("doCourse");
  159. // } else {
  160. // this.$navTo.togo("/pages3/polyv/detail", {
  161. // id: item.courseId,
  162. // goodsId: this.goodsId,
  163. // orderGoodsId: this.orderGoodsId,
  164. // });
  165. // }
  166. }
  167. });
  168. } else {
  169. if (this.businessData.goodsLearningOrder == 2) {
  170. //学习顺序是从头到尾学习,没学完上一课不能学习下一课
  171. let prevItem = this.courseList[index - 1]; //上一课
  172. if (
  173. prevItem.stuAllNum + prevItem.recordNum ==
  174. prevItem.secAllNum + prevItem.examNum
  175. ) {
  176. if (item.rebuild === 0) {
  177. //未重修
  178. this.$navTo.togo("/pages2/learn/details", {
  179. id: item.courseId,
  180. gradeId: item.gradeId,
  181. goodsId: this.goodsId,
  182. orderGoodsId: this.orderGoodsId,
  183. });
  184. return;
  185. }
  186. this.$api.courseDetail(item.courseId).then((res) => {
  187. if (res.data.code == 200) {
  188. // if (res.data.data.educationName == "继续教育") {
  189. this.$api
  190. .lockLockStatus({
  191. action: "jxjy",
  192. uuid: this.$method.getUuid(),
  193. })
  194. .then((res) => {
  195. if (res.data.code == 200) {
  196. //有其他端在操作,不能学习
  197. uni.showToast({
  198. icon: "none",
  199. title: res.data.msg,
  200. duration: 2000,
  201. });
  202. } else if (res.data.code == 500) {
  203. //可以学习
  204. this.$navTo.togo("/pages3/polyv/detail", {
  205. id: item.courseId,
  206. goodsId: this.goodsId,
  207. orderGoodsId: this.orderGoodsId,
  208. });
  209. }
  210. });
  211. // websocket.sendMsg("doCourse");
  212. // } else {
  213. // this.$navTo.togo("/pages3/polyv/detail", {
  214. // id: item.courseId,
  215. // goodsId: this.goodsId,
  216. // orderGoodsId: this.orderGoodsId,
  217. // });
  218. // }
  219. }
  220. });
  221. } else {
  222. uni.showToast({
  223. icon: "none",
  224. title: "请按顺序学完上一课再学习这一课",
  225. });
  226. }
  227. } else {
  228. if (item.rebuild === 0) {
  229. //未重修
  230. this.$navTo.togo("/pages2/learn/details", {
  231. id: item.courseId,
  232. gradeId: item.gradeId,
  233. goodsId: this.goodsId,
  234. orderGoodsId: this.orderGoodsId,
  235. });
  236. return;
  237. }
  238. this.$api.courseDetail(item.courseId).then((res) => {
  239. if (res.data.code == 200) {
  240. // if (res.data.data.educationName == "继续教育") {
  241. this.$api
  242. .lockLockStatus({
  243. action: "jxjy",
  244. uuid: this.$method.getUuid(),
  245. })
  246. .then((res) => {
  247. if (res.data.code == 200) {
  248. //有其他端在操作,不能学习
  249. uni.showToast({
  250. icon: "none",
  251. title: res.data.msg,
  252. duration: 2000,
  253. });
  254. } else if (res.data.code == 500) {
  255. //可以学习
  256. this.$navTo.togo("/pages3/polyv/detail", {
  257. id: item.courseId,
  258. goodsId: this.goodsId,
  259. orderGoodsId: this.orderGoodsId,
  260. });
  261. }
  262. });
  263. // websocket.sendMsg("doCourse");
  264. // } else {
  265. // this.$navTo.togo("/pages3/polyv/detail", {
  266. // id: item.courseId,
  267. // goodsId: this.goodsId,
  268. // orderGoodsId: this.orderGoodsId,
  269. // });
  270. // }
  271. }
  272. });
  273. }
  274. }
  275. },
  276. courseCourseList() {
  277. let self = this;
  278. this.param.goodsId = this.goodsId;
  279. this.param.gradeId = this.gradeId;
  280. // /course/courseList查询商品下的课程列表
  281. this.$api.courseCourseList(this.param).then((res) => {
  282. if (res.data.code == 200) {
  283. self.courseList.push.apply(self.courseList, res.data.rows);
  284. self.param.total = res.data.total;
  285. console.log(res.data.rows.length, "res.data.rows.length");
  286. if (res.data.rows.length) {
  287. this.courseBusiness(res.data.rows[0].businessId);
  288. }
  289. }
  290. });
  291. },
  292. appointment() {
  293. this.$navTo.togo(
  294. "/pages2/appointment/index?orderGoodsId=" + this.orderGoodsId
  295. );
  296. },
  297. },
  298. };
  299. </script>
  300. <style>
  301. page {
  302. background: #eaeef1;
  303. }
  304. </style>
  305. <style lang="scss" scope>
  306. .box_progress {
  307. display: flex;
  308. justify-content: space-between;
  309. align-items: center;
  310. margin-top: 20rpx;
  311. }
  312. .bottomBox {
  313. background: #ffffff;
  314. width: 94%;
  315. border-bottom-left-radius: 24rpx;
  316. border-bottom-right-radius: 24rpx;
  317. margin: 0 auto;
  318. padding: 20rpx;
  319. .learing_bt {
  320. width: 165rpx;
  321. height: 48rpx;
  322. line-height: 48rpx;
  323. background: #FFB102;
  324. border-radius: 16rpx;
  325. font-size: 24rpx;
  326. font-weight: 400;
  327. color: #FFFFFF;
  328. text-align: center;
  329. }
  330. }
  331. .content_box {
  332. display: flex;
  333. align-items: center;
  334. color: #999999;
  335. margin-top: 8rpx;
  336. }
  337. .content {
  338. color: #000000;
  339. margin: 0 8rpx;
  340. }
  341. .wk_icon {
  342. width: 24rpx;
  343. height: 24rpx;
  344. margin-right: 8rpx;
  345. }
  346. .class_item {
  347. width: 100%;
  348. background: #ffffff;
  349. border-radius: 24rpx;
  350. padding: 20rpx 20rpx 30rpx 20rpx;
  351. z-index: 999;
  352. position: relative;
  353. background: #FFFFFF;
  354. box-shadow: 0px 0px 20px 1px rgba(1,99,235,0.1000);
  355. }
  356. </style>