|
@@ -1,27 +1,17 @@
|
|
|
-
|
|
|
import { getDictData, getIndustryTreeData } from '@/api/common/index'
|
|
|
// 定义对应的api
|
|
|
-const DICT_CITY_API = {
|
|
|
- menduner_exp_type: getDictData, // 工作经验
|
|
|
- menduner_pay_unit: getDictData, // 薪酬单位
|
|
|
- menduner_enterprise_type: getDictData, // 企业类型
|
|
|
- menduner_business_status: getDictData, // 经营状态
|
|
|
- menduner_scale: getDictData, // 人员规模
|
|
|
- menduner_financing_status: getDictData, // 融资状态
|
|
|
- menduner_education_system_type: getDictData, // 学制类型
|
|
|
- menduner_education_type: getDictData, // 学历
|
|
|
- menduner_job_type: getDictData, // 求职类型
|
|
|
- menduner_industry_type: getIndustryTreeData // 行业类型
|
|
|
-}
|
|
|
+// const DICT_CITY_API = {
|
|
|
+// menduner_exp_type: getDictData
|
|
|
+// }
|
|
|
|
|
|
-const setDict = (type, val, cacheTime) => {
|
|
|
+const setDict = (type, val, cacheTime = 7200) => {
|
|
|
localStorage.setItem(type, JSON.stringify({
|
|
|
data: val,
|
|
|
- expire: Date.now() + cacheTime
|
|
|
+ expire: Date.now() + cacheTime * 1000
|
|
|
}))
|
|
|
}
|
|
|
|
|
|
-export const getDict = (type, params) => {
|
|
|
+export const getDict = (type, params, apiType = 'dict') => {
|
|
|
return new Promise((resolve) => {
|
|
|
const item = localStorage.getItem(type)
|
|
|
const catchData = item ? JSON.parse(item) : null
|
|
@@ -30,7 +20,11 @@ export const getDict = (type, params) => {
|
|
|
}
|
|
|
// 传参按照规范参数传
|
|
|
const query = params ? params : { type }
|
|
|
- DICT_CITY_API[type](query).then(data => {
|
|
|
+ const apiFn = {
|
|
|
+ dict: getDictData,
|
|
|
+ industryDict: getIndustryTreeData
|
|
|
+ }
|
|
|
+ apiFn[apiType](query).then(data => {
|
|
|
setDict(type, data, Date.now())
|
|
|
resolve({ data })
|
|
|
})
|