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
| <template>
| <view class="u-p-h-50">
| <view class="title">您好,欢迎注册!</view>
| <u-form labelPosition="top" :model="form" :rules="rules" labelWidth="200"
| :labelStyle="{fontSize:'34rpx',fontWeight:'bold'}" ref="uForm">
| <u-form-item label="姓名" prop="memberName" borderBottom>
| <u-input v-model="form.memberName" border="none" placeholder="请输入姓名"></u-input>
| </u-form-item>
| <!-- <u-form-item label="身份证号" prop="idcard" borderBottom>
| <u-input v-model="form.idcard" border="none" placeholder="请输入身份证号"></u-input>
| </u-form-item>-->
| <u-form-item label="手机号" prop="mobile" borderBottom>
| <u-input v-model="form.mobile" border="none" placeholder="请输入手机号"></u-input>
| </u-form-item>
| <u-form-item label="图形验证码" prop="captchaCode" borderBottom>
| <u-input v-model="form.captchaCode" border="none" placeholder="请输入图形验证码"></u-input>
| <image @click="getImgCode" class="img-code" slot="right" :src="imgCode.bg" mode=""></image>
| </u-form-item>
| <u-form-item label="短信验证码" prop="verificationCode" borderBottom>
| <u-input v-model="form.verificationCode" maxlength="6" border="none" placeholder="请输入短信验证码"></u-input>
| <u-button slot="right" @tap="getCode" color="#de2d35" plain>{{tips}}</u-button>
| </u-form-item>
| </u-form>
| <view class="u-text-center u-m-t-40 color-999 u-font-24">
| <label @click="checked = !checked" class="radio">
| <radio style="transform: scale(0.7);" color="#de2d35" :checked="checked" /><text>我已阅读并同意</text>
| <text style="color: #de2d35;" @click.stop="show = true">《资金监管平台用户注册协议》</text>
| </label>
|
| </view>
| <u-modal confirmText="阅读并同意" confirmColor="#de2d35" @confirm="show = false;checked = true" :show="show" title="资金监管平台用户注册协议">
| <scroll-view scroll-y style="height: 60vh;">
| <user-agreement></user-agreement>
| </scroll-view>
| </u-modal>
| <u-code :seconds="seconds" ref="uCode" @change="codeChange"></u-code>
| <view class="btn-box">
| <u-button @click="submit" text="注册" type="error" color="#de2d35" shape="circle"></u-button>
| </view>
| </view>
| </template>
|
| <script>
| import {
| getVerify,
| getH5PayCheckVerifyCode,
| h5PayLogin
| } from '@/common/api/index'
| export default {
| data() {
| return {
| show: false,
| checked: true,
| cid: '',
| imgCode: {},
| tips: '',
| // refCode: null,
| seconds: 60,
| form: {
| memberName: '',
| idcard: '',
| mobile: '',
| captchaCode: '',
| verificationCode: '',
| },
| rules: {
| memberName: [{
| type: 'string',
| required: true,
| message: '姓名不能为空',
| trigger: ['blur']
| }],
| idcard: [{
| type: 'string',
| required: true,
| message: '身份证号不能为空',
| trigger: ['blur']
| }, {
| validator: (rule, value, callback) => {
| return uni.$u.test.idCard(value);
| },
| message: '身份证号不正确',
| // 触发器可以同时用blur和change
| trigger: ['blur'],
| }],
| mobile: [{
| type: 'string',
| required: true,
| message: '手机号不能为空',
| trigger: ['blur']
| },
| {
| validator: (rule, value, callback) => {
| return uni.$u.test.mobile(value);
| },
| message: '手机号码不正确',
| // 触发器可以同时用blur和change
| trigger: ['change'],
| }
| ],
| captchaCode: [{
| type: 'string',
| required: true,
| message: '图形验证码不能为空',
| trigger: ['blur', 'change']
| }],
| verificationCode: [{
| type: 'string',
| required: true,
| message: '短信验证码不能为空',
| trigger: ['blur', 'change']
| }],
| },
| };
| },
| onLoad(opt) {
| this.cid = opt.cid
| this.getImgCode()
| },
| methods: {
| codeChange(text) {
| this.tips = text;
| },
| getCode() {
| if (!this.form.captchaCode) {
| uni.showToast({
| icon: 'none',
| title: '请输入图形验证码'
| })
| return
| }
| if (!this.form.mobile) {
| uni.showToast({
| icon: 'none',
| title: '请输入手机号'
| })
| return
| }
| if (this.$refs.uCode.canGetCode) {
| // 模拟向后端请求验证码
| uni.showLoading({
| title: '正在获取验证码'
| })
| getH5PayCheckVerifyCode({
| mobile: this.form.mobile,
| captchaCode: this.form.captchaCode,
| verifyToken: this.imgCode.token
| }).then(res => {
| uni.hideLoading();
| // 这里此提示会被this.start()方法中的提示覆盖
| uni.$u.toast('验证码已发送');
| // 通知验证码组件内部开始倒计时
| this.$refs.uCode.start();
| }).catch(() => {
| // uni.hideLoading();
| this.getImgCode()
| })
| } else {
| uni.$u.toast('倒计时结束后再发送');
| }
| },
| getImgCode() {
| uni.showLoading()
| getVerify().then(res => {
| uni.hideLoading();
| res.bg = 'data:image/jpeg;base64,' + res.bg
| this.imgCode = res
| }).catch(() => {
| uni.hideLoading();
| })
| },
| submit() {
| if(!this.checked){
| uni.showToast({
| icon: 'none',
| title: '请先阅读并同意用户协议'
| })
| return
| }
| this.$refs.uForm.validate().then(res => {
| uni.showLoading()
| h5PayLogin(this.form).then(res => {
| uni.hideLoading();
| uni.setStorageSync('IS_NEW', false)
| uni.redirectTo({
| url: '/pages/pay/scanpay?cid=' + this.cid
| })
| }).catch(() => {
| uni.hideLoading();
| })
| }).catch(errors => {
| // uni.$u.toast('校验失败')
| })
| }
| },
| }
| </script>
| <style>
| page {
| background-color: #fff;
| }
| </style>
| <style lang="scss">
| .title {
| font-size: 44rpx;
| font-weight: bold;
| padding: 50rpx 0;
| }
|
| .btn-box {
| margin-top: 40rpx;
| }
|
| .img-code {
| width: 140rpx;
| height: 70rpx;
| }
| </style>
|
|