myHouse.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="my-house-list">
  3. <mescroll-body top="40" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
  4. <view class="my-house">
  5. <custom-waterfalls-flow :value="list" @wapperClick="clickItem" @imageClick="clickItem">
  6. <!-- #ifdef MP-WEIXIN -->
  7. <view class="item" v-for="(item,index) in list" :key="index" slot="slot{{index}}">
  8. <view class="title">{{item.title}}</view>
  9. <view class="desc">{{item.desc}}</view>
  10. </view>
  11. <!-- #endif -->
  12. <!-- #ifndef MP-WEIXIN -->
  13. <template v-slot:default="item">
  14. <view class="item">
  15. <view class="title">{{item.title}}</view>
  16. <view class="desc">{{item.desc}}</view>
  17. </view>
  18. </template>
  19. <!-- #endif -->
  20. </custom-waterfalls-flow>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. getHouseListByPage
  28. } from '@/request/api/house.js'
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. export default {
  31. mixins: [MescrollMixin], // 使用mixin
  32. data() {
  33. return {
  34. list: []
  35. }
  36. },
  37. methods: {
  38. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  39. upCallback(page) {
  40. getHouseListByPage({
  41. currPage: page.num,
  42. pageSize: 10,
  43. // chargePersonId: this.$store.getters.user.userId,
  44. chargePersonId: 4
  45. }).then(res => {
  46. if (res.code === 200) {
  47. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  48. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  49. let data = res.data.dataList.map(node => {
  50. return {
  51. houseId: node.id,
  52. image: this.imageUrl(node.showPicture),
  53. title: `${node.projectItemName}-${node.projectItemTargetName}-${node.roomNumber}`
  54. }
  55. })
  56. this.list = this.list.concat(data); //追加新数据
  57. } else {
  58. this.mescroll.endErr();
  59. }
  60. }).catch(() => {
  61. //联网失败, 结束加载
  62. this.mescroll.endErr();
  63. })
  64. },
  65. imageUrl(data) {
  66. if (!data) return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  67. return JSON.parse(data)[0].url;
  68. },
  69. clickItem(item) {
  70. this.$navigateTo('/pages/house/house?houseId=' + item.houseId);
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .my-house-list {
  77. .my-house {
  78. padding: 0 30rpx;
  79. box-sizing: border-box;
  80. .item {
  81. position: absolute;
  82. bottom: 0;
  83. width: 100%;
  84. height: 56rpx;
  85. background-color: rgba(0, 0, 0, 0.6);
  86. line-height: 56rpx;
  87. font-size: 24rpx;
  88. font-weight: 300;
  89. padding: 0 20rpx;
  90. overflow: hidden;
  91. color: #fff;
  92. }
  93. }
  94. }
  95. </style>