特易招,招聘小程序
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.

264 lines
4.9 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. import http from './http.js'
  2. let limit = {}
  3. let debounce = {}
  4. const config = {
  5. // 示例
  6. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  7. // auth : false, showLoading : true, loadingTitle : '加载中...',
  8. // limit : 1000
  9. // },
  10. getConfig : {url : '/api/getConfig', method : 'GET', limit : 500},
  11. /**
  12. * 登录的接口
  13. */
  14. // 微信登录接口
  15. wxLogin: {
  16. url: '/api/login/login',
  17. method: 'GET',
  18. limit : 500,
  19. showLoading : true,
  20. },
  21. // 修改个人信息接口
  22. updateInfo: {
  23. url: '/info/updateInfo',
  24. method: 'POST',
  25. auth: true,
  26. limit : 500,
  27. showLoading : true,
  28. },
  29. //隐私政策
  30. getPrivacyPolicy: {
  31. url: '/login/getPrivacyPolicy',
  32. method: 'GET',
  33. },
  34. //用户协议
  35. getUserAgreement: {
  36. url: '/login/getUserAgreement',
  37. method: 'GET',
  38. },
  39. /**
  40. * 公共的接口
  41. */
  42. //关于本程序
  43. commonAboutUs: {
  44. url: '/api/common/aboutUs',
  45. method: 'GET',
  46. },
  47. //个人记工-新建账本
  48. commonAddBill: {
  49. url: '/api/common/addBill',
  50. method: 'POST',
  51. auth: true,
  52. limit : 500,
  53. showLoading : true,
  54. },
  55. //班组记工-新建账本
  56. commonAddBills: {
  57. url: '/api/common/addBills',
  58. method: 'POST',
  59. auth: true,
  60. limit : 500,
  61. showLoading : true,
  62. },
  63. // 我的服务-兑换码
  64. commonAddExchange: {
  65. url: '/api/common/addExchange',
  66. method: 'POST',
  67. auth: true,
  68. limit : 500,
  69. showLoading : true,
  70. },
  71. // 个人记工-技工问题
  72. commonAddQuestion: {
  73. url: '/api/common/addQuestion',
  74. method: 'POST',
  75. auth: true,
  76. limit : 500,
  77. showLoading : true,
  78. },
  79. // 班组记工-技工问题
  80. commonAddQuestions: {
  81. url: '/api/common/addQuestions',
  82. method: 'POST',
  83. auth: true,
  84. limit : 500,
  85. showLoading : true,
  86. },
  87. // 我的服务-会员充值(开通VIP)
  88. commonAddRecharge: {
  89. url: '/api/common/addRecharge',
  90. method: 'POST',
  91. auth: true,
  92. limit : 500,
  93. showLoading : true,
  94. },
  95. // 我的服务-获取积分-充值积分
  96. commonAddScoreByRecharge: {
  97. url: '/api/common/addScoreByRecharge',
  98. method: 'POST',
  99. auth: true,
  100. limit : 500,
  101. showLoading : true,
  102. },
  103. //获取工种列表
  104. commonQueryJobTypeList: {
  105. url: '/api/common/queryJobTypeList',
  106. method: 'GET',
  107. },
  108. //获取banner图列表
  109. commonQueryBannerList: {
  110. url: '/api/common/queryBannerList',
  111. method: 'GET',
  112. },
  113. //获取开放地址列表
  114. commonQueryAddressList: {
  115. url: '/api/common/queryAddressList',
  116. method: 'GET',
  117. },
  118. //个人记工-全年收支
  119. commonQueryBill: {
  120. url: '/api/common/queryBill',
  121. method: 'GET',
  122. },
  123. //班组记工-全年收支
  124. commonQueryBills: {
  125. url: '/api/common/queryBills',
  126. method: 'GET',
  127. },
  128. //个人记工-在建项目
  129. commonQueryStrartJobList: {
  130. url: '/api/common/queryStrartJobList',
  131. method: 'GET',
  132. },
  133. //个人记工-在建项目
  134. commonQueryStrartJobLists: {
  135. url: '/api/common/queryStrartJobLists',
  136. method: 'GET',
  137. },
  138. /**
  139. * 求职者的接口
  140. */
  141. //获取工作信息列表
  142. employeeQueryJobList: {
  143. url: '/api/employee/queryJobList',
  144. method: 'GET',
  145. },
  146. //根据Id查看工作详情
  147. employeeQueryJobById: {
  148. url: '/api/employee/queryJobById',
  149. method: 'GET',
  150. },
  151. //我的收藏
  152. employeeQueryCollectionJobList: {
  153. url: '/api/employee/queryJobCollectionList',
  154. method: 'GET',
  155. },
  156. //联系记录-我看过谁(我的找活)
  157. employeeQueryWatchWho: {
  158. url: '/api/employee/queryWatchWho',
  159. method: 'GET',
  160. },
  161. //联系记录-谁看过我(谁看过我的简历)
  162. employeeQueryWatchMe: {
  163. url: '/api/employee/queryWatchMe',
  164. method: 'GET',
  165. },
  166. /**
  167. * boss的接口
  168. */
  169. //获取简历列表
  170. bossQueryJobList: {
  171. url: '/api/boss/queryJobList',
  172. method: 'GET',
  173. },
  174. //根据Id查看简历详情
  175. bossQueryResumeById: {
  176. url: '/api/boss/queryResumeById',
  177. method: 'GET',
  178. },
  179. }
  180. export function api(key, data, callback, loadingTitle) {
  181. let req = config[key]
  182. if (!req) {
  183. console.error('无效key' + key);
  184. return
  185. }
  186. if (typeof callback == 'string') {
  187. loadingTitle = callback
  188. }
  189. if (typeof data == 'function') {
  190. callback = data
  191. data = {}
  192. }
  193. // 接口限流
  194. if (req.limit) {
  195. let storageKey = req.url
  196. let storage = limit[storageKey]
  197. if (storage && new Date().getTime() - storage < req.limit) {
  198. return
  199. }
  200. limit[storageKey] = new Date().getTime()
  201. }
  202. //必须登录
  203. if (req.auth) {
  204. if (!uni.getStorageSync('token')) {
  205. uni.navigateTo({
  206. url: '/pages_order/auth/wxLogin'
  207. })
  208. console.error('需要登录')
  209. return
  210. }
  211. }
  212. // 接口防抖
  213. if(req.debounce){
  214. let storageKey = req.url
  215. let storage = debounce[storageKey]
  216. if (storage) {
  217. clearTimeout(storage)
  218. }
  219. debounce[storageKey] = setTimeout(() => {
  220. clearTimeout(storage)
  221. delete debounce[storageKey]
  222. http.http(req.url, data, callback, req.method,
  223. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  224. }, req.debounce)
  225. return
  226. }
  227. http.http(req.url, data, callback, req.method,
  228. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  229. }
  230. export default api