<template>
	<view>
		<!-- <view class="status"  bindtap="goUrl"  data-url="/pages/my/seperate/seperate?id={{orderId}}&fdid={{id}}"  > -->
		<view class="status">
			<text v-if="orderId">订单编号：{{orderId}}</text>
			<text v-if="detail.expressNo">{{detail.express}}：{{detail.expressNo}}</text>
			<text v-if="detail.mobile">客服电话：{{detail.mobile}}</text>
			<image src="/static/pages/images/rico.png" class="rico1"></image>
		</view>
		<view class="wuliu">
			<view class="tit">物流跟踪</view>
			<view class="pslist" v-if="detail.messages">
				<block v-for="(item, index) in detail.messages" :key="index">
					<view :class="'li ' + (index==0?'ing':'')">
						<view class="lis">
							<view>{{item.context}}</view>
							<text>{{item.ftime}}</text>
						</view>
					</view>
				</block>
			</view>
			<view class="nodata" v-else>
				<image :src="picUrlss+'empty.png'"></image>
				<text>暂无</text>
			</view>
		</view>
		<view class="confirm" @click="confirmOrder" v-if="!isReceived&&type!=1">确认收货</view>
	</view>
</template>

<script>
	const app = getApp();
	const req = require("../../utils/request.js");

	export default {
		data() {
			return {
				picUrlss: req.public.picUrls,
				detail: {},
				//物流详情 
				id: 0,
				orderId: '',
				fdidx: '',
				type: 0,
				isReceived: false
			};
		},

		components: {},
		props: {},
		onLoad: function(options) {
			this.setData({
				id: options.id,
				orderId: options.orderId ? options.orderId : '',
				type: options.type ? options.type : 0,
				isReceived: options.isReceived ? true : false
			});

			if (options.fdidx) {
				this.fdidx = options.fdidx;
				uni.setNavigationBarTitle({
					title: "分单" + this.chinanum(options.fdidx) + "物流"
				});
			}

			this.getDetail();
		},
		methods: {
			chinanum(num) {
				var china = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
				var arr = [];
				num = num.toString();
				var english = num.split('');

				for (var i = 0; i < english.length; i++) {
					arr.push(china[english[i] * 1]);
				}

				return arr.join("");
			},

			goUrl(e) {
				var dataset = e.currentTarget.dataset;
				// console.log(dataset.url);
				uni.navigateTo({
					url: dataset.url
				});
			},

			getDetail() {
				var _this = this;

				req.getRequest('/api/deliver/detail', {
					id: this.id,
					type: this.type
				}, res => {
					_this.setData({
						detail: res
					});
				});
			},
			confirmOrder() {
				//确认收货
				// let index = event.currentTarget.dataset.index;
				// let page = this.data.pageList[index];
				let that = this;
				req.msgConfirm('确认执行该操作？', () => {
					req.postRequest(
						'/api/order/newReceiving',
						{
							id: that.id
						},
						() => {
							uni.navigateBack();
						}
					);
				});
			},
			

		}
	};
</script>
<style>
	@import "./logistics.css";
</style>
