myHouse.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. }).then(res => {
  45. if (res.code === 200) {
  46. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  47. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  48. console.log(res.data.dataList);
  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. console.log(data);
  57. this.list = this.list.concat(data); //追加新数据
  58. } else {
  59. this.mescroll.endErr();
  60. }
  61. }).catch(() => {
  62. //联网失败, 结束加载
  63. this.mescroll.endErr();
  64. })
  65. },
  66. imageUrl(data) {
  67. if (!data || data === '[]') return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  68. return JSON.parse(data)[0].url;
  69. },
  70. clickItem(item) {
  71. this.$navigateTo('/pages/house/house?houseId=' + item.houseId);
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. .my-house-list {
  78. .my-house {
  79. padding: 0 30rpx;
  80. box-sizing: border-box;
  81. .item {
  82. position: absolute;
  83. bottom: 0;
  84. width: 100%;
  85. height: 56rpx;
  86. background-color: rgba(0, 0, 0, 0.6);
  87. line-height: 56rpx;
  88. font-size: 24rpx;
  89. font-weight: 300;
  90. padding: 0 20rpx;
  91. overflow: hidden;
  92. color: #fff;
  93. }
  94. }
  95. }
  96. </style>