guoshilong
2023-10-27 2311b03aee9db1bebacdd2ced13c071efda6a011
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<template>
    <view class="container">
        <view class="logo">
            <image src="https://sk.hubeishuiyi.cn/business/xcxImg/wxlogo.png" lazy-load show-menu-by-longpress
                style="width: 100rpx;height: 100rpx;"></image>
            <view class="title">荆楚水库</view>
        </view>
        <view class="content">
            <view class="top">
                <u--form labelPosition="top" labelWidth="60" :model="form" :rules="rules" ref="form">
                    <view class="cell">
                        <u-form-item label="手机号:" prop="phone" borderBottom ref="phone">
                            <u-input v-model="form.phone" border="none" placeholder="请输入手机号">
                                <template slot="suffix">
                                    <u-code ref="uCode" @change="codeChange" seconds="60" changeText="x秒后重新获取"></u-code>
                                    <u-button @tap="getCodeBtn" :text="tips" type="success" size="mini"></u-button>
                                </template>
                            </u-input>
                        </u-form-item>
                    </view>
                    <view class="cell">
                        <u-form-item label="验证码:" prop="password" borderBottom ref="password">
                            <u--input v-model="form.password" border="none" placeholder="请输入验证码">
                            </u--input>
                        </u-form-item>
                    </view>
                </u--form>
                <view class="privacy-policy">
                    <u-radio-group size="15" v-model="radioGroupValue" placement="column" @change="groupChange">
                        <u-radio name="check" @change="radioChange">
                            查看并同意<navigator url="../user/privacyPolicy" hover-class="navigator-hover">
                                《隐私政策》
                            </navigator>
                        </u-radio>
                    </u-radio-group>
                    <view class="statement">
                        仅限湖北省水库管理人员使用
                    </view>
                </view>
                <button class="submit" @click="submit" :disabled="disabled">登录</button>
                <view class="page-change">
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import md5 from '@/utils/md5.js'
    import {
        getCode,
        codeLogin
    } from "@/api/login"
    import loginMixin from './mixin/loginMixin'
    export default {
        onLoad(option) {
            const {
                redirect
            } = option
            if (redirect) this.redirect = redirect
        },
        mixins: [loginMixin],
        data() {
            return {
                tenantId: '000000',
                form: {
                    phone: "",
                    password: ""
                },
                rules: {
                    'phone': [{
                            type: 'string',
                            required: true,
                            message: '请填写手机号',
                            trigger: ['blur', 'change']
                        },
                        {
                            validator: (rule, value, callback) => {
                                return uni.$u.test.mobile(value);
                            },
                            message: '手机号码不正确',
                            trigger: ['change', 'blur'],
                        }
                    ],
                    'password': {
                        type: 'string',
                        required: true,
                        message: '请输入验证码',
                        trigger: ['blur', 'change']
                    }
                },
                disabled: false,
                redirect: '',
                tips: "",
            }
        },
        methods: {
            codeChange(e) {
                this.tips = e
            },
            async getCodeBtn() {
                const that = this
                const flag = uni.$u.test.mobile(this.form.phone.trim())
                if (!flag) return uni.$u.toast("手机号格式不正确")
                if (this.$refs.uCode.canGetCode) {
                    // 模拟向后端请求验证码
                    uni.showLoading({
                        title: '正在获取验证码'
                    })
                    const obj = {
                        userNumber: that.form.phone
                    }
                    const res = await getCode(obj)
                    if (res.code != 200) {
                        uni.hideLoading();
                        return uni.$u.toast(res.msg);
                    }
                    uni.hideLoading();
                    uni.$u.toast('验证码已发送');
                    this.$refs.uCode.start();
                } else {
                    uni.$u.toast('倒计时结束后再发送');
                }
            },
            submit() {
                const that = this
                this.$refs.form.validate().then(async res => {
 
                    if (!this.isPrivacyCheck()) {
                        return
                    }
 
                    const val = await codeLogin(this.tenantId, this.form.phone, this.form.password, "account")
                    this.$u.func.login(val)
                }).catch(err => {
                    this.$u.func.showToast({
                        title: err.data.error_description
                    })
                })
            },
            handleInputCheck() {
                this.disabled = false
            }
        }
    }
</script>
 
<style lang="scss">
    .privacy-policy {
        width: 100%;
        padding: 40rpx 40rpx 0 80rpx;
        font-size: 28rpx;
    }
 
 
    .container {
        min-height: 100vh;
        overflow: hidden;
        background: url("https://sk.hubeishuiyi.cn/business/xcxImg/reservoirImg/default.jpg") no-repeat;
        background-size: 100% 100%;
 
        .set-icon {
            vertical-align: middle;
            width: 41rpx;
            height: auto;
            margin-right: 35rpx;
        }
    }
 
    .logo {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 200rpx 0;
 
        image {
            box-shadow: 4rpx 4rpx 20rpx #fafafa;
        }
 
        .title {
            margin-top: 40rpx;
            font-weight: 700;
            font-size: 32rpx;
        }
    }
 
    .content {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;
 
        // height: 90vh;
        width: 100%;
 
        .top {
            width: 100%;
            background: #fff;
            padding: 20px 0;
            position: fixed;
            bottom: 0px;
 
        }
 
        .logo {
            display: block;
            width: 281rpx;
            height: auto;
            margin: 0 auto 120rpx;
        }
 
        .cell {
            width: 100%;
            padding: 0 85rpx;
            box-sizing: border-box;
            margin-top: 36rpx;
 
            .name {
                font-size: 22rpx;
                font-family: Source Han Sans CN;
                font-weight: 400;
                color: #3e4a59;
                line-height: 30rpx;
                opacity: 0.72;
            }
 
            .input-box {
                padding: 30rpx 0;
                border-bottom: 2rpx solid #f6f6f6;
                display: flex;
                align-items: center;
 
                .code {
                    font-size: 22rpx;
                    font-family: Source Han Sans CN;
                    font-weight: 400;
                    color: #0d0d0d;
                    line-height: 30rpx;
 
                    text {
                        color: #5f88ff;
                    }
                }
 
                .ipt {
                    flex: 1;
                    font-size: 24rpx;
                }
 
                .hold {
                    font-size: 26rpx;
                    font-family: Source Han Sans CN;
                    font-weight: 400;
                    color: #3e4a59;
                    line-height: 30px;
                    opacity: 0.45;
                }
            }
        }
 
        .agree {
            margin: 27rpx 95rpx 0;
            font-size: 22rpx;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #cacaca;
            line-height: 34rpx;
 
            .a {
                color: #000000;
            }
        }
 
        .submit {
            margin: 60rpx 90rpx 0;
            border: none;
            width: 572rpx;
            height: 86rpx;
            line-height: 86rpx;
            box-sizing: border-box;
            border-radius: 15rpx;
            background-color: #5f88ff;
            color: #ffffff;
 
            &::after {
                content: none;
            }
 
            &::before {
                content: none;
            }
 
            &[disabled='true'] {
                background: #e4e4e4;
                font-size: 36rpx;
                font-family: Source Han Sans CN;
                font-weight: 500;
                color: #ffffff;
            }
        }
 
        .tip {
            margin-top: 30rpx;
            text-align: center;
            font-size: 22rpx;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #cacaca;
            line-height: 34rpx;
        }
 
        .change {
            margin-top: 20rpx;
            text-align: center;
            font-size: 22rpx;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #5f88ff;
            line-height: 34rpx;
        }
 
        .tag {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 22rpx;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #9f9f9f;
            line-height: 34rpx;
 
            &::before {
                content: '';
                display: block;
                width: 160rpx;
                height: 1px;
                background: #d8d8d8;
                opacity: 0.86;
            }
 
            &::after {
                content: '';
                display: block;
                width: 160rpx;
                height: 1px;
                background: #d8d8d8;
                opacity: 0.86;
            }
        }
 
        .chat-arr {
            margin-top: 50rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
 
            .icon {
                width: 73rpx;
                height: 73rpx;
            }
        }
 
        .page-change {
            display: flex;
            justify-content: space-evenly;
        }
    }
</style>