拓恒河湖长制全民护河平台WEB端
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.

41 lines
1.2KB

  1. import baseurl from '../environment.js'
  2. export const request = function(data) {
  3. return new Promise((resolve, reject) => {
  4. if(data.showLoading) {
  5. wx.showLoading({
  6. title: '加载中',
  7. mask: true
  8. })
  9. }
  10. // 接口api拼接环境地址
  11. data.url = baseurl + data.url
  12. wx.request({
  13. ...data,
  14. success: function(res) {
  15. // 处理请求
  16. if(data.url === baseurl+'/aliyunOss/getSecurityToken') {
  17. resolve(res.data)
  18. } else {
  19. if(res.data.code == 0) { // 请求成功状态码
  20. resolve(res.data)
  21. } else {
  22. reject(res.data.msg)
  23. }
  24. }
  25. },
  26. fail: function (error) {
  27. reject(error)
  28. },
  29. complete: function () {
  30. if (data.showLoading) {
  31. wx.hideLoading()
  32. }
  33. }
  34. })
  35. }).catch(e => {
  36. wx.showToast({
  37. icon: "error",
  38. title: e || '系统错误',
  39. })
  40. })
  41. }