index.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <u-swiper :list="bannerList" @click="click" 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. getBanners() {
  43. this.$u.api.getInformationList(0, 6, {}).then(res => {
  44. this.bannerList = res.data.records || []
  45. })
  46. },
  47. scrolltolower() {
  48. this.loadmore()
  49. },
  50. loadmore() {
  51. this.page.current++;
  52. this.getProfessionalStyleList();
  53. },
  54. doRefresh() {
  55. this.page.current = 1;
  56. this.page.status = 'loadmore'
  57. this.list = [];
  58. this.getProfessionalStyleList();
  59. },
  60. getProfessionalStyleList() {
  61. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  62. // 防止重复下拉
  63. return;
  64. }
  65. this.page.status = 'loading';
  66. //
  67. this.$u.api.getProfessionalStyleList(this.page.current, this.page.size, {
  68. name: this.keyword || ''
  69. }).then(res => {
  70. if (res.data.records && res.data.records.length > 0) {
  71. this.list.push(...res.data.records)
  72. }
  73. this.page.total = res.data.total || 0;
  74. if (this.page.size * this.page.current >= res.data.total) {
  75. this.page.status = 'nomore'
  76. } else {
  77. this.page.status = 'loadmore'
  78. }
  79. })
  80. },
  81. toDetail(id) {
  82. uni.navigateTo({
  83. url: "/pages/yuecai/dish/detail/index?id=" + id,
  84. })
  85. }
  86. },
  87. }
  88. </script>
  89. <style scoped lang="scss">
  90. </style>