<template>
|
<div class="login">
|
<van-loading color="#92D1FF" class="loading-box" v-if="isLoading" />
|
|
<!-- 顶部导航栏 -->
|
<div class="header">
|
<div class="back-btn" @click="onRoute('/')">
|
<img src="../../assets/image/icon_back2.png" alt="" />
|
</div>
|
<div class="sign-up " @click="$router.push('/register')">{{ $t('register') }}</div>
|
</div>
|
|
<!-- Logo -->
|
<div class="logo-wrap">
|
<img src="../../assets/image/login_logo.png" alt="logo" />
|
</div>
|
|
<!-- 标题 -->
|
<div class="title textColor">{{ $t('letsStartLogin') }}</div>
|
|
<!-- 账号输入 -->
|
<ExInput :label="$t('account')" :placeholderText="$t('entryAccount')" v-model="username" />
|
|
<!-- 密码输入 -->
|
<ExInput style="padding-bottom:0!important;" :label="$t('password')" :placeholderText="$t('entryPassword')"
|
v-model="password" typeText="password" />
|
|
<!-- 登录按钮 -->
|
<van-button class="w-full sign-in-btn" type="primary" @click="verifyLogin">
|
{{ $t('login') }}
|
</van-button>
|
|
<!-- 钱包登录按钮 -->
|
<!-- <van-button class="w-full wallet-btn" plain @click="onLoginByWallet">
|
{{ $t('loginByWallet') }}
|
</van-button> -->
|
|
<!-- 忘记密码 -->
|
<div class="forget-wrap textColor" @click="$router.push('/forget')">
|
<span>{{ $t('forgot') }}</span>
|
<span> {{ $t('password') }}</span>
|
</div>
|
|
<nationality-list ref='controlChildRef' :title="$t('selectArea')" @getName="getName"></nationality-list>
|
</div>
|
</template>
|
|
<script setup>
|
import ExInput from "@/components/ex-input/index.vue";
|
import { _loginUser } from "@/service/login.api";
|
import { GET_USERINFO } from '@/store/types.store'
|
import { useUserStore } from '@/store/user';
|
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'
|
|
const router = useRouter()
|
const { t } = useI18n()
|
|
const onRoute = (path) => {
|
if (path == 'back') {
|
router.go(-1)
|
} else {
|
router.push(path)
|
}
|
}
|
|
let username = ref('')
|
let password = ref('')
|
let dialCode = ref(0)
|
let icon = ref('')
|
const type = ref(3)
|
|
const controlChildRef = ref(null)
|
const isLoading = ref(false)
|
|
const getName = (params) => {
|
icon.value = params.code;
|
dialCode.value = params.dialCode;
|
}
|
|
const verifyLogin = () => {
|
if (username.value == '') {
|
showToast(t('entryAccount'));
|
return false
|
}
|
if (password.value == '') {
|
showToast(t('entryPassword'));
|
return false
|
}
|
loginUser()
|
}
|
|
const onLoginByWallet = () => {
|
router.push('/walletLogin')
|
}
|
|
const userStore = useUserStore();
|
const loginUser = () => {
|
isLoading.value = true
|
_loginUser({
|
userName: username.value,
|
passWord: password.value,
|
type: type.value
|
}).then((res) => {
|
console.log("reslogin")
|
console.log(res)
|
isLoading.value = false
|
userStore[GET_USERINFO](res)
|
store.commit('user/SET_USERINFO', res)
|
router.push('/')
|
}).catch((res) => {
|
isLoading.value = false
|
console.log(res)
|
})
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
:deep(.van-loading) {
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -50%);
|
}
|
|
.login {
|
width: 100%;
|
min-height: 100vh;
|
padding: 0 3rem 5rem;
|
font-size: 1.62rem;
|
box-sizing: border-box;
|
background: #fff;
|
}
|
|
/* 顶部导航 */
|
.header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding-top: 3rem;
|
padding-bottom: 1rem;
|
|
.back-btn {
|
width: 4rem;
|
height: 4rem;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
cursor: pointer;
|
|
img {
|
width: 100%;
|
}
|
}
|
|
.sign-up {
|
font-size: 2.4rem;
|
font-weight: 500;
|
cursor: pointer;
|
}
|
}
|
|
/* Logo */
|
.logo-wrap {
|
display: flex;
|
justify-content: center;
|
margin-bottom: 3rem;
|
|
img {
|
width: 18rem;
|
object-fit: contain;
|
}
|
}
|
|
/* 标题 */
|
.title {
|
font-size: 3.6rem;
|
text-align: center;
|
margin-bottom: 4.5rem;
|
}
|
|
/* 登录按钮 */
|
.sign-in-btn {
|
margin-top: 5.5rem;
|
border-radius: 1rem !important;
|
height: 7.5rem !important;
|
font-size: 2.5rem;
|
}
|
|
/* 钱包登录按钮 */
|
.wallet-btn {
|
margin-top: 1.75rem;
|
border-radius: 1rem !important;
|
height: 6.25rem !important;
|
font-size: 2rem !important;
|
font-weight: 500 !important;
|
color: #333 !important;
|
border-color: #333 !important;
|
background: #fff !important;
|
|
:deep(.van-button__text) {
|
color: #333;
|
}
|
}
|
|
/* 忘记密码 */
|
.forget-wrap {
|
margin-top: 3rem;
|
text-align: center;
|
font-size: 2rem;
|
cursor: pointer;
|
}
|
</style>
|