合并人才集团代码

This commit is contained in:
2025-11-03 12:30:37 +08:00
parent 233e5fecdc
commit 1c6d5c7a15
118 changed files with 12562 additions and 14 deletions

19
utilsRc/auth.js Normal file
View File

@@ -0,0 +1,19 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:55:08
* @LastEditors: lip
*/
const TokenKey = 'App-Token'
export function getToken() {
return uni.getStorageSync(TokenKey)
}
export function setToken(token) {
return uni.setStorageSync(TokenKey, token)
}
export function removeToken() {
return uni.removeStorageSync(TokenKey)
}

248
utilsRc/common.js Normal file
View File

@@ -0,0 +1,248 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:56:06
* @LastEditors: shirlwang
*/
import {
getPersonBase
} from '@/apiRc/person';
import store from '@/utilsRc/store';
import tab from '@/utilsRc/plugins/tab.js'
/**
* 显示消息提示框
* @param content 提示的标题
*/
export function toast(content) {
uni.showToast({
icon: 'none',
title: content
})
}
/**
* 显示模态弹窗
* @param content 提示的标题
*/
export function showConfirm(content, cancelText, confirmText, showCancel) {
return new Promise((resolve, reject) => {
uni.showModal({
title: '提示',
content: content,
cancelText: cancelText || '取消',
confirmText: confirmText || '确定',
showCancel: showCancel === false ? false : true,
success: function(res) {
resolve(res)
}
})
})
}
// 修改后的 checkPersonBase 方法
export function checkPersonBase() {
return new Promise((resolve) => {
const roles = store.getters.roles;
const userId = store.getters.userId;
const isRole = (role) => roles.includes(role);
if (isRole('qunzhong')) {
getPersonBase(userId).then(resp => {
const shouldGoToPersonInfo = resp.data.auditStatus === '0';
if (shouldGoToPersonInfo) {
uni.showModal({
title: '提示',
content: '您的个人信息尚未维护,请前往维护个人信息。',
confirmText: '去维护',
cancelText: '取消',
success: function(res) {
if (res.confirm) {
tab.navigateTo('/pages/personInfo/index');
}
resolve(false); // 需要维护,返回 false
}
});
} else {
resolve(true); // 不需要维护,返回 true
}
});
} else {
resolve(true); // 非群众角色直接放行
}
});
}
/**
* 参数处理
* @param params 参数
*/
export function tansParams(params) {
let result = ''
for (const propName of Object.keys(params)) {
const value = params[propName]
var part = encodeURIComponent(propName) + "="
if (value !== null && value !== "" && typeof(value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && value[key] !== "" && typeof(value[key]) !== 'undefined') {
let params = propName + '[' + key + ']'
var subPart = encodeURIComponent(params) + "="
result += subPart + encodeURIComponent(value[key]) + "&"
}
}
} else {
result += part + encodeURIComponent(value) + "&"
}
}
}
return result
}
/**
* 姓名、手机、邮箱、身份证脱敏
* @param str 姓名或手机或邮箱或身份证
* @param type 数据类型
*/
export function publicEncrypt(str, type) {
if (!str) {
return ''
} else if (type == 'name') {
return str.substr(0, 1) + '*'
} else if (type == 'idCard') {
return str.replace(/^(.{6})(?:\d+)(.{4})$/, '$1********$2')
} else if (type == 'phone') {
return str.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
} else if (type == 'email') {
let count, emailArr, emailFront, emailBack;
emailArr = str.split('@');
emailFront = emailArr[0];
count = emailFront.length / 2;
emailFront = emailFront.substring(0, emailFront.length - count);
emailBack = emailArr[1];
return emailFront + '***@' + emailBack;
}
}
/**
* 根据value值筛选对应的label
* @param {Array} options - 原数组
* @param {string | Number} value - 表示
* @returns {string} - 返回后的汉字
*/
export function getLabelByValue(options = [], value, valueKey = 'value', labelKey = 'label') {
for (let i = 0; i < options.length; i++) {
// 动态使用传入的 valueKey 和 labelKey
if (options[i][valueKey] === value) {
return options[i][labelKey];
}
}
return null;
}
/**
* 将数组转换为字符串
* @param {Array} arr - 要转换的数组
* @param {string} delimiter - 用于连接数组元素的分隔符,默认为逗号
* @returns {string} - 转换后的字符串
*/
export function arrayToString(arr, delimiter = ',') {
return arr.join(delimiter);
}
/* 延时函数 */
export function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
/* 获取当前年月日 时分秒 */
export function getCurrentDate() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始需要加1
const day = String(date.getDate()).padStart(2, '0'); // 使用padStart补零
const hours = String(date.getHours()).padStart(2, '0'); // 补零
const minutes = String(date.getMinutes()).padStart(2, '0'); // 补零
const seconds = String(date.getSeconds()).padStart(2, '0'); // 补零
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
export function processFileUrl(fileUrl) {
let fileList = [];
if (typeof fileUrl === 'string' && fileUrl) {
// 如果 fileUrl 是一个字符串,则按照逗号分割成数组
const urls = fileUrl.split(',').map(url => url.trim()); // 去除每个 URL 前后的空白字符
fileList = urls.map(url => ({
url,
success: 'success',
name: 'fileUrl'
}));
}
return fileList;
}
// 密码强校验
export function isPasswordComplex(password) {
// 长度在8位以上并且包含大小写字母、数字和特殊符号
return /^(?=.*[A-Za-z])(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&*!])[A-Za-z\d@#$%^&*!]{8,}$/.test(password);
}
// 手机号码校验
export function isPhoneNumberValid(phoneNumber) {
// 匹配国内常见的手机号格式
return /^1[3-9]\d{9}$/.test(phoneNumber);
}
// 身份证校验函数
export function isValidIdCard (idCard) {
if (typeof idCard !== 'string') {
return false;
}
// 定义省份代码
const provinceCodes = {
11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古",
21: "辽宁", 22: "吉林", 23: "黑龙江",
31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东",
41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南",
50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏",
61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆",
71: "台湾", 81: "香港", 82: "澳门", 91: "国外"
};
// 检查长度
if (!/^\d{17}(\d|X|x)$/.test(idCard)) {
return false;
}
// 验证省份代码
const provinceCode = idCard.substring(0, 2);
if (!provinceCodes[provinceCode]) {
return false;
}
// 验证出生日期
const birthDate = idCard.substring(6, 14);
const birthYear = parseInt(birthDate.substring(0, 4), 10);
const birthMonth = parseInt(birthDate.substring(4, 6), 10);
const birthDay = parseInt(birthDate.substring(6, 8), 10);
const birthDateObject = new Date(birthYear, birthMonth - 1, birthDay);
if (
birthDateObject.getFullYear() !== birthYear ||
birthDateObject.getMonth() + 1 !== birthMonth ||
birthDateObject.getDate() !== birthDay
) {
return false;
}
// 验证校验码
const weightFactors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
const sum = idCard
.substring(0, 17)
.split('')
.reduce((acc, num, index) => acc + parseInt(num, 10) * weightFactors[index], 0);
const checkCode = checkCodes[sum % 11];
return checkCode === idCard[17].toUpperCase();
};

38
utilsRc/config.js Normal file
View File

@@ -0,0 +1,38 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2022-12-28 13:59:09
* @LastEditors: shirlwang
*/
// 应用全局配置
let exports = {
// baseUrl: 'http://127.0.0.1:8903', // 本地开发
// baseUrl: 'http://172.20.0.104:8903', // xubaiqi 地址
// baseUrl: 'http://172.20.1.76:8903', // 演示环境内网
// baseUrl: 'http://36.140.162.216:8904/prod-api', // 演示环境外网
// baseUrl: 'http://10.160.0.5:8903', // 演示环境外网
// baseUrl: 'http://111.34.80.140:8081/prod-api', // 正式环境(不要轻易连接)
baseUrl: 'http://10.160.0.5:8907', // 正式环境在济南人才上部署(不要轻易连接)
// 应用信息
appInfo: {
// 应用名称
name: "泉就业H5",
// 应用版本
version: "1.1.0",
// 应用logo
logo: "/static/logo.png",
}
}
export default exports

19
utilsRc/constant.js Normal file
View File

@@ -0,0 +1,19 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:53:48
* @LastEditors: lip
*/
const constant = {
avatar: 'vuex_avatar',
name: 'vuex_name',
roles: 'vuex_roles',
permissions: 'vuex_permissions',
type: 'vuex_type',
phonenumber: 'vuex_phonenumber',
nick: 'vuex_nick',
userId: 'vuex_userId',
handlerData: 'vuex_handlerData',
}
export default constant

13
utilsRc/errorCode.js Normal file
View File

@@ -0,0 +1,13 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:56:30
* @LastEditors: lip
*/
export default {
'401': '您的登录状态已过期,请重新登录',
'403': '当前操作没有权限',
'404': '访问资源不存在',
'default': '系统未知错误,请反馈给管理员'
}

60
utilsRc/plugins/auth.js Normal file
View File

@@ -0,0 +1,60 @@
import store from '@/store'
function authPermission(permission) {
const all_permission = "*:*:*"
const permissions = store.getters && store.getters.permissions
if (permission && permission.length > 0) {
return permissions.some(v => {
return all_permission === v || v === permission
})
} else {
return false
}
}
function authRole(role) {
const super_admin = "shequn"
const roles = store.getters && store.getters.roles
if (role && role.length > 0) {
return roles.some(v => {
return super_admin === v || v === role
})
} else {
return false
}
}
export default {
// 验证用户是否具备某权限
hasPermi(permission) {
return authPermission(permission)
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) {
return permissions.some(item => {
return authPermission(item)
})
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) {
return permissions.every(item => {
return authPermission(item)
})
},
// 验证用户是否具备某角色
hasRole(role) {
return authRole(role)
},
// 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr(roles) {
return roles.some(item => {
return authRole(item)
})
},
// 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd(roles) {
return roles.every(item => {
return authRole(item)
})
}
}

14
utilsRc/plugins/index.js Normal file
View File

@@ -0,0 +1,14 @@
import tab from './tab'
import auth from './auth'
import modal from './modal'
export default {
install(Vue) {
// 页签操作
Vue.prototype.$tab = tab
// 认证对象
Vue.prototype.$auth = auth
// 模态框对象
Vue.prototype.$modal = modal
}
}

View File

@@ -0,0 +1,50 @@
import ULoadingPage from 'uview-ui/components/u-loading-page/u-loading-page'; // 确保正确引入组件
export default {
install(Vue) {
// 注册 u-loading-page 组件为全局组件
Vue.component('u-loading-page', ULoadingPage);
// 用于存储全局的 loading 组件实例
let loadingInstance = null;
// 创建一个全局的显示 loading 的方法
Vue.prototype.$showLoading = function () {
// 如果没有创建过实例,则创建一个
if (!loadingInstance) {
const LoadingConstructor = Vue.extend({
data() {
return {
loading: true, // 控制 loading 显示的状态
};
},
render(h) {
return h('u-loading-page', {
props: {
loading: this.loading,
loadingText: '',
loadingColor: "#000",
iconSize: '58rpx',
},
style: {
zIndex: '200',
opacity: 0.7
}
});
}
});
loadingInstance = new LoadingConstructor();
loadingInstance.$mount(); // 手动挂载实例
document.body.appendChild(loadingInstance.$el); // 将组件挂载到 body
}
loadingInstance.loading = true; // 显示 loading
};
// 创建一个全局的隐藏 loading 的方法
Vue.prototype.$hideLoading = function () {
if (loadingInstance) {
loadingInstance.loading = false; // 隐藏 loading
}
};
},
};

74
utilsRc/plugins/modal.js Normal file
View File

@@ -0,0 +1,74 @@
export default {
// 消息提示
msg(content) {
uni.showToast({
title: content,
icon: 'none'
})
},
// 错误消息
msgError(content) {
uni.showToast({
title: content,
icon: 'error'
})
},
// 成功消息
msgSuccess(content) {
uni.showToast({
title: content,
icon: 'success'
})
},
// 隐藏消息
hideMsg(content) {
uni.hideToast()
},
// 弹出提示
alert(content) {
uni.showModal({
title: '提示',
content: content,
showCancel: false
})
},
// 确认窗体
confirm(content) {
return new Promise((resolve, reject) => {
uni.showModal({
title: '系统提示',
content: content,
cancelText: '取消',
confirmText: '确定',
success: function(res) {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
},
// 提示信息
showToast(option) {
if (typeof option === "object") {
uni.showToast(option)
} else {
uni.showToast({
title: option,
icon: "none",
duration: 2500
})
}
},
// 打开遮罩层
loading(content) {
uni.showLoading({
title: content,
icon: 'none'
})
},
// 关闭遮罩层
closeLoading() {
uni.hideLoading()
}
}

30
utilsRc/plugins/tab.js Normal file
View File

@@ -0,0 +1,30 @@
export default {
// 关闭所有页面,打开到应用内的某个页面
reLaunch(url) {
return uni.reLaunch({
url: url
})
},
// 跳转到tabBar页面并关闭其他所有非tabBar页面
switchTab(url) {
return uni.switchTab({
url: url
})
},
// 关闭当前页面,跳转到应用内的某个页面
redirectTo(url) {
return uni.redirectTo({
url: url
})
},
// 保留当前页面,跳转到应用内的某个页面
navigateTo(url) {
return uni.navigateTo({
url: url
})
},
// 关闭当前页面,返回上一页面或多级页面
navigateBack() {
return uni.navigateBack()
}
}

107
utilsRc/request.js Normal file
View File

@@ -0,0 +1,107 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-05-12 08:44:49
* @LastEditors: shirlwang
*/
import store from './store/index.js'
import configRc from './config.js'
import { getToken } from '@/utilsRc/auth'
import errorCode from '@/utilsRc/errorCode'
import { toast, showConfirm, tansParams } from '@/utilsRc/common'
let timeout = 10000
const baseUrl = configRc.baseUrl
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
config.header['Authorization'] = 'Bearer ' + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjoxIiwicm5TdHIiOiJVMDRocERSZjdZMXJUbUxXb05uOUpzYUdDZzBNazJJQSIsInVzZXJJZCI6MX0.LZ29vvA4tK3b9Hki4nU9Jb1himXZM2AEOue3CMRY95w'
// get请求映射params参数
if (config.params) {
let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1)
config.url = url
}
return new Promise((resolve, reject) => {
uni.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: baseUrl + config.url,
// url: 'https://gccrcdh.sd-talent.cn:80/zhq' + config.url,
data: config.data,
header: config.header,
dataType: 'json'
}).then(response => {
let res = response.data
let error = response.errMsg!='request:ok'
if (error) {
toast('网络出小差,请稍后再试')
reject('网络出小差,请稍后再试')
return
}
const code = res.code || 200
console.log(code, 'const code = res.code || 200')
const msg = errorCode[code] || res.msg || errorCode['default']
const isShowModel = getApp().globalData.isShowModel
if (code === 200) {
resolve(res)
}else if (code === 401) {
if(isShowModel === false) {
getApp().globalData.isShowModel = true
showConfirm('您好!登录后,您才可以继续操作。', '取消', '去登录').then(res => {
if (res.confirm) {
getApp().globalData.isShowModel = false
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login/login-one' })
})
} else if(res.cancel) {
getApp().globalData.isShowModel = false
uni.navigateBack()
}
})
}
// reject(code)
}
// if (code === 401) {
// showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
// if (res.confirm) {
// store.dispatch('LogOut').then(res => {
// uni.reLaunch({ url: '/page_other/login/index' })
// })
// }
// })
// reject('无效的会话,或者会话已过期,请重新登录。')
// } else
else if (code === 500) {
toast(msg)
reject('500')
} else if (code !== 200 && code !== 9999) {
// 9999是正常的业务状态码不应该被当作错误处理
toast(msg)
reject(code)
}
resolve(res.data)
})
.catch(error => {
console.log(error, 'error')
let message = error.errMsg
if (message === 'Network Error') {
message = '网络出小差,请稍后再试'
} else if (message.includes('timeout')) {
message = '系统接口请求超时'
} else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常'
}
toast(message)
reject(error)
})
})
}
export default request

44
utilsRc/storage.js Normal file
View File

@@ -0,0 +1,44 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:56:55
* @LastEditors: lip
*/
import constant from './constant'
// 存储变量名
let storageKey = 'storage_data'
// 存储节点变量名
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions, constant.type, constant
.phonenumber,
constant.userId,
constant.handlerData,
constant.nick
]
// 存储的数据
let storageData = uni.getStorageSync(storageKey) || {}
const storage = {
set: function(key, value) {
if (storageNodeKeys.indexOf(key) != -1) {
let tmp = uni.getStorageSync(storageKey)
tmp = tmp ? tmp : {}
tmp[key] = value
uni.setStorageSync(storageKey, tmp)
}
},
get: function(key) {
return storageData[key] || ""
},
remove: function(key) {
delete storageData[key]
uni.setStorageSync(storageKey, storageData)
},
clean: function() {
uni.removeStorageSync(storageKey)
}
}
export default storage

19
utilsRc/store/getters.js Normal file
View File

@@ -0,0 +1,19 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 15:59:34
* @LastEditors: lip
*/
const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
roles: state => state.user.roles,
permissions: state => state.user.permissions,
userId: state => state.user.userId,
handlerData: state => state.user.handlerData,
nick: state => state.user.nick,
showExitPopup: state => state.user.showExitPopup,
publicKey: state => state.user.publicKey
}
export default getters

18
utilsRc/store/index.js Normal file
View File

@@ -0,0 +1,18 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 09:04:34
* @LastEditors: shirlwang
*/
import user from '@/utilsRc/store/modules/user'
import getters from './getters'
// src/store/index.js
import { createStore } from 'vuex';
let store = createStore({
modules: {
user
},
getters
});
export default store;

View File

@@ -0,0 +1,233 @@
import config from '@/config'
import storage from '@/utilsRc/storage'
import constant from '@/utilsRc/constant'
import {
login,
logout,
getInfo,
register,
smsLogin,
wechatLogin
} from '@/apiRc/login'
import {
getToken,
setToken,
removeToken
} from '@/utilsRc/auth'
import {sm2} from 'sm-crypto'
// const sm2 = require('sm-crypto').sm2
const baseUrl = config.baseUrl
const user = {
state: {
token: getToken(),
name: storage.get(constant.name),
avatar: storage.get(constant.avatar),
roles: storage.get(constant.roles),
permissions: storage.get(constant.permissions),
type: storage.get(constant.type),
phonenumber: storage.get(constant.phonenumber),
nick: storage.get(constant.nick),
userId: storage.get(constant.userId),
handlerData: storage.get(constant.handlerData),
showExitPopup: false,
publicKey: '04970A174A090FCCD2B2503DD978152ACB906919245E4C8F237BE290E6E72334DDD89B857177A11C609FAA62CC62AD75D4BB1395E2A22F2663357A5D3EF9B1C1B8',
},
mutations: {
SET_TOKEN: (state, token) => {
state.token = token
// 同时更新存储中的token
setToken(token)
},
SET_NAME: (state, name) => {
state.name = name
storage.set(constant.name, name)
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
storage.set(constant.avatar, avatar)
},
SET_ROLES: (state, roles) => {
state.roles = roles
storage.set(constant.roles, roles)
},
SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions
storage.set(constant.permissions, permissions)
},
SET_TYPE: (state, type) => {
state.type = type
storage.set(constant.type, type)
},
SET_PHONENUMBER: (state, phonenumber) => {
state.phonenumber = phonenumber
storage.set(constant.phonenumber, phonenumber)
},
SET_NICK: (state, nick) => {
state.nick = nick
storage.set(constant.nick, nick)
},
SET_USER_ID: (state, userId) => {
state.userId = userId
storage.set(constant.userId, userId)
},
// 存储经办人信息
SET_HAND_LER(state, data) {
state.handlerData = data
storage.set(constant.handlerData, data)
},
SET_SHOWEXITPOPUP(state, type) {
state.showExitPopup = type
}
},
actions: {
// 登录
Login({
commit,
state
}, userInfo) {
return new Promise((resolve, reject) => {
const info = JSON.parse(JSON.stringify(userInfo))
info.password = '04' + sm2.doEncrypt(info.password, state.publicKey, 0)
info.username = '04' + sm2.doEncrypt(info.username, state.publicKey, 0)
login(info).then(res => {
console.log('登录接口返回:', res);
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 登录
SMSLogin({
commit
}, userInfo) {
return new Promise((resolve, reject) => {
smsLogin(userInfo).then(res => {
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 登录
WXLogin({
commit
}, userInfo) {
return new Promise((resolve, reject) => {
wechatLogin(userInfo).then(res => {
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
resolve()
}).catch(error => {
reject(error)
})
})
},
// 注册
Register({
commit
}, userInfo) {
const username = userInfo.username
const password = userInfo.password
const code = userInfo.code
const uuid = userInfo.uuid
const userType = userInfo.userType
const userNumber = userInfo.userNumber
return new Promise((resolve, reject) => {
register(username, password, code, uuid, userType, userNumber).then(res => {
uni.showToast({
title: `账号${username}注册成功`,
icon: 'none'
})
resolve()
}).catch(error => {
reject(error)
})
})
},
// 获取用户信息
GetInfo({
commit,
state
}) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
const user = res.data.user
const avatar = (user == null || user.avatar == "" || user.avatar == null) ?
"https://rc.jinan.gov.cn/qcwjyH5/static/icon/my.png" : user.avatar
const username = (user == null || user.userName == "" || user.userName ==
null) ? "" : user.userName
const usertype = (user == null || user.userType == "" || user.userType ==
null) ? "" : user.userType
const usernumber = (user == null || user.phonenumber == "" || user
.phonenumber == null) ? "" : user.phonenumber
const nick = (user == null || user.nickName == "" || user.nickName == null) ?
"" : user.nickName
const userId = (user == null || user.userId == "" || user.userId == null) ? "" :
user.userId
if (res.data.roles && res.data.roles.length > 0) {
commit('SET_ROLES', res.data.roles)
commit('SET_PERMISSIONS', res.data.permissions)
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}
commit('SET_NAME', username)
commit('SET_AVATAR', avatar)
commit('SET_TYPE', usertype)
commit('SET_PHONENUMBER', usernumber)
commit('SET_NICK', nick)
commit('SET_USER_ID', userId)
// commit('SET_HAND_LER', {
// deptName: user.dept.deptName,
// nickName: user.nickName
// })
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 退出系统
LogOut({
commit,
state
}) {
return new Promise((resolve, reject) => {
logout(state.token).then(() => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
commit('SET_PERMISSIONS', [])
commit('SET_TYPE', '')
commit('SET_NICK', '')
commit('SET_PHONENUMBER', '')
commit('SET_USER_ID', '')
commit('SET_SHOWEXITPOPUP', false)
removeToken()
storage.clean()
resolve()
}).catch(error => {
reject(error)
})
})
}
}
}
export default user