web
2025-03-17 56d13900e2d74eeb9e22a9d86dc929640a676f6f
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
    <div class="user-container">
        <div class="user-content">
            <div class="title">个人信息</div>
            <div class="user-form">
                <div class="item">
                    <div class="name">头像:</div>
                    <div class="image">
                        <img :src="preUrl + form.headImg" class="userImage"/>
                    </div>
                </div>
                <div class="item">
                    <div class="name">用户名:</div>
                    <div class="info">{{ form.userName }}</div>
                </div>
                <div class="item">
                    <div class="name">昵称:</div>
                    <div class="info">{{ form.nickName }}</div>
                </div>
                <div class="item">
                    <div class="name">联系方式:</div>
                    <div class="info">{{ form.contact }}</div>
                </div>
                <div class="item">
                    <div class="name">邮箱:</div>
                    <div class="info">{{ form.email }}</div>
                </div>
                <div class="item">
                    <div class="name">密码:</div>
                    <div class="info pwd">
                        ********
                        <el-button type="plain" @click="isShow = true">修改密码</el-button>
                    </div>
                </div>
            </div>
            <div class="bottom">
                <el-button type="primary" @click="loginOut">退出登录</el-button>
            </div>
            <div class="footer"></div>
        </div>
        <el-dialog v-model="isShow">
            <div class="title">修改密码</div>
            <el-form model="pwdForm" :rules="rules">
                <el-form-item prop="oldPassword" label="旧密码">
                    <el-input v-model="pwdForm.oldPassword" placeholder="请输入旧密码"></el-input>
                </el-form-item>
                <el-form-item prop="newPassword" label="新密码">
                    <el-input v-model="pwdForm.newPassword"  placeholder="请输入新密码"></el-input>
                </el-form-item>
                <el-form-item class="handel-btn">
                    <el-button  @click="cancel()">取消</el-button>
                    <el-button type="primary"  @click="modifyPwd()">提交</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script setup>
import {userDetail} from '@/api/login'
const { proxy } = getCurrentInstance();
const form = ref({})
import  { PREURL } from "@/config/index";
const preUrl = ref(PREURL)
const getUserInfo = async () =>{
    let id = JSON.parse(localStorage.getItem('id'))
    await userDetail().get(id).then(res => {
        form.value = res.data
    })
}
//修改密码
const rules  = ref({
    oldPassword: [{ required: true, trigger: "blur", message: "请输入旧密码" }],
    newPassword: [{ required: true, trigger: "blur", message: "请输入新密码" }],
})
const isShow = ref(false)
const pwdForm = ref({
    oldPassword:'',
    newPassword:'',
})
const modifyPwd = async () =>{
    await userDetail().setPsw(pwdForm.value).then(res => {
        if(res.code == 200){
            proxy.$modal.msgSuccess("修改成功");
        }
    })
}
const cancel = () =>{
    isShow.value = false
    pwdForm.value = {}
}
onMounted(() =>{
    getUserInfo()
})
 
</script>
 
<style lang="scss" scoped>
.user-container{
    width: 100%;
    padding: 1% 12%;
    .user-content{
        width: 100%;
        background: rgba(242, 246, 248, 0.4);
        border-radius: 20px;
        .title{
            width: 100%;
            height:80px;
            background: rgba(112, 184, 225, 0.13);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 30px;
            color: #262627;
            border-top-left-radius: 20px;
            border-top-right-radius: 20px;
        }
        .user-form{
            width: 100%;
            height:550px;
            padding: 10px 80px;
            .item{
                width: 100%;
                height: 16%;
                display: flex;
                justify-content:flex-start;
                align-items:center;
                margin-left: 10%;
                .name{
                    width:90px;
                    font-size: 20px;
                    color: #626268;
                    font-weight: bold;
                    margin-right: 20px;
                }
                .info{
                    width: 70%;
                    height: 35%;
                    display: flex;
                    align-items:center;
                    border-bottom: 1px solid rgba(29, 33, 41, 0.27);
                    font-size: 18px;
                    color: rgba(66, 66, 67, 0.98);
                    font-weight: bold;
                }
                .pwd{
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    .el-button{
                        margin-bottom: 10px;
                    }
                }
            }
        }
        .bottom{
            width: 100%;
            height:80px;
            //background: rgba(112, 184, 225, 0.13);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 30px;
            color: #262627;
        }
        .footer{
            width: 100%;
            height:100px;
            background: rgba(112, 184, 225, 0.13);
            border-bottom-left-radius: 20px;
            border-bottom-right-radius: 20px;
        }
    }
    :deep(.el-dialog){
        width: 40%;
        height:40vh;
        padding: 10px 200px;
        .title{
            width: 100%;
            height: 50px;
            display: flex;
            justify-content:center;
            align-items: center;
            font-weight: bold;
            font-size: 20px;
            margin-bottom: 50px;
        }
        .el-form{
            .el-form-item{
                margin-bottom: 30px;
            }
            .handel-btn{
                width: 50%;
                margin: 0 auto;
                .el-button{
                    width: 40%;
                    height: 35px;
                    display: flex;
                    justify-content:center;
                    align-items: center;
                    font-size: 18px;
                    margin: 20px auto;
                    letter-spacing: 6px;
                }
            }
        }
    }
}
.image{
    border:1px solid rgba(112, 184, 225, 0.32);
    border-radius: 10px;
    padding: 5px;
}
.userImage{
    width: 100px;
    max-height:100px;
}
</style>