<template>
	<!-- 寄快递 -->
	<view class="" style="padding: 0 24rpx;">
		<view style="position: relative;padding-bottom: 20rpx;">
			<!-- 自定义导航栏 -->
			<image src="/static/images/index/back.png"
				style="width: 750rpx;height: 1200rpx;position: absolute;top: 0;z-index: -1;left:-24rpx;" mode="">
			</image>
			<u-navbar :autoBack='true' :title='i18n.delivery' bgColor="rgba(248, 50, 36, 0.2)" :placeholder='true'
				:safeAreaInsetTop="true" style="position: absolute;z-index: 110;background-color: rgba(0,0,0,0);">
				<view class="u-nav-slot" slot="left" style="display: flex;">
					<u-icon name="arrow-left" color="rgba(0, 0, 0, 1)" size="24" @click="uni.navigateBack()"></u-icon>
				</view>
			</u-navbar>
			<!-- 邮寄地址 -->
			<view class="mail">
				<view class="u-flex u-row-around" style="margin-top: 40rpx;padding: 0 80rpx;">
					<view class="flexc">
						<view class="entrepotname">{{topadd.province_name + topadd.city_name}}</view>
						<view class="adda">{{topadd.name}}</view>
					</view>
					<image src="/pageB/static/images/arrows.png" style="width: 130rpx;height: 10rpx;" mode=""></image>
					<view class="flexc">
						<view class="entrepotname">{{bottomadd.province_name + bottomadd.city_name}}</view>
						<view class="adda">{{bottomadd.name}}</view>
					</view>
				</view>
				<view class="boxinfo">
					<view class="">
						<text class="abouta">{{i18n.typeof}}：</text>
						<text class="abouta" style='color:rgba(34, 34, 34, 1)'>{{goodinfo.goodname}}</text>
						<text class="abouta" style='margin:0 16rpx'>|</text>
						<text class="abouta">{{i18n.weight}}：</text>
						<text class="abouta" style='color:rgba(34, 34, 34, 1)'>{{goodinfo.weight}}kg</text>
						<text class="abouta" style='margin:0 16rpx'>|</text>
						<text class="abouta">{{i18n.number}}：</text>
						<text class="abouta" style='color:rgba(34, 34, 34, 1)'>{{goodinfo.number}}{{i18n.piece}}</text>
					</view>
					<view class="" style="margin-top: 20rpx;">
						<text class="abouta">{{i18n.flow}}:</text>
						<text class="abouta" style='color:rgba(34, 34, 34, 1)'>{{rightname}}</text>
					</view>
				</view>
			</view>
			<!-- 地址 -->
			<view class="address">
				<view class="left u-flex" style="display: flex;" @click="send">
					<view class="u-row-between left" style="display: flex;flex-direction: column;">
						<image src="/static/express/ji.png" style='width: 40rpx;;height:40rpx ;' mode=""></image>
						<!-- <image src="/static/express/change.png" style='width: 40rpx;;height:40rpx ;' mode=""></image> -->
					</view>
					<view class=" u-row-between left"
						style="flex: 1;margin-left: 28rpx;border-bottom:2rpx solid rgba(151, 151, 151, 0.08) ;display: flex;">
						<view v-if="JSON.stringify(topadd)==='{}'" class="u-row-between " style="">
							<view class="pople">{{i18n.sender}}</view>
							<view class="jiadd" style="margin-top: 14rpx;">{{i18n.informat}}</view>
						</view>
						<view v-else class="u-row-between " style="" @click="send">
							<view class="">
								<text class="topname">{{topadd.name}}</text>
								<text class="topaddress"
									style="margin-left: 8rpx;">{{replacePhoneToStar(topadd.mobile)}}</text>
							</view>
							<view class="topaddress" style="margin-top: 14rpx;">{{topadd.full_address}}</view>
						</view>
						<!-- 						<view class="u-flex" @click.stop="addbook(0)">
							<view class="" style="color: rgba(151, 151, 151, 1);">|</view>
							<text class="right">{{i18n.addressbook}}</text>
						</view> -->
					</view>
				</view>
				<view class="left u-flex"
					style="display: flex;margin-top: 26rpx;border-bottom:2rpx solid rgba(151, 151, 151, 0.08)"
					@click="recipe">
					<view class="u-row-between left" style="display: flex;flex-direction: column;">
						<image src="/static/express/shou.png" style='width: 40rpx;;height:40rpx ;' mode=""></image>
						<!-- <image src="../../static/express/change.png" style='width: 40rpx;;height:40rpx ;' mode=""> -->
						</image>
					</view>
					<view class=" u-row-between left" style="flex: 1;margin-left: 28rpx;display: flex;">
						<view v-if="JSON.stringify(bottomadd)==='{}'" class="u-row-between " style="">
							<view class="pople">{{i18n.recipient}}</view>
							<view class="jiadd" style="margin-top: 14rpx;">{{i18n.informat}}</view>
						</view>
						<view v-else class="u-row-between " style="" @click="send">
							<view class="">
								<text class="topname">{{bottomadd.name}}</text>
								<text class="topaddress"
									style="margin-left: 8rpx;">{{replacePhoneToStar(bottomadd.mobile)}}</text>
							</view>
							<view class="topaddress" style="margin-top: 14rpx;">{{bottomadd.full_address}}</view>
						</view>
						<!-- 						<view class="u-flex" @click.stop="addbook(1)">
							<view class="" style="color: rgba(151, 151, 151, 1);">|</view>
							<text class="right">{{i18n.addressbook}}</text>
						</view> -->
					</view>
				</view>
			</view>
			<!-- 快递服务 -->
			<view class="wup u-flex u-row-between">
				<view>{{i18n.Expressservice}}</view>
				<view class="u-flex" @click="toexpress">
					<view class="selection">{{expname||i18n.selection}}</view>
					<image src="../static/express/next1.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
				</view>
			</view>
			<!-- 下一步 -->
			<view class="next  u-flex-between" style="display: flex;">
				<!-- 				<view class="" style="flex: 1;">
					<view class="sum">
						<text>预估总价</text>
						<text style="color: rgba(248, 50, 36, 1);">¥ - -</text>
					</view>
					<view class="deal u-flex" style="margin-top: 16rpx;">
						<u-checkbox-group shape='circle' v-model="checkboxValue1" placement="column" @change="checkboxChange">
							<u-checkbox :customStyle="{marginBottom: '8px',marginTop:'5px'}" :name="deal" >
							</u-checkbox>
						</u-checkbox-group>
						<text>我阅读并同意</text>
						<text style="color: rgba(248, 50, 36, 1);">《国际快递服务协议》</text>
					</view>
				</view> -->
				<view class="tonext " style="" @click="payorder">
					{{i18n.Orderconfirmation}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deal: -1,
				checkboxValue1: [],
				expname: '',
				language: 'zh-CN',
				goodinfo: {},
				topadd: {},
				bottomadd: {},
				leftname: '',
				rightname: '',
				container_id: '',
				unit_price: '',
				number: '',
				sum: "",
				code: ''
			}
		},
		onLoad(options) {
			this.goodinfo = JSON.parse(decodeURIComponent(options.goodinfo))
			this.topadd = JSON.parse(decodeURIComponent(options.topadd))
			this.bottomadd = JSON.parse(decodeURIComponent(options.bottom))
			this.leftname = options.leftname
			this.rightname = options.rightname
			this.container_id = options.container_id
			this.unit_price = options.unit_price
			this.number = options.number
		},
		onShow() {
			if (uni.getStorageSync('language') != '') {
				this.language = uni.getStorageSync('language')
			}
		},
		computed: {
			i18n() {
				return this.$t('index')
			}
		},
		methods: {
			payorder() {
				uni.$u.http.post('/api/express-order/common-create', {
					from_address_id: this.topadd.id, //1	是	String	寄件地址ID
					to_address_id: this.bottomadd.id, //2	是	String	收件地址ID
					container_id: this.container_id, //1	是	String	货柜ID
					goods_name: this.goodinfo.goodname, //樱桃	是	String	商品信息名称
					goods_num: this.goodinfo.number, //100	是	String	商品数量
					goods_weight: this.goodinfo.weight, //20	是	String	商品重量
					goods_length: Number(this.goodinfo.length), //30	是	String	商品体积: 长
					goods_width: Number(this.goodinfo.width), //	40	是	String	商品体积: 宽
					goods_height: Number(this.goodinfo.height), //	237	是	String	商品体积: 高
					goods_type: this.goodinfo.goodtype, //normal	是	String	商品类型: normal. 正常商品, special. 特殊商品
					domestic_logistics_company_code: this.code
				}).then((res) => {
					console.log(res)
					this.$u.toast(this.i18n.successful)
					setTimeout(() => {
						uni.navigateTo({
							url: '/pageB/orderinfo?orderinfo=' + encodeURIComponent(JSON.stringify(
								res))
						})
					})
					// uni.navigateTo({
					// 	url: '/pageA/payorder?sum=' + res.estimated_price +'&type=' + 'express_order'+'&orderid='+res.id
					// })
				}).catch(() => {

				})
			},
			toexpress() {
				uni.navigateTo({
					url: '/pageB/expresstype',
					events: {
						todcp: (res) => {
							console.log(res)
							this.expname = res.concant
							this.code = res.code
						}
					}
				})
			},
			//正则匹配手机号
			replacePhoneToStar: function(phone) {
				if (phone) {
					return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
				}
			},
			//地址薄
			addbook(index) {
				var that = this
				uni.navigateTo({
					url: "/pageC/addressManagement/addressManagement?index=" + index,
					events: {
						getadd(res) {
							if (index == 1) {
								that.topadd = res
								console.log('topadd', that.topadd);
							} else {
								that.bottomadd = res
								console.log('bottom', that.bottomadd);
								that.province_id = that.bottomadd.province_id
							}
						}
					}
				})
			},
			send() {
				uni.navigateTo({
					url: '/pageB/Senderinfor'
				})
			},
			recipe() {
				uni.navigateTo({
					url: '/pageB/recipientinfo'
				})
			},
			checkboxChange(n) {
				console.log('change', n);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.topname {
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 30rpx;
		color: #222222;
		line-height: 42rpx;
		text-align: left;
		font-style: normal;
	}

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

	.selection {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #666666;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
	}

	.mail {
		width: 702rpx;
		// height: 332rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-top: 38rpx;
		padding: 1rpx 20rpx 28rpx;
		box-sizing: border-box;

		.abouta {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #777777;
			line-height: 34rpx;
			text-align: left;
			font-style: normal;
		}

		.boxinfo {
			margin-top: 26rpx;
			width: 662rpx;
			// height: 148rpx;
			background: #F4F4F4;
			border-radius: 12rpx;
			padding: 28rpx 20rpx;
			box-sizing: border-box;
		}

		.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: 600;
			font-size: 32rpx;
			color: #222222;
			line-height: 44rpx;
			text-align: left;
			font-style: normal;
		}
	}

	.sum {
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #222222;
		line-height: 34rpx;
		text-align: left;
		font-style: normal;
	}

	.deal {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 20rpx;
		color: #666666;
		line-height: 28rpx;
		text-align: left;
		font-style: normal;
	}

	.tonext {
		width: 686rpx;
		height: 88rpx;
		background: #F83224;
		box-shadow: 0rpx 16rpx 40rpx -12rpx rgba(255, 21, 21, 0.5);
		border-radius: 44rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 88rpx;
		text-align: center;
		font-style: normal;
	}

	.next {
		width: 750rpx;
		height: 166rpx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 12rpx 24rpx;
		box-sizing: border-box;
	}

	.wup {
		width: 704rpx;
		height: 76rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-top: 20rpx;
		padding: 0rpx 20rpx;
		box-sizing: border-box;
	}

	.info {
		height: 100rpx;
		border-bottom: 2rpx solid rgba(151, 151, 151, 0.08);



		.wupin {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #333333;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
		}

		.change {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #666666;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
		}

		.mast {
			width: 62rpx;
			height: 30rpx;
			border-radius: 16rpx;
			border: 1rpx solid #F83224;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			color: #FF1515;
			line-height: 30rpx;
			text-align: center;
			font-style: normal;
			margin-left: 12rpx;
		}
	}

	.mon {
		font-family: HarmonyOS_Sans_Medium;
		font-size: 20rpx;
		color: #F83224;
		line-height: 26rpx;
		text-align: left;
		font-style: normal;
	}

	.bigtitle {
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 28rpx;
		color: #222222;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
	}

	.timeb {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 22rpx;
		color: #666666;
		line-height: 32rpx;
		text-align: left;
		font-style: normal;
	}

	.timea {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 22rpx;
		color: #555555;
		line-height: 32rpx;
		text-align: left;
		font-style: normal;
	}

	.pinb {
		width: 148rpx;
		height: 64rpx;
		background: #FF1515;
		border-radius: 42rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
		line-height: 64rpx;
		text-align: center;
		font-style: normal;
	}

	.label {
		margin-top: 20rpx;
		width: 702rpx;
		height: 288rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 32rpx 20rpx;
		box-sizing: border-box;

		.left {
			width: 144rpx;
			height: 144rpx;
			background: #F5F5F5;
			border-radius: 8rpx;

			.bourn {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 20rpx;
				color: #222222;
				line-height: 28rpx;
				text-align: left;
				font-style: normal;
			}

			.addres {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #222222;
				line-height: 40rpx;
				text-align: left;
				font-style: normal;
			}
		}
	}

	.flexc {
		width: 300rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.hai {
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 32rpx;
		color: #222222;
		line-height: 44rpx;
		text-align: left;
		font-style: normal;
		margin-right: 10rpx;
	}

	.more {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 24rpx;
		color: #F83224;
		line-height: 34rpx;
		text-align: left;
		font-style: normal;
	}

	.parcel {
		width: 702rpx;
		height: 260rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-top: 20rpx;
		padding: 24rpx;
		box-sizing: border-box;

		.myparcel {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 28rpx;
			color: #222222;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
		}

		.add {
			width: 240rpx;
			height: 48rpx;
			background: rgba(248, 50, 36, 0.06);
			border-radius: 24rpx;

			.addtext {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 20rpx;
				color: #000000;
				line-height: 28rpx;
				text-align: left;
				font-style: normal;
			}
		}
	}

	.address {
		width: 702rpx;
		// height: 776rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 48rpx 24rpx 36rpx;
		box-sizing: border-box;
		margin-top: 20rpx;

		.bottom {
			padding: 0 76rpx;
			box-sizing: border-box;
			margin-top: 48rpx;

			.friend {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #555555;
				line-height: 40rpx;
				text-align: left;
				font-style: normal;
				margin-left: 12rpx;
			}
		}

		.mail {
			width: 646rpx;
			height: 84rpx;
			background: #F83224;
			box-shadow: 0rpx 16rpx 40rpx -12rpx rgba(255, 21, 21, 0.5);
			border-radius: 44rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 84rpx;
			text-align: center;
			font-style: normal;
		}



		.left {
			height: 128rpx;

			.pople {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #222222;
				line-height: 42rpx;
				text-align: left;
				font-style: normal;
			}

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

			.right {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #222222;
				line-height: 36rpx;
				text-align: left;
				font-style: normal;
				margin-left: 18rpx;
			}
		}
	}

	::v-deep .u-navbar__content.data-v-1194bf80 {
		background-color: rgba(0, 0, 0, 0) !important;
	}

	::v-deep .u-status-bar.data-v-13f16680 {
		background-color: rgba(0, 0, 0, 0) !important;
	}

	::v-deep .u-subsection--button.data-v-b14d3440 {
		/* padding: 6rpx 34rpx !important; */
		border-radius: 64rpx !important;
	}

	::v-deep .u-subsection--button__bar.data-v-b14d3440 {
		border-radius: 32rpx !important;
	}
</style>