//app.js
App({
  onLaunch: function () {
    
  },
  post(url,data){
    /** 
  * 自定义post函数,返回Promise
  * +-------------------
  * @param {String}      url 接口网址
  * @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
  * +-------------------
  * @return {Promise}    promise 返回promise供后续操作
  */
  wx.showNavigationBarLoading()
  wx.showLoading({
    title: '加载中',
  })
    var promise = new Promise((resolve, reject) => {
    let that=this;
    let postData=data;
    let baseurl ='http://192.168.1.112/portal/';//仅为测试地址
    //发起网络请求
    wx.request({
      url: baseurl+url,
      data:postData,
      method:'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      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,
    users_id:''
  }
})