罗广辉
2025-10-23 6d009f08368f93713c1ebeca6acde4163042faa4
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
<!-- 修改密码 -->
<template>
    <view class="container">
        <view class="detailBox">
            <div class="orderRow">
                <!-- type="password" :password-icon="passwordIcon" -->
                <div class="rowTitle">原始密码</div>
                <u-input input-align="right" v-model="passwordForm.oldPassword"   placeholder="请输入"
                    class="input-item" />
            </div>
            <div class="orderRow">
                <div class="rowTitle">新密码</div>
                <u-input input-align="right" v-model="passwordForm.newPassword" placeholder="请输入"
                    class="input-item" />
 
            </div>
            <div class="orderRow">
                <div class="rowTitle">确认密码</div>
                <u-input input-align="right" v-model="passwordForm.newPassword1"  placeholder="请输入"
                    class="input-item" />
            </div>
        </view>
        <view class="btngroup">
            <u-button color="#AEAEAE" class="custom-style" shape="circle" @click="reset">重置</u-button>
            <u-button color="#1D6FE9" class="custom-style" shape="circle" @click="submit">提交</u-button>
        </view>
    </view>
</template>
 
<script setup>
    import {
        useUserStore
    } from "@/store/index.js";
    import md5 from "js-md5";
    import {
        getUserInfo,
        updateInfo,
        updatePassword
    } from '@/api/user/index.js';
 const passwordIcon={
      show: 'fas fa-eye',     // 显示密码时的图标
      hide: 'fas fa-eye-slash' // 隐藏密码时的图标
    }
    const userStore = useUserStore();
    const passwordForm = ref({
        oldPassword: '',
        newPassword: '',
        newPassword1: '',
    });
    const clearForm = () => {
        passwordForm.value = {
            oldPassword: '',
            newPassword: '',
            newPassword1: '',
        };
    };
    const reset = () => {
        clearForm();
    };
    const submit = () => {
 
        updatePassword(md5(passwordForm.value.oldPassword),
            md5(passwordForm.value.newPassword),
            md5(passwordForm.value.newPassword1)).then(res => {
            if (res.data.code === 200) {
                uni.showToast({
                    title: '修改信息成功',
                    icon: 'none',
                    duration: 2000
                });
                clearForm();
                userStore.setUserInfo(null)
                uni.redirectTo({
                    url: '/pages/login/index'
                })
 
            } else {
                uni.showToast({
                    title: res.msg,
                    icon: 'none',
                    duration: 2000
                });
            }
 
        });
 
    };
    onShow(async () => {
        clearForm();
    });
</script>
 
<style lang="scss" scoped>
    .container {
 
        width: 100%;
 
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
 
        background: url('/src/static/images/user/allBg.svg') no-repeat center center;
        background-size: cover;
 
        background-attachment: fixed;
 
 
    }
 
    .detailBox {
        margin-top: 20px;
        width: 351px;
 
        min-height: 163px;
        background: #FFFFFF;
        border-radius: 6px;
 
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
 
        .orderRow {
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 48px;
            border-bottom: 1px solid #f5f5f5;
            color: #7b7b7b;
            padding: 0 12px;
 
            .rowTitle {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 15px;
                color: #222324;
                white-space: nowrap;
            }
 
            ::v-deep .u-input {
                border: none !important;
                background: transparent !important;
            }
 
            ::v-deep .u-input__input {
                border: none !important;
                box-shadow: none !important;
                background: transparent !important;
                padding: 0 !important;
                margin: 0 !important;
                height: auto !important;
            }
        }
    }
 
    .btngroup {
        display: flex;
        position: absolute;
        bottom:75px;
    }
 
    .u-button:first-child {
        margin-right: 15px;
    }
 
    .custom-style {
        width: 138px;
        height: 38px;
    }
</style>