赛思维微信客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

3 years ago
  1. var app = getApp();
  2. // const baseURL = 'http://8.140.133.55:8096'; // 赛思维正式环境
  3. const baseURL = 'http://101.201.121.115:8096'; // 赛思维测试环境
  4. /**
  5. * POST请求
  6. * URL接口
  7. * postData参数json类型
  8. * doSuccess成功的回调函数
  9. * doFail失败的回调函数
  10. */
  11. const http = ({
  12. url = '',
  13. param = {},
  14. ...other
  15. } = {}) => {
  16. return new Promise((resolve, reject) => {
  17. wx.request({
  18. url: baseURL + url,
  19. data: param,
  20. header: {
  21. 'content-type': 'application/json' // 默认值 ,另一种是 "content-type": "application/x-www-form-urlencoded"
  22. },
  23. ...other,
  24. complete: (res) => {
  25. if (res.statusCode === 200) {
  26. resolve(res.data)
  27. } else {
  28. reject(res)
  29. }
  30. }
  31. })
  32. })
  33. };
  34. // get方法
  35. const get = (url, param = {}) => {return http({url,param,method: 'GET'})}
  36. // post方法
  37. const post = (url, param = {}) => {return http({url,param,method: 'POST'})
  38. }
  39. module.exports = {
  40. get,
  41. post,
  42. baseURL
  43. }