index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view>
  3. <view class="shenbaoList">
  4. <view class="list_li" v-for="(item,index) in list" :key="index" @click="detail(item)">
  5. <image :src="item.thumb_resource.url" mode="aspectFit" class="img"></image>
  6. <view class="title"><text style="margin-right: 5px;">{{item.title}}</text> <text class="tag"
  7. v-for="item1 in item.labels" :key="item1">{{item1}}</text></view>
  8. <!-- <view class="tag">类型:英语</view> -->
  9. <view class="li_bottom">
  10. <view class="">
  11. 视频数量:<text style="color: #fc521c;font-weight: 550;">{{item.video_nums}}</text>
  12. </view>
  13. <view class="">
  14. 观看人数:<text style="color: #fc521c;font-weight: 550;">{{item.user_count}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. var app = getApp()
  23. import navBar from '../../components/navBar/navbar.vue';
  24. export default {
  25. components: {
  26. navBar
  27. },
  28. data() {
  29. return {
  30. list: [],
  31. page: 1,
  32. total_pages:''
  33. };
  34. },
  35. onLoad() {
  36. app.request('/courses/list', 'get').then(res => {
  37. console.log(res)
  38. this.list = res.data.data.data
  39. this.total_pages = res.data.data.meta.pagination.total_pages
  40. })
  41. },
  42. onShow() {
  43. },
  44. onReachBottom() {
  45. console.log('触底时间')
  46. uni.showLoading()
  47. if(this.total_pages>this.page){
  48. this.page++;
  49. let params = {
  50. page: this.page
  51. }
  52. app.request('/courses/list',params, 'get').then(res => {
  53. console.log(res)
  54. this.list = this.list.concat(res.data.data.data)
  55. })
  56. }else{
  57. uni.showToast({
  58. title: '到底了~',
  59. icon: 'none'
  60. })
  61. }
  62. uni.hideLoading()
  63. },
  64. methods: {
  65. backLast: function() {
  66. uni.reLaunch({
  67. url: './index'
  68. })
  69. },
  70. detail(item) {
  71. uni.navigateTo({
  72. url: './detail?slug=' + item.slug
  73. })
  74. },
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. page {
  80. background: #f5f5f5;
  81. padding-bottom: 50upx;
  82. }
  83. .title {
  84. padding: 8px 0;
  85. font-weight: 550;
  86. color: #3e3e3e;
  87. font-size: 16px;
  88. }
  89. .shenbaoList {
  90. display: flex;
  91. flex-direction: column;
  92. width: 100%;
  93. align-items: center;
  94. .tag {
  95. display: inline-block;
  96. border-radius: 3px;
  97. border: solid 1px #1c85f1;
  98. color: #1c85f1;
  99. font-size: 12px;
  100. padding: 0px 3px;
  101. margin-right: 5px;
  102. font-weight: normal;
  103. }
  104. .list_li {
  105. display: flex;
  106. flex-direction: column;
  107. width: 90%;
  108. margin-top: 20upx;
  109. padding: 20upx;
  110. font-size: 26upx;
  111. background: white;
  112. border-radius: 10upx;
  113. view {
  114. // margin-top: 4px;
  115. }
  116. .img {
  117. width: 100%;
  118. height: 260upx;
  119. background-color: #f5f5f5;
  120. }
  121. .text1 {
  122. padding-top: 10upx;
  123. }
  124. .li_bottom {
  125. display: flex;
  126. align-items: center;
  127. justify-content: space-between;
  128. // padding-top: 10upx;
  129. .none {
  130. background: blue;
  131. color: white;
  132. display: flex;
  133. align-items: center;
  134. justify-content: center;
  135. padding: 5upx 10upx;
  136. }
  137. .upload {
  138. background: green;
  139. color: white;
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. padding: 5upx 15upx;
  144. }
  145. }
  146. }
  147. }
  148. </style>