index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <u-swiper :list="list1" @click="click"></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. list1: [
  23. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  24. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  25. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  26. ],
  27. page: {
  28. current: 1,
  29. size: 10,
  30. total: 0,
  31. // loadmore loading nomore
  32. status: 'loadmore',
  33. loadingText: '正在加载中',
  34. loadmoreText: '上拉加载更多',
  35. nomoreText: '没有更多了'
  36. },
  37. keyword: '',
  38. list: []
  39. }
  40. },
  41. onShow() {
  42. this.getProfessionalStyleList();
  43. },
  44. methods: {
  45. scrolltolower() {
  46. this.loadmore()
  47. },
  48. loadmore() {
  49. this.page.current++;
  50. this.getProfessionalStyleList();
  51. },
  52. doRefresh() {
  53. this.page.current = 1;
  54. this.page.status = 'loadmore'
  55. this.list = [];
  56. this.getProfessionalStyleList();
  57. },
  58. getProfessionalStyleList() {
  59. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  60. // 防止重复下拉
  61. return;
  62. }
  63. this.page.status = 'loading';
  64. //
  65. this.$u.api.getProfessionalStyleList(this.page.current, this.page.size, {
  66. name: this.keyword || ''
  67. }).then(res => {
  68. if (res.data.records && res.data.records.length > 0) {
  69. this.list.push(...res.data.records)
  70. }
  71. this.page.total = res.data.total || 0;
  72. if (this.page.size * this.page.current >= res.data.total) {
  73. this.page.status = 'nomore'
  74. } else {
  75. this.page.status = 'loadmore'
  76. }
  77. })
  78. },
  79. toDetail(id) {
  80. uni.navigateTo({
  81. url: "/pages/yuecai/dish/detail/index?id=" + id,
  82. })
  83. }
  84. },
  85. }
  86. </script>
  87. <style scoped lang="scss">
  88. </style>