course.vue 11 KB

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