<template>
|
<van-nav-bar :left-arrow="false" class="head">
|
<template #left>
|
<div class="textColor" @click="onRoute('/')">{{ $t('首页') }}</div>
|
</template>
|
<template #title>
|
<img :src="LOGO" alt="" class="head_logo">
|
</template>
|
<template #right>
|
<img :src="languageObj.image" alt="" class="gq" @click="onRoute('/language')">
|
</template>
|
</van-nav-bar>
|
|
<div class="login">
|
<div class="login_title textColor">{{ $t('login') }}</div>
|
|
<ExInput style="padding-bottom:16px !important;" :placeholderText="getRegType(activeIndex, false)"
|
v-model="username" :dialCode="dialCode" @selectArea="onSelectArea" :area="isArea" :icon="icon"
|
@pressEnter="verifyLogin" />
|
|
<ExInput style="padding-bottom:0 !important;" :placeholderText="$t('entryPassword')" v-model="password"
|
typeText="password" @pressEnter="verifyLogin" />
|
|
<div class="forget" @click="$router.push('/forget')">{{ $t('forgetPassword') }}</div>
|
|
<van-button class="w-full btnBackground2 btnText" style="margin-top:2rem;" type="primary"
|
@click="verifyLogin">{{
|
$t('login')
|
}}
|
</van-button>
|
|
<div class="noTips textColor1">
|
{{ $t('noAccount') }}?
|
<span class="textColor" @click="$router.push('/register')">
|
{{ $t('goRegister') }}</span>
|
</div>
|
<nationality-list ref='controlChildRef' :title="$t('selectArea')" @getName="getName"></nationality-list>
|
</div>
|
</template>
|
|
<script setup>
|
import ExInput from "@/components/ex-input/new-input.vue";
|
import { _loginUser } from "@/service/login.api";
|
import { _exchangerateuserconfig } from "@/service/trade.api";
|
import { GET_USERINFO } from '@/store/types.store'
|
import { useUserStore } from '@/store/user';
|
import { useLanguageStore } from '@/store/language.store'
|
import { useI18n } from 'vue-i18n'
|
import nationalityList from '../authentication/components/nationalityList.vue'
|
import { ref } from 'vue';
|
import { useRouter } from 'vue-router';
|
import { showToast } from "vant";
|
import store from '@/store/store'
|
import { LOGO, lang } from "@/config";
|
const { t } = useI18n()
|
|
const router = useRouter()
|
const onRoute = (path) => {
|
if (path == 'back') {
|
router.go(-1)
|
} else {
|
router.push(path)
|
}
|
}
|
|
let username = ref('')
|
let password = ref('')
|
let activeIndex = ref(0)
|
let isArea = ref(false)
|
let dialCode = ref(0)
|
let icon = ref('')
|
const type = ref(3)
|
|
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 controlChildRef = ref(null)
|
const onSelectArea = () => {
|
controlChildRef.value.open();
|
}
|
|
//获取到当前选中国家的code值
|
const getName = (params) => {
|
icon.value = params.code;
|
dialCode.value = params.dialCode;
|
}
|
|
const changeIndex = (index) => {
|
activeIndex.value = index;
|
switch (index) {
|
case 0:
|
case 1: {
|
isArea.value = false;
|
break;
|
}
|
case 2: {
|
isArea.value = true;
|
break;
|
}
|
}
|
}
|
|
const verifyLogin = () => {
|
switch (activeIndex.value) {
|
case 0:
|
{
|
type.value = 3;
|
break;
|
}
|
case 1:
|
{
|
type.value = 2;
|
break;
|
}
|
case 2:
|
{
|
type.value = 1;
|
break;
|
}
|
}
|
if (username.value == '') {
|
switch (activeIndex.value) {
|
case 0:
|
{
|
showToast(t('entryAccount'));
|
break;
|
}
|
case 1:
|
{
|
showToast(t('entryEmail'));
|
break;
|
}
|
case 2:
|
{
|
showToast(t('entryPhone'));
|
break;
|
}
|
}
|
return false
|
}
|
if (password.value == '') {
|
showToast(t('entryPassword'));
|
return false
|
}
|
loginUser()
|
}
|
|
const userStore = useUserStore();
|
const loginUser = () => {
|
_loginUser({
|
userName: (activeIndex.value == 0 || activeIndex.value == 1) ? username.value : `${dialCode.value}${username.value}`,
|
passWord: password.value,
|
type: type.value
|
}).then((res) => {
|
userStore[GET_USERINFO](res)
|
store.commit('user/SET_USERINFO', res)
|
router.push('/')
|
}).catch((res) => {
|
console.log(res)
|
})
|
}
|
|
// 语言切换
|
const languageStore = useLanguageStore()
|
const languageObj = lang.find(i => i.key == languageStore.language)
|
|
const ddddd = () => {
|
if (store.state.vant.theme == 'light') store.commit('vant/SET_THEME', 'dark')
|
else store.commit('vant/SET_THEME', 'light')
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.head_logo {
|
height: 3rem;
|
}
|
|
.gq {
|
height: 2rem;
|
}
|
|
.head {
|
@include themify() {
|
border-bottom: themed("divi_line") 1px solid;
|
}
|
}
|
|
::v-deep .van-nav-bar__text {
|
@include themify() {
|
color: themed("text_color");
|
}
|
}
|
|
.login {
|
width: 100%;
|
font-size: 1.3rem;
|
box-sizing: border-box;
|
padding: 1.5rem;
|
min-height: 100vh;
|
|
@include themify() {
|
background: themed("main_background");
|
}
|
|
:deep(.textColor) {
|
color: $log-c;
|
}
|
|
.login_title {
|
font-size: 3.5rem;
|
margin-top: 5rem;
|
margin-bottom: 4rem;
|
}
|
|
.divider {
|
width: 100%;
|
height: 2px;
|
border-radius: 1px;
|
background: $bg_yellow;
|
}
|
|
.log {
|
width: 100%;
|
|
img {
|
width: 8.5rem;
|
}
|
}
|
|
.w-full {
|
border: none;
|
font-size: 16px;
|
font-weight: 600;
|
}
|
}
|
|
|
.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;
|
}
|
|
.login-tab {
|
margin-bottom: 20px;
|
|
div {
|
padding: 0 20px;
|
height: 34px;
|
line-height: 34px;
|
text-align: center;
|
border-radius: 4px;
|
margin-right: 10px;
|
}
|
|
.active {
|
background: $US_tabActice_background;
|
color: $color_main;
|
}
|
}
|
|
.forget {
|
font-size: 1.4rem;
|
line-height: 1.6rem;
|
margin-top: 3.4rem;
|
text-decoration: underline;
|
}
|
|
.noTips {
|
margin-top: 2.4rem;
|
text-align: center;
|
font-size: 1.5rem;
|
|
span {
|
text-decoration: underline;
|
}
|
}
|
</style>
|