course.vue 9.8 KB

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