<template>
<view :class="$isEmpty(buiding_list)?'empty-wrap':''">
	<view class="bg-gray" style="padding: 16rpx 30rpx;">
		<text >当前选择小区：</text>
	</view>
	<view class="bg-white" style="padding:30rpx 30rpx 20rpx 30rpx;border-bottom: 1rpx solid #efefef;display: flex;justify-content: space-between;">
		<view class="text-blue">
			<text class="">{{residential_name}}</text>
		</view>
		<view class="cu-btn line-blue sm round" @tap="change">
			<text class="cuIcon-refresh padding-right-10"></text>
			<text>切换小区</text>
		</view>
	</view>
	<view class="bg-gray" style="padding: 12rpx 30rpx;">
		<text >选择楼栋：</text>
	</view>
	<u-cell-group v-if="!$isEmpty(buiding_list)">
		<u-cell-item  @click="jump(item)"  v-for="(item, index) in buiding_list" :key="index"  :title="item.name" :arrow="false"></u-cell-item>
	</u-cell-group>
	
	<u-empty marginTop="200" icon-size="260"  v-if="$isEmpty(buiding_list)&&!loading" text="暂无楼栋信息" src="http://139.9.103.171:1888/miniofile/xlyq/empty/empty.png"></u-empty>

	<u-back-top :scroll-top="scrollTop"></u-back-top>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
	  loading:true,
	  scrollTop:0,
		
      buiding_list: null,
      //小区集合
      residential_name: null //小区名字

    };
  },
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //小区名字
    this.residential_name = options.residential_name
    var residential_id = options.residential_id 
	this.getBuilding(residential_id)
  },
  methods: {
	  change(){
		uni.navigateBack({
			delta:1
		})  
	  },
	  jump(item){
		  app.globalData.building_id=item.id
		  let params={
			  building_name:item.name,
			  building_id:item.id,
			  residential_name:this.residential_name
		  }
		  uni.navigateTo({
		  	url:"../chooseUnit/chooseUnit"+this.$u.queryParams(params)
		  })
	  },
    //根据小区id获取楼栋信息
    getBuilding: function (residential_id) {
		uni.showLoading({
			title:"数据加载中.."
		})
      let that = this;
      let params = {
		  residential_id:residential_id
      };
      let operation = 'estate/getBuildingsByResidentialId';
      app.globalData.postRequest(params, operation, function (res) {
        //获取成功
        if (res.data.result_code == 1) {
          that.setData({
            buiding_list: res.data.list
          });
        } else {
          app.globalData.oneFailHint(res.data.result_msg);
        }
		uni.hideLoading()
		that.loading=false
      });
    }
  }
};
</script>
<style>
page{
  overflow-y: scroll
}

.isOver {
	width: 100%;
	height: 50px;
	line-height: 50px;
	text-align: center;
	// background: #fff;
	font-size: 28rpx;
}
	
.nav_section {
  width: 100%;
  background:#fff;

}

.nav_section_items {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 30rpx;
  border-bottom: 2rpx solid #ddd;
  position: relative;
}

.nav_section_items:active {
  background: #ddd;
}



.nav_section_items .section_cont view {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.nav_section_items .section_cont .section_cont_sub {
  font-size: 30rpx;
  line-height: 50rpx;
  color: #000;
  margin-bottom: 10rpx;
}
.section_cont_tel .info{
  width: 500rpx;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: inline-block;
}

.empty-wrap{	background-color: #FFFFFF;	min-height: 100vh;}
</style>