index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="high-seas-container">
  3. <navbar>
  4. <view class="nav">
  5. <view class="nav-city" @click="$navigateTo('/pages/city/city?activeCity='+JSON.stringify(activeCity))">
  6. <uni-icons class="city-icon" type="location-filled" size="16"></uni-icons>
  7. <text class="city-name">{{activeCity.cityName}}</text>
  8. </view>
  9. <view class="nav-search"
  10. :style="'height:' + boundingClientRect.height + 'px;border-radius:' + boundingClientRect.height + 'px;line-height:'+(boundingClientRect.height-2)+'px'">
  11. 搜索房源或项目
  12. </view>
  13. <view class="wx-operation"
  14. :style="'width:' + boundingClientRect.width + 'px;height:'+ boundingClientRect.height+'px;'">
  15. </view>
  16. </view>
  17. </navbar>
  18. <mescroll-body :top="getNavBarHeight()" bottom="20" @init="mescrollInit" @down="downCallback" @up="upCallback">
  19. <view class="house-list">
  20. <house-item v-for="(item,index) in list" :house="item" :key="item.id"></house-item>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import navbar from "@/components/common/navbar.vue";
  27. import houseItem from "@/components/house/houseItem.vue";
  28. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  29. import {
  30. getOpenHouseListByPage
  31. } from '@/request/api/house.js'
  32. export default {
  33. mixins: [MescrollMixin], // 使用mixin
  34. data() {
  35. return {
  36. boundingClientRect: {},
  37. list: [],
  38. activeCity: {
  39. cityName: '上海市',
  40. cityCode: '310100'
  41. },
  42. }
  43. },
  44. onShow() {
  45. this.boundingClientRect = wx.getMenuButtonBoundingClientRect();
  46. },
  47. onLoad() {
  48. uni.$on('changeCity', data => {
  49. this.activeCity = data;
  50. })
  51. },
  52. methods: {
  53. // 获取状态栏高度
  54. geStatusBarHeight() {
  55. return uni.getSystemInfoSync()['statusBarHeight']
  56. },
  57. // 获取导航栏高度
  58. getNavBarHeight() {
  59. // #ifdef MP-WEIXIN
  60. let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  61. // 导航栏高度 = 胶囊高度 + 上间距 + 下间距 + 微调 (menuButtonInfo.top - uni.getSystemInfoSync()['statusBarHeight'] = 上间距)
  62. let navbarHeight = menuButtonInfo.height + (menuButtonInfo.top - uni.getSystemInfoSync()[
  63. 'statusBarHeight']) * 2 + 2
  64. // #endif
  65. // #ifdef APP-PLUS || H5
  66. let navbarHeight = 44
  67. // #endif
  68. return (navbarHeight + this.geStatusBarHeight()) * 2;
  69. },
  70. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  71. upCallback(page) {
  72. getOpenHouseListByPage({
  73. currPage: page.num,
  74. pageSize: 10
  75. }).then(res => {
  76. if (res.code === 200) {
  77. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  78. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  79. this.list = this.list.concat(res.data.dataList); //追加新数据
  80. } else {
  81. this.mescroll.endErr();
  82. }
  83. }).catch(() => {
  84. //联网失败, 结束加载
  85. this.mescroll.endErr();
  86. })
  87. }
  88. },
  89. components: {
  90. navbar,
  91. houseItem
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .high-seas-container {
  97. .nav {
  98. height: 100%;
  99. background: #fff;
  100. width: 100%;
  101. display: flex;
  102. align-items: center;
  103. .nav-city {
  104. height: 50rpx;
  105. max-width: 160rpx;
  106. min-width: 120rpx;
  107. border-radius: 50rpx;
  108. border: 1px solid $uni-primary;
  109. margin-left: 30rpx;
  110. box-sizing: border-box;
  111. display: flex;
  112. align-items: center;
  113. margin-bottom: 4rpx;
  114. .city-icon {
  115. margin-left: 10rpx;
  116. margin-top: 4rpx;
  117. .uni-icons {
  118. color: $uni-primary !important;
  119. }
  120. }
  121. .city-name {
  122. color: $uni-primary;
  123. font-size: 24rpx;
  124. overflow: hidden;
  125. white-space: nowrap;
  126. text-overflow: ellipsis;
  127. padding: 0 20rpx 0 6rpx;
  128. }
  129. }
  130. .nav-search {
  131. flex: 1;
  132. width: 0;
  133. border: 1px solid $uni-border-1;
  134. line-height: 1;
  135. padding-left: 30rpx;
  136. color: $uni-secondary-color;
  137. margin: 0 20rpx;
  138. box-sizing: border-box;
  139. margin-bottom: 4rpx;
  140. font-weight: 200;
  141. }
  142. .wx-operation {
  143. margin-right: 8px;
  144. margin-bottom: 4rpx;
  145. }
  146. }
  147. .house-list {
  148. padding: 30rpx;
  149. }
  150. }
  151. </style>