|
|
- import http from './http.js'
-
- let limit = {}
- let debounce = {}
-
- const config = {
- // 示例
- // wxLogin : {url : '/api/wxLogin', method : 'POST',
- // auth : false, showLoading : true, loadingTitle : '加载中...',
- // limit : 1000
- // },
-
- getConfig : {url : '/api/getConfig', method : 'GET', limit : 500},
-
-
-
-
-
- /**
- * 登录的接口
- */
- // 微信登录接口
- wxLogin: {
- url: '/api/login/login',
- method: 'GET',
- limit : 500,
- showLoading : true,
- },
- // 修改个人信息接口
- updateInfo: {
- url: '/info/updateInfo',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- //隐私政策
- getPrivacyPolicy: {
- url: '/login/getPrivacyPolicy',
- method: 'GET',
- },
- //用户协议
- getUserAgreement: {
- url: '/login/getUserAgreement',
- method: 'GET',
- },
-
-
-
- /**
- * 公共的接口
- */
-
- //关于本程序
- commonAboutUs: {
- url: '/api/common/aboutUs',
- method: 'GET',
- },
- //个人记工-新建账本
- commonAddBill: {
- url: '/api/common/addBill',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- //班组记工-新建账本
- commonAddBills: {
- url: '/api/common/addBills',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- // 我的服务-兑换码
- commonAddExchange: {
- url: '/api/common/addExchange',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- // 个人记工-技工问题
- commonAddQuestion: {
- url: '/api/common/addQuestion',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- // 班组记工-技工问题
- commonAddQuestions: {
- url: '/api/common/addQuestions',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- // 我的服务-会员充值(开通VIP)
- commonAddRecharge: {
- url: '/api/common/addRecharge',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- // 我的服务-获取积分-充值积分
- commonAddScoreByRecharge: {
- url: '/api/common/addScoreByRecharge',
- method: 'POST',
- auth: true,
- limit : 500,
- showLoading : true,
- },
- //获取工种列表
- commonQueryJobTypeList: {
- url: '/api/common/queryJobTypeList',
- method: 'GET',
- },
- //获取banner图列表
- commonQueryBannerList: {
- url: '/api/common/queryBannerList',
- method: 'GET',
- },
- //获取开放地址列表
- commonQueryAddressList: {
- url: '/api/common/queryAddressList',
- method: 'GET',
- },
- //个人记工-全年收支
- commonQueryBill: {
- url: '/api/common/queryBill',
- method: 'GET',
- },
- //班组记工-全年收支
- commonQueryBills: {
- url: '/api/common/queryBills',
- method: 'GET',
- },
- //个人记工-在建项目
- commonQueryStrartJobList: {
- url: '/api/common/queryStrartJobList',
- method: 'GET',
- },
- //个人记工-在建项目
- commonQueryStrartJobLists: {
- url: '/api/common/queryStrartJobLists',
- method: 'GET',
- },
-
-
- /**
- * 求职者的接口
- */
-
-
- //获取工作信息列表
- employeeQueryJobList: {
- url: '/api/employee/queryJobList',
- method: 'GET',
- },
- //根据Id查看工作详情
- employeeQueryJobById: {
- url: '/api/employee/queryJobById',
- method: 'GET',
- },
- //我的收藏
- employeeQueryCollectionJobList: {
- url: '/api/employee/queryJobCollectionList',
- method: 'GET',
- },
- //联系记录-我看过谁(我的找活)
- employeeQueryWatchWho: {
- url: '/api/employee/queryWatchWho',
- method: 'GET',
- },
- //联系记录-谁看过我(谁看过我的简历)
- employeeQueryWatchMe: {
- url: '/api/employee/queryWatchMe',
- method: 'GET',
- },
-
- /**
- * boss的接口
- */
- //获取简历列表
- bossQueryJobList: {
- url: '/api/boss/queryJobList',
- method: 'GET',
- },
- //根据Id查看简历详情
- bossQueryResumeById: {
- url: '/api/boss/queryResumeById',
- method: 'GET',
- },
- }
-
- export function api(key, data, callback, loadingTitle) {
- let req = config[key]
-
- if (!req) {
- console.error('无效key' + key);
- return
- }
-
- if (typeof callback == 'string') {
- loadingTitle = callback
- }
-
- if (typeof data == 'function') {
- callback = data
- data = {}
- }
-
- // 接口限流
- if (req.limit) {
- let storageKey = req.url
- let storage = limit[storageKey]
- if (storage && new Date().getTime() - storage < req.limit) {
- return
- }
- limit[storageKey] = new Date().getTime()
- }
-
- //必须登录
- if (req.auth) {
- if (!uni.getStorageSync('token')) {
- uni.navigateTo({
- url: '/pages_order/auth/wxLogin'
- })
- console.error('需要登录')
- return
- }
- }
-
- // 接口防抖
- if(req.debounce){
-
- let storageKey = req.url
- let storage = debounce[storageKey]
-
- if (storage) {
- clearTimeout(storage)
- }
-
- debounce[storageKey] = setTimeout(() => {
-
- clearTimeout(storage)
-
- delete debounce[storageKey]
-
- http.http(req.url, data, callback, req.method,
- loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
- }, req.debounce)
-
- return
- }
-
- http.http(req.url, data, callback, req.method,
- loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
- }
-
-
-
- export default api
|