<template>
	<view class="footList">
		<view class="tips">
			提示:号码很火哦,下单太慢可能会被别人捡走
		</view>
		<view class="list">
			<view class="li" v-for="(item,index) in boxList" :key="index" @tap="ListClick(item.mobile_id)">
				<view class="number">{{item.no}}</view>
				<view class="Operator">{{item.network}} {{item.city}}</view>
				<view class="money">¥{{item.amount}}</view>
				<view class="btn" @tap.stop="deleteMet(item.mobile_user_history_id)">删除</view>
			</view>
			
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script> 
	export default {
		data() {
			return {
				list: 15,
				page: 1,
				boxList:[],
				status: 'loadmore',
			}
		},
		onReachBottom() {
			// 下拉加载
			this.status = 'loading';
			this.page = ++ this.page;
			let obj={
				page:this.page,
				limit:this.list,
			}
			this.$http.history(obj).then(res=>{
				// console.log(res)
				if(res.data.code==1){
					if(obj.page<res.data.data.per_page || obj.page == res.data.data.per_page){
						let arr=this.boxList.concat(res.data.data.data)
						this.boxList=arr;
						console.log(this.boxList)
					}
					this.status = 'nomore'								
				}else{
					this.status = 'nomore'
				}
			})
		},
		onLoad() {
			this.listMet()
		},
		methods: {
			// 号码详情
			ListClick(id){
				console.log(id)
			     uni.navigateTo({
			       url: '/pageA/order/order?id='+id,
			     })
			},
			listMet(){
				let obj={
					page:this.page,
					limit:this.list,
				}
				this.$http.history(obj).then(res=>{
					console.log(res)
					if(res.data.code==1){
						this.boxList=res.data.data.data
						if(res.data.data.total<this.list){
							this.status = 'nomore'
						}
					}
				})
			},
			deleteMet(id){
				this.$http.delete({id:id})
				.then(res=>{
					console.log(res)
					if(res.data.code==1){						
						uni.showToast({
							title: '删除成功',
							duration: 2000
						});
						this.page==1
						this.listMet()
					}else{
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F1F1F1;
	}
	.footList{
		.tips{
			background-color: #FF9D50;
			padding: 8rpx 0;
			font-size: 24rpx;
			text-align: center;
		}
		.list{
			margin-top: 20rpx;
			.li{
				position: relative;
				box-sizing: border-box;
				padding: 20rpx;
				background-color: #fff;
				margin-bottom: 20rpx;
				box-shadow: 0rpx 2rpx 8rpx #f1f2fb;
				.number{
					font-size: 30rpx;
					font-weight: 700;
				}
				.Operator{
					font-size: 24rpx;
					color: #696969;
					margin-top: 20rpx;
				}
				.money{
					position: absolute;
					right: 200rpx;
					top: 50%;
					transform: translateY(-50%);
					font-size: 32rpx;
					font-weight: 700;
				}
				.btn{
					position: absolute;
					font-size: 24rpx;
					padding: 10rpx 30rpx;
					border-radius: 6rpx;
					right: 20rpx;
					top: 50%;
					transform: translateY(-50%);
					border: 1rpx solid #484848;
				}
			}
		}
	}
</style>
