index.vue 5.5 KB

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