index.vue 6.5 KB

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