1
李凌
2025-09-22 517b4a398d9ca06788366f2c4b94d5d8831af5fc
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<template>
    <div class="register">
        <div class="top flex justify-between items-center">
            <img src="../../assets/image/icon-close.png" alt="" @click="router.go(-1)">
            <div @click="onRoute('/customerService')">{{ $t('onLineService') }}</div>
        </div>
        <div class="title textColor">{{ $t('更换绑定') }}</div>
        <div class="flex re-tab">
            <!-- <div class="textColor1" :class="activeIndex == 0 ? 'active' : ''" @click="changeIndex(0)">{{
                $t('account')
            }}</div> -->
            <div class="textColor1" :class="activeIndex == 1 ? 'active' : ''" @click="changeIndex(1)">
                {{ $t('email') }}
            </div>
            <div class="textColor1" :class="activeIndex == 2 ? 'active' : ''" @click="changeIndex(2)">
                {{ $t('phoneNum') }}
            </div>
        </div>
        <ExInput :label="getRegType(activeIndex, true)" :placeholderText="getRegType(activeIndex, false)"
            v-model="username" :area="isArea" :dialCode="dialCode" @selectArea="onSelectArea" :icon="icon" />
 
        <ExInput :label="$t('repassword')" :placeholderText="$t('请输入')" v-model="password"
            typeText="password" />
        <!-- <ExInput :label="$t('repassword')" :placeholderText="$t('surePassword')" v-model="repassword"
            typeText="password" /> -->
        <ExInput :label="$t('fundsPassword')" :placeholderText="$t('请输入')" v-model="safeword" typeText="password"
            v-if="activeIndex === 1 || activeIndex === 2" />
        <div class="inputCom" v-if="activeIndex === 1 || activeIndex === 2">
            <p class="label  textColor">{{ $t('验证码') }}</p>
            <div class="iptbox inputBackground">
                <input class="inputBackground textColor" type="text" :placeholder="$t('entryVerifyCode')"
                    v-model="verifyCode">
                <span v-if="type !== 3" @click="senCode">{{ $t('sendVerifyCode') }}
                    <template v-if="time">({{ time }})s</template>
                </span>
            </div>
        </div>
 
        <!-- <ExInput :label="$t('金融机构代码')" :placeholderText="$t('请输入')" v-model="invitCode" :clearBtn="false" /> -->
 
        <div class="protocol textColor">
            <i @click="agreeProt">
                <img v-show="agree" src="../../assets/image/login/prot2.png" alt="" />
                <img v-show="!agree" src="../../assets/image/login/prot1.png" alt="" />
            </i>
            <!-- {{ $t('readAgree') }}<span class="colorMain" @click="router.push('/TermsOfService')">{{
                $t('serviceConf')
            }}</span> -->
            {{ $t('readAgree') }}<span class="colorMain" @click="router.push('/aboutUs?serviceTerm=23')">{{
                $t('serviceConf')
            }}</span>
        </div>
        <van-button class="w-full" style="margin-top:10px;" type="primary" @click="register">{{ $t('confirm') }}
        </van-button>
        <!-- <div class="noTips textColor">{{ $t('hasAccount') }}<span class="colorMain" @click="router.push('/login')">
                {{ $t('goLogin') }}</span>
        </div> -->
        <nationality-list ref='controlChildRef' :title="$t('selectArea')" @getName="getName"></nationality-list>
 
        <Vcode :imgs="[img1, img2]" :show="show" @success="onSuccess" :canvasHeight="200" @fail="onFail"
            @close="show = false;" sliderText='' :successText="$t('vertifyPass')" :failText="$t('vertifuFail')" />
 
        <div>{{ msg }}</div>
    </div>
</template>
 
<script setup>
import ExInput from "@/components/ex-input/index.vue";
import { _registerUser, _sendVerifyCode } from "@/service/login.api";
import { _bindEmailRegister, _registerEorP } from "@/service/user.api.js";
import { useUserStore } from '@/store/user';
import { GET_USERINFO } from '@/store/types.store'
import nationalityList from '../authentication/components/nationalityList.vue'
import Vcode from "vue3-puzzle-vcode";
import img1 from "@/assets/image/slider/1.png";
import img2 from "@/assets/image/slider/2.png";
import { getStorage } from '@/utils/index'
import { useI18n } from 'vue-i18n'
import { customerServiceUrl } from "@/config";
import { useRouter } from 'vue-router';
import { ref, onMounted, reactive, onUnmounted } from 'vue';
import { showToast } from "vant";
import store from '@/store/store'
const customer_service_url = ref(customerServiceUrl) // 客服链接,有值的话就会跳转到客服外链
const { t } = useI18n()
const router = useRouter()
const onRoute = (path) => {
    if (path == 'back') {
        router.go(-1)
    } else {
        if (path == '/customerService') {
            if (customer_service_url.value) {
                window.location.href = customer_service_url.value;
            } else {
                router.push(path)
            }
        } else {
            router.push(path)
        }
    }
}
const userStore = useUserStore();
 
let show = ref(false)
const msg = ref('')
const type = ref(1)
const time = ref(0)
let agree = ref(false)
const username = ref('')
const password = ref('')
const repassword = ref('')
const verifyCode = ref('')
const safeword = ref('')
const fundPassword = ref('')
const refundPassword = ref('')
const activeIndex = ref(1)
const typeText = ref('password')
let isArea = ref(false)
let dialCode = ref(0)
let icon = ref('')
const state = reactive({
    timer: null
})
 
let invitCode = ref('')
onMounted(() => {
    console.log(store)
    let usercode = getStorage('usercode')
    if (usercode) {
        invitCode = usercode;
    }
    clearInterval(state.timer)
    state.timer = null
})
 
onUnmounted(() => {
    clearInterval(state.timer)
    state.timer = null
})
 
const getRegType = (activeIndex, bFlag) => {
    switch (activeIndex) {
        case 0:
            return bFlag ? t('account') : t('entryAccount');
        case 1:
            return bFlag ? t('email') : t('entryEmail');
        case 2:
            return bFlag ? t('phoneNum') : t('entryPhone');
    }
}
 
const senCode = () => {
    if (time.value > 0) {
        return false
    }
    _sendVerifyCode({
        target: activeIndex.value === 1 ? username.value : dialCode.value + username.value,
    }).then((res) => {
        time.value = 30;
        state.timer = setInterval(() => {
            if (time.value > 0) {
                time.value = time.value - 1
            } else {
                time.value = 0;
                clearInterval(state.timer)
                state.timer = null
            }
        }, 1000);
    }).catch((error) => {
        showToast(t(error.msg));
    });
}
 
const onSuccess = () => {
    console.log('onSuccess')
    registerApi();
    show.value = false;
}
const onFail = () => {
    msg.value = ''
}
const onRefresh = () => {
    msg.value = ''
}
 
const controlChildRef = ref(null)
const onSelectArea = () => {
    controlChildRef.value.open();
}
 
const getName = (params) => {
    icon.value = params.code;
    dialCode.value = params.dialCode;
}
const agreeProt = () => {
    agree.value = !agree.value
}
const register = () => {
    console.log(activeIndex.value, 'activeIndex.value')
    if (activeIndex.value == 0) {
        if (username.value == '') {
            showToast(t('entryAccount'));
            return
        }
        if (username.value.length < 6 || username.value.length > 30) {
            showToast(t('accountLength'));
            return
        }
    } else if (activeIndex.value == 1) {
        let match = username.value.search(/@/);
        if (username.value == '' || match.value == -1) {
            showToast(t('entryCorrectEmail'));
            return
        }
        if (safeword.value == '') {
            showToast(t('safewordTips'));
            return
        }
        if (verifyCode.value.length < 6) {
            showToast(t('entryVerifyTips'));
            return
        }
    } else if (activeIndex.value == 2) {
        if (!(/(^[1-9]\d*$)/.test(username.value))) {
            showToast(t('entryPhone'));
            return
        }
        if (username.value == '') {
            showToast(t('entryPhone'));
            return
        }
    }
    if (password.value == '') {
        showToast(t('entryPassword'));
        return
    }
    if (password.value.length < 6) {
        showToast(t('passwordTips'));
        return
    }
    // if (repassword.value !== password.value) {
    //     showToast(t('noSamePassword'));
    //     return
    // }
    if (!agree.value) {
        showToast(t('agreeServiceCond'));
        return
    }
    show.value = true
}
const changeIndex = (index) => {
    activeIndex.value = index;
    if (index == 0 || index == 1) {
        isArea.value = false
    } else {
        isArea.value = true
    }
}
const registerApi = () => {
    switch (activeIndex.value) {
        case 0:
            {
                type.value = 3;
                break;
            }
        case 1:
            {
                type.value = 2;
                break;
            }
        case 2:
            {
                type.value = 1;
                break;
            }
    }
 
    _registerEorP({
        username: activeIndex.value === 1 ? username.value : dialCode.value + username.value,
        password: password.value,
        type: activeIndex.value === 1 ? '2' : '1',   // 2邮箱,1手机
        verifcode: verifyCode.value,
        safeword: safeword.value
    }).then((res) => {
        userStore[GET_USERINFO](res)
        store.state.user.userInfo = res
        // 其他操作??
        // router.push('/identity')
        router.push('/login')
    })
}
</script>
 
<style lang="scss" scoped>
.activeBKClick {
    &:active {
        background: $tab_background;
        opacity: 0.5;
    }
}
 
.activeClick {
    &:active {
        background: $mainbgWhiteColor;
        opacity: 0.5;
    }
}
 
.register {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
    font-size: 13px;
    background-color: $mainbgWhiteColor;
}
 
.top {
    padding-left: 9px;
    padding-top: 9px;
 
    img {
        width: 18px;
        height: 18px;
    }
}
 
.title {
    font-weight: 700;
    font-size: 26px;
    margin-top: 27px;
    margin-bottom: 33px;
}
 
.re-tab {
    margin-bottom: 22px;
 
    div {
        padding: 0 18px;
        height: 34px;
        line-height: 34px;
        text-align: center;
        border-radius: 4px;
        margin-right: 10px;
    }
 
    .active {
        // background: $US_tabActice_background;
        background: $bg_yellow;
        // color: $color_main;
        color: $text_color4;
    }
}
 
.forget {
    color: $color_main;
    font-size: 12px;
    line-height: 14px;
}
 
.noTips {
    margin-top: 24px;
}
 
.protocol {
    display: flex;
    align-items: center;
    height: 15px;
 
    i {
        width: 15px;
        height: 15px;
        margin-right: 9px;
 
        img {
            width: 100%;
            height: 100%;
        }
    }
}
 
.iptbox {
    height: 44px;
    margin-top: 8px;
    margin-bottom: 18px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px;
 
    input {
        flex: 1;
        height: 100%;
        border: none;
    }
 
    span {
        color: $color_main;
    }
}
</style>