<template>
	<view>
		<view class="w750 flex-col justify-center align-center">
			<view class="w700" style="margin: 0 auto;">
				<u-loading-icon size="80" :show="loadingShow"></u-loading-icon>
			</view>
			<view class="w700 bg-white radius padding margin-bottom-xs margin-top-xs" v-for="item,index in carList"
				:key="index">
				<view class="flex-row justify-between">
					<text class="text-lg text-bold">{{ item.realName }}</text>
					<view @click="call(item.phonenumber)">
						<u--text prefixIcon="phone-fill" mode="phone" iconStyle="font-size: 24rpx" size="30rpx"
							color="#0055ff" :text="item.phonenumber"></u--text>
					</view>
				</view>
				<u-line hairline margin="20rpx 0"></u-line>

				<view class="flex-row justify-between ">
					<text>品牌、型号</text> <text>{{item.carBrand + item.carModel }}</text>
				</view>
				<view class="flex-row justify-between">
					<text>期望年限</text> <text>{{ item.kilometersRange + '年以内' }}</text>
				</view>
				<view class="flex-row justify-between">
					<text>期望里程</text> <text>{{ item.kilometersRange + 'Km以内' }}</text>
				</view>
				<view class="flex-row justify-between">
					<text>期望价格</text> <text>{{ item.kilometersRange + '万元以内' }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				carList: [],
				loadingShow: true,
				isLoadMore: false, //是否加载中
				params: {
					pageSize: 10,
					pageNum: 1,
				},
				status: 'loadmore',
			}
		},
		onLoad() {
			this.getCarList()
		},
		onReachBottom() {
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.status = 'loading';
				this.isLoadMore = true
				this.params.pageNum++
				this.getCarList()
			}
		},
		methods: {
			async getCarList() {
				const res = await this.$request({
					url: '/system/buy/listWx',
					data: {

						pageSize: this.params.pageSize,
						pageNum: this.params.pageNum
						// 'params[beginCarKilometers]': this.beginCarKilometers,
						// 'params[endCarKilometers]': this.endCarKilometers,
					}
				})
				this.carList = this.carList.concat(res.rows);

				if (res.rows.length < this.params.pageSize) { //判断接口返回数据量小于请求数据量，则表示此为最后一页
					this.status = 'nomore';
					this.isLoadMore = true
				} else {
					this.isLoadMore = false
				}

				this.loadingShow = false
				console.log(res);
			},
			call(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber: phoneNumber.toString(), //电话号码
					success: function(e) {
						console.log(e);
					},
					fail: function(e) {
						console.log(e);

					}
				})
			},
		}
	}
</script>

<style>

</style>