list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. console.log(res);
  111. this.recommendList = res.data.recommendList
  112. })
  113. },
  114. getKcList(type) {
  115. let that = this;
  116. let item = that.navList[that.currentIndex]
  117. if(item.loaded && type == 'tab') {
  118. return
  119. }
  120. if(item.loadingType == 'noMore' || item.loadingType == 'loading') {
  121. return
  122. }
  123. item.loadingType = 'loading'
  124. getKcList({
  125. type1: item.type,
  126. page: item.page,
  127. pageSize: item.pageSize
  128. }).then(res => {
  129. console.log(res);
  130. item.list = item.list.concat(res.data.grlist)
  131. item.page++
  132. if(item.pageSize == res.data.grlist.length) {
  133. item.loadingType = 'more'
  134. }else {
  135. item.loadingType = 'noMore'
  136. }
  137. item.loaded = true
  138. })
  139. },
  140. navClick(index) {
  141. this.currentIndex = index
  142. this.getKcList('tab')
  143. }
  144. }
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .top-swiper {
  149. margin: auto;
  150. width: 750rpx;
  151. height: 392rpx;
  152. .carousel-item {
  153. // border-radius: 20rpx;
  154. .imageitem {
  155. // margin: auto;
  156. width: 750rpx;
  157. height: 392rpx;
  158. }
  159. }
  160. }
  161. .nav {
  162. width: 750rpx;
  163. height: 88rpx;
  164. margin: 20rpx 0;
  165. .nav-item {
  166. line-height: 88rpx;
  167. width: 50%;
  168. text-align: center;
  169. font-size: 30rpx;
  170. font-weight: 500;
  171. color: #333333;
  172. height: 100%;
  173. }
  174. .action {
  175. font-weight: bold;
  176. color: $base-color;
  177. }
  178. background-color: #fff;
  179. }
  180. .scroll-wrap {
  181. // background-color: red;
  182. }
  183. .kc-item {
  184. // border-bottom: #c8c7cc solid 1px;
  185. padding: 22rpx 0;
  186. justify-content: center;
  187. background-color: #fff;
  188. .kc-img {
  189. flex-shrink: 0;
  190. width: 266rpx;
  191. height: 164rpx;
  192. margin-right: 20rpx;
  193. background-color: #eee;
  194. }
  195. .kc-info {
  196. height: 164rpx;
  197. width: 360rpx;
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-between;
  201. align-items: flex-start;
  202. // background-color: red;
  203. .info-tit {
  204. width: 100%;
  205. font-size: 32rpx;
  206. color: #000;
  207. }
  208. .info-cate {
  209. width: 100%;
  210. color: #ff5a97;
  211. font-size: 28rpx;
  212. }
  213. .info-info {
  214. width: 360rpx;
  215. font-size: 24rpx;
  216. .rs {
  217. color: #8f8f94;
  218. }
  219. .visit {
  220. color: $base-color;
  221. }
  222. }
  223. }
  224. }
  225. </style>