logistics.js 1.99 KB
import logisticsService from './logisticsService.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    expressSender: '',
    expressCompanyName: '',
    wayBillCode: '',
    expressInfoDetailList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let orderCode = options.orderCode ? options.orderCode  : '';
    this.fetchLogisticsInfo(orderCode);
  },

  fetchLogisticsInfo: function (orderCode) {
    let that = this;
    let params = {
      orderCode,
    }

    let api = new logisticsService();
    api.fetchLogisticsInfo(params)
      .then(data => {
        if (data) {
          let expressSender = data.expressSender ? data.expressSender : '';
          let expressCompanyName = data.expressCompanyName ? data.expressCompanyName:'';
          let wayBillCode = data.wayBillCode ? data.wayBillCode:'';
          let expressInfoDetailList = data.expressInfoDetailList ? data.expressInfoDetailList : [];

          that.setData({
            expressSender,
            expressCompanyName,
            wayBillCode,
            expressInfoDetailList
          })
        }
      })
      .catch(error => {

      })
  },
  
  onCopyOrderCode: function() {
    let orderCode = String(this.data.wayBillCode);
    wx.setClipboardData({
      data: orderCode,
      success (res) {
        
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})