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

240 lines
4.5 KiB

10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
8 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
8 months ago
10 months ago
8 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
10 months ago
  1. import http from './http.js'
  2. import utils from '../utils/utils.js'
  3. let limit = {}
  4. let debounce = {}
  5. const models = [
  6. 'score', 'boss', 'login', 'vip', 'company', 'work','index-lzx', 'resume',
  7. 'config',
  8. 'examination',
  9. 'collect',
  10. 'contact',
  11. ]
  12. const config = {
  13. // 示例
  14. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  15. // auth : false, showLoading : true, loadingTitle : '加载中...',
  16. // limit : 1000
  17. // },
  18. // getConfig : {url : '/api/getConfig', method : 'GET', limit : 500},
  19. /**
  20. * 公共的接口
  21. */
  22. //关于本程序
  23. commonAboutUs: {
  24. url: '/api/common/aboutUs',
  25. method: 'GET',
  26. },
  27. //新建账本
  28. commonAddBill: {
  29. url: '/api/common/addBill',
  30. method: 'POST',
  31. auth: true,
  32. limit : 500,
  33. showLoading : true,
  34. },
  35. // 我的服务-兑换码
  36. commonAddExchange: {
  37. url: '/api/common/addExchange',
  38. method: 'POST',
  39. auth: true,
  40. limit : 500,
  41. showLoading : true,
  42. },
  43. // 技工问题
  44. commonAddQuestion: {
  45. url: '/api/common/addQuestion',
  46. method: 'POST',
  47. auth: true,
  48. limit : 500,
  49. showLoading : true,
  50. },
  51. // 我的服务-会员充值(开通VIP)
  52. commonAddRecharge: {
  53. url: '/api/common/addRecharge',
  54. method: 'POST',
  55. auth: true,
  56. limit : 500,
  57. showLoading : true,
  58. },
  59. // 我的服务-获取积分-充值积分
  60. commonAddScoreByRecharge: {
  61. url: '/api/common/addScoreByRecharge',
  62. method: 'POST',
  63. auth: true,
  64. limit : 500,
  65. showLoading : true,
  66. },
  67. //获取工种列表
  68. commonQueryJobTypeList: {
  69. url: '/api/common/queryJobTypeList',
  70. method: 'GET',
  71. },
  72. //获取工作性质列表
  73. commonQueryJobNatureList: {
  74. url: '/api/common/queryJobNatureList',
  75. method: 'GET',
  76. },
  77. //获取banner图列表
  78. commonQueryBannerList: {
  79. url: '/api/common/queryBannerList',
  80. method: 'GET',
  81. },
  82. //获取开放地址列表
  83. commonQueryAddressList: {
  84. url: '/api/common/queryAddressList',
  85. method: 'GET',
  86. },
  87. //全年收支
  88. commonQueryBill: {
  89. url: '/api/common/queryBill',
  90. method: 'GET',
  91. },
  92. //记工记账项目列表
  93. commonQueryNotebookList: {
  94. url: '/api/common/queryNotebookList',
  95. method: 'GET',
  96. },
  97. //会员中心-正式积分||临时积分
  98. commonQueryScore: {
  99. url: '/api/common/queryScore',
  100. method: 'GET',
  101. },
  102. //积分记录
  103. commonQueryScoreRecord: {
  104. url: '/api/common/queryScoreRecord',
  105. method: 'GET',
  106. },
  107. //我的服务-获取VIP配置信息
  108. commonQueryVipType: {
  109. url: '/api/common/queryVipType',
  110. method: 'GET',
  111. },
  112. /**
  113. * 求职者的接口
  114. */
  115. //我的找活
  116. employeeQueryResumeByUserId: {
  117. url: '/api/employee/queryResumeByUserId',
  118. method: 'GET',
  119. auth: true,
  120. },
  121. //联系记录-我看过谁
  122. employeeQueryWatchWho: {
  123. url: '/api/employee/queryWatchWho',
  124. method: 'GET',
  125. auth: true,
  126. },
  127. //电子合同-获取电子合同列表
  128. employeeQueryContractList: {
  129. url: '/api/employee/queryContractList',
  130. method: 'GET',
  131. auth: true,
  132. },
  133. /**
  134. * boss的接口
  135. */
  136. //电子合同-获取电子合同列表
  137. bossQueryContractList: {
  138. url: '/api/boss/queryContractList',
  139. method: 'GET',
  140. auth: true,
  141. },
  142. }
  143. export function api(key, data, callback, loadingTitle) {
  144. let req = config[key]
  145. if (!req) {
  146. console.error('无效key' + key);
  147. return
  148. }
  149. if (typeof callback == 'string') {
  150. loadingTitle = callback
  151. }
  152. if (typeof data == 'function') {
  153. callback = data
  154. data = {}
  155. }
  156. // 接口限流
  157. if (req.limit) {
  158. let storageKey = req.url
  159. let storage = limit[storageKey]
  160. if (storage && new Date().getTime() - storage < req.limit) {
  161. return
  162. }
  163. limit[storageKey] = new Date().getTime()
  164. }
  165. //必须登录
  166. if (req.auth) {
  167. if (!uni.getStorageSync('token')) {
  168. utils.toLogin()
  169. console.error('需要登录')
  170. return
  171. }
  172. }
  173. // 接口防抖
  174. if(req.debounce){
  175. let storageKey = req.url
  176. let storage = debounce[storageKey]
  177. if (storage) {
  178. clearTimeout(storage)
  179. }
  180. debounce[storageKey] = setTimeout(() => {
  181. clearTimeout(storage)
  182. delete debounce[storageKey]
  183. http.http(req.url, data, callback, req.method,
  184. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  185. }, req.debounce)
  186. return
  187. }
  188. http.http(req.url, data, callback, req.method,
  189. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  190. }
  191. function addApiModel(model, key){
  192. for(let k in model){
  193. if(config[`${k}`]){
  194. console.error(`重名api------model=${key},key=${k}`);
  195. uni.showModal({
  196. title: `重名api------model=${key},key=${k}`
  197. })
  198. continue
  199. }
  200. config[`${k}`] = model[k]
  201. // config[`${key}_${k}`] = model[k]
  202. }
  203. }
  204. models.forEach(key => {
  205. addApiModel(require(`./model/${key}.js`).default, key)
  206. })
  207. export default api