<template>
	<!-- yocode 物流信息 -->
	<view class="content ViewLogistics yocode">
		
		<!-- 地图呀 -->
		<!-- <view class="page-body">
			<view class="page-section page-section-gap">
				<map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers">
				</map>
			</view>
		</view> -->
		
		<view class="wuliuboxss flex ali-c">
			<image class="imgs" :src="statictowUrl+'/static/applet5'+logisticLogo" mode=""></image>
			<view class="rightinfos">
				<view  class="wuliutype">{{shipperName}}</view>
				<view class="wuliucode">运单号: {{logisticCode}}</view>
				<view class="wuliutel">官方电话: {{phone}}</view>
			</view>
		</view>
		
		<!-- 查看物流的组件 alidata2.state -->
		<ali :state="3" :datas="list" :ways="information"></ali>
		
	</view>
</template>

<script>
import ali from '@/components/WuLiu-step/WuLiu-step.vue';
import {checkLogistics} from "@/utils/api/api.js";
export default {
	components: {
		ali
	},
	computed: {
		staticUrl () {//静态资源地址
			return this.$store.state.staticUrl;
		},
		staticUrl1(){
			return this.$store.state.staticUrl1;
		},
		statictowUrl(){
			return this.$store.state.statictowUrl;
		},
		uploadurl(){
			return this.$store.state.uploadurl;
		}
	},
	data() {
		return {
			
			//地图的东西
			title: 'map',
			latitude: 39.909,
			longitude: 116.39742,
			covers: [{
				latitude: 39.909,
				longitude: 116.39742,
				iconPath: '/static/news/address.png'
			}, {
				latitude: 39.90,
				longitude: 116.39,
				iconPath: '/static/news/address.png'
			}],
						
			alidata: {
				state: 2,
				uptime: '2019-05-23 17:52:06',
				data: [
					
				],
				information: {
					no: '231880744913',
					sName: 'SF',
					expName: '顺丰速运',
					url: 'http:www.sf-express.com',
					tel: '95338',
					img: 'https://oss-cn2.apistore.cn/exp/SF.png'
				}
			},
			alidata2: {
				state: 3,
				uptime: '2019-05-24 10:58:24',
				data: [
					
				],
				information: {
					no: '70939995911523',
					sName: 'HTKY',
					expName: '百世快递(原汇通)',
					url: 'http:www.htky365.com',
					tel: '021-62963636',
					img: 'https:oss-cn2.apistore.cnexpHTKY.png'
				}
			},
		
			list: [],
			logisticCode: "",
			shipperName: "",
			logisticLogo: "",
			phone: "",
			information: {
				no: '',
				sName: '',
				expName: '',
				url: '',
				tel: '',
				img: ''
			}
		};
	},
	onLoad(options) {
		this.init();
		
		var that = this;
		console.log(options);
		let params = {
		  order_id: options.order_id,
		  action: options.action,
		  vendor_id:options.vendor,
		};
		checkLogistics(params).then(res => {
		  console.log(res);
		  if (res.code == 0) {
			let data = res.data;
			let list = this.checkArray(data.Traces) ? data.Traces : [];
			let logistics_info = this.getLogisticsConfig(data.ShipperCode)
			
			this.list=list.reverse();
			this.logisticCode=data.LogisticCode;
			this.shipperName=logistics_info.name;
			this.logisticLogo= logistics_info.img_url;
			this.phone=logistics_info.phone;
			
		  }
		})
	},
	methods: {
		init() {
		},
		/**
		  * 获取快递公司信息
		*/
		getLogisticsConfig(shipperCode) {
		    let config = {
		      'YTO': { 'name': '圆通速递', 'phone': '95554', 'img_url': '/images/delivery_icon/YTO.png' },
		      'HTKY': { 'name': '百世快递', 'phone': '95320', 'img_url': '/images/delivery_icon/HTKY.png' },
		      'ZTO': { 'name': '中通快递', 'phone': '95311', 'img_url': '/images/delivery_icon/ZTO.png' },
		      'STO': { 'name': '申通快递', 'phone': '95543', 'img_url': '/images/delivery_icon/STO.png' },
		      'SF': { 'name': '顺丰速运', 'phone': '95338', 'img_url': '/images/delivery_icon/SF.png' },
		      'YD': { 'name': '韵达速递', 'phone': '95546', 'img_url': '/images/delivery_icon/YD.png' },
		      'YZPY': { 'name': '邮政快递包裹', 'phone': '11185', 'img_url': '/images/delivery_icon/EMS.png' },
		      'EMS': { 'name': 'EMS', 'phone': '11183', 'img_url': '/images/delivery_icon/EMS.png' },
		      'HHTT': { 'name': '天天快递', 'phone': '400-188-8888', 'img_url': '/images/delivery_icon/HHTT.png' },
		      'JD': { 'name': '京东快递', 'phone': '950616', 'img_url': '/images/delivery_icon/JD.png' },
		      'UC': { 'name': '优速快递', 'phone': '95349', 'img_url': '/images/qishou@2x.png' },
		      'DBL': { 'name': '德邦快递', 'phone': '95353', 'img_url': '/images/delivery_icon/DBL.png' },
		      'ZJS': { 'name': '宅急送', 'phone': '400-678-9000', 'img_url': '/images/qishou@2x.png' },
		      'TNT': { 'name': 'TNT快递', 'phone': '400-820-9868', 'img_url': '/images/qishou@2x.png' },
		      'UPS': { 'name': 'UPS', 'phone': '400-820-8388', 'img_url': '/images/qishou@2x.png' },
		      'DHL': { 'name': 'DHL', 'phone': '95380', 'img_url': '/images/qishou@2x.png' },      
		      'FEDEX': { 'name': 'FEDEX联邦(国内件）', 'phone': '400-886-1888', 'img_url': '/images/qishou@2x.png' },
		      'FEDEX_GJ': { 'name': 'FEDEX联邦(国际件）', 'phone': '400-886-1888', 'img_url': '/images/qishou@2x.png' },
		    }
		    return config[shipperCode] || {};
		},
		checkArray (obj) {
		  if (obj != undefined && obj != null && obj[0] != undefined) {
		    return true;
		  } else {
		    return false;
		  }
		}
	}
};
</script>

<style lang="scss">
	@import "./ViewLogistics.scss";
</style>
