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
| <template>
| <view class="login-container">
| <view class="p30">
| <view class="group-bd">
| <view class="form-level d-s-c">
| <view class="d-s-c field-name">
| <text class="orange">*</text>
| <text class="gray3">手机号:</text>
| </view>
| <view class="val flex-1"><input type="text" v-model="formData.mobile" placeholder="请输入要绑定的新手机号" :disabled="is_send" /></view>
| </view>
| <view class="form-level d-s-c">
| <view class="d-s-c field-name">
| <text class="orange">*</text>
| <text class="gray3">验证码:</text>
| </view>
| <view class="val flex-1 d-b-c">
| <input class="flex-1" type="number" v-model="formData.code" placeholder="请输入验证码" />
| <button class="get-code-btn" type="default" @click="sendCode" :disabled="is_send">{{ send_btn_txt }}</button>
| </view>
| </view>
| </view>
| </view>
|
| <view class="btns p30"><button type="default" @click="formSubmit">提交</button></view>
| </view>
| </template>
|
| <script>
| export default {
| data() {
| return {
| /*表单数据对象*/
| formData: {
| /*手机号*/
| mobile: '',
| /*验证码*/
| code: '',
| },
| /*是否已发验证码*/
| is_send: false,
| /*发送按钮文本*/
| send_btn_txt: '获取验证码',
| /*当前秒数*/
| second: 60,
| ip: '',
| };
| },
| onLoad() {
|
| },
| methods: {
| /*提交*/
| formSubmit() {
| let self = this;
| if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.formData.mobile)) {
| uni.showToast({
| title: '手机有误,请重填!',
| duration: 2000,
| icon: 'none'
| });
| return;
| }
|
| if (self.formData.code == '') {
| uni.showToast({
| title: '验证码不能为空!',
| duration: 2000,
| icon: 'none'
| });
| return;
| }
|
| uni.showLoading({
| title: '正在提交'
| });
| uni.navigateBack();
| self._post(
| 'user.userweb/bindMobile',
| self.formData,
| result => {
| uni.showToast({
| title: '绑定成功',
| duration: 2000
| });
| setTimeout(function(){
| // 执行回调函数
| uni.navigateBack();
| }, 2000);
| },
| false,
| () => {
| uni.hideLoading();
| }
| );
| },
|
| /*发送短信*/
| sendCode() {
| let self = this;
|
| if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.formData.mobile)) {
| uni.showToast({
| title: '手机有误,请重填!',
| duration: 2000,
| icon: 'none'
| });
| return;
| }
|
| self._post(
| 'user.userweb/sendCode',
| {
| mobile: self.formData.mobile
| },
| result => {
| if (result.code == 1) {
| uni.showToast({
| title: '发送成功'
| });
| self.is_send = true;
| self.changeMsg();
| }
| }
| );
| },
|
| /*改变发送验证码按钮文本*/
| changeMsg() {
| if (this.second > 0) {
| this.send_btn_txt = this.second + '秒';
| this.second--;
| setTimeout(this.changeMsg, 1000);
| } else {
| this.send_btn_txt = '获取验证码';
| this.second = 60;
| this.is_send = false;
| }
| },
| }
| };
| </script>
|
| <style lang="scss" scoped>
| .login-container {
| background: #ffffff;
| }
| .login-container input {
| height: 88rpx;
| line-height: 88rpx;
| }
| .wechatapp {
| padding: 80rpx 0 48rpx;
| border-bottom: 1rpx solid #e3e3e3;
| margin-bottom: 72rpx;
| text-align: center;
| }
|
| .wechatapp .header {
| width: 190rpx;
| height: 190rpx;
| border: 2px solid #fff;
| margin: 0rpx auto 0;
| border-radius: 50%;
| overflow: hidden;
| box-shadow: 1px 0px 5px rgba(50, 50, 50, 0.3);
| }
|
| .auth-title {
| color: #585858;
| font-size: 34rpx;
| margin-bottom: 40rpx;
| }
|
| .auth-subtitle {
| color: #888;
| margin-bottom: 88rpx;
| font-size: 28rpx;
| }
|
| .login-btn {
| padding: 0 20rpx;
| }
|
| .login-btn button {
| height: 88rpx;
| line-height: 88rpx;
| background: #04be01;
| color: #fff;
| font-size: 30rpx;
| border-radius: 999rpx;
| text-align: center;
| }
|
| .no-login-btn {
| margin-top: 20rpx;
| padding: 0 20rpx;
| }
|
| .no-login-btn button {
| height: 88rpx;
| line-height: 88rpx;
| background: #dfdfdf;
| color: #fff;
| font-size: 30rpx;
| border-radius: 999rpx;
| text-align: center;
| }
|
| .get-code-btn {
| width: 200rpx;
| height: 80rpx;
| line-height: 76rpx;
| padding: 0rpx 30rpx;
| border-radius: 40rpx;
| white-space: nowrap;
| border: 1rpx solid $dominant-color;
| color: $dominant-color;
| font-size: 30rpx;
| }
| .get-code-btn[disabled='true'] {
| border: 1rpx solid #cccccc;
| }
|
| .btns button {
| height: 90rpx;
| line-height: 90rpx;
| font-size: 34rpx;
| border-radius: 45rpx;
| background: $dominant-color;
| color: #ffffff;
| }
| </style>
|
|