<template>
<view>
<!--mine/deliverExtend/deliverExtend.wxml-->
<view class="top">该订单已被拆分为{{list.length}}个包裹发货</view>
<view v-for="(item, index) in list" :key="index" class="bgfff content">
  <view class="dflex wuliu">
    <view class="dflex imag"><image src="/mine/static/mine/images/list.png" class="dingdan"></image>分单{{index+1}} </view>
    <view>{{item.express?item.express:''}} {{item.expressNo?item.expressNo:''}}</view>
  </view>
  <view class="kuaidi">
    <view class="psfs dflex" @tap="goUrl" :data-url="'/mine/logistics/logistics?id=' + item.id + '&orderId=' + id">
      <image src="/static/pages/images/psico.png" class="psico"></image>
      <view class="flex">
        <view>{{item.logistics.context}}</view>
        <text>{{item.logistics.time?item.logistics.time:time}}</text>
      </view>
      <image src="/static/pages/images/more.png" class="rico1"></image>
    </view>
  </view>
  <view v-for="(items, index2) in item.extendDTOList" :key="index2" class="product">
    <view>{{items.productName}}</view>
    <!-- <view class="guige">规格：额阿伟啊</view> -->
    <view class="money dflex">
      <view class="pic">￥<text>{{items.money}}</text></view>
      <view>x{{items.quantity}}</view>
    </view>
  </view>
  <view class="all">查看全部</view>
</view>
</view>
</template>

<script>
// mine/deliverExtend/deliverExtend.js
const app = getApp(); // const QRCode = require('../../utils/weapp.qrcode.js')
// const QRCode = require('../../utils/weapp.qrcode.js')
const req = require("../../utils/request.js");

export default {
  data() {
    return {
      id: "",
      time: "",
      list: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.query = options;
    this.setData({
      id: options.orderId
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.deliverExtend();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},
  methods: {
    // 获取分单发货的
    deliverExtend() {
      let time = new Date().toLocaleString();
      this.setData({
        time: time
      });
      req.postRequest('/api/order/deliverExtend', {
        id: this.query.orderId
      }, res => {
        // console.log(res);

        if (!res) {} else {
          res = res.map(it => {
            it.logistics = JSON.parse(it.logistics);
            return it;
          });
          // console.log(res);
          this.setData({
            list: res
          });
        }
      });
    },

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

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