var baseUrl = ''
if(process.env.NODE_ENV === 'development'){//开发环境
  // baseUrl= 'http://pay.tuyoyoo.com/'
  baseUrl='http://192.168.0.213:7888/'
}else{
  baseUrl= 'https://manager.pangdly.com/'
}
const request = (url = '', data = {},showLoad) => {
  data.reqId = new Date().getTime() //获取时间戳
  let show=showLoad||false
  return new Promise((resolve, reject) => {
    if(!show){
      uni.showLoading({
        title:'加载中',
        mask:true
      })
    }
    uni.request({
      method: 'POST',
      url: baseUrl + url+'?token='+uni.getStorageSync('token'),
      data:data,
      dataType: 'json',
    }).then((response) => {
      uni.hideLoading()
      let [error,res] = response        
      resolve(res.data)
    }).catch(error => {
      uni.hideLoading()
      let [err, res] = error
      reject(err)
    })
  })
}
export default request