bug修改

This commit is contained in:
jiang 2024-07-31 15:06:58 +08:00
parent bc13169c25
commit 41579ccd28
6 changed files with 104 additions and 34 deletions

View File

@ -13,6 +13,18 @@ export function login(data) {
})
}
export function isLogin(data) {
return request({
url: '/auth/isLogin',
headers: {
isToken: false,
repeatSubmit: false
},
method: 'post',
data: data
})
}
export function getPhoneCode(payload) {
return request({
url: '/auth/getPhoneCode',

View File

@ -1,4 +1,4 @@
import { login, logout, getInfo, refreshToken, getPhoneCode } from '@/api/login'
import { login, logout, getInfo, refreshToken, getPhoneCode, isLogin } from '@/api/login'
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
const user = {
@ -36,6 +36,34 @@ const user = {
},
actions: {
IsLogin({ commit }, userInfo) {
let payload = {}
const loginType = userInfo.loginType
if (loginType === 'password') {
payload = {
username: userInfo.username.trim(),
password: userInfo.password,
uuid: userInfo.uuid,
code: userInfo.code,
loginType: loginType
}
} else if (loginType === 'mobile') {
payload = {
mobile: userInfo.mobile.trim(),
verificationCode: userInfo.verificationCode,
uuid: userInfo.uuid,
code: userInfo.code,
loginType: loginType
}
}
return new Promise((resolve, reject) => {
isLogin(payload).then(res => {
resolve(res);
}).catch(error => {
reject(error)
})
})
},
// 登录
Login({ commit }, userInfo) {
let payload = {}
@ -78,7 +106,6 @@ const user = {
code: userInfo.code,
mobileCodeType: userInfo.mobileCodeType
}
console.log(payload)
return new Promise((resolve, reject) => {
getPhoneCode(payload).then(res => {
resolve()

View File

@ -7,7 +7,8 @@ import { blobValidate, tansParams } from '@/utils/bonus'
import cache from '@/plugins/cache'
import { saveAs } from 'file-saver'
import { decryptCBC, encryptCBC } from '@/utils/aescbc'
import { hashWithSM3AndSalt } from '@/utils/sm' // 导入SM3哈希函数
import { hashWithSM3AndSalt } from '@/utils/sm'
import data from '@/views/system/dict/data.vue' // 导入SM3哈希函数
let downloadLoadingInstance
export let isRelogin = { show: false }
@ -117,12 +118,12 @@ service.interceptors.request.use(
service.interceptors.response.use(
(res) => {
// 自动解密响应数据
if (res.data.decrypt) {
/* if (res.data.decrypt) {
res.data = JSON.parse(decryptCBC(res.data.data))
} else if (typeof res.data.code === 'undefined') {
res.data = res.data.data
}
} */
console.log(res.data.code)
// 获取状态码
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
@ -150,6 +151,7 @@ service.interceptors.response.use(
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
console.log(data)
Message({ message: msg, type: 'error' })
return Promise.reject(new Error(msg))
} else if (code === 601) {

View File

@ -67,7 +67,7 @@
</div>
</el-form-item>
<el-form-item prop="verificationCode">
<el-input v-model="loginForm.verificationCode" :readonly="!isSendingCode" placeholder="请输入验证码">
<el-input v-model="loginForm.verificationCode" placeholder="请输入验证码">
<template slot="append">
<el-button
type="primary"
@ -95,7 +95,7 @@
size="medium"
type="primary"
style="width: 100%;"
@click.native.prevent="handleLogin"
@click.native.prevent="isLogin"
>
<span v-if="!loading"> </span>
<span v-else> 中...</span>
@ -225,13 +225,42 @@ export default {
}
})
},
isLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
if (this.loginForm.rememberMe) {
Cookies.set('username', this.loginForm.username, { expires: 30 })
Cookies.set('password', encrypt(this.loginForm.password), { expires: 30 })
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
} else {
Cookies.remove('username')
Cookies.remove('password')
Cookies.remove('rememberMe')
}
let that = this
this.loginForm.loginType = this.loginMethod
this.$store.dispatch('IsLogin', this.loginForm)
.then(res => {
if (res.data) {
this.$modal.confirm('账号已在其他地方登录是否继续登录!!!!').then(function() {
return that.handleLogin()
}).then(() => {
}).catch(() => {
})
} else {
that.handleLogin()
}
})
.catch(() => {
this.loading = false
if (this.captchaEnabled) this.getCode()
})
}
})
},
sendCode() {
let form = new FormData
form.append('13123', '123123')
console.log(form.getAll("13123"))
if (!this.loginForm.code) {
this.$message.error('请先填写验证码')
return
@ -249,7 +278,7 @@ export default {
this.countdown -= 1
if (this.countdown <= 0) {
clearInterval(timer)
/* this.isSendingCode = false */
this.isSendingCode = false
}
}, 1000)
})
@ -259,12 +288,12 @@ export default {
if (this.captchaEnabled) {
this.getCode()
}
//
this.isSendingCode = false
this.countdown = 0
})
},
}
,
toggleLoginMethod() {
this.loginMethod = this.loginMethod === 'password' ? 'mobile' : 'password'
this.loginForm.username = ''

View File

@ -56,19 +56,19 @@
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
<el-table-column prop="status" label="状态" width="100">
<el-table-column prop="deptName" label="部门名称" min-width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" min-width="200"></el-table-column>
<el-table-column prop="status" label="状态" min-width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
<el-table-column label="创建时间" align="center" prop="createTime" min-width="200">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" min-width="200" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"

View File

@ -56,26 +56,26 @@
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column>
<el-table-column prop="icon" label="图标" align="center" width="100">
<el-table-column prop="menuName" label="菜单名称" align="center" :show-overflow-tooltip="true" width="160"></el-table-column>
<el-table-column prop="icon" label="图标" align="center" min-width="100">
<template slot-scope="scope">
<svg-icon :icon-class="scope.row.icon" />
</template>
</el-table-column>
<el-table-column prop="orderNum" label="排序" width="60"></el-table-column>
<el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="status" label="状态" width="80">
<el-table-column prop="orderNum" align="center" label="排序" min-width="60"></el-table-column>
<el-table-column prop="perms" align="center" label="权限标识" min-width="60" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="component" align="center" label="组件路径" :show-overflow-tooltip="true" min-width="60"></el-table-column>
<el-table-column prop="status" align="center" label="状态" min-width="60">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime">
<el-table-column label="创建时间" align="center" min-width="60" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" min-width="60" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"