course.vue 11 KB

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