能效诊断
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
// import vm from '@/utils/bus'
|
||||
import { getLoginInfoByGrsg, getUserInfo, getUserLevel } from '@/api/common.js'
|
||||
const tokenKey = 'stk',
|
||||
platformKey = 'pfk',
|
||||
// unoKey = 'suno',
|
||||
uidKey = 'suid',
|
||||
userTypeKey = 'sut',
|
||||
duidKey = 'sduid',
|
||||
sak = 'saikey'
|
||||
const getValueByKey = key => {
|
||||
return sessionStorage.getItem(key) ? sessionStorage.getItem(key) : ''
|
||||
}
|
||||
|
||||
const getDefaultState = () => ({
|
||||
token: getValueByKey(tokenKey),
|
||||
ai: getValueByKey(sak),
|
||||
platform: getValueByKey(platformKey),
|
||||
userid: '',
|
||||
username: '',
|
||||
realname: '',
|
||||
mobile: '',
|
||||
uno: '', //0500024691
|
||||
//能效
|
||||
uid: getValueByKey(uidKey),
|
||||
userType: getValueByKey(userTypeKey),
|
||||
//需求响应
|
||||
duid: getValueByKey(duidKey),
|
||||
staticUrl: process.env.STATIC_RESOURCE_URL,
|
||||
isEncrypt: true,
|
||||
role: '1', //1: 运维员,2:班组长,3:用能客户
|
||||
sgcode: '',
|
||||
deptid: '',
|
||||
isEnergyUser: true,
|
||||
userLevel: '',
|
||||
to: {
|
||||
path: ''
|
||||
},
|
||||
cityType: process.env.VUE_APP_CITY_TYPE=='sx', //外观图片必填
|
||||
cityIsNx: process.env.VUE_APP_CITY_TYPE=='sx', //位置必填
|
||||
imageRecognition: process.env.VUE_APP_CITY_TYPE=='ah', // 图像识别
|
||||
validate: process.env.VUE_APP_CITY_TYPE=='ah', // 大区间校验
|
||||
})
|
||||
|
||||
const state = getDefaultState()
|
||||
|
||||
const mutations = {
|
||||
GET_USER_LEVEL:(state, data)=>{
|
||||
state.userLevel = data
|
||||
sessionStorage.setItem('level', data)
|
||||
// getUserLevel().then((res)=>{
|
||||
// if(res.code == 0) {
|
||||
// state.userLevel = res.data
|
||||
// sessionStorage.setItem('level', res.data)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
RESET_STATE: (state) => {
|
||||
Object.assign(state, getDefaultState())
|
||||
},
|
||||
SET_TOKEN: (state, data) => {
|
||||
console.log(data);
|
||||
state.token = data
|
||||
// state.platform = platform
|
||||
if(data instanceof Object) {
|
||||
sessionStorage.setItem(tokenKey, JSON.stringify(data))
|
||||
sessionStorage.setItem('__TOKEN', data.token)
|
||||
} else {
|
||||
sessionStorage.setItem(tokenKey, data)
|
||||
sessionStorage.setItem('__TOKEN', data)
|
||||
}
|
||||
// sessionStorage.setItem(platformKey, platform)
|
||||
},
|
||||
SET_AI: (state, ai) => {
|
||||
state.ai = ai
|
||||
sessionStorage.setItem(sak, ai)
|
||||
},
|
||||
SET_PATH: (state, data) => {
|
||||
state.to.path = data.path
|
||||
sessionStorage.setItem('path', data.path)
|
||||
},
|
||||
|
||||
SET_USER_ID: (state, userid) => {
|
||||
state.userid = userid
|
||||
sessionStorage.setItem('userId', userid)
|
||||
},
|
||||
SET_USER_NAME: (state, username) => {
|
||||
state.username = username
|
||||
},
|
||||
SET_REALNAME: (state, realname) => {
|
||||
state.realname = realname
|
||||
},
|
||||
SET_MOBILE: (state, mobile) => {
|
||||
state.mobile = mobile
|
||||
},
|
||||
SET_USER_CONST_NO: (state, uno) => {
|
||||
state.uno = uno
|
||||
},
|
||||
SET_USER_CONST_INFO: (state, { uid, userType }) => {
|
||||
state.uid = uid
|
||||
state.userType = userType
|
||||
sessionStorage.setItem(uidKey, uid)
|
||||
sessionStorage.setItem(userTypeKey, userType)
|
||||
},
|
||||
SET_DEMAND_USER_CONST_INFO(state, duid) {
|
||||
state.duid = duid
|
||||
sessionStorage.setItem(duidKey, duid)
|
||||
},
|
||||
SET_ROLE(state, role) {
|
||||
state.role = role
|
||||
},
|
||||
SET_SG_CODE(state, sgcode) {
|
||||
state.sgcode = sgcode
|
||||
},
|
||||
SET_DEPT_ID: (state, deptid) => {
|
||||
state.deptid = deptid
|
||||
},
|
||||
SET_ENERGY_TYPE(state, user_category_code) {
|
||||
//user_category_code 3:用能客户 2:能源服务商
|
||||
state.isEnergyUser = user_category_code == 3
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
getLoginInfo({ commit, state }) {
|
||||
// const ai = sessionStorage.getItem('ai')
|
||||
return new Promise(resolve => {
|
||||
let params = {
|
||||
ai: state.ai,
|
||||
login_source: "5",
|
||||
appCode: ["NXGL"]
|
||||
}
|
||||
// const str = JSON.stringify(params)
|
||||
// alert(str)
|
||||
getLoginInfoByGrsg(params).then(res => {
|
||||
// console.log(res);
|
||||
// const result = JSON.stringify(res)
|
||||
// alert(result)
|
||||
if (res.code == 0) {
|
||||
console.log(res,'125');
|
||||
commit('SET_TOKEN', {
|
||||
token: res.data.access_token,
|
||||
platform: 'grsg'
|
||||
})
|
||||
// commit('SET_AI', ai)
|
||||
resolve(true)
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
getUserInfo({ commit }) {
|
||||
console.log(this);
|
||||
return new Promise((resolve) => {
|
||||
getUserInfo().then(res => {
|
||||
// if (res.code == vm.$StatusCode.SUCCESS) {
|
||||
if(res.code == 0) {
|
||||
console.log(res);
|
||||
|
||||
const { data } = res
|
||||
let {
|
||||
user_name,
|
||||
real_name,
|
||||
mobile_phone,
|
||||
user_id,
|
||||
account_card,
|
||||
gw_yc_code, dept_id,
|
||||
user_category_code
|
||||
} = data.user_info
|
||||
commit('SET_USER_ID', user_id)
|
||||
commit('SET_USER_CONST_NO', account_card)
|
||||
commit('SET_USER_NAME', user_name)
|
||||
commit('SET_REALNAME', real_name)
|
||||
commit('SET_MOBILE', mobile_phone)
|
||||
commit('SET_SG_CODE', gw_yc_code)
|
||||
commit('SET_DEPT_ID', dept_id)
|
||||
commit('SET_ENERGY_TYPE', user_category_code)
|
||||
// commit('GET_USER_LEVEL')
|
||||
resolve(true)
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
// }
|
||||
})
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
Reference in New Issue
Block a user