api.js 854 B

1234567891011121314151617181920212223242526272829303132
  1. const BASE_URL = 'http://colliery.nxjiewei.com/api'
  2. // const BASE_URL = 'http://ningdongyunying.nxjiewei.com/api'
  3. // const BASE_URL = 'http://zaoquan.nxjiewei.com:8011/api'
  4. // const BASE_URL = 'http://yangchangwan.nxjiewei.com:8011/api'
  5. // const BASE_URL = 'http://renjiazhuang.nxjiewei.com:8011/api'
  6. export const myRequest = (options)=>{
  7. return new Promise((resolve,reject)=>{
  8. uni.request({
  9. url:BASE_URL+options.url,
  10. method:options.method || "GET",
  11. data:options.data || {},
  12. header:options.header || {},
  13. success: (res) => {
  14. console.log(res)
  15. if(res.data.code !== 0){
  16. return uni.showToast({
  17. title:"获取数据失败"
  18. });
  19. }
  20. resolve(res)
  21. },
  22. fail: (err) => {
  23. console.log(err)
  24. uni.showToast({
  25. title:"请求接口失败"
  26. })
  27. reject(err)
  28. }
  29. })
  30. })
  31. }