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

292 lines
5.5 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
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
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. commonAddExchange: {
  57. url: '/api/common/addExchange',
  58. method: 'POST',
  59. auth: true,
  60. limit : 500,
  61. showLoading : true,
  62. },
  63. // 技工问题
  64. commonAddQuestion: {
  65. url: '/api/common/addQuestion',
  66. method: 'POST',
  67. auth: true,
  68. limit : 500,
  69. showLoading : true,
  70. },
  71. // 我的服务-会员充值(开通VIP)
  72. commonAddRecharge: {
  73. url: '/api/common/addRecharge',
  74. method: 'POST',
  75. auth: true,
  76. limit : 500,
  77. showLoading : true,
  78. },
  79. // 我的服务-获取积分-充值积分
  80. commonAddScoreByRecharge: {
  81. url: '/api/common/addScoreByRecharge',
  82. method: 'POST',
  83. auth: true,
  84. limit : 500,
  85. showLoading : true,
  86. },
  87. //获取工种列表
  88. commonQueryJobTypeList: {
  89. url: '/api/common/queryJobTypeList',
  90. method: 'GET',
  91. },
  92. //获取工作性质列表
  93. commonQueryJobNatureList: {
  94. url: '/api/common/queryJobNatureList',
  95. method: 'GET',
  96. },
  97. //获取banner图列表
  98. commonQueryBannerList: {
  99. url: '/api/common/queryBannerList',
  100. method: 'GET',
  101. },
  102. //获取开放地址列表
  103. commonQueryAddressList: {
  104. url: '/api/common/queryAddressList',
  105. method: 'GET',
  106. },
  107. //全年收支
  108. commonQueryBill: {
  109. url: '/api/common/queryBill',
  110. method: 'GET',
  111. },
  112. //记工记账项目列表
  113. commonQueryNotebookList: {
  114. url: '/api/common/queryNotebookList',
  115. method: 'GET',
  116. },
  117. //会员中心-正式积分||临时积分
  118. commonQueryScore: {
  119. url: '/api/common/queryScore',
  120. method: 'GET',
  121. },
  122. //积分记录
  123. commonQueryScoreRecord: {
  124. url: '/api/common/queryScoreRecord',
  125. method: 'GET',
  126. },
  127. //我的服务-获取VIP配置信息
  128. commonQueryVipType: {
  129. url: '/api/common/queryVipType',
  130. method: 'GET',
  131. },
  132. /**
  133. * 求职者的接口
  134. */
  135. //获取工作信息列表
  136. employeeQueryJobList: {
  137. url: '/api/employee/queryJobListByAll',
  138. method: 'GET',
  139. },
  140. //根据Id查看工作详情
  141. employeeQueryJobById: {
  142. url: '/api/employee/queryJobById',
  143. method: 'GET',
  144. },
  145. //我的收藏
  146. employeeQueryCollectionJobList: {
  147. url: '/api/employee/queryJobCollectionList',
  148. method: 'GET',
  149. },
  150. //我的找活
  151. employeeQueryResumeByUserId: {
  152. url: '/api/employee/queryResumeByUserId',
  153. method: 'GET',
  154. },
  155. //联系记录-我看过谁
  156. employeeQueryWatchWho: {
  157. url: '/api/employee/queryWatchWho',
  158. method: 'GET',
  159. },
  160. //联系记录-谁看过我
  161. employeeQueryWatchMe: {
  162. url: '/api/employee/queryWatchMe',
  163. method: 'GET',
  164. },
  165. //电子合同-获取电子合同列表
  166. employeeQueryContractList: {
  167. url: '/api/employee/queryContractList',
  168. method: 'GET',
  169. },
  170. /**
  171. * boss的接口
  172. */
  173. //获取简历列表
  174. bossQueryJobList: {
  175. url: '/api/boss/queryResumeListByAll',
  176. method: 'GET',
  177. },
  178. //根据Id查看简历详情
  179. bossQueryResumeById: {
  180. url: '/api/boss/queryResumeById',
  181. method: 'GET',
  182. },
  183. //电子合同-获取电子合同列表
  184. bossQueryContractList: {
  185. url: '/api/boss/queryContractList',
  186. method: 'GET',
  187. },
  188. //我的收藏
  189. bossQueryCollectionJobList: {
  190. url: '/api/boss/queryJobCollectionList',
  191. method: 'GET',
  192. },
  193. //我的招工
  194. bossQueryJobListByUserId: {
  195. url: '/api/boss/queryJobListByUserId',
  196. method: 'GET',
  197. },
  198. //会员中心-联系记录-我看过谁
  199. bossQueryWatchWho: {
  200. url: '/api/boss/queryWatchWho',
  201. method: 'GET',
  202. },
  203. //会员中心-联系记录-谁看过我
  204. bossQueryWatchMe: {
  205. url: '/api/boss/queryWatchMe',
  206. method: 'GET',
  207. },
  208. }
  209. export function api(key, data, callback, loadingTitle) {
  210. let req = config[key]
  211. if (!req) {
  212. console.error('无效key' + key);
  213. return
  214. }
  215. if (typeof callback == 'string') {
  216. loadingTitle = callback
  217. }
  218. if (typeof data == 'function') {
  219. callback = data
  220. data = {}
  221. }
  222. // 接口限流
  223. if (req.limit) {
  224. let storageKey = req.url
  225. let storage = limit[storageKey]
  226. if (storage && new Date().getTime() - storage < req.limit) {
  227. return
  228. }
  229. limit[storageKey] = new Date().getTime()
  230. }
  231. //必须登录
  232. if (req.auth) {
  233. if (!uni.getStorageSync('token')) {
  234. uni.navigateTo({
  235. url: '/pages_order/auth/wxLogin'
  236. })
  237. console.error('需要登录')
  238. return
  239. }
  240. }
  241. // 接口防抖
  242. if(req.debounce){
  243. let storageKey = req.url
  244. let storage = debounce[storageKey]
  245. if (storage) {
  246. clearTimeout(storage)
  247. }
  248. debounce[storageKey] = setTimeout(() => {
  249. clearTimeout(storage)
  250. delete debounce[storageKey]
  251. http.http(req.url, data, callback, req.method,
  252. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  253. }, req.debounce)
  254. return
  255. }
  256. http.http(req.url, data, callback, req.method,
  257. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  258. }
  259. export default api