lin
2026-05-21 bc67eb7b9a46c3abedbde46c4989894e9712e99f
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
<template>
    <view>
        <view class="login-title">
            <view class="login-title-1">重置密码</view>
        </view>
        <view class="login-list">
            <view class="login-item">
                <input type="tel" v-model="formData.phone" placeholder="请输入手机号" />
            </view>
            <view class="login-item">
                <input type="password" v-model="formData.pass" placeholder="请输入新密码" />
            </view>
            <view class="login-item">
                <input type="password" v-model="formData.tpass" placeholder="请确认新密码" />
            </view>
            <view class="login-item">
                <input type="number" v-model="formData.code" maxlength="4" placeholder="请输入验证码" />
                <text class="code2" v-if="leftTime < 60">{{leftTime}}S后获取</text>
                <text class="code" @click="sendCode" v-else>获取验证码</text>
            </view>
        </view>
        <view class="loginBtn">
            <view class="loginBtn-desc">
                <image @click="agreeClick" class="loginBtn-icon" :src="!loginAct ? '/static/imgs/check.png' : '/static/imgs/checked.png'" mode=""></image>
                <text>我已阅读并同意</text>
                <text class="blue" @tap="goAgree(1)">《注册协议》</text>
                <text class="blue" @tap="goAgree(1)">《隐私政策》</text>
            </view>
            <view :class="loginAct ? 'login-btn active' : 'login-btn'" @click="findPassword">找回密码</view>
            <view class="loginDesc">
                <view class="fc" @tap="$util.goPages('/pages/login/login')">已有账号,立即登录</view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                loginAct: false,
                formData: {
                    phone: '',
                    pass: '',
                    tpass: '',
                    code: '',
                },
                phoneReg: /^\d{11}$/,
                leftTime: 60,
            }
        },
        onLoad(op) {
        },
        methods: {
            agreeClick () {
                this.loginAct = !this.loginAct
            },
            goAgree (t) {
                // #ifdef APP-PLUS
                let url = this.$baseUrl + '/?gp=' + t
                plus.runtime.openURL(url)
                // #endif
            },
            findPassword () {
                let t = this
                if(!t.loginAct) {
                    return uni.showToast({
                        title: '请阅读并同意协议政策',
                        icon: 'error'
                    })
                }
                if(t.formData.phone == '' || !t.phoneReg.test(t.formData.phone)){
                    return uni.showToast({
                        title: '手机号错误!',
                        icon: 'error',
                    })
                }
                if(t.formData.pass == ''){
                    return uni.showToast({
                        title: '请输入密码!',
                        icon: 'error',
                    })
                }
                if(t.formData.tpass == ''){
                    return uni.showToast({
                        title: '请输入确认密码!',
                        icon: 'error',
                    })
                }
                if(t.formData.tpass != t.formData.pass){
                    return uni.showToast({
                        title: '密码不一致!',
                        icon: 'error',
                    })
                }
                if(t.formData.code == ''){
                    return uni.showToast({
                        title: '请输入验证码!',
                        icon: 'error',
                    })
                }
                t.$util.post('User/findpass', this.formData).then(res => {
                    if(res.code == 1) {
                        uni.showToast({
                            title: res.msg || '操作成功'
                        })
                        setTimeout(() => {
                            t.$util.goPages('/pages/login/login')
                        }, 1500)
                    } else {
                        uni.showToast({
                            title: res.msg || '登录失败',
                            icon: 'error'
                        })
                    }
                })
            },
            sendCode () {
                let t = this
                if(this.formData.phone == '' || !this.phoneReg.test(t.formData.phone)){
                    return uni.showToast({
                        title: '手机号错误!',
                        icon: 'error',
                    })
                }
                if (this.leftTime < 60) {
                    return false
                }
                this.$util.post('Sms/sendVerificationCode', {phone: this.formData.phone}).then(res => {
                    if(res.code == 1){
                        console.log(res)
                        t.countDown()
                        uni.showToast({
                            title:'发送成功',
                            icon:'none'
                        })
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none',
                        })
                    }
                })
            },
            countDown() {
                this.leftTime--
                if (this.leftTime > 0) {
                    setTimeout(this.countDown, 1000)
                } else {
                    this.leftTime = 60
                }
            },
        }
    }
</script>
 
<style>
    @import url(/static/css/login.css);
</style>