index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <u-swiper :list="bannerList" @click="clickInfo" keyName="cover"></u-swiper>
  4. <u-list @scrolltolower="scrolltolower" height="calc(100% - 50px)" lowerThreshold="10">
  5. <u-list-item v-for="(item, index) in list" :key="index">
  6. <u-cell :title="item.name" @click="toDetail(item.id)">
  7. <u-avatar slot="icon" shape="square" size="35" :src="item.cover"
  8. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  9. </u-cell>
  10. </u-list-item>
  11. <u-loadmore :status="page.status" :loading-text="page.loadingText" :loadmore-text="page.loadmoreText"
  12. :nomore-text="page.nomoreText" />
  13. </u-list>
  14. </view>
  15. </template>
  16. <script>
  17. import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  18. export default {
  19. mixins: [themeMixins],
  20. data() {
  21. return {
  22. bannerList: [],
  23. page: {
  24. current: 1,
  25. size: 10,
  26. total: 0,
  27. // loadmore loading nomore
  28. status: 'loadmore',
  29. loadingText: '正在加载中',
  30. loadmoreText: '上拉加载更多',
  31. nomoreText: '没有更多了'
  32. },
  33. keyword: '',
  34. list: []
  35. }
  36. },
  37. onShow() {
  38. this.getProfessionalStyleList();
  39. this.getBanners()
  40. },
  41. methods: {
  42. clickInfo(index) {
  43. if (index < 0) {
  44. return;
  45. }
  46. uni.navigateTo({
  47. url: "/pages/yuecai/information/detail/index?id=" + this.bannerList[index].id,
  48. })
  49. },
  50. getBanners() {
  51. this.$u.api.getInformationList(0, 6, {}).then(res => {
  52. this.bannerList = res.data.records || []
  53. })
  54. },
  55. scrolltolower() {
  56. this.loadmore()
  57. },
  58. loadmore() {
  59. this.page.current++;
  60. this.getProfessionalStyleList();
  61. },
  62. doRefresh() {
  63. this.page.current = 1;
  64. this.page.status = 'loadmore'
  65. this.list = [];
  66. this.getProfessionalStyleList();
  67. },
  68. getProfessionalStyleList() {
  69. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  70. // 防止重复下拉
  71. return;
  72. }
  73. this.page.status = 'loading';
  74. //
  75. this.$u.api.getProfessionalStyleList(this.page.current, this.page.size, {
  76. name: this.keyword || ''
  77. }).then(res => {
  78. if (res.data.records && res.data.records.length > 0) {
  79. this.list.push(...res.data.records)
  80. }
  81. this.page.total = res.data.total || 0;
  82. if (this.page.size * this.page.current >= res.data.total) {
  83. this.page.status = 'nomore'
  84. } else {
  85. this.page.status = 'loadmore'
  86. }
  87. })
  88. },
  89. toDetail(id) {
  90. uni.navigateTo({
  91. url: "/pages/yuecai/professional_style/detail/index" + id,
  92. })
  93. }
  94. },
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. </style>