<template>
    <view class="container">
        <scroll-view 
            scroll-y
            @scrolltolower="loadMore"
            lower-threshold="100"
            :style="{ height: `calc(100vh - 100rpx)` }"
            :show-scrollbar="false" 
            class="scroll-view">
            <view class="scroll-view-item" v-for="(item, index) in list" :key="index">
                <view class="scroll-list">
                    <view class="uni-list-cell">
                        <view class="uni-list-cell-left" style="font-weight: bold;">
                            {{ item.building_name }}
                        </view>
                        <view class="uni-list-cell-db" style="color:#007aff;font-weight: bold;" v-if="item.is_exist == 1">
                            估价 {{ item.eva_total_value }}
                        </view>
                        <view class="uni-list-cell-db" style="color:#ff4804;font-weight: bold;" v-else>
                            暂无评估结果
                        </view>
                    </view>
                    <view class="uni-list-cell">
                        <view class="uni-list-cell-left">
                            建筑面积
                        </view>
                        <view class="uni-list-cell-db">
                            {{ item.size }} ㎡
                        </view>
                    </view>
                    <view class="uni-list-cell">
                        <view class="uni-list-cell-left">
                            询价时间
                        </view>
                        <view class="uni-list-cell-db">
                            {{ item.eva_submit_datetime }}
                        </view>
                    </view>
                </view>
            </view>
        </scroll-view>
    </view>
</template>
<script>
    import { autoInquiryList } from '../../api/inquiry/inquiry'
    export default {
        data() {
            return {
                page: 1,
                limit: 10,
                loading: false,
                list: [],
            }
        },
        onLoad() {
            this.getList();
        },
        methods: {
            getList() {
                autoInquiryList({
                    page: this.page,
                    limit: this.limit})
                    .then((res) => {
                        console.log(res);
                        if (res.code === 1) {
                            const newData = res.data.data || []
                            if (this.page === 1) {
                                this.list = newData
                            } else {
                                this.list = [...this.list, ...newData]
                            }
                        }
                    })
            },
            loadMore() {
                if (this.loading) {
                    return;
                }
                this.loading = true;    
                this.page++;
                this.getList();
            }
        }
    }
</script>
<style>
.container{
    display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 93vh;
  background-color: #f5f5f5;
}
/* 将 mask 缩小到一行 */
.uni-popup-mask {
  height: 1px;
}
/* 将 mask 演示为浅蓝色 */
.uni-popup-mask::before {
  background-color: #e6f1ff;
}
.uni-list-cell {
  line-height: 90rpx;
  display: flex;
  align-items: center;
}
.uni-input {
  height: 50rpx;
  padding: 0rpx 25rpx;
  line-height: 30rpx;
  font-size: 28rpx;
  text-align: right;
}
.property-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    z-index: 2000;
    margin-top: 5px;
}
.uni-file-picker{
    margin-top: 40rpx;
}
.scroll-list{
    width: 100%;
    background-color: #fff;
    margin-bottom: 20rpx;
}
.uni-list-cell-db{
    text-align: right;
    padding-left: 20rpx;
    padding-right: 20rpx;
}
</style>