course.vue 12 KB

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