data.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <mescroll-empty :option="option" @emptyclick="$navigateTo('/pages/login/login')" v-if="isEmpty">
  4. </mescroll-empty>
  5. <mescroll-body top="30" bottom="30" @init="mescrollInit" @down="downCallback" @up="upCallback" v-else>
  6. <view class="data-house-list">
  7. <view class="data-house-item" v-for="(item,index) in list" :key="item.id"
  8. @click="$navigateTo('/pages/dataDetail/dataDetail?houseId='+item.id)">
  9. <image class="image" :src="imageUrl(item.showPicture)" mode="aspectFill"></image>
  10. <view class=" content">
  11. <view class="title">{{item.projectItemName}}-{{item.projectItemTargetName}}-{{item.roomNumber}}
  12. </view>
  13. <view class="const">
  14. <view class="const-item">
  15. <uni-icons class="inherit-icons" type="map-filled" color="#7f7f7f"></uni-icons>
  16. <text class="text">2</text>
  17. </view>
  18. <view class="const-item">
  19. <uni-icons class="inherit-icons" type="calendar-filled" color="#7f7f7f"></uni-icons>
  20. <text class="text">2</text>
  21. </view>
  22. </view>
  23. <view class="sub">{{item.projectName}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </mescroll-body>
  28. </view>
  29. </template>
  30. <script>
  31. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  32. import {
  33. getHouseListByPage
  34. } from '@/request/api/house.js'
  35. export default {
  36. mixins: [MescrollMixin], // 使用mixin
  37. data() {
  38. return {
  39. option: {
  40. tip: '暂未加入项目'
  41. },
  42. list: [],
  43. isEmpty: true
  44. }
  45. },
  46. onLoad() {
  47. uni.$on('reloadData', () => {
  48. this.mescroll.resetUpScroll();
  49. })
  50. },
  51. onShow() {
  52. this.isEmpty = true;
  53. if (!uni.getStorageSync('token')) {
  54. this.option = {
  55. tip: '暂未登录',
  56. btnText: '点击登录'
  57. }
  58. } else if (!this.$store.getters.project.id) {
  59. this.option = {
  60. tip: '暂未加入项目'
  61. }
  62. } else {
  63. this.isEmpty = false;
  64. }
  65. },
  66. methods: {
  67. imageUrl(data) {
  68. if (!data || data === '[]') return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  69. return JSON.parse(data)[0].url;
  70. },
  71. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  72. upCallback(page) {
  73. getHouseListByPage({
  74. currPage: page.num,
  75. pageSize: 10,
  76. projectId: this.$store.getters.project.id
  77. }).then(res => {
  78. if (res.code === 200) {
  79. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  80. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  81. this.list = this.list.concat(res.data.dataList); //追加新数据
  82. } else {
  83. this.mescroll.endErr();
  84. }
  85. }).catch(() => {
  86. //联网失败, 结束加载
  87. this.mescroll.endErr();
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .data-house-list {
  95. padding: 0 30rpx;
  96. .data-house-item {
  97. height: 200rpx;
  98. background: #fff;
  99. display: flex;
  100. align-items: center;
  101. border-radius: 16rpx;
  102. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  103. padding: 0 30rpx;
  104. margin-bottom: 30rpx;
  105. }
  106. .image {
  107. width: 200rpx;
  108. height: 140rpx;
  109. border-radius: 8rpx;
  110. }
  111. .content {
  112. margin-left: 20rpx;
  113. }
  114. .title {
  115. font-size: 32rpx;
  116. font-weight: 600;
  117. margin-bottom: 10rpx;
  118. }
  119. .sub {
  120. font-weight: 300;
  121. font-size: 24rpx;
  122. margin-top: 10rpx;
  123. color: $uni-secondary-color;
  124. }
  125. .const {
  126. display: flex;
  127. align-items: center;
  128. .const-item {
  129. display: flex;
  130. align-items: center;
  131. color: $uni-secondary-color;
  132. margin-right: 20rpx;
  133. }
  134. .text {
  135. margin-left: 6rpx;
  136. }
  137. }
  138. }
  139. </style>