import store from '../store/store.js'

//正式环境https://www.jtfw8.com/WXXCX
//测试环境http://116.62.129.2/CSWX
const apiBaseUrl = "http://116.62.129.2/CSWX"


const http = (options) => {
  return new Promise((resolve,reject) => {
    wx.request({
      url: apiBaseUrl + options.url,
      method: options.method || 'GET',
      data: options.data || {},
      header: options.header || {
        appid:store.state.appid,
        token:store.state.token
      },
      success:resolve,
      fail:reject
    })
  })
}


export default http
export {http,apiBaseUrl}