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

49 satır
1.4KB

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