list.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="content">
  3. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" >
  4. <swiper-item v-for="item in recommendList" class="carousel-item" @click="navTo('/pages/eduction/detail?id=' + item.gr_id + '&img=' + encodeURI(item.indeximg))">
  5. <image class="imageitem" :src="item.indeximg.indexOf('http') == -1 ? ('https://myj.liuniu946.com' +item.indeximg) : item.indeximg " />
  6. </swiper-item>
  7. </swiper>
  8. <view class="nav flex">
  9. <view class="nav-item" v-for="(item,index) in navList" @click="navClick(index)"
  10. :class="{'action': index == currentIndex}">
  11. {{item.title}}
  12. </view>
  13. </view>
  14. <scroll-view scroll-y="true" :style="{'height':height}" class="scroll-wrap" @scrolltolower="getKcList">
  15. <view class="kc-item flex" v-for="item in navList[currentIndex].list" @click="navTo('/pages/eduction/detail?id=' + item.gr_id + '&img=' + encodeURI(item.indeximg))">
  16. <image :src="item.indeximg.indexOf('http') == -1 ? ('https://myj.liuniu946.com' +item.indeximg) : item.indeximg " mode="" class="kc-img"></image>
  17. <view class="kc-info">
  18. <view class="info-tit clamp">
  19. {{item.title}}
  20. </view>
  21. <view class="info-cate clamp">
  22. {{item.ins}}
  23. </view>
  24. <view class="info-info flex">
  25. <view class="rs">
  26. {{item.count}}
  27. </view>
  28. <view class="visit">
  29. {{item.alll}}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <uni-load-more :status="navList[currentIndex].loadingType"></uni-load-more>
  35. </scroll-view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. getKcList,
  41. recommend
  42. } from '@/api/index.js'
  43. export default {
  44. data() {
  45. return {
  46. recommendList: [],
  47. height: '',
  48. currentIndex: 0,
  49. navList: [{
  50. title: '全部',
  51. page: 1,
  52. pageSize: 10,
  53. list: [],
  54. loadingType: 'morde',
  55. loaded: false
  56. }, {
  57. title: '视频',
  58. page: 1,
  59. pageSize: 10,
  60. list: [],
  61. loadingType: 'morde',
  62. type: 0,
  63. loaded: false
  64. },
  65. {
  66. title: '音频',
  67. page: 1,
  68. pageSize: 10,
  69. list: [],
  70. loadingType: 'morde',
  71. type: 1,
  72. loaded: false
  73. }
  74. ]
  75. };
  76. },
  77. onLoad(opt) {},
  78. onShow() {
  79. this.getKcList()
  80. this.getrecommendList()
  81. },
  82. onReady(res) {
  83. var that = this;
  84. uni.getSystemInfo({
  85. success: resu => {
  86. const query = uni.createSelectorQuery();
  87. query.select('.scroll-wrap').boundingClientRect();
  88. query.exec(function(res) {
  89. that.height = resu.windowHeight - res[0].top + 'px';
  90. });
  91. },
  92. fail: res => {}
  93. });
  94. },
  95. onReachBottom() {
  96. },
  97. methods: {
  98. navTo(url) {
  99. uni.navigateTo({
  100. url,
  101. fail() {
  102. uni.switchTab({
  103. url
  104. })
  105. }
  106. })
  107. },
  108. getrecommendList() {
  109. recommend().then(res => {
  110. this.recommendList = res.data.recommendList
  111. })
  112. },
  113. getKcList(type) {
  114. let that = this;
  115. let item = that.navList[that.currentIndex]
  116. if(item.loaded && type == 'tab') {
  117. return
  118. }
  119. if(item.loadingType == 'noMore' || item.loadingType == 'loading') {
  120. return
  121. }
  122. item.loadingType = 'loading'
  123. getKcList({
  124. type1: item.type,
  125. page: item.page,
  126. pageSize: item.pageSize
  127. }).then(res => {
  128. item.list = item.list.concat(res.data.grlist)
  129. item.page++
  130. if(item.pageSize == res.data.grlist.length) {
  131. item.loadingType = 'more'
  132. }else {
  133. item.loadingType = 'noMore'
  134. }
  135. item.loaded = true
  136. })
  137. },
  138. navClick(index) {
  139. this.currentIndex = index
  140. this.getKcList('tab')
  141. }
  142. }
  143. };
  144. </script>
  145. <style lang="scss" scoped>
  146. .top-swiper {
  147. margin: auto;
  148. width: 750rpx;
  149. height: 392rpx;
  150. .carousel-item {
  151. // border-radius: 20rpx;
  152. .imageitem {
  153. // margin: auto;
  154. width: 750rpx;
  155. height: 392rpx;
  156. }
  157. }
  158. }
  159. .nav {
  160. width: 750rpx;
  161. height: 88rpx;
  162. margin: 20rpx 0;
  163. .nav-item {
  164. line-height: 88rpx;
  165. width: 50%;
  166. text-align: center;
  167. font-size: 30rpx;
  168. font-weight: 500;
  169. color: #333333;
  170. height: 100%;
  171. }
  172. .action {
  173. font-weight: bold;
  174. color: $base-color;
  175. }
  176. background-color: #fff;
  177. }
  178. .scroll-wrap {
  179. // background-color: red;
  180. }
  181. .kc-item {
  182. // border-bottom: #c8c7cc solid 1px;
  183. padding: 22rpx 0;
  184. justify-content: center;
  185. background-color: #fff;
  186. .kc-img {
  187. flex-shrink: 0;
  188. width: 266rpx;
  189. height: 164rpx;
  190. margin-right: 20rpx;
  191. background-color: #eee;
  192. }
  193. .kc-info {
  194. height: 164rpx;
  195. width: 360rpx;
  196. display: flex;
  197. flex-direction: column;
  198. justify-content: space-between;
  199. align-items: flex-start;
  200. // background-color: red;
  201. .info-tit {
  202. width: 100%;
  203. font-size: 32rpx;
  204. color: #000;
  205. }
  206. .info-cate {
  207. width: 100%;
  208. color: #ff5a97;
  209. font-size: 28rpx;
  210. }
  211. .info-info {
  212. width: 360rpx;
  213. font-size: 24rpx;
  214. .rs {
  215. color: #8f8f94;
  216. }
  217. .visit {
  218. color: $base-color;
  219. }
  220. }
  221. }
  222. }
  223. </style>