course.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view style="padding: 30rpx">
  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="22"
  34. :show-percent="false"
  35. active-color="#ff9900"
  36. :percent="(item.stuAllNum / item.secAllNum) * 100"
  37. ></u-line-progress
  38. ></view>
  39. <view
  40. ><u-button
  41. type="warning"
  42. size="mini"
  43. @click.stop="jump(item, index)"
  44. >进入学习</u-button
  45. ></view
  46. >
  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. this.itemIndex = index;
  116. if (index == 0) {
  117. if (item.rebuild === 0) {
  118. //未重修
  119. this.$navTo.togo("/pages2/learn/details", {
  120. id: item.courseId,
  121. gradeId: item.gradeId,
  122. goodsId: this.goodsId,
  123. });
  124. return;
  125. }
  126. this.$api.courseDetail(item.courseId).then((res) => {
  127. if (res.data.code == 200) {
  128. if (res.data.data.educationName == "继续教育") {
  129. this.$api
  130. .lockLockStatus({
  131. action: "jxjy",
  132. })
  133. .then((res) => {
  134. if (res.data.code == 200) {
  135. //有其他端在操作,不能学习
  136. uni.showToast({
  137. icon: "none",
  138. title: res.data.msg,
  139. mask: true,
  140. duration: 3000,
  141. });
  142. } else if (res.data.code == 500) {
  143. //可以学习
  144. this.$navTo.togo("/pages3/polyv/detail", {
  145. id: item.courseId,
  146. goodsId: this.goodsId,
  147. orderGoodsId: this.orderGoodsId,
  148. });
  149. }
  150. });
  151. // websocket.sendMsg("doCourse");
  152. } else {
  153. this.$navTo.togo("/pages3/polyv/detail", {
  154. id: item.courseId,
  155. goodsId: this.goodsId,
  156. orderGoodsId: this.orderGoodsId,
  157. });
  158. }
  159. }
  160. });
  161. } else {
  162. if (this.businessData.goodsLearningOrder == 2) {
  163. //学习顺序是从头到尾学习,没学完上一课不能学习下一课
  164. let prevItem = this.courseList[index - 1]; //上一课
  165. if (
  166. prevItem.stuAllNum + prevItem.recordNum ==
  167. prevItem.secAllNum + prevItem.examNum
  168. ) {
  169. if (item.rebuild === 0) {
  170. //未重修
  171. this.$navTo.togo("/pages2/learn/details", {
  172. id: item.courseId,
  173. gradeId: item.gradeId,
  174. goodsId: this.goodsId,
  175. });
  176. return;
  177. }
  178. this.$api.courseDetail(item.courseId).then((res) => {
  179. if (res.data.code == 200) {
  180. if (res.data.data.educationName == "继续教育") {
  181. this.$api
  182. .lockLockStatus({
  183. action: "jxjy",
  184. })
  185. .then((res) => {
  186. if (res.data.code == 200) {
  187. //有其他端在操作,不能学习
  188. uni.showToast({
  189. icon: "none",
  190. title: res.data.msg,
  191. duration: 2000,
  192. });
  193. } else if (res.data.code == 500) {
  194. //可以学习
  195. this.$navTo.togo("/pages3/polyv/detail", {
  196. id: item.courseId,
  197. goodsId: this.goodsId,
  198. orderGoodsId: this.orderGoodsId,
  199. });
  200. }
  201. });
  202. // websocket.sendMsg("doCourse");
  203. } else {
  204. this.$navTo.togo("/pages3/polyv/detail", {
  205. id: item.courseId,
  206. goodsId: this.goodsId,
  207. orderGoodsId: this.orderGoodsId,
  208. });
  209. }
  210. }
  211. });
  212. } else {
  213. uni.showToast({
  214. icon: "none",
  215. title: "请按顺序学完上一课再学习这一课",
  216. });
  217. }
  218. } else {
  219. if (item.rebuild === 0) {
  220. //未重修
  221. this.$navTo.togo("/pages2/learn/details", {
  222. id: item.courseId,
  223. gradeId: item.gradeId,
  224. goodsId: this.goodsId,
  225. });
  226. return;
  227. }
  228. this.$api.courseDetail(item.courseId).then((res) => {
  229. if (res.data.code == 200) {
  230. if (res.data.data.educationName == "继续教育") {
  231. this.$api
  232. .lockLockStatus({
  233. action: "jxjy",
  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. }
  254. }
  255. });
  256. }
  257. }
  258. },
  259. courseCourseList() {
  260. let self = this;
  261. this.param.goodsId = this.goodsId;
  262. this.param.gradeId = this.gradeId;
  263. this.$api.courseCourseList(this.param).then((res) => {
  264. if (res.data.code == 200) {
  265. self.courseList.push.apply(self.courseList, res.data.rows);
  266. self.param.total = res.data.total;
  267. if (res.data.rows.length) {
  268. this.courseBusiness(res.data.rows[0].businessId);
  269. }
  270. }
  271. });
  272. },
  273. appointment() {
  274. this.$navTo.togo("/pages2/appointment/index");
  275. },
  276. },
  277. };
  278. </script>
  279. <style>
  280. page {
  281. background: #eaeef1;
  282. }
  283. </style>
  284. <style scope>
  285. .box_progress {
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. margin-top: 20rpx;
  290. }
  291. .bottomBox {
  292. background: #ffffff;
  293. width: 94%;
  294. border-bottom-left-radius: 24rpx;
  295. border-bottom-right-radius: 24rpx;
  296. margin: 0 auto;
  297. padding: 20rpx;
  298. }
  299. .content_box {
  300. display: flex;
  301. align-items: center;
  302. color: #999999;
  303. margin-top: 8rpx;
  304. }
  305. .content {
  306. color: #000000;
  307. margin: 0 8rpx;
  308. }
  309. .wk_icon {
  310. width: 24rpx;
  311. height: 24rpx;
  312. margin-right: 8rpx;
  313. }
  314. .class_item {
  315. width: 100%;
  316. background: #ffffff;
  317. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  318. border-radius: 24rpx;
  319. padding: 20rpx;
  320. z-index: 999;
  321. position: relative;
  322. }
  323. </style>