<template>
	<view class="container">
		<view class="box" v-for="(item,index) in list" :key="index">
			<view class="texts">
				<text class="text">发货地：</text><text class="text1">{{item.deliver_address}}</text>
			</view>
			<view class="texts">
				<text class="text">收货地：</text><text class="text1">{{item.receiving_address}}</text>
			</view>
			<!-- <view class="biaoqian">
				<view class="biaoqian1" :style="{background:item.background,color:item.color}"
					v-for="(item,index) in biaqqian" :key="index">
					{{item.text}}
				</view>
			</view> -->
			<view class="biaoqian">
				<view class="biaoqian1">
					车型：{{item.car_type}}
				</view>
				<view class="biaoqian2">
					装载量：{{item.loading_capacity}}
				</view>
				<view class="biaoqian3">
					运费价格：{{item.freight}}
				</view>
				<view class="biaoqian4">
					{{item.transport_time}}
				</view>
			</view>
			<view class="xinxis">
				<view class="">
					<text class="xinxis1">发布时间：</text><text class="text1">{{item.release_time}}</text>
				</view>
				<view class="">
					<text class="xinxis1">下架时间：</text><text class="text1">{{item.delisting_time}}</text>
				</view>
				<view class="">
					<text class="xinxis1">装货时间：</text><text class="text1">{{item.loading_start_time}}至{{item.loading_end_time}} </text>
				</view>
				<view class="">
					<text class="xinxis1">发货电话：</text><text class="text1">{{item.mobile}}</text>
				</view>
			</view>
			<button :class="item.status=='2'?'btn':'btndis'" @click="qiangdan(item)">抢单</button>
		</view>
		<uni-popup ref="popup" background-color="#fff" :mask-click='false'>
			<view class="popbox" v-if="status">
				<view class="close">
					<image src="@/static/close-l.png" mode="" style="width: 44rpx;height: 44rpx;" @click="close">
					</image>
				</view>
				<view class="cg">
					<image src="@/static/成功.png" mode="" style="width: 130rpx;height: 130rpx;"></image>
				</view>
				<view class="wenzi">
					抢单成功
				</view>
				<view class="cgwenzi">
					您好，您已抢单成功，请尽快前往发货地装货
				</view>
			</view>
			<view class="popbox" v-else>
				<view class="close">
					<image src="@/static/close-l.png" mode="" style="width: 44rpx;height: 44rpx;" @click="close">
					</image>
				</view>
				<view class="cg">
					<image src="@/static/失败.png" mode="" style="width: 130rpx;height: 130rpx;"></image>
				</view>
				<view class="wenzi">
					抢单失败
				</view>
				<view class="cgwenzi">
					您好，您来晚了一步，订单已被其他司机抢走了，请选择其他订单
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: true,
				list: [],
				item: 3,
				href: 'https://uniapp.dcloud.io/component/README?id=uniui',
				biaqqian: [{
						text: '车型：13.6',
						background: '#E2ECFA',
						color: '#0D5DC9'
					},
					{
						text: '装载量：20m³',
						background: '#E7F4F9',
						color: '#14B2EC'
					},
					{
						text: '运费价格：￥500',
						background: '#F9EEEE',
						color: '#E45050'
					},
					{
						text: '今日达',
						background: '#F9F3EB',
						color: '#FA9512'
					},
				]
			}
		},
		onShow() {
			this.taskList(1)
		},
		onReachBottom(){
			console.log(11122);
		},
		methods: {
			taskList(page) {
				this.$api.taskList({
					page
				}).then(res => {
					this.list = res.data.list
				})
			},
			qiangdan(e) {
				if (e.status == 2) {
					this.$refs.popup.open('center')
					this.$api.orderGrabbing({
						task_id: e.id
					}).then(res => {
						if (res.code == 200) {
							this.status = true
							this.$refs.popup.open('center')
							this.taskList(1)
						}
					}).catch(res => {
						uni.hideToast();
						this.status = false
						this.$refs.popup.open('center')
						this.taskList(1)
					})
				} else {

				}

			},
			close() {
				this.$refs.popup.close('center')
			},
		}
	}
</script>

<style scoped>
	.cg {
		text-align: center;
	}

	.cgwenzi {
		margin-top: 30rpx;
		text-align: center;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 26rpx;
		color: #222222;
	}

	.wenzi {
		margin-top: 20rpx;
		text-align: center;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 36rpx;
		color: #222222;
	}

	.popbox {
		width: 660rpx;
		height: 450rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}

	.close {
		text-align: right;
		margin: 22rpx;
	}

	.btn {
		margin-top: 29rpx;
		width: 602rpx;
		height: 90rpx;
		background: #0D5DC9;
		box-shadow: 0rpx 4rpx 13rpx 0rpx rgba(39, 58, 132, 0.28);
		border-radius: 45rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 36rpx;
		text-align: center;
		line-height: 90rpx;
	}

	.btndis {
		margin-top: 29rpx;
		width: 602rpx;
		height: 90rpx;
		background: #999C9F;
		box-shadow: 0rpx 4rpx 13rpx 0rpx rgba(39, 58, 132, 0.28);
		border-radius: 45rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 36rpx;
		text-align: center;
		line-height: 90rpx;
	}

	.xinxis {
		margin-top: 30rpx;
		font-size: 26rpx;
	}

	.xinxis1 {
		color: #999999;
	}

	.biaoqian {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		font-size: 24rpx;
	}

	.biaoqian1 {
		padding: 19rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
		background: #E2ECFA;
		color: #0D5DC9
	}

	.biaoqian2 {
		padding: 19rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
		background: #E7F4F9;
		color: #14B2EC
	}

	.biaoqian3 {
		padding: 19rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
		background: #F9EEEE;
		color: #E45050
	}

	.biaoqian4 {
		padding: 19rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
		background: #F9F3EB;
		color: #FA9512
	}

	.container {
		padding: 24rpx;
		font-size: 14px;
		line-height: 24px;
		padding-top: 0;
	}

	.box {
		padding: 30rpx;
		background: #fff;
		margin-top: 20rpx;
	}

	.texts {
		font-size: 30rpx;
		margin-bottom: 29rpx;
	}

	.text {
		color: #999999;
	}
</style>