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

293 lines
5.6 KiB

8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 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. commonQueryScore: {
  140. url: '/api/common/queryScore',
  141. method: 'GET',
  142. },
  143. /**
  144. * 求职者的接口
  145. */
  146. //获取工作信息列表
  147. employeeQueryJobList: {
  148. url: '/api/employee/queryJobList',
  149. method: 'GET',
  150. },
  151. //根据Id查看工作详情
  152. employeeQueryJobById: {
  153. url: '/api/employee/queryJobById',
  154. method: 'GET',
  155. },
  156. //我的收藏
  157. employeeQueryCollectionJobList: {
  158. url: '/api/employee/queryJobCollectionList',
  159. method: 'GET',
  160. },
  161. //联系记录-我看过谁(我的找活)
  162. employeeQueryWatchWho: {
  163. url: '/api/employee/queryWatchWho',
  164. method: 'GET',
  165. },
  166. //联系记录-谁看过我(谁看过我的简历)
  167. employeeQueryWatchMe: {
  168. url: '/api/employee/queryWatchMe',
  169. method: 'GET',
  170. },
  171. //电子合同-获取电子合同列表
  172. employeeQueryContractList: {
  173. url: '/api/employee/queryContractList',
  174. method: 'GET',
  175. },
  176. /**
  177. * boss的接口
  178. */
  179. //获取简历列表
  180. bossQueryJobList: {
  181. url: '/api/boss/queryResumeListByAll',
  182. method: 'GET',
  183. },
  184. //根据Id查看简历详情
  185. bossQueryResumeById: {
  186. url: '/api/boss/queryResumeById',
  187. method: 'GET',
  188. },
  189. //电子合同-获取电子合同列表
  190. bossQueryContractList: {
  191. url: '/api/boss/queryContractList',
  192. method: 'GET',
  193. },
  194. //我的收藏
  195. bossQueryCollectionJobList: {
  196. url: '/api/boss/queryJobCollectionList',
  197. method: 'GET',
  198. },
  199. //会员中心-联系记录-我看过谁(我的招工)
  200. bossQueryWatchWho: {
  201. url: '/api/boss/queryWatchWho',
  202. method: 'GET',
  203. },
  204. //会员中心-联系记录-谁看过我(谁看过我的招工)
  205. bossQueryWatchMe: {
  206. url: '/api/boss/queryWatchMe',
  207. method: 'GET',
  208. },
  209. }
  210. export function api(key, data, callback, loadingTitle) {
  211. let req = config[key]
  212. if (!req) {
  213. console.error('无效key' + key);
  214. return
  215. }
  216. if (typeof callback == 'string') {
  217. loadingTitle = callback
  218. }
  219. if (typeof data == 'function') {
  220. callback = data
  221. data = {}
  222. }
  223. // 接口限流
  224. if (req.limit) {
  225. let storageKey = req.url
  226. let storage = limit[storageKey]
  227. if (storage && new Date().getTime() - storage < req.limit) {
  228. return
  229. }
  230. limit[storageKey] = new Date().getTime()
  231. }
  232. //必须登录
  233. if (req.auth) {
  234. if (!uni.getStorageSync('token')) {
  235. uni.navigateTo({
  236. url: '/pages_order/auth/wxLogin'
  237. })
  238. console.error('需要登录')
  239. return
  240. }
  241. }
  242. // 接口防抖
  243. if(req.debounce){
  244. let storageKey = req.url
  245. let storage = debounce[storageKey]
  246. if (storage) {
  247. clearTimeout(storage)
  248. }
  249. debounce[storageKey] = setTimeout(() => {
  250. clearTimeout(storage)
  251. delete debounce[storageKey]
  252. http.http(req.url, data, callback, req.method,
  253. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  254. }, req.debounce)
  255. return
  256. }
  257. http.http(req.url, data, callback, req.method,
  258. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  259. }
  260. export default api