express.js 1.94 KB
import wx from '../../../../utils/wx';
import Yas from '../../../../common/yas';
import orderModel from '../../../../models/home/order';

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;
let yas;

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) {
    let order_code = options.order_code;

    this.setData({
      order_code
    });

    this.expressDetail();

    yas = new Yas(app);
    yas.pageOpenReport();

  },
  copyExpressNo: function() {
    wx.setClipboardData({data: this.data.orderID})
      .then(() => {
        wx.showModal({
          content: '已复制到剪贴板!',
          showCancel: false,
          confirmText: '确定',
        });
      });
  },
  expressDetail: function() {
    let params = {
      method: 'app.express.li',
      uid: app.getUid(),
      fromPage: 'iFP_Logistics',
      order_code: this.data.order_code,
      physical_channel: 1
    };

    orderModel.expressDetail(params)
      .then(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;

          this.setData({
            logisticsCompany,
            orderID,
            logo,
            list,
            hasOrder
          });
        } else {
          wx.showModal({
            content: data.message,
            showCancel: false,
            confirmText: '确定'
          });
        }
      });
  }
});