course.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. informId: '', //消息id,从公众号消息模板进来的才有
  68. };
  69. },
  70. onLoad(option) {
  71. this.goodsId = Number(option.goodsId);
  72. this.gradeId = Number(option.goodsId);
  73. this.orderGoodsId = Number(option.orderGoodsId);
  74. // 公众号模板消息的数据埋点
  75. if (option.informId) {
  76. this.informId = option.informId
  77. // this.clickOfficial()
  78. }
  79. this.$store.getters.dictObj;
  80. },
  81. onShow() {
  82. if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
  83. return;
  84. }
  85. this.courseCourseList();
  86. this.informId && this.clickOfficial() // 从公众号消息点击进来上报一次
  87. if (this.itemIndex !== "") {
  88. this.refreshByIndex();
  89. }
  90. },
  91. onReachBottom() {
  92. if (this.courseList.length < this.param.total) {
  93. this.param.pageNum++;
  94. this.courseCourseList();
  95. }
  96. },
  97. methods: {
  98. // 新增微信公众号模板消息点击数据
  99. clickOfficial() {
  100. this.$http({
  101. url: '/data/click',
  102. method: 'post',
  103. data: { informId: this.informId }
  104. }).then((res) => {
  105. if (res.data.code == 200) {
  106. console.log('埋点')
  107. }
  108. })
  109. },
  110. /**
  111. * 返回刷新之前进入的课程数据
  112. */
  113. refreshByIndex() {
  114. this.$api
  115. .courseCourseList({
  116. pageNum: this.itemIndex + 1,
  117. pageSize: 1,
  118. goodsId: this.goodsId,
  119. gradeId: 0,
  120. })
  121. .then((res) => {
  122. if (res.data.code == 200) {
  123. this.$set(this.courseList, this.itemIndex, res.data.rows[0]);
  124. }
  125. });
  126. },
  127. /**
  128. * 获取业务层次详情
  129. */
  130. courseBusiness(businessId) {
  131. this.$api.courseBusiness(businessId).then((res) => {
  132. this.businessData = res.data.data;
  133. });
  134. },
  135. jump(item, index) {
  136. this.itemIndex = index;
  137. this.$navTo.togo("/pages3/live/detail", {
  138. courseId: item.courseId,
  139. goodsId: this.goodsId,
  140. gradeId:0,
  141. orderGoodsId: this.orderGoodsId,
  142. });
  143. },
  144. courseCourseList() {
  145. let self = this;
  146. this.param.goodsId = this.goodsId;
  147. this.param.gradeId = this.gradeId;
  148. this.$api.courseCourseList(this.param).then((res) => {
  149. if (res.data.code == 200) {
  150. self.courseList.push.apply(self.courseList, res.data.rows);
  151. self.param.total = res.data.total;
  152. // if (res.data.rows.length) {
  153. // this.courseBusiness(res.data.rows[0].businessId);
  154. // }
  155. }
  156. });
  157. },
  158. appointment() {
  159. this.$navTo.togo("/pages2/appointment/index?orderGoodsId="+this.orderGoodsId);
  160. },
  161. },
  162. };
  163. </script>
  164. <style>
  165. page {
  166. background: #eaeef1;
  167. }
  168. </style>
  169. <style scope lang="scss">
  170. .box_progress {
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. margin-top: 20rpx;
  175. }
  176. .bottomBox {
  177. background: #ffffff;
  178. width: 94%;
  179. border-bottom-left-radius: 24rpx;
  180. border-bottom-right-radius: 24rpx;
  181. margin: 0 auto;
  182. padding: 20rpx;
  183. }
  184. .content_box {
  185. display: flex;
  186. align-items: center;
  187. color: #999999;
  188. margin-top: 8rpx;
  189. }
  190. .content {
  191. color: #000000;
  192. margin: 0 8rpx;
  193. }
  194. .wk_icon {
  195. width: 24rpx;
  196. height: 24rpx;
  197. margin-right: 8rpx;
  198. }
  199. .class_item {
  200. width: 100%;
  201. background: #ffffff;
  202. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  203. border-radius: 24rpx;
  204. padding: 20rpx;
  205. z-index: 999;
  206. position: relative;
  207. }
  208. </style>