var baseUrl = ''
if(process.env.NODE_ENV === 'development'){//开发环境
  baseUrl= 'https://pay.tuyoyoo.com/'
}else{
  baseUrl= 'https://manager.pangdly.com/'
}

const request = (url = '', data = {}, type = 'POST') => {
  data.reqId = new Date().getTime() //获取时间戳
  return new Promise((resolve, reject) => {
    uni.request({
      method: type,
      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