request.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //测试地址
  2. const baseUrl = 'http://dms.66km.com.cn/'
  3. //const baseUrl = 'http://192.168.0.10:20187/'
  4. const configUrl='http://qw.66km.com.cn/'
  5. //正式地址
  6. //66 dmsqw.66km.com
  7. /* const baseUrl = 'http://apidms.66km.com/'
  8. const configUrl='http://dmsqw.66km.com/' */
  9. //欧洲维修
  10. /* const baseUrl = 'https://crm.eurorepar.cn/'
  11. const configUrl='http://dmshf.eurorepar.cn/' */
  12. const http = (url = '', date = {}, type = 'POST', header = {
  13. }) => {
  14. return new Promise((resolve, reject) => {
  15. header={};
  16. var token=uni.getStorageSync('token')
  17. header['token']=token;
  18. if(url=='enterprise/wechat/extCustomerMobile'){
  19. header['Content-Type']='application/x-www-form-urlencoded';
  20. }else{
  21. header['Content-Type']='application/json;charset=utf-8';
  22. }
  23. uni.request({
  24. method: type,
  25. url: baseUrl + url,
  26. data: date,
  27. header: header,
  28. dataType: 'json',
  29. }).then((response) => {
  30. // console.log(response.data.code)
  31. //console.log(response.data.data.code)
  32. //let [error, res] = response;
  33. // console.log(res)
  34. /* if(res.data.code==401||res.data.code==403){
  35. uni.clearStorageSync()
  36. }else if(res.data.code==409){
  37. // getToken(url,date,type,header)
  38. } */
  39. /* if(response.data.data.code!=1){
  40. console.log(res.data.data.msg)
  41. uni.hideLoading();
  42. uni.clearStorageSync()
  43. uni.showToast({
  44. title: res.data.data.msg,
  45. icon: 'none',
  46. duration: 3000
  47. });
  48. } */
  49. /* if(response.data.code!=1){
  50. //console.log(res.data.msg)
  51. uni.hideLoading();
  52. //uni.clearStorageSync()
  53. uni.showToast({
  54. title: response.data.msg,
  55. icon: 'none',
  56. duration: 3000
  57. });
  58. }else{
  59. } */
  60. resolve(response.data);
  61. }).catch(error => {
  62. let [err, res] = error;
  63. reject(err)
  64. })
  65. });
  66. }
  67. export default {
  68. http,configUrl
  69. }