course.vue 10 KB

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