course.vue 11 KB

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