updpassword.vue
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<div class="container" style="margin: 10px;">
<el-form ref="model" :model="model" label-width="80px">
<el-form-item label="原密码">
<el-input v-model="model.oldpassword"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input v-model="model.newpassword"></el-input>
</el-form-item>
<el-form-item >
<el-button type="success" @click="UpdPwd">确认修改</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import {
UpdPassword
} from '../../api/user.js'
import {removeToken,removeUser} from '../../utils/auth.js'
export default {
data() {
return {
model: {
"id": 0,
"oldpassword": '',
"newpassword": ''
}
}
},
created() {
},
methods: {
UpdPwd() {
let GetRole = localStorage.getItem("userRole")
console.log('www',GetRole)
let jsondata=GetRole
console.log('用户信息',jsondata)
this.model.id=jsondata
if(this.model.oldpassword==''){
this.$message.error('请输入原密码')
return
}
if(this.model.newpassword==''){
this.$message.error('请输入新密码')
return
}
UpdPassword(this.model).then(res => {
if (res.data.code == 200) {
this.$message.success('密码修改成功')
this.model.oldpassword=''
this.model.newpassword=''
removeToken()
removeUser()
localStorage.removeItem('userRole')
setTimeout(()=>{
this.$router.push({
path: '/login'
})
},2000)
} else {
this.$message.error(res.data.message)
}
})
}
}
}
</script>
<style>
</style>