143 lines
3.3 KiB
Vue
143 lines
3.3 KiB
Vue
<template>
|
|
<view v-if="isLoading">
|
|
<!-- 头部 -->
|
|
<status-nav :ifReturn="false" navBarTitle="小区选择"></status-nav>
|
|
<!-- 小区列表 -->
|
|
<view class="estate-list background-white pad-zy20 border-box">
|
|
<view class="item font26 flex" @tap="choiseEstate(item.id,item.name)" v-for="(item,index) in estateList" :key="index">{{item.name}}</view>
|
|
</view>
|
|
<!-- 进入主页 -->
|
|
<view class="back-idle flex" :style="{top:statusHeight+'px'}" @tap="backIdle">
|
|
<image src="/static/icon-home.png" mode="widthFix"></image>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import goodList from '@/components/goods-list/goods-list.vue';
|
|
import tabbar from '@/components/tabbar/tabbar';
|
|
export default {
|
|
components:{
|
|
goodList,
|
|
tabbar
|
|
},
|
|
data() {
|
|
return {
|
|
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
|
|
estateList:[], //商品列表
|
|
keyword:'', //关键词
|
|
page:1, //页数
|
|
size:10, //条数
|
|
total:0, //总数
|
|
isLoading:false, //是否加载完成
|
|
estate:1, //1:闲置进入,2:车位进入,3:房屋进入
|
|
}
|
|
},
|
|
onLoad(op) {
|
|
if(op.estate) this.estate = op.estate;
|
|
// 查询小区列表
|
|
this.getEstateList();
|
|
},
|
|
onReachBottom(e) {
|
|
if(this.estateList.length<this.total){
|
|
this.page++;
|
|
// 查询商品列表
|
|
this.getEstateList();
|
|
}
|
|
},
|
|
methods: {
|
|
// 获取定位
|
|
getLocation(){
|
|
uni.getLocation({
|
|
type: 'wgs84',
|
|
geocode:true, // 设置该参数为true可直接获取经纬度及城市信息
|
|
success: (res)=> {
|
|
console.log('位置信息',res)
|
|
},
|
|
fail: (err)=> {
|
|
uni.showToast({
|
|
title: '获取地址失败,将导致部分功能不可用',
|
|
icon:'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
// 查询小区列表
|
|
getEstateList(){
|
|
uni.showLoading({
|
|
title:'加载中'
|
|
})
|
|
let params = {
|
|
page:this.page,
|
|
size:this.size
|
|
}
|
|
if(this.page==1) this.estateList = [];
|
|
this.$requst.get('/api/v1/goods/area',params).then(res=>{
|
|
if(res.code == 0){
|
|
console.log(res,'小区列表')
|
|
this.total = res.data.total;
|
|
let estateArr = [];
|
|
res.data.list.forEach(item=>{
|
|
let obj = {
|
|
id:item.id,
|
|
name:item.title,
|
|
}
|
|
estateArr.push(obj)
|
|
})
|
|
this.estateList = this.estateList.concat(estateArr);
|
|
}
|
|
uni.hideLoading();
|
|
this.isLoading = true;
|
|
})
|
|
},
|
|
|
|
// 选择小区
|
|
choiseEstate(id,name){
|
|
// 缓存小区信息
|
|
uni.setStorageSync('area_id',id);
|
|
uni.setStorageSync('area_name',name);
|
|
if(this.estate == 1){
|
|
uni.reLaunch({
|
|
url:`/pages/idle/idle`
|
|
})
|
|
}
|
|
},
|
|
|
|
// 返回闲置
|
|
backIdle(){
|
|
if(!uni.getStorageSync('area_id')||!uni.getStorageSync('area_name')){
|
|
uni.setStorageSync('area_id',this.estateList[0].id);
|
|
uni.setStorageSync('area_name',this.estateList[0].name);
|
|
}
|
|
uni.reLaunch({
|
|
url:`/pages/idle/idle`
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
.estate-list .item{
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
height: 80rpx;
|
|
border-bottom: 2rpx solid #f4f5f6;
|
|
}
|
|
.estate-list .item:last-child{
|
|
border-bottom: 0;
|
|
}
|
|
.back-idle{
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
width: 60rpx;
|
|
height: 100rpx;
|
|
position: fixed;
|
|
left: 20rpx;
|
|
z-index: 999;
|
|
}
|
|
.back-idle>image{
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
}
|
|
</style> |