cuiqian2004
8 天以前 30311cd24ee3b1567ffafac002494bb67feda657
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
<template>
    <view class="pages-login-register">
        <view class="uni-panel-content items-center">
            <view class="login-content">
                <view class="justify-center">
                    <image class="title-img" src="/images/earth.svg" alt="svg 图片" />
                </view>
                <view class="login-form">
                    <view class="login-form-item ">
                        <image class="icon" src="/images/mobile.svg" alt="svg 图片" />
                        <input class="input" :focus="formData.accountFocus" name="account" comfirm-type="done"
                            type="text" v-model="form.account" placeholder="输入手机号码" />
                    </view>
                    <view class="login-form-item ">
                        <image class="icon" src="/images/chat.svg" alt="svg 图片" />
                        <input class="input" comfirm-type="done" v-model="form.mobileCode" placeholder="短信验证码" />
                        <view v-if="disabledSendCode" class="disabled">{{sendCodeCountdown}}秒后重新发送</view>
                        <a v-else @click="clickSendVerifyCode">发送验证码</a>
 
                    </view>
                    <view class="login-form-item ">
                        <image class="icon" src="/images/lock.svg" alt="svg 图片" />
                        <input class="input" :focus="formData.passwordFocus" name="password" password
                            comfirm-type="done" v-model="form.password" placeholder="设置登录密码" />
 
                    </view>
                    <view class=" login-form-item ">
                        <checkbox :value="checkedAgree" @change="handleAgreeChange" />已阅读并同意《<a
                            @click="clickUserAgreement">用户协议</a>》
                    </view>
                    <view class="button-group">
                        <a-button :disabled="disabledOk" type="primary" class="button" @click="clickOK">确认</a-button>
                    </view>
                </view>
 
            </view>
        </view>
    </view>
</template>
 
<script>
    import {
        showToast,
        showModal
    } from "@/comm/utils.js"
    import {
        Button
    } from 'antd-mobile-vue-next'
    export default {
        name: "PagesLoginRegister",
        components: {
            'a-button': Button
        },
        data() {
            return {
                form: {
                    account: '',
                    password: '',
                    mobileCode: "",
                },
                formData: {
                    accountFocus: true,
                    passwordFocus: false
                },
                disabledSendCode: false,
                sendCodeCountdown: 0,
                checkedAgree: false
            }
        },
        computed: {
            disabledOk() {
                let text = this.form.account.trim()
                if (!text) {
                    return true
                }
                text = this.form.password.trim()
                if (!text) {
                    return true
                }
                text = this.form.mobileCode.trim()
                if (!text) {
                    return true
                }
                return false
            }
        },
        methods: {
            setData(obj) {
                let that = this;
                let keys = [];
                let val, data;
 
                Object.keys(obj).forEach(function(key) {
                    keys = key.split(".");
                    val = obj[key];
                    data = that.$data;
                    keys.forEach(function(key2, index) {
                        if (index + 1 == keys.length) {
                            that.$set(data, key2, val);
                        } else {
                            if (!data[key2]) {
                                that.$set(data, key2, {});
                            }
                        }
                        data = data[key2];
                    });
                });
            },
            handleAgreeChange(e) {
 
                console.log(e)
                this.checkedAgree = e.detail.value;
            },
            clickOK() {
                if (!this.checkedAgree) {
                    showToast("请阅读并同意用户协议")
                    return
                }
                uni.reLaunch({
                    url: "/pages/login/index"
                })
            },
            clickSendVerifyCode() {
 
                if (this.disabledSendCode) {
                    return
                }
                let text = this.form.account.trim()
                if (!text) {
                    showToast("请输入手机号")
                    return
                }
 
                this.sendCodeCountdown = 60
                this.disabledSendCode = true
                const idInterval = setInterval(() => {
                    if (this.sendCodeCountdown > 0) {
                        this.sendCodeCountdown--
                    } else {
                        this.sendCodeCountdown = 0
                        clearInterval(idInterval);
                        this.disabledSendCode = false
                    }
                }, 1000)
            },
            clickUserAgreement() {},
 
 
        }
    }
</script>
 
<style lang="scss" scoped>
    .pages-login-register {
        display: flex;
        width: 750rpx;
        height: 100vh;
        flex-direction: column;
 
        .uni-panel-content {
            display: flex;
            flex: 1;
            width: 750rpx;
        }
 
        .login-content {
            width: 750rpx;
        }
 
        .justify-center {
            justify-content: center;
        }
 
        .items-center {
            align-items: center
        }
 
        .title-img {
            display: block;
            margin: auto;
            width: 300rpx;
            height: 300rpx;
        }
 
        .login-form {
            display: flex;
            padding: 20rpx 40rpx;
            flex-direction: column;
        }
 
        .login-form-item {
            padding: 10rpx;
            display: flex;
            margin: 10rpx;
            font-size: 30rpx !important;
            flex-direction: row;
            border-bottom: 2rpx solid #ddd;
 
            .icon {
                opacity: 0.3;
                margin: 12rpx 20rpx;
                width: 40rpx;
                height: 40rpx;
            }
 
            .input {
                flex: 1;
                padding: 12rpx 16rpx;
                background-color: transparent;
            }
 
        }
 
        .button-group {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            font-size: 30rpx !important;
        }
 
        .disabled {
            color: #888;
        }
 
        .button {
            margin: auto;
            margin-top: 20rpx;
            width: 300rpx;
            
        }
 
    }
</style>