|
@@ -1,9 +1,9 @@
|
|
|
|
|
|
import { getDictData } from '@/api/common/index'
|
|
import { getDictData } from '@/api/common/index'
|
|
// 定义对应的api
|
|
// 定义对应的api
|
|
-const DICT_CITY_API = {
|
|
|
|
- menduner_exp_type: getDictData
|
|
|
|
-}
|
|
|
|
|
|
+// const DICT_CITY_API = {
|
|
|
|
+// menduner_exp_type: getDictData
|
|
|
|
+// }
|
|
|
|
|
|
const setDict = (type, val, cacheTime = 7200) => {
|
|
const setDict = (type, val, cacheTime = 7200) => {
|
|
localStorage.setItem(type, JSON.stringify({
|
|
localStorage.setItem(type, JSON.stringify({
|
|
@@ -12,7 +12,7 @@ const setDict = (type, val, cacheTime = 7200) => {
|
|
}))
|
|
}))
|
|
}
|
|
}
|
|
|
|
|
|
-export const getDict = (type) => {
|
|
|
|
|
|
+export const getDict = (type, apiType = 'dict') => {
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
const item = localStorage.getItem(type)
|
|
const item = localStorage.getItem(type)
|
|
const catchData = item ? JSON.parse(item) : null
|
|
const catchData = item ? JSON.parse(item) : null
|
|
@@ -23,7 +23,10 @@ export const getDict = (type) => {
|
|
const query = {
|
|
const query = {
|
|
type
|
|
type
|
|
}
|
|
}
|
|
- DICT_CITY_API[type](query).then(data => {
|
|
|
|
|
|
+ const apiFn = {
|
|
|
|
+ dict: getDictData
|
|
|
|
+ }
|
|
|
|
+ apiFn[apiType](query).then(data => {
|
|
setDict(type, data, Date.now())
|
|
setDict(type, data, Date.now())
|
|
resolve({ data })
|
|
resolve({ data })
|
|
})
|
|
})
|