cshenfu
2024-05-21 09d8c671d5e6e6045677bfb5218a5fb78c26aa0f
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<template>
    <view class="flex-col page">
        <!-- #ifdef APP-PLUS -->
        <view class="status_bar">
            <view class="top_view"></view>
        </view>
        <!-- #endif -->
        <u-icon name="arrow-left" class="back" color="#707070" size="40" @click="pageBack">
        </u-icon>
        <view class="flex-col group">
            <text class="text">忘记密码</text>
            <text class="text_1">请输入手机号验证码修改密码</text>
            <view class="flex-col group_1">
                <view class="flex-row section_1">
                    <u-icon name="account" color="#707070" size="30" style="margin-right: 12rpx;"></u-icon>
                    <input style="font-size: 28rpx;" type="text" v-model="form1.mobile" :maxlength="11"
                        placeholder="请输入您的手机号" placeholder-class="input-placeholder" />
                </view>
                <view class="justify-between section_2">
                    <view class="flex-row group_2">
                        <u-icon name="email" color="#707070" size="30" style="margin-right: 12rpx;"></u-icon>
                        <input style="font-size: 28rpx;" type="number" password v-model="form1.code" placeholder="验证码"
                            placeholder-class="input-placeholder" />
                    </view>
                    <view class="flex-col text-wrapper">
                        <!-- 验证码倒计时开始 -->
                        <vk-u-verification-code seconds="60" :mobile="form1.mobile" type="reset">
                        </vk-u-verification-code>
                        <!-- 验证码倒计时结束 -->
                    </view>
                </view>
                <view class="section_3 flex-row">
                    <u-icon name="lock" color="#707070" size="30" style="margin-right: 12rpx;"></u-icon>
                    <input style="font-size: 28rpx;" type="text" password v-model="form1.password" placeholder="请输入新密码"
                        placeholder-class="input-placeholder" />
                </view>
                <view class="section_3 flex-row">
                    <u-icon name="lock" color="#707070" size="30" style="margin-right: 12rpx;"></u-icon>
                    <input style="font-size: 28rpx;" type="text" password v-model="form1.password2"
                        placeholder="请再次输入新密码" placeholder-class="input-placeholder" />
                </view>
            </view>
            <view class="flex-col items-center button" @click="resetPassword">
                <text>确定</text>
            </view>
        </view>
    </view>
</template>
 
<script>
    var that; // 当前页面对象
    var vk; // vk依赖
    export default {
        data() {
            // 页面数据变量
            return {
                // init请求返回的数据
                data: {
 
                },
                // 表单请求数据
                form1: {
                    mobile: "",
                    password: "",
                    password2: "",
                    code: ""
                },
                scrollTop: 0,
                isRotate: false
            }
        },
        onPageScroll(e) {
            that.scrollTop = e.scrollTop;
        },
        // 监听 - 页面每次【加载时】执行(如:前进)
        onLoad(options) {
            that = this;
            vk = that.vk;
            //console.log("onLoad",options);
            that.init(options);
        },
        // 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
        onReady() {
 
        },
        // 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
        onShow() {
 
        },
        // 监听 - 页面每次【隐藏时】执行(如:返回)
        onHide() {
 
 
        },
        // 监听 - 页面下拉刷新
        onPullDownRefresh() {
            setTimeout(function() {
                uni.stopPullDownRefresh();
            }, 1000);
        },
        // 监听 - 页面触底部
        onReachBottom() {
 
        },
        // 监听 - 窗口尺寸变化(仅限:App、微信小程序)
        onResize() {
 
        },
        // 监听 - 点击右上角转发时
        onShareAppMessage(options) {
 
        },
        // 监听 - 页面创建时
        created() {
 
        },
        // 函数
        methods: {
            // 页面数据初始化函数
            init(options = {}) {
                console.log("init: ", options);
            },
            pageBack() {
                uni.navigateBack({
                    delta: 1
                })
            },
            pageTo(path) {
                vk.navigateTo(path);
            },
            resetPassword() {
                const { mobile, code, password, password2 } = that.form1;
                //重置密码
                if (that.isRotate) {
                    //判断是否加载中,避免重复点击请求
                    return false;
                }
                if (!vk.pubfn.checkStr(mobile, 'mobile')) {
                    vk.toast('请输入正确的手机号码', "none");
                    return;
                }
                if (!vk.pubfn.checkStr(password, 'pwd')) {
                    vk.toast('密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线', "none");
                    return;
                }
                if (!vk.pubfn.checkStr(password2, 'pwd')) {
                    vk.toast('密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线', "none");
                    return;
                }
                if (password != password2) {
                    vk.toast('两次密码必须相同!', "none");
                    return;
                }
                if (!vk.pubfn.checkStr(code, 'mobileCode')) {
                    vk.toast('验证码格式为6位数字', "none");
                    return;
                }
                that.isRotate = true;
                vk.userCenter.resetPasswordByMobile({
                    data: that.form1,
                    success: function(data) {
                        that.isRotate = false;
                        vk.alert("密码重置成功,新密码为:" + password, function() {
                            // 进入首页
                            vk.redirectTo("../index/index");
                        });
                    },
                    complete: function() {
                        that.isRotate = false;
                    }
                });
            }
        },
        // 过滤器
        filters: {
 
        },
        // 计算属性
        computed: {
 
        }
    }
</script>
<style lang="scss" scoped>
    .page {
        background-color: #f5f5f5;
        width: 100%;
        height: 100vh;
        overflow-y: auto;
 
        .back {
            padding: 30rpx 20rpx 0;
            height: 11.5vw;
        }
 
        .group {
            padding: 50rpx 30rpx 0;
            flex: 1 1 auto;
            overflow-y: auto;
 
            .text {
                color: rgb(51, 51, 51);
                font-size: 42rpx;
                line-height: 50rpx;
                letter-spacing: 2.1rpx;
                white-space: nowrap;
                font-weight: bold;
            }
 
            .text_1 {
                margin-top: 47rpx;
                color: rgb(153, 153, 153);
                font-size: 28rpx;
                line-height: 34rpx;
                white-space: nowrap;
            }
 
            .group_1 {
                margin-top: 141rpx;
 
                .section_1 {
                    padding: 34rpx 60rpx 32rpx;
                    color: rgb(153, 153, 153);
                    font-size: 28rpx;
                    line-height: 34rpx;
                    white-space: nowrap;
                    background-color: rgb(255, 255, 255);
                    border-radius: 50rpx;
                }
 
                .section_2 {
                    margin-top: 40rpx;
                    padding-left: 62rpx;
                    background-color: rgb(255, 255, 255);
                    border-radius: 50rpx;
 
                    .group_2 {
                        align-self: center;
                        color: rgb(153, 153, 153);
                        font-size: 28rpx;
                        line-height: 34rpx;
                        white-space: nowrap;
                    }
 
                    .text-wrapper {
                        padding: 34rpx 20rpx;
                        color: rgb(255, 255, 255);
                        font-size: 28rpx;
                        line-height: 34rpx;
                        white-space: nowrap;
                        background-color: rgb(51, 51, 51);
                        border-radius: 0px 50rpx 50rpx 0px;
                        height: 100rpx;
                    }
                }
 
                .section_3 {
                    margin-top: 40rpx;
                    color: rgb(153, 153, 153);
                    font-size: 28rpx;
                    line-height: 34rpx;
                    white-space: nowrap;
                    padding: 34rpx 64rpx 32rpx;
                    background-color: rgb(255, 255, 255);
                    border-radius: 50rpx;
                }
            }
 
            .button {
                margin-top: 118rpx;
                padding: 32rpx 0 30rpx;
                color: rgb(255, 255, 255);
                font-size: 32rpx;
                line-height: 38rpx;
                white-space: nowrap;
                background-color: rgb(51, 51, 51);
                border-radius: 50rpx;
            }
        }
    }
</style>