艺易修小程序24.08.21
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.

86 lines
3.1 KiB

6 months ago
5 months ago
5 months ago
5 months ago
6 months ago
5 months ago
6 months ago
  1. import http from './http.js'
  2. const config = {
  3. // 示例
  4. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  5. // auth : false, showLoading : true, loadingTitle : '加载中...',
  6. // limit : 1000
  7. // },
  8. // 维修员登录接口(手机号)
  9. repairLogin: { url: '/school/login/login', method: 'GET' , auth : false , showLoading : true , loadingTitle : '登录中...' , limit : 500 },
  10. //学生登录(微信)
  11. studentLogin: { url: '/school/login/loginWx', method: 'GET' , auth : false , showLoading : true , loadingTitle : '登录中...' , limit : 500 },
  12. //微信登录用户(学生)-修改个人信息
  13. updateInfo: { url: '/school-api/updateUserInfo', method: 'GET' , auth : true , limit : 500 },
  14. //微信登录用户(学生)-获取个人信息
  15. getUserInfo: { url: '/school-api/getUserInfo', method: 'GET' , auth : true , limit : 500 },
  16. //微信登录用户(学生)-增加报修单
  17. addSchoolOrder : {url : '/school-api/addUserSchoolOrder', method : 'GET', auth : true , limit : 500},
  18. //驳回(维修员)
  19. editSchoolOrderError : {url : '/school-api/editSchoolOrderError', method : 'GET', auth : true , limit : 500},
  20. //结单(维修员)
  21. editSchoolOrderSuccess : {url : '/school-api/editSchoolOrderSuccess', method : 'GET', auth : true , limit : 500},
  22. //微信登录用户(学生)-报修列表
  23. getUserSchoolOrderPage : {url : '/school-api/getUserSchoolOrderPage', method : 'GET', auth : true , limit : 500},
  24. //获取楼栋
  25. getActorGoList : {url : '/school-api/getActorGoList', method : 'GET', auth : false , limit : 500},
  26. //获取室号
  27. getFloorList : {url : '/school-api/getFloorList', method : 'GET', auth : false , limit : 500},
  28. //小程序(维修员)-列表-分配给维修的订单
  29. getSchoolOrderList : {url : '/school-api/getUserSchoolOrderList', method : 'GET', auth : true , limit : 500},
  30. //隐私政策
  31. getPrivacyPolicy : { url : '/school/login/getPrivacyPolicy', method : 'GET', auth : false , limit : 500},
  32. //用户协议
  33. getUserAgreement : { url : '/school/login/getUserAgreement', method : 'GET', auth : false , limit : 500},
  34. //获取维修项目
  35. getRepairList : { url : '/school-api/getRepairList', method : 'GET', auth : false , limit : 500},
  36. //获取流转明细
  37. getOrderFlowList : { url : '/school-api/getOrderFlowList', method : 'GET', auth : false , limit : 500},
  38. }
  39. export function api(key, data, callback, loadingTitle){
  40. let req = config[key]
  41. if (!req) {
  42. console.error('无效key' + key);
  43. return
  44. }
  45. if(typeof callback == 'string'){
  46. loadingTitle = callback
  47. }
  48. if(typeof data == 'function'){
  49. callback = data
  50. data = {}
  51. }
  52. // 接口限流
  53. if(req.limit){
  54. let storageKey = 'limit:' + req.url
  55. let storage = uni.getStorageSync(storageKey)
  56. if(storage && new Date().getTime() - parseInt(storage) < req.limit){
  57. return
  58. }
  59. uni.setStorageSync(storageKey, new Date().getTime())
  60. }
  61. //必须登录
  62. if (req.auth) {
  63. if (!uni.getStorageSync('token')) {
  64. uni.navigateTo({
  65. url: '/pages/login/studentLogin'
  66. })
  67. console.error('需要登录')
  68. return
  69. }
  70. }
  71. http.http(req.url, data, callback, req.method,
  72. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  73. }
  74. export default api