index.vue 6.3 KB

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