fix
Helius
2021-02-20 45fb4b11ad51bb38306765b11a6747402e382cee
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
<template>
    <!-- 修改密码 -->
    <view class="container">
        <view class="mt-30">
            <input placeholder="旧密码" type="password" v-model="oldPassword" placeholder-class="placeholder" class="input-group-row"/>
            <input placeholder="新密码" type="password" v-model="newPassword" placeholder-class="placeholder" class="input-group-row"/>
            <input placeholder="确认密码" type="password" v-model="password" placeholder-class="placeholder" class="input-group-row"/>
        </view>
        <button :disabled="isDisabled" class="blue-btn btn" @click="change">确认修改</button>
    </view>
</template>
 
<script>
    export default{
        data(){
            return{
                oldPassword:'',
                newPassword:'',
                password:'',
                isDisabled:false
            }
        },
        methods:{
            valid(){
                if(!this.oldPassword.trim()){
                    this.$toast.info('请输入旧密码');
                    return false;
                }
                if(!this.newPassword.trim()){
                    this.$toast.info('请输入新密码');
                    return false;
                }
                if(this.newPassword.trim()!==this.password.trim()){
                    this.$toast.info('两次密码不一致');
                    return false;
                }
            },
            change(){
                if(this.valid() === false){
                    return;
                }
                this.isDisabled = true;
                this.$httpUtils.request('/api/user/modifyPwd',{
                    oldPwd: this.oldPassword.trim(),
                    newPwd: this.newPassword.trim()
                },'post').then((res)=>{
                    if(res.status == 200){
                        uni.navigateBack();
                    }
                    this.$toast.info(res.info);
                    this.isDisabled = false;
                }).catch((err) => {
                    this.isDisabled = false;
                })
            }
        }
    }
</script>
 
<style>
    .container{
        padding: 0 15px;
    }
    .btn{
        margin-top: 40px;
    }
</style>