jiangping
2023-10-26 519b464e4ed3d07bd5aa23a4067e5869058de2e5
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="password">
        <view class="password_tip">
            <image src="@/static/password_ic_tip@2x.png" alt="" />
            <text>密码由6-20个英文字母、数字或符号组成</text>
        </view>
        <view class="password_list">
            <view class="password_list_item">
                <text>当前绑定</text>
                <view class="password_list_item_box">
                    <input type="number" disabled v-model="userInfo.companyUser.phone" maxlength="11">
                </view>
            </view>
            <view class="password_list_item">
                <text>验证码</text>
                <view class="password_list_item_box">
                    <input type="text" v-model="form.verificationCode" maxlength="4" placeholder="请输入手机验证码">
                    <p @click="getVerificationCode" v-if="!code.isOpen">获取验证码</p>
                    <p v-else>{{code.num}}</p>
                </view>
            </view>
            <view class="password_list_item">
                <text>新密码</text>
                <view class="password_list_item_box">
                    <input type="text" v-model="form.newPhone" maxlength="11" placeholder="请输入新密码">
                </view>
            </view>
            <view class="password_list_item">
                <text>确认密码</text>
                <view class="password_list_item_box">
                    <input type="text" v-model="form.newPhone" maxlength="11" placeholder="再次输入新密码">
                </view>
            </view>
        </view>
        <view class="password_footer">
            <button v-preventReClick class="password_footer_submit" @click="submit">
                <text>完成</text>
            </button>
        </view>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    import { phoneRegular } from '@/common/config.js'
    export default {
        data() {
            return {
                form: {
                    newPhone: '',
                    verificationCode: ''
                },
                code: {
                    num: 60,
                    isOpen: false,
                    timer: 0
                }
            };
        },
        computed: mapState([
            'userInfo'
        ]),
        methods: {
            // 获取验证码
            getVerificationCode() {
                this.code.isOpen = true
                this.code.timer = setInterval(() => {
                    if (this.code.num === 0) {
                        clearInterval(this.code.timer)
                        this.code.isOpen = false
                        this.code.num = 60
                    }
                    this.code.num = this.code.num - 1
                }, 1000)
            },
            // 提交修改
            submit() {
                // if (!this.form.newPhone) {
                //     uni.showToast({ title: '新手机号不能为空', icon: 'none', duration: 2000 });
                // } else if (!phoneRegular.test(this.form.newPhone)) {
                //     uni.showToast({ title: '手机号不合法', icon: 'none', duration: 2000 });
                // } else if (!this.form.verificationCode) {
                //     uni.showToast({ title: '验证码不能为空', icon: 'none', duration: 2000 });
                // } else {
                //     console.log('可以提交')
                // }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .password {
        width: 100%;
        .password_tip {
            padding: 20rpx 30rpx;
            display: flex;
            background: #F7F7F7;
            box-sizing: border-box;
            image {
                width: 24rpx;
                height: 24rpx;
                margin-right: 10rpx;
                margin-top: 8rpx;
            }
            text {
                font-size: 24rpx;
                font-weight: 400;
                color: #666666;
            }
        }
        .password_list {
            padding: 0 30rpx;
            .password_list_item {
                display: flex;
                align-items: center;
                height: 90rpx;
                border-bottom: 1rpx solid #E5E5E5;
                text {
                    width: 150rpx;
                    flex-shrink: 0;
                    font-size: 30rpx;
                    font-weight: 400;
                    color: #222222;
                }
                .password_list_item_box {
                    display: flex;
                    justify-content: space-between;
                    flex: 1;
                    input {
                        border: none;
                        font-size: 30rpx;
                    }
                    input::-webkit-input-placeholder {
                        font-size: 28rpx;
                        font-weight: 400;
                        color: #B2B2B2;
                    }
                    p {
                        font-size: 26rpx;
                        font-weight: 400;
                        color: #4275FC;
                    }
                }
            }
        }
        .password_footer {
            margin-top: 80rpx;
            padding: 0 30rpx;
            .password_footer_submit {
                width: 100%;
                height: 88rpx;
                border: none;
                background: #4275FC;
                box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.08);
                border-radius: 8rpx;
                display: flex;
                align-items: center;
                justify-content: center;
                text {
                    font-size: 30rpx;
                    font-weight: 500;
                    color: #FFFFFF;
                }
            }
        }
    }
</style>