<template>
	<view class="container">
		<view class="express-box">
			<view class="top-text">
				<image class='logo' :src="expressList.result.logo" mode="widthFix"></image>
				<text class="top-com" v-if="expressList.result.deliverystatus=='0'">揽件中</text>
				<text class="top-com" v-if="expressList.result.deliverystatus=='1'">运输中</text>
				<text class="top-com" v-if="expressList.result.deliverystatus=='2'">派件中</text>
				<text class="top-com" v-if="expressList.result.deliverystatus=='3'">已签收</text>
			</view>
			<view class="top-text">
				<text>国内承运物流:</text>
				<text class="top-com">{{expressList.result.expName}}</text>
			</view>
			<view class="top-text">
				<text>运单号:</text>
				<text>{{expressList.result.number }}</text>
				<view class="fz" @click="copy(expressList.result.number)">
					复制
				</view>
			</view>
			<view class="top-text">
				<text>联系电话:</text>
				<text>{{expressList.result.expPhone }}</text>
				<view class="bh" @click="bh(expressList.result.expPhone)">
					拨打
				</view>
			</view>
			<view class="express-body">
				<uni-steps :options="expressList.result.list" active-color="#007AFF" :active="active"
					direction="column">
				</uni-steps>
			</view>
		</view>
	</view>
</template>

<script>
	// #ifdef H5
	import {
		weixindata,
		shareLoad
	} from '@/utils/wxAuthorized';
	// #endif
	import {
		express
	} from '@/api/order.js';
	import uniSteps from '@/components/uni-steps/uni-steps.vue';
	export default {
		components: {
			uniSteps
		},
		data() {
			return {
				id: '',
				expressList: [],
				active: 0
			}
		},
		onLoad(option) {
			this.id = option.id
			// #ifdef H5
			this.IndexShare()
			// #endif

		},
		onShow() {
			this.loadData()
		},
		onShareAppMessage(res) {
			return {
				title: '物流详情', //分享的名称
				path: 'pages/order/expressInfo?id=' + this.id,
			}
			console.log('pages/index/index?' + path, '分享数据');
		},
		methods: {
			IndexShare() {
				let obj = this;
				let path = 'https://hy.liuniu946.com/pages/order/expressInfo?id=' + this.id
				let data = {
					link: path,
					title: '物流详情',
					desc: '欢迎加入玲卿加',
					imgUrl: 'https://hy.liuniu946.com/static/image/hylogo.jpg'
				};
				console.log(data, '分享数据');
				shareLoad(data);
			},
			loadData() {
				express({
					id: this.id,
				}).then(({
					data
				}) => {
					this.expressList = data.express;
					console.log(this.expressList, '000000')
				})
			},
			copy(e) {
				uni.setClipboardData({
					data: e,
					success: () => { //复制成功的回调函数
						uni.showToast({ //提示
							title: "复制快递单号成功"
						})
					}
				})
			},
			bh(e) {
				uni.makePhoneCall({
					phoneNumber: e, //电话号码
					success: function(e) {
						console.log(e);
					},
					fail: function(e) {
						console.log(e);

					}
				})
			}
		},

	}
</script>

<style lang="scss">
	.container {
		.logo {
			border-radius: 10rpx;
			margin: 10rpx;
			width: 60rpx;
		}

		.fz {
			text-align: center;
			width: 110rpx;
			border-radius: 30rpx;
			padding: 8rpx;
			color: #FFFFFF;
			background-color: #f75022;
		}

		.bh {
			text-align: center;
			width: 110rpx;
			border-radius: 30rpx;
			padding: 8rpx;
			color: #FFFFFF;
			background-color: #1090ff;
		}

		.express-box {
			letter-spacing: 8rpx;
			padding: 30rpx;
			border-bottom-left-radius: 40rpx;
			border-bottom-right-radius: 40rpx;
			height: 320rpx;
			background-color: #FFFFFF;

			.top-text {
				width: 100%;
				height: 60rpx;
				background: #FFFFFF;
				padding-left: 20rpx;
				font-size: $font-base;
				border-radius: $border-radius-sm;
				display: flex;
				align-items: center;

				.top-com {
					margin-right: 10rpx;
				}

			}

			.express-body {
				margin-top: 80rpx;
				background: #FFFFFF;
				border-radius: $border-radius-sm;
				padding: 20rpx 10rpx 20rpx 0;
			}
		}
	}
</style>