course.vue 8.6 KB

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