index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <u-swiper height="185" :list="bannerList" @click="clickInfo" keyName="cover"></u-swiper>
  4. <u-list @scrolltolower="scrolltolower" height="calc(100% - 47px)" lowerThreshold="10">
  5. <view class="info-list">
  6. <view class="dis-flex flex-x-between info-item" v-for="(item, index) in list" :key="index"
  7. @click="toDetail(item.id)">
  8. <view class="info-pic">
  9. <u-image width="175rpx" height="175rpx" mode="aspectFill" :src="item.cover"></u-image>
  10. </view>
  11. <view class="info-view">
  12. <view class="info-title">
  13. {{item.subTitle}}
  14. </view>
  15. <view class="dis-flex info-bottom">
  16. <view style="margin-right: 20rpx;">{{item.createTime?item.createTime.substring(0,10):''}}</view>
  17. <u-icon name="thumb-up" color="#7f7f7f" size="18"></u-icon>
  18. <view style="margin-right: 20rpx;">{{item.likeNum || 0}}点赞</view>
  19. <u-icon name="eye" color="#7f7f7f" size="18"></u-icon>
  20. <view>{{item.views || 0}}阅读量</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <u-loadmore :status="page.status" :loading-text="page.loadingText" :loadmore-text="page.loadmoreText"
  26. :nomore-text="page.nomoreText" />
  27. </u-list>
  28. </view>
  29. </template>
  30. <script>
  31. import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  32. export default {
  33. mixins: [themeMixins],
  34. data() {
  35. return {
  36. bannerList: [],
  37. page: {
  38. current: 1,
  39. size: 10,
  40. total: 0,
  41. // loadmore loading nomore
  42. status: 'loadmore',
  43. loadingText: '正在加载中',
  44. loadmoreText: '上拉加载更多',
  45. nomoreText: '没有更多了'
  46. },
  47. keyword: '',
  48. list: []
  49. }
  50. },
  51. onShow() {
  52. this.getProfessionalStyleList();
  53. this.getBanners()
  54. },
  55. methods: {
  56. clickInfo(index) {
  57. if (index < 0) {
  58. return;
  59. }
  60. uni.navigateTo({
  61. url: "/pages/yuecai/information/detail/index?id=" + this.bannerList[index].id,
  62. })
  63. },
  64. getBanners() {
  65. this.$u.api.getInformationList(0, 6, {}).then(res => {
  66. this.bannerList = res.data.records || []
  67. })
  68. },
  69. scrolltolower() {
  70. this.loadmore()
  71. },
  72. loadmore() {
  73. this.page.current++;
  74. this.getProfessionalStyleList();
  75. },
  76. doRefresh() {
  77. this.page.current = 1;
  78. this.page.status = 'loadmore'
  79. this.list = [];
  80. this.getProfessionalStyleList();
  81. },
  82. getProfessionalStyleList() {
  83. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  84. // 防止重复下拉
  85. return;
  86. }
  87. this.page.status = 'loading';
  88. //
  89. this.$u.api.getProfessionalStyleList(this.page.current, this.page.size, {
  90. name: this.keyword || ''
  91. }).then(res => {
  92. if (res.data.records && res.data.records.length > 0) {
  93. this.list.push(...res.data.records)
  94. }
  95. this.page.total = res.data.total || 0;
  96. if (this.page.size * this.page.current >= res.data.total) {
  97. this.page.status = 'nomore'
  98. } else {
  99. this.page.status = 'loadmore'
  100. }
  101. })
  102. },
  103. toDetail(id) {
  104. uni.navigateTo({
  105. url: "/pages/yuecai/professional_style/detail/index?id=" + id,
  106. })
  107. }
  108. },
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .info-list {
  113. height: calc(100% - 95px);
  114. overflow: auto;
  115. background-color: #f4f6f8;
  116. .info-item {
  117. padding: 20rpx;
  118. border-bottom: 2rpx solid white;
  119. .info-pic {
  120. width: 175rpx;
  121. height: 175rpx;
  122. background: bisque;
  123. }
  124. .info-view {
  125. width: calc(100% - 205rpx);
  126. .info-title {
  127. height: 75px;
  128. word-break: break-all;
  129. color: #65371b;
  130. font-size: 24rpx;
  131. font-weight: 300;
  132. line-height: 47rpx;
  133. word-spacing: 2rpx;
  134. overflow: hidden;
  135. text-overflow: -o-ellipsis-lastline;
  136. overflow: hidden;
  137. text-overflow: ellipsis;
  138. display: -webkit-box;
  139. -webkit-line-clamp: 3;
  140. line-clamp: 3;
  141. -webkit-box-orient: vertical;
  142. }
  143. .info-bottom {
  144. color: #7f7f7f;
  145. font-size: 24rpx;
  146. margin-top: 10rpx;
  147. }
  148. }
  149. }
  150. }
  151. </style>