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

272 lines
5.1 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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. //获取banner图列表
  93. commonQueryBannerList: {
  94. url: '/api/common/queryBannerList',
  95. method: 'GET',
  96. },
  97. //获取开放地址列表
  98. commonQueryAddressList: {
  99. url: '/api/common/queryAddressList',
  100. method: 'GET',
  101. },
  102. //全年收支
  103. commonQueryBill: {
  104. url: '/api/common/queryBill',
  105. method: 'GET',
  106. },
  107. //项目列表
  108. commonQueryNotebookList: {
  109. url: '/api/common/queryNotebookList',
  110. method: 'GET',
  111. },
  112. //会员中心-正式积分||临时积分
  113. commonQueryScore: {
  114. url: '/api/common/queryScore',
  115. method: 'GET',
  116. },
  117. //积分记录
  118. commonQueryScoreRecord: {
  119. url: '/api/common/queryScoreRecord',
  120. method: 'GET',
  121. },
  122. /**
  123. * 求职者的接口
  124. */
  125. //获取工作信息列表
  126. employeeQueryJobList: {
  127. url: '/api/employee/queryJobList',
  128. method: 'GET',
  129. },
  130. //根据Id查看工作详情
  131. employeeQueryJobById: {
  132. url: '/api/employee/queryJobById',
  133. method: 'GET',
  134. },
  135. //我的收藏
  136. employeeQueryCollectionJobList: {
  137. url: '/api/employee/queryJobCollectionList',
  138. method: 'GET',
  139. },
  140. //联系记录-我看过谁(我的找活)
  141. employeeQueryWatchWho: {
  142. url: '/api/employee/queryWatchWho',
  143. method: 'GET',
  144. },
  145. //联系记录-谁看过我(谁看过我的简历)
  146. employeeQueryWatchMe: {
  147. url: '/api/employee/queryWatchMe',
  148. method: 'GET',
  149. },
  150. //电子合同-获取电子合同列表
  151. employeeQueryContractList: {
  152. url: '/api/employee/queryContractList',
  153. method: 'GET',
  154. },
  155. /**
  156. * boss的接口
  157. */
  158. //获取简历列表
  159. bossQueryJobList: {
  160. url: '/api/boss/queryResumeListByAll',
  161. method: 'GET',
  162. },
  163. //根据Id查看简历详情
  164. bossQueryResumeById: {
  165. url: '/api/boss/queryResumeById',
  166. method: 'GET',
  167. },
  168. //电子合同-获取电子合同列表
  169. bossQueryContractList: {
  170. url: '/api/boss/queryContractList',
  171. method: 'GET',
  172. },
  173. //我的收藏
  174. bossQueryCollectionJobList: {
  175. url: '/api/boss/queryJobCollectionList',
  176. method: 'GET',
  177. },
  178. //会员中心-联系记录-我看过谁(我的招工)
  179. bossQueryWatchWho: {
  180. url: '/api/boss/queryWatchWho',
  181. method: 'GET',
  182. },
  183. //会员中心-联系记录-谁看过我(谁看过我的招工)
  184. bossQueryWatchMe: {
  185. url: '/api/boss/queryWatchMe',
  186. method: 'GET',
  187. },
  188. }
  189. export function api(key, data, callback, loadingTitle) {
  190. let req = config[key]
  191. if (!req) {
  192. console.error('无效key' + key);
  193. return
  194. }
  195. if (typeof callback == 'string') {
  196. loadingTitle = callback
  197. }
  198. if (typeof data == 'function') {
  199. callback = data
  200. data = {}
  201. }
  202. // 接口限流
  203. if (req.limit) {
  204. let storageKey = req.url
  205. let storage = limit[storageKey]
  206. if (storage && new Date().getTime() - storage < req.limit) {
  207. return
  208. }
  209. limit[storageKey] = new Date().getTime()
  210. }
  211. //必须登录
  212. if (req.auth) {
  213. if (!uni.getStorageSync('token')) {
  214. uni.navigateTo({
  215. url: '/pages_order/auth/wxLogin'
  216. })
  217. console.error('需要登录')
  218. return
  219. }
  220. }
  221. // 接口防抖
  222. if(req.debounce){
  223. let storageKey = req.url
  224. let storage = debounce[storageKey]
  225. if (storage) {
  226. clearTimeout(storage)
  227. }
  228. debounce[storageKey] = setTimeout(() => {
  229. clearTimeout(storage)
  230. delete debounce[storageKey]
  231. http.http(req.url, data, callback, req.method,
  232. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  233. }, req.debounce)
  234. return
  235. }
  236. http.http(req.url, data, callback, req.method,
  237. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  238. }
  239. export default api