highseas.vue 4.4 KB

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