index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view>
  3. <view class="video_list">
  4. <view class="video_item" v-for="(item, index) in videoList">
  5. <view class="video_info">
  6. <image class="thumb_img" :src="item.thumb" mode="aspectFit"></image>
  7. <view>
  8. <view class="video_type">
  9. <text class="type_name">{{ item.type_name }}</text>
  10. </view>
  11. <view class="video_title">{{ item.name }}</view>
  12. <view class="video_time">
  13. <text class="time_info">{{ item.end_time }} </text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="video_btn">
  18. <button class="after_exam" @click="goExam(item.id, item.report_id, item.learn_status)">
  19. {{ item.report_id > 0 ? "查看报告" : "课后评测" }}
  20. </button>
  21. <button class="to_learn" @click.stop="goDetail(item.id)">开始学习</button>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="to_bottom" v-if="!videoList.length"> -----您还没有可学习课程-----</view>
  26. <view class="contact_follow">
  27. <button class="contact_btn" open-type="contact">
  28. <uni-icons type="headphones" size="30" color="#FFFFFF"></uni-icons>
  29. </button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. // 产品列表
  38. videoList: [],
  39. // 请求参数
  40. requestParam: {
  41. page: 1,
  42. status: 0,
  43. },
  44. // 是否最后一页
  45. isLast: false,
  46. // 是否请求中
  47. isReqing: false,
  48. };
  49. },
  50. onLoad() {},
  51. onShow() {
  52. // 没有数据的话,或者请求中,不允许刷新
  53. if (this.isReqing) return;
  54. // 初始化页码为1
  55. this.requestParam.page = 1;
  56. // 是否是最后一页
  57. this.isLast = false;
  58. // 设置请求中
  59. this.isReqing = true;
  60. // 请求列表
  61. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  62. // 设置非请求中
  63. this.isReqing = false;
  64. // 成功结果
  65. if (re.code == "success") {
  66. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  67. this.videoList = re.data.data;
  68. }
  69. });
  70. },
  71. onPullDownRefresh() {
  72. // 如果请求中,不允许请求,
  73. if (this.isReqing) return false;
  74. // 初始化页码为1
  75. this.requestParam.page = 1;
  76. // 是否是最后一页
  77. this.isLast = false;
  78. // 设置请求中
  79. this.isReqing = true;
  80. // 请求列表
  81. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  82. // 设置非请求中
  83. this.isReqing = false;
  84. // 成功结果
  85. if (re.code == "success") {
  86. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  87. this.videoList = re.data.data;
  88. }
  89. });
  90. uni.stopPullDownRefresh();
  91. },
  92. onReachBottom() {
  93. // 如果页码是0,避免第一页重复
  94. if (this.requestParam.page < 1) return;
  95. // 最后一页不请求
  96. if (this.isLast) return;
  97. // 请求中,不再请求
  98. if (this.isReqing) return;
  99. // 增加一页
  100. this.requestParam.page = this.requestParam.page + 1;
  101. // 设置请求中
  102. this.isReqing = true;
  103. // 请求列表
  104. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  105. // 设置非请求中
  106. this.isReqing = false;
  107. // 成功结果
  108. if (re.code == "success") {
  109. // 数据
  110. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  111. // 追加数据
  112. this.videoList.push(...re.data.data);
  113. }
  114. });
  115. },
  116. methods: {
  117. goDetail(id) {
  118. uni.navigateTo({
  119. url: "/pages/video/detail?id=" + id,
  120. });
  121. },
  122. goExam(id, report_id, status) {
  123. if (status < 0) {
  124. uni.showToast({
  125. title: "请先完成课程再来答题吧",
  126. icon: "none",
  127. duration: 2000,
  128. });
  129. return;
  130. }
  131. if (report_id > 0) {
  132. uni.navigateTo({
  133. url: "/pages/video/record?type=exam&record_id=" + report_id,
  134. });
  135. return;
  136. }
  137. uni.navigateTo({
  138. url: "/pages/video/exam?id=" + id,
  139. });
  140. },
  141. },
  142. };
  143. </script>
  144. <style lang="less">
  145. .video_list {
  146. float: left;
  147. width: 750rpx;
  148. display: block;
  149. overflow: hidden;
  150. .video_item {
  151. display: block;
  152. width: 700rpx;
  153. overflow: hidden;
  154. margin-bottom: 10rpx;
  155. padding: 20rpx 25rpx;
  156. border-radius: 10rpx;
  157. background-color: #ffffff;
  158. .video_btn {
  159. display: flex;
  160. align-items: center;
  161. justify-content: flex-end;
  162. gap: 20rpx;
  163. margin-top: 10rpx;
  164. .to_learn {
  165. margin: 0;
  166. color: #fff;
  167. border: none;
  168. width: 140rpx;
  169. height: 50rpx;
  170. font-size: 26rpx;
  171. line-height: 50rpx;
  172. padding: 0rpx 0rpx;
  173. text-align: center;
  174. border-radius: 10rpx;
  175. background-color: #5045e6;
  176. }
  177. .to_learn::after {
  178. border: none;
  179. }
  180. .after_exam {
  181. margin: 0;
  182. color: #5045e6;
  183. border: none;
  184. width: 140rpx;
  185. height: 50rpx;
  186. font-size: 26rpx;
  187. line-height: 50rpx;
  188. padding: 0rpx 0rpx;
  189. text-align: center;
  190. border-radius: 10rpx;
  191. background-color: #fff;
  192. border: 1px solid #5045e6;
  193. }
  194. }
  195. .video_info {
  196. width: 100%;
  197. display: flex;
  198. .thumb_img {
  199. width: 200rpx;
  200. height: 200rpx;
  201. border-radius: 10rpx;
  202. margin-right: 20rpx;
  203. }
  204. .video_type {
  205. color: #999999;
  206. width: 480rpx;
  207. display: block;
  208. height: 60rpx;
  209. font-size: 26rpx;
  210. line-height: 60rpx;
  211. }
  212. .video_title {
  213. width: 480rpx;
  214. display: block;
  215. height: 80rpx;
  216. font-size: 32rpx;
  217. overflow: hidden;
  218. font-weight: bold;
  219. line-height: 40rpx;
  220. text-overflow: ellipsis;
  221. }
  222. .video_time {
  223. color: #999999;
  224. width: 480rpx;
  225. display: block;
  226. height: 60rpx;
  227. font-size: 26rpx;
  228. line-height: 60rpx;
  229. }
  230. }
  231. }
  232. }
  233. .contact_follow {
  234. bottom: 30%;
  235. right: 20rpx;
  236. width: 100rpx;
  237. height: 100rpx;
  238. display: block;
  239. position: fixed;
  240. border-radius: 50%;
  241. background-color: #1296db;
  242. .contact_btn {
  243. border: none;
  244. width: 100rpx;
  245. color: #ffffff;
  246. height: 100rpx;
  247. padding: 0rpx 0rpx;
  248. line-height: 100rpx;
  249. text-align: center;
  250. border-radius: 50%;
  251. background-color: #1296db;
  252. }
  253. .contact_btn::after {
  254. border: none;
  255. }
  256. }
  257. </style>