myHouse.vue 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. let data = res.data.dataList.map(node => {
  49. return {
  50. houseId: node.id,
  51. image: this.imageUrl(node.showPicture),
  52. title: `${node.projectItemName}-${node.projectItemTargetName}-${node.roomNumber}`
  53. }
  54. })
  55. this.list = this.list.concat(data); //追加新数据
  56. } else {
  57. this.mescroll.endErr();
  58. }
  59. }).catch(() => {
  60. //联网失败, 结束加载
  61. this.mescroll.endErr();
  62. })
  63. },
  64. imageUrl(data) {
  65. if (!data || data === '[]') return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  66. return JSON.parse(data)[0].url;
  67. },
  68. clickItem(item) {
  69. this.$navigateTo('/pages/house/house?houseId=' + item.houseId);
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss">
  75. .my-house-list {
  76. .my-house {
  77. padding: 0 30rpx;
  78. box-sizing: border-box;
  79. .item {
  80. position: absolute;
  81. bottom: 0;
  82. width: 100%;
  83. height: 56rpx;
  84. background-color: rgba(0, 0, 0, 0.6);
  85. line-height: 56rpx;
  86. font-size: 24rpx;
  87. font-weight: 300;
  88. padding: 0 20rpx;
  89. overflow: hidden;
  90. color: #fff;
  91. }
  92. }
  93. }
  94. </style>