// pages/logistics/logistics.js
var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    wuliu: '',
    wuliuList: [],
    remind: '加载中'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var that = this;
    that.reloadData(options);
  },
  // 数据加载
  reloadData: function (options) {
    var that = this;
    var orderId = options.orderId;
    WXAPI.logisticsDetails({
      accessId: app.globalData.accessId,
      storeId: 239,
      storeType: 1,
      id: orderId,
      o_source: 1,
      type: '',
    }).then(res => {
      if (res.code == 200) {
        var data = res.data;
        if (data.list.length > 0) {
          that.setData({
            wuliu: data.list[0],
            wuliuList: data.list[0].list,
          })
        }
      }
    });
  },

  //页面加载完成函数
  onReady: function () {
    var that = this;
    setTimeout(function () {
      that.setData({
        remind: ''
      });
    }, 1000);
  },
  copyText: function (e) {
    console.log(e.currentTarget)
    var text = e.currentTarget.dataset.text;
    wx.setClipboardData({
      data: text,
      success: function (res) {
        wx.showToast({
          title: '复制成功',
          icon: 'none',
          duration: 2000
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }

})