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
| <template>
| <view class="main">
| <u-form :model="modelForm"
| label-position="top"
| :rules="rules"
| ref="uForm"
| label-width="80px">
| <u-form-item prop="phone"
| label="手机号"
| required
| borderBottom>
| <u--input v-model="modelForm.phone"
| border="surround"
| placeholder="请输入手机号"></u--input>
| </u-form-item>
| <u-form-item prop="idCard"
| label="身份证号"
| required
| borderBottom>
| <u--input v-model="modelForm.idCard"
| border="surround"
| placeholder="请输入身份证号"></u--input>
| </u-form-item>
| <u-form-item>
| <view class="process-button">
| <u-button type="primary"
| text="验证"
| :loading="processLoading"
| @click.stop="process"></u-button>
| </view>
| </u-form-item>
| </u-form>
| </view>
| </template>
|
| <script>
| export default {
| data() {
| return {
| modelForm: {
| phone: '',
| idCard: ''
| },
| processLoading: false,
| rules: {
| phone: [{
| required: true,
| message: '请输入手机号',
| // blur和change事件触发检验
| trigger: ['blur', 'change']
| },
| {
| min: 11,
| max: 11,
| message: '请输入合法手机号'
| },
| {
| validator: (rule, value, callback) => {
| return uni.$u.test.mobile(value);
| },
| message: '手机号码格式不正确',
| trigger: ['change', 'blur']
| }
| ],
| idCard: [{
| type: 'string',
| required: true,
| message: '请输入身份证号',
| trigger: ['blur', 'change']
| },
| {
| pattern: /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
| message: '身份证号格式不正确',
| trigger: ['blur', 'change']
| }
| ],
| }
| }
| },
| onReady() {
| this.$refs.uForm.setRules(this.rules)
| },
| methods: {
| process() {
| this.$refs.uForm.validate().then(res => {
| this.processLoading = true;
| this.$reqGet('phoneAndCard', { phone: this.modelForm.phone, idCard: this.modelForm.idCard })
| .then(res => {
| this.processLoading = false;
| if (res.code === 0) {
| uni.$u.toast('验证成功,即将跳转重置密码界面')
| setTimeout(() => {
| uni.navigateTo({
| url: `/pages/login/resetPassword/resetPassword?userInfo=${JSON.stringify(res.data)}`
| })
| }, 1000)
| } else {
| uni.$u.toast(res.msg ? res.msg : '验证失败')
| }
| })
|
| }).catch(errors => {
| uni.$u.toast('请填写完整信息')
| })
| }
| }
| }
| </script>
|
| <style lang="scss"
| scoped>
| .main {
| width: 94%;
| margin: vww(10) auto;
|
| .process-button {
| margin-top: vww(20);
| }
| }
| </style>
|
|