<template>
	<view class="container">
		<view class="list" v-for="(item,index) in list" :key='index'>
			<view class="list-top">
				救援者姓名：{{item.to_name}}
			</view>
			<view class="list-phone">
				手机号：{{item.to_phone}}
			</view>
			<view class="list-time">
				救援时间：{{item.add_time}}
			</view>
			<view class="list-type" v-if="item.status == 1">
				已接受
			</view>
			<view class="list-type" v-if="item.status == 0">
				未接受
			</view>
			<view class="list-type" v-if="item.status == 2">
				已拒绝
			</view>
			<view class="list-box">
				<view class="box-item" @click="tocall(item.to_phone)">
					<image src="../../static/icon/call.png" mode="" class="call"></image>
					拨打电话
				</view>
				
				
			</view>
		</view>
		<empty v-if="list.length === 0"></empty>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import { getseek } from '@/api/index.js';
	import empty from '@/components/empty';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		components: {
			empty,
			uniLoadMore
		},
		data() {
			return{
				page:1,
				limit:10,
				list:[],
				loadingType: 'more',
			}
		},
		onLoad() {
			this.loadData();
		},
		// 下拉加载
		onReachBottom() {
			this.loadData();
		},
		methods:{
			tocall(num){
				console.log(num);
				uni.makePhoneCall({
					phoneNumber: num //仅为示例
				});
			},
			async loadData() {
				let obj = this;
				if (obj.loadingType === 'noMore') {
					//防止重复加载
					return;
				}
				// 修改当前对象状态为加载中
				obj.loadingType = 'loading';
				getseek({
					page: obj.page,
					limit: obj.limit
				}).then(({ data }) => {
					obj.list = obj.list.concat(data);
					obj.page++;
					if (obj.limit == data.length) {
						obj.loadingType = 'more';
					} else {
						obj.loadingType = 'noMore';
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.container{
		line-height: 1;
		.list{
			width: 710rpx;
			background: #FFFFFF;
			box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
			border-radius: 10rpx;
			margin: 20rpx auto 0;
			padding: 30rpx;
			.list-top{
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				line-height: 36px;
			}
			.list-phone{
				font-size: 24rpx;
				font-weight: 500;
				color: #666666;
				margin-top: 20rpx;
			}
			.list-time{
				font-size: 24rpx;
				font-weight: 500;
				color: #666666;
				margin-top: 20rpx;
			}
			.list-type{
				font-size: 28rpx;
				font-weight: 500;
				color: #C9101B;
				margin-top: 20rpx;
			}
			.list-box{
				display: flex;
				justify-content: center;
				padding: 0 40rpx;
				margin-top: 20rpx;
				.box-item{
					width: 210rpx;
					height: 65rpx;
					background: #C9101B;
					border-radius: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 28rpx;
					font-weight: 500;
					color: #FFFFFF;
					.call{
						width: 28rpx;
						height: 40rpx;
						margin-right: 10rpx;
					}
					
				}
				.box-item1{
					width: 210rpx;
					height: 65rpx;
					background: #FF4F4F;
					border-radius: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 28rpx;
					font-weight: 500;
					color: #FFFFFF;
					.veo{
						width: 40rpx;
						height: 40rpx;
						margin-right: 10rpx;
					}
				}
			}
			
		}
	}
</style>
