bind.vue
4.64 KB
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
<template>
<div v-if="showBind" class="third-bind-wrapper">
<div class="bind-dialog">
<div class="under-row">
<i class="iconfont iconphone2"></i>
<div class="select-block">
<CubeSelect class="area-code-select" v-model="code" :options="options" :title="selectTitle"></CubeSelect>
</div>
<CubeInput class="bind-input" v-model="phone" placeholder="请输入手机号"></CubeInput>
</div>
<div class="under-row">
<i class="iconfont iconyanzhengma"></i>
<CubeInput class="bind-input" v-model="smsCode" placeholder="请输入验证码"></CubeInput>
<CubeButton class="send-sms-btn" :disabled="!!sendBtnText" @click="sendSMS">{{sendBtnText || '获取验证码'}}</CubeButton>
</div>
<div class="submit-row">
<CubeButton class="bind-btn" @click="bindSubmit">登录</CubeButton>
</div>
</div>
</div>
</template>
<script>
import { Button, Input, Select } from 'cube-ui';
import { mapActions, mapState } from 'vuex';
const areaList = [{
value: '+61',
name: '澳大利亚'
}, {
value: '+82',
text: '韩国'
}, {
value: '+1',
text: '加拿大'
}, {
value: '+60',
text: '马来西亚'
}, {
value: '+1',
text: '美国'
}, {
value: '+81',
text: '日本'
}, {
value: '+65',
text: '新加坡'
}, {
value: '+44',
text: '英国'
}, {
value: '+86',
text: '中国'
}, {
value: '+853',
text: '中国澳门'
}, {
value: '+886',
text: '中国台湾'
}, {
value: '+852',
text: '中国香港'
}];
export default {
name: 'ThirdBind',
data() {
return {
showBind: false,
code: '+86',
options: areaList,
selectTitle: '选择国家和地区',
phone: '',
smsCode: '',
sendBtnText: ''
}
},
methods: {
...mapActions(['sendBindSms', 'submitThirdBind']),
show() {
this.bindCode = this.$route.query.bind_code;
this.showBind = true;
},
close() {
this.showBind = false;
},
toast(msg, time = 2000) {
this.$createToast && this.$createToast({
txt: msg,
type: 'txt',
time
}).show();
},
sendSMS() {
let total = 60;
let timer = setInterval(() => {
if (--total) {
this.sendBtnText = '重新获取 ' + total;
} else {
this.sendBtnText = '';
clearInterval(timer);
}
}, 1000);
this.sendBtnText = '重新获取 ' + total;
this.sendBindSms({
mobile: this.phone,
bindCode: this.bindCode
});
},
bindSubmit() {
if (this.phone && this.smsCode) {
this.submitThirdBind({
mobile: this.phone,
code: this.smsCode,
bindCode: this.bindCode
}).then(res => {
if (res.code === 200) {
this.close();
} else {
this.toast(res.message);
}
});
} else {
this.toast(this.phone ? '请输入短信验证码' : '请输入手机号');
}
}
},
components: {
CubeInput: Input,
CubeSelect: Select,
CubeButton: Button
}
};
</script>
<style lang="scss" scoped>
.third-bind-wrapper {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
z-index: 99;
display: flex;
justify-content: center;
align-items: center;
}
.bind-dialog {
width: 670px;
height: 600px;
padding: 100px 60px;
font-size: 24px;
box-sizing: border-box;
background-color: #fff;
color: #444;
}
.under-row {
line-height: 80px;
border-bottom: 1px solid #eaeaea;
margin-bottom: 20px;
display: flex;
justify-content: center;
align-items: center;
}
.iconfont {
font-size: 40px;
margin-right: 10px;
vertical-align: middle;
}
.select-block {
min-width: 130px;
position: relative;
margin-right: 10px;
&:after {
content: "";
width: 1px;
background-color: #eaeaea;
position: absolute;
right: 0;
top: 30%;
bottom: 30%;
}
}
.area-code-select {
display: inline-block;
&:after {
border: 0;
}
/deep/ .cube-select-text {
font-size: 12px;
}
}
.bind-input {
flex-grow: 1;
&:after {
border: 0;
}
/deep/ .cube-input-field {
font-size: 12px;
}
}
.send-sms-btn {
width: 180px;
height: 54px;
line-height: 54px;
padding: 0;
font-size: 12px;
border-radius: 27px;
transform: scale(0.9);
&:after {
border: 0;
}
}
.submit-row {
margin-top: 80px;
}
.bind-btn {
height: 120px;
font-size: 28px;
background: #022c46;
&.cube-btn_disabled {
background: #ccc;
}
}
</style>