<template>
	<!-- 我的包裹 -->
	<view>
		<view class="top">
			<view class="inputbg u-flex">
				<u-icon name="search" color="#777777" size="32"></u-icon>
				<input type="text" :placeholder="i18n.orderSearch" style="flex: 1;margin-left: 12rpx;" v-model="keyword" />
			</view>
			<!-- rgba(252, 97, 74, 1) -->
			<view class="">
				<u-tabs :scrollable='false' :current='current' :list="list1" @click="click"></u-tabs>
			</view>
		</view>
		<view class="content">
			<view class="kg u-flex">
				<image src="static/images/kg.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
				<text style="margin-left: 20rpx;">{{i18n.orderWeight}}{{sumweight}}kg</text>
			</view>
			<view class="">
				<view class="info" v-for="(item,idx) in goodslist" :key="idx" style="margin-bottom: 20rpx;">
					<view class="u-flex u-row-between">
						<view class="u-flex ">
							<!-- <view class="tab">{{i18n.purchase}}</view> -->
							<view class="tab" style="background: rgba(255, 103, 0, 1);">{{i18n.selfPost}}</view>
							<text class="order">{{i18n.OrderNumber}}：{{item.order_no}}</text>
						</view>
						<!-- <text class="order" style="color:rgba(248, 50, 36, 1) ;">{{i18n.receiveGoods}}</text> -->
						<text v-if="item.status=='imperfect'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">待完善</text>
						<text v-if="item.status=='domestic_undelivered'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国内未发货</text>
						<text v-if="item.status=='domestic_delivered'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国内已发货</text>
						<text v-if="item.status=='domestic_received'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国内已收货</text>
						<text v-if="item.status=='unpaid'" class="order" style="color:rgba(248, 50, 36, 1) ;">待付款</text>
						<text v-if="item.status=='overseas_undelivered'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国际未发货</text>
						<text v-if="item.status=='overseas_delivered'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国际已发货</text>
						<text v-if="item.status=='overseas_received'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">国际已收货</text>
						<text v-if="item.status=='finished'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">已完成</text>
						<text v-if="item.status=='closed'" class="order" style="color:rgba(248, 50, 36, 1) ;">已关闭</text>
						<text v-if="item.status=='refunding'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">退款中</text>
						<text v-if="item.status=='refunded'" class="order"
							style="color:rgba(248, 50, 36, 1) ;">已退款</text>
					</view>
					<view class="u-flex u-row-around" style="margin-top: 40rpx;">
						<view class="flexc">
							<view class="entrepotname">{{item.from_full_address}}</view>
							<view class="adda">{{item.from_name}}</view>
						</view>
						<image src="/pageB/static/images/arrows.png" style="width: 130rpx;height: 10rpx;" mode="">
						</image>
						<view class="flexc">
							<view class="entrepotname">{{item.to_full_address}}</view>
							<view class="adda">{{item.to_name}}</view>
						</view>
					</view>
					<view class="" style="margin-top: 36rpx;text-align: right;">
						<text class="sum">{{i18n.total}}</text>
						<text class="money" style="">¥</text>
						<text class="money" style="font-size: 36rpx;">{{item.estimated_price}}</text>
						<!-- <text class="money">.00</text> -->
					</view>
					<view class="content-bottom u-flex u-row-between">
						<text class="weight">{{i18n.Parcelweight}}：{{item.estimated_weight}}kg</text>
						<view class="u-flex">
							<!-- 冻结 -->
							<view class="btn" v-if="item.is_frozen==1" @click="frozen(item.id)">{{i18n.Frozen}}</view>
							<view class="btn">{{i18n.recover}}</view>
							<!-- 查看详情 -->
							<view class="btn" @click="detail(item.id)">{{i18n.details}}</view>
							<view class="btn"
								style="background-color:rgba(248, 50, 36, 1) ;color: #fff;border: 2rpx solid rgba(248, 50, 36, 0);">
								{{i18n.payment}}
							</view>
							<view class="btn"
								style="background-color:rgba(248, 50, 36, 1) ;color: #fff;border: 2rpx solid rgba(248, 50, 36, 0);">
								{{i18n.mail}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0, //tab切换
				list1: [],
				status: '', //状态
				goodslist: [],
				sumweight: 0,
				to_transit: 0, //发往中转点
				transit_receipt: 0, //中转已签收
				to_overseas: 0 ,//正发往海外
				keyword:'',//关键词搜索
			};
		},
		onLoad(options) {
			console.log(options);
			this.current = options.index
			if (this.current == 0) {
				this.status = 'to_transit'
			} else if (this.current == 1) {
				this.status = 'transit_receipt'
			} else {
				this.status = 'to_overseas'
			}
		},
		computed: {
			i18n() {
				return this.$t('index')
			}
		},
		onShow() {
			this.getnumber()
			uni.setNavigationBarTitle({
				title: this.i18n.mine + this.i18n.parcel
			})
			this.getlist()
		},
		methods: {
			detail(id) {

			},
			//冻结
			frozen(id) {
				uni.$u.http
					.post(`/api/address/default/${id}`)
					.then((res) => {
						console.log(res);
					})
					.catch(() => {});
			},
			//获取列表
			getlist() {
				uni.$u.http.get('/api/express-order?', {
					params: {
						order_no:this.keyword,
						container_id: '',
						status_collection: this.status
					}
				}).then((res) => {
					this.goodslist = res.data
					this.goodslist.forEach((item) => {
						this.sumweight += Number(item.estimated_weight)
					})
				}).catch(() => {

				})
			},
			//获取列表数量
			getnumber() {
				uni.$u.http.get('/api/express-order/status-count', {

				}).then((res) => {
					this.to_transit = res.to_transit //发往中转点
					this.transit_receipt = res.transit_receipt //发往中转点
					this.to_overseas = res.to_overseas //发往中转点
					this.list1 = [{
						name: this.i18n.deliver + this.to_transit,
					}, {
						name: this.i18n.Sign + this.transit_receipt,
					}, {
						name: this.i18n.overseas + this.to_overseas
					}]
				}).catch(() => {

				})
			},
			click(item) {
				console.log('item', item);
				this.current = item.index
				if (this.current == 0) {
					this.status = 'to_transit'
					this.getlist()
				} else if (this.current == 1) {
					this.status = 'transit_receipt'
					this.getlist()
				} else {
					this.status = 'to_overseas'
					this.getlist()
				}
			}
		},
		mounted() {

		}
	}
</script>

<style lang="scss" scoped>
	.flexc {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.content {
		padding: 20rpx 24rpx;
		box-sizing: border-box;

		.content-bottom {
			border-top: 2rpx solid rgba(151, 151, 151, 0.1);
			margin-top: 30rpx;
			padding-top: 30rpx;

			.weight {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #444444;
				line-height: 36rpx;
				text-align: left;
				font-style: normal;
			}

			.btn {
				// width: 132rpx;
				height: 68rpx;
				border-radius: 34rpx;
				border: 1rpx solid rgba(151, 151, 151, 0.7);
				display: inline;
				padding: 0 20rpx;
				box-sizing: border-box;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				line-height: 68rpx;
				text-align: center;
				font-style: normal;
				margin-left: 20rpx;
			}
		}

		.sum {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #333333;
			line-height: 34rpx;
			text-align: left;
			font-style: normal;
			margin-right: 8rpx;
		}

		.money {
			font-family: JDZhengHT, JDZhengHT;
			font-weight: 400;
			// font-size: 26rpx;
			color: #F83224;
			line-height: 32rpx;
			text-align: left;
			font-style: normal;
		}

		.adda {
			margin-top: 8rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #222222;
			line-height: 34rpx;
			text-align: right;
			font-style: normal;
		}

		.entrepotname {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #222222;
			line-height: 44rpx;
			text-align: left;
			font-style: normal;
			text-align: center;
			width: 300rpx;
		}

		.tab {
			// width: 96rpx;
			height: 36rpx;
			background: #FF1515;
			border-radius: 4rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			color: #FFFFFF;
			line-height: 36rpx;
			text-align: center;
			font-style: normal;
			margin-right: 8rpx;
			padding: 0 8rpx;
		}

		.order {
			font-family: SFPro, SFPro;
			font-weight: 400;
			font-size: 26rpx;
			color: #333333;
			line-height: 30rpx;
			text-align: left;
			font-style: normal;
		}

		.info {
			width: 702rpx;
			// height: 366rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 28rpx 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
		}

		.kg {
			width: 702rpx;
			// height: 68rpx;
			background: #FBE8E6;
			border-radius: 10rpx;
			padding: 18rpx 26rpx;
			box-sizing: border-box;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #F83224;
			line-height: 34rpx;
			text-align: left;
			font-style: normal;
		}
	}

	.top {
		padding: 20rpx 24rpx;
		box-sizing: border-box;
		background-color: #fff;

		.inputbg {
			width: 694rpx;
			height: 72rpx;
			background: #F4F4F4;
			border-radius: 38rpx;
			padding: 0 38rpx;
			box-sizing: border-box;
		}
	}
</style>