//app.js
App({
  post: function (url, data, headerParams) {
    wx.showNavigationBarLoading()
    wx.showLoading({
      title: '',
    })
    var promise = new Promise((resolve, reject) => {
      let that = this;
      let postData = data;
      let baseUrl = 'http://maifuzi.w.bronet.cn/api/';
      let header = {
        'content-type': 'application/x-www-form-urlencoded'
      }
      header = Object.assign(header, headerParams)
      wx.request({
        url: baseUrl + url,
        data: postData,
        method: 'POST',
        header: header,
        success: function (res) {
          resolve(res)
          setTimeout(function () {
            wx.hideLoading()
          }, 600)
          wx.hideNavigationBarLoading()
        },
        error: function (e) {
          reject('');
          wx.hideLoading()
          wx.hideNavigationBarLoading()
          wx.showModal({
            title: '',
            content: res.data.msg,
            showCancel: false
          })
        }
      })
    });
    wx.hideLoading()
    return promise;
  },
  globalData: {
    userInfo: null
  }
})