logisticsDetails.js 2.11 KB
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';

let app = getApp();
const windowHeights = app.globalData.systemInfo.windowHeight;
const windowWidth = app.globalData.systemInfo.windowWidth;
const pixelRatio = app.globalData.systemInfo.pixelRatio;
let sc = windowWidth * pixelRatio / 750;

let listH = parseInt((windowHeights * pixelRatio) / sc - 221) - 5;

Page({
  
  data: {
    dot1: "./images/1@2x.png",
    dot2: "./images/2@2x.png",
    listH,
    logo: '',
    hasOrder: false,
    orderID: '',
    logisticsCompany: '',
    order_code: '',
    list: null,
  },


  onLoad: function (options) {
    // console.log(options);

    //获取应用实例
    
    let order_code = options.order_code;

    this.setData({
      order_code,
    });

    this.getLogisticInfo();
  },

  copyTapped: function(){
    wx.setClipboardData({
      data: this.data.orderID,
      success: function (res) {
        wx.showModal({
          content: '已复制到剪贴板!',
          showCancel: false,
          confirmText: "ok",
          success: function (res) {
          }
        })
      },
    })  
  },



  getLogisticInfo: function () {
    let that = this;
    let param = {
      method: 'app.express.li',
      uid: app.getUid(),
      fromPage: 'iFP_Logistics',
      order_code: this.data.order_code,
      physical_channel: 1,
    };

    GET(API_HOST, param)
      .then(function (data) {
        // console.log(data);
        if (data && data.code == 200) {
          let list = data.data.express_detail;
          let hasOrder = true;
          let logo = data.data.logo;
          let logisticsCompany = data.data.caption;
          let orderID = data.data.express_number;
          // console.log(list);

          that.setData({
            logisticsCompany,
            orderID,
            logo,
            list,
            hasOrder,
          });
        } else {
          wx.showModal({
            content: data.message,
            showCancel: false,
            confirmText: "确定",
          });
        }
      })
      .catch(function (error) {
      });
  },

})