SlyWaterfall.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="" :style="$getStyle(styles.boxStyle)">
  3. <u-waterfall v-model="dataLists">
  4. <template v-slot:left="{leftList}">
  5. <view class="warter-left" :style="$getStyle(styles.goodsItem)" v-for="(item, index) in leftList"
  6. :key="index">
  7. <!-- {{item.image}} -->
  8. <!-- 这里编写您的内容,item为您传递给v-model的数组元素 -->
  9. <Goods :GoodsInfo="item" :styles="styles" />
  10. <!-- <u-lazy-load threshold="-100" border-radius="10" :image="item.image" :index="index"></u-lazy-load> -->
  11. </view>
  12. </template>
  13. <template v-slot:right="{rightList}">
  14. <view class="warter-right" :style="$getStyle(styles.goodsItem)" v-for="(item, index) in rightList"
  15. :key="index">
  16. <!-- 这里编写您的内容,item为您传递给v-model的数组元素 -->
  17. <Goods :GoodsInfo="item" :styles="styles" />
  18. </view>
  19. </template>
  20. </u-waterfall>
  21. <template v-if="reachBottom">
  22. <u-loadmore :status="loadStatus" />
  23. </template>
  24. </view>
  25. </template>
  26. <script>
  27. import Mixin from "../Mixin";
  28. import Goods from "./Goods.vue"
  29. import {
  30. getGoodsListApi
  31. } from "./../api_list.js"
  32. export default {
  33. name: "SlyWaterfall",
  34. mixins: [Mixin],
  35. components: {
  36. Goods
  37. },
  38. data() {
  39. return {
  40. page: 0,
  41. pageSize: 10,
  42. reachBottom: false,
  43. loadStatus: 'loadmore', // loading / nomore
  44. }
  45. },
  46. onLoad() {
  47. },
  48. created() {
  49. },
  50. methods: {
  51. onReachBottom() {
  52. if (!this.reachBottom) return
  53. },
  54. onNetworkRequest() {
  55. if (!this.reachBottom) this.reachBottom = true
  56. if (this.loadStatus === 'loading') return;
  57. this.loadStatus = 'loading'
  58. if (this.page < 1) {
  59. this.page = 0
  60. this.goodsList = []
  61. };
  62. this.page++;
  63. getGoodsListApi({
  64. page: this.page,
  65. limit: this.pageSize
  66. }).then(res => {
  67. const {
  68. page
  69. } = res;
  70. this.dataLists = this.dataLists.concat(page.list)
  71. if (this.page >= page.totalPage) {
  72. this.loadStatus = 'nomore'
  73. } else {
  74. this.loadStatus = 'loadmore'
  75. }
  76. }).catch(err => {
  77. if (this.pageSize > 1) {
  78. this.pageSize--;
  79. this.loadStatus = 'loadmore'
  80. } else {
  81. this.pageSize = 0;
  82. this.loadStatus = 'nomore'
  83. }
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .warter-left {
  91. margin-left: 0 !important;
  92. }
  93. .warter-right {
  94. margin-right: 0 !important;
  95. }
  96. .warter-left,
  97. .warter-right {
  98. overflow: hidden;
  99. &:first-child {
  100. margin-top: 0 !important;
  101. }
  102. }
  103. </style>