course.vue 11 KB

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