lxf
2025-04-21 0d5daf444d5b2338bf5c2a19630bd0333a6b852a
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<template>
  <div class="register">
    <div class="top" @click="$router.go(-1)">
      <img
        :src="require(`../../assets/theme/${theme}/image/Union.png`)"
        alt=""
      />
    </div>
    <!-- <Step :step="1"></Step> -->
    <div class="title textColor">{{ $t("注册") }}</div>
    <div class="flex re-tab">
      <!--            <div class="textColor1" :class="activeIndex == 0 ? 'active' : ''" @click="changeIndex(0)">{{ $t('账号') }}</div>-->
      <!-- <div
        class="textColor1"
        :class="activeIndex == 1 ? 'active' : ''"
        @click="changeIndex(1)"
      >
        {{ $t("邮箱") }}
      </div> -->
      <!-- <div class="textColor1" :class="activeIndex == 2 ? 'active' : ''" @click="changeIndex(2)">{{ $t('手机号') }}</div> -->
    </div>
    <ExInput
      :label="getRegType(activeIndex, true)"
      :placeholderText="getRegType(activeIndex, false)"
      v-model.trim="username"
      :area="isArea"
      :dialCode="dialCode"
      @selectArea="onSelectArea"
      :icon="icon"
    />
    <ExInput
      :label="$t('手机号')"
      :placeholderText="$t('请输入手机号')"
      v-model="phone"
    />
    <ExInput
      :label="$t('设置密码')"
      :placeholderText="$t('密码(6-12个字符)')"
      v-model="password"
      typeText="password"
    />
    <ExInput
      :label="$t('确认密码')"
      :placeholderText="$t('请确认密码')"
      v-model="repassword"
      typeText="password"
    />
    <ExInput
      :label="$t('资金密码')"
      :placeholderText="$t('资金密码(6位数字)')"
      v-model="safeword"
      typeText="password"
    />
    <ExInput
      :label="$t('确认资金密码')"
      :placeholderText="$t('请确认资金密码')"
      v-model="resafeword"
      typeText="password"
    />
    <ExInput
      :label="$t('邀请码(选填)')"
      :placeholderText="$t('请输入邀请码')"
      v-model="invitCode"
      :clearBtn="false"
    />
    <!-- <div class="title textColor">{{ $t("邮箱验证") }}</div> -->
    <p>{{ $t("verifyEmailTips", { account: account }) }}</p>
    <div class="iptbox inputBackground">
      <input
        class="inputBackground textColor"
        type="text"
        :placeholder="$t('请输入验证码')"
        v-model="verifyCode"
      />
      <span @click="senCode"
        >{{ $t("发送验证码") }}
        <template v-if="time"> ({{ time }})s</template></span
      >
    </div>
    <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("我已阅读并同意")
      }}<span
        class="colorMain"
        @click="$router.push('/TermsOfService?serviceTerm=1')"
        >{{ $t("服务条款") }}</span
      >
    </div>
    <div class="btn btnMain" @click="register">{{ $t("注册") }}</div>
    <div class="noTips textColor">
      {{ $t("已有账号")
      }}<span class="colorMain" @click="$router.push('/login')">
        {{ $t("去登录") }}</span
      >
    </div>
    <nationality-list
      ref="controlChild"
      :title="$t('选择区域码')"
      @getName="getName(arguments)"
    ></nationality-list>
 
    <Vcode
      :imgs="[img1, img2]"
      :show="show"
      @success="onSuccess"
      :canvasHeight="200"
      @fail="onFail"
      @close="show = false"
      sliderText=""
      :successText="$t('验证通过!')"
      :failText="$t('验证失败,请重试')"
    />
 
    <div>{{ msg }}</div>
  </div>
</template>
 
<script>
import { Popup } from "vant";
import ExInput from "@/components/ex-input";
import Step from "./step.vue";
import Axios from "@/API/login.js";
import { mapActions, mapGetters } from "vuex";
import { GET_USERINFO } from "@/store/const.store";
import nationalityList from "../authentication/components/nationalityList.vue";
import Vcode from "vue-puzzle-vcode";
import img1 from "../../assets/image/slider/1.png";
import img2 from "../../assets/image/slider/2.png";
import { getStorage } from "@/utils/utis";
export default {
  props: {},
  components: {
    [Popup.name]: Popup,
    ExInput,
    Step,
    nationalityList,
    Vcode,
  },
  data() {
    return {
      show: false,
      msg: "",
      type: 3, // 1手机 2 邮箱 3账号
      agree: false,
      username: "",
      password: "",
      repassword: "",
      phone: "",
      resafeword: "",
      safeword: "",
      invitCode: "", //邀请码
      activeIndex: 1,
      typeText: "password",
      isArea: false,
      dialCode: 0, //电话号前缀
      icon: "",
      img1,
      img2,
      account: "",
      timer: "",
      time: 0,
      verifyCode: "",
    };
  },
  mounted() {
    let usercode = getStorage("usercode");
    if (usercode) {
      this.invitCode = usercode;
    }
  },
  computed: {
    ...mapGetters({
      theme: "home/theme",
    }),
  },
  methods: {
    ...mapActions("user", [GET_USERINFO]),
    getRegType(activeIndex, bFlag) {
      switch (activeIndex) {
        case 0:
          return bFlag ? this.$t("账号") : this.$t("请输入账号");
        case 1:
          return bFlag ? this.$t("邮箱") : this.$t("请输入邮箱");
        case 2:
          return bFlag ? this.$t("手机号") : this.$t("请输入手机号");
      }
    },
    onClose() {
      console.log("onClose");
    },
    onSuccess() {
      console.log("onSuccess");
      this.registerApi();
      this.show = false;
    },
    onFail() {
      this.msg = "";
    },
    onRefresh() {
      this.msg = "";
    },
    onSelectArea() {
      this.openBtn();
    },
    //打开国家列表底部弹窗
    openBtn() {
      this.$refs.controlChild.open();
    },
    //获取到当前选中国家的code值
    getName(params) {
      this.icon = params[1];
      this.dialCode = params[2];
    },
    agreeProt() {
      this.agree = !this.agree;
    },
    register() {
      // if (this.activeIndex == 0){
      //     let match = this.username.search(/@/);
      //     if (this.username == '' || match == -1) {
      //         this.$toast(this.$t('请输入正确的邮箱地址'));
      //         return
      //     }
      // }else{
      //     if (this.username == '' ) {
      //         this.$toast(this.$t('请输入手机号'));
      //         return
      //     }
      // }
      switch (this.activeIndex) {
        case 0: {
          if (this.username == "") {
            this.$toast(this.$t("请输入账号"));
            return;
          }
          if (this.username.length < 6 || this.username.length > 30) {
            this.$toast(this.$t("账号长度必须6-30位"));
            return;
          }
          break;
        }
        case 1: {
          let match = this.username.search(/@/);
          if (this.username == "" || match == -1) {
            this.$toast(this.$t("请输入正确的邮箱地址"));
            return;
          }
          break;
        }
        case 2: {
          if (this.username == "") {
            this.$toast(this.$t("请输入手机号"));
            return;
          }
          break;
        }
      }
      if (this.password == "") {
        this.$toast(this.$t("请输入密码"));
        return;
      }
      if (this.password.length < 6) {
        this.$toast(this.$t("密码(6-12个字符)"));
        return;
      }
      if (this.repassword !== this.password) {
        this.$toast(this.$t("密码不一致"));
        return;
      }
      if (!this.agree) {
        this.$toast(this.$t("请同意服务条款"));
        return;
      }
      if (this.verifyCode.length < 6) {
        this.$toast(this.$t("请输入6位验证码"));
        return;
      }
      // this.show = true
      this.registerApi();
    },
    bindEmail() {
      Axios.bindEmail({
        email: this.account,
        verifcode: this.verifyCode,
      })
        .then((res) => {
          this.$toast(this.$t("绑定成功"));
          // this.$router.push('/setFond')
          this.setSafewordReg();
        })
        .catch((error) => {
          if (error.code === "ECONNABORTED") {
            this.$toast(this.$t("网络超时!"));
          } else if (error.msg !== undefined) {
            this.$toast(this.$t(error.msg));
          }
        });
    },
    changeIndex(index) {
      this.activeIndex = index;
      switch (index) {
        case 0:
        case 1: {
          this.isArea = false;
          break;
        }
        case 2: {
          this.isArea = true;
          break;
        }
      }
    },
    registerApi() {
      switch (this.activeIndex) {
        case 0: {
          this.type = 3;
          break;
        }
        case 1: {
          this.type = 2;
          break;
        }
        case 2: {
          this.type = 1;
          break;
        }
      }
      Axios.registerUser({
        username:
          this.activeIndex == 0 || this.activeIndex == 1
            ? this.username
            : `${this.username}`,
        phone: this.phone,
        password: this.password,
        re_password: this.repassword,
        re_safeword: this.resafeword,
        safeword: this.safeword,
        type: this.type,
        usercode: this.invitCode,
        verifcode: this.verifyCode,
      })
        .then((res) => {
          this.GET_USERINFO(res.data);
          //   if (this.activeIndex == 0 || this.activeIndex == 2) {
          this.$router.push("/finish");
          //   } else {
          // this.$router.push('/userCenter')
          // this.$router.push({
          //   name: "verify",
          //   query: {
          //     type: this.activeIndex,
          //     account:
          //       this.activeIndex == 1 ? this.username : `${this.username}`,
          //   },
          // });
          //   }
        })
        .catch((error) => {
          if (error.code === "ECONNABORTED") {
            this.$toast(this.$t("网络超时!"));
          } else if (error.msg !== undefined) {
            this.$toast(this.$t(error.msg));
          }
        });
    },
    senCode() {
      if (this.time > 0) {
        return false;
      }
      Axios.sendVerifyCode({
        target: this.username,
      })
        .then((res) => {
          this.time = 30;
          this.timer = setInterval(() => {
            if (this.time > 0) {
              this.time = this.time - 1;
            } else {
              this.time = 0;
              clearInterval(this.timer);
            }
          }, 1000);
        })
        .catch((error) => {
          if (error.code === "ECONNABORTED") {
            this.$toast(this.$t("网络超时!"));
          } else if (error.msg !== undefined) {
            this.$toast(this.$t(error.msg));
          }
        });
    },
  },
};
</script>
 
<style lang="scss" scoped>
.register {
  width: 100%;
  box-sizing: border-box;
  padding: 32px;
  font-size: 26px;
}
 
.top {
  padding-left: 18px;
  padding-top: 18px;
 
  img {
    width: 37px;
    height: 37px;
  }
}
 
.title {
  font-weight: 700;
  font-size: 52px;
  margin-top: 54px;
  margin-bottom: 66px;
}
 
.re-tab {
  margin-bottom: 44px;
 
  div {
    padding: 0 36px;
    height: 68px;
    line-height: 68px;
    text-align: center;
    border-radius: 8px;
    margin-right: 20px;
  }
 
  .active {
    @include themify() {
      background: themed("tab_background");
    }
 
    @include themify() {
      color: themed("text_color");
    }
  }
}
 
.forget {
  color: #1d91ff;
  font-size: 24px;
  line-height: 28px;
}
 
.btn {
  color: #fff;
  height: 88px;
  line-height: 88px;
  text-align: center;
  font-size: 32px;
  margin-top: 40px;
  border-radius: 10px;
}
 
.noTips {
  margin-top: 48px;
}
 
.protocol {
  display: flex;
  align-items: center;
  height: 30px;
  margin-top: 20px;
  i {
    width: 30px;
    height: 30px;
    margin-right: 18px;
 
    img {
      width: 100%;
      height: 100%;
    }
  }
}
 
.iptbox {
  height: 88px;
  margin-top: 16px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px;
  input {
    flex: 1;
    height: 100%;
    border: none;
  }
  span {
    color: #1d91ff;
  }
}
</style>