2025-01-09 11:57:50 +00:00
|
|
|
<script setup>
|
2025-01-15 05:05:06 +00:00
|
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import countryCode from '../countryRegion/data/index.js'
|
2025-01-17 06:07:19 +00:00
|
|
|
import {senCode, userLogin} from "@/api/auth/index.js";
|
2025-01-23 11:43:45 +00:00
|
|
|
import {authStore} from "@/stores/auth/index.js";
|
2025-01-20 05:59:50 +00:00
|
|
|
import {message} from '@/components/x-message/useMessage.js'
|
2025-02-17 05:33:31 +00:00
|
|
|
import {fddCheck} from "~/api/goods/index.js";
|
2025-02-20 12:40:00 +00:00
|
|
|
const {userInfo,token,selectedZone}= authStore()
|
2025-01-10 06:00:42 +00:00
|
|
|
const router = useRouter();
|
2025-01-15 05:05:06 +00:00
|
|
|
const route = useRoute();
|
|
|
|
const { locale } = useI18n()
|
2025-01-13 03:30:20 +00:00
|
|
|
definePageMeta({
|
2025-03-07 03:48:59 +00:00
|
|
|
name: 'login',
|
2025-02-12 08:50:52 +00:00
|
|
|
i18n: 'login.title'
|
2025-01-13 03:30:20 +00:00
|
|
|
})
|
2025-01-16 08:18:38 +00:00
|
|
|
const loadingRef=ref({
|
2025-01-20 05:59:50 +00:00
|
|
|
loading1:false,
|
|
|
|
loading2:false,
|
2025-01-16 08:18:38 +00:00
|
|
|
})
|
|
|
|
const isExist=ref(false)//帐号是否存在 true存在
|
|
|
|
const isReal=ref(false) //isReal 是否实名过
|
2025-03-02 06:10:24 +00:00
|
|
|
const codeInput=ref(null)
|
2025-01-10 06:00:42 +00:00
|
|
|
function goToPage() {
|
|
|
|
router.push('/countryRegion');
|
|
|
|
}
|
2025-01-20 03:42:25 +00:00
|
|
|
const interval=ref(null)
|
2025-01-16 08:28:21 +00:00
|
|
|
const startCountdown=()=> {
|
2025-01-20 03:42:25 +00:00
|
|
|
if (interval.value){
|
|
|
|
clearInterval(interval.value);
|
|
|
|
}
|
2025-01-16 08:28:21 +00:00
|
|
|
countdown.value = 60;
|
2025-01-20 03:42:25 +00:00
|
|
|
interval.value = setInterval(() => {
|
2025-01-16 08:28:21 +00:00
|
|
|
if (countdown.value > 0) {
|
|
|
|
countdown.value--;
|
|
|
|
} else {
|
2025-01-20 03:42:25 +00:00
|
|
|
clearInterval(interval.value);
|
2025-01-16 08:28:21 +00:00
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
const countdown = ref(0);
|
2025-02-25 06:42:14 +00:00
|
|
|
const phoneNum = ref('')
|
|
|
|
const code = ref('')
|
2025-01-15 05:05:06 +00:00
|
|
|
const pane = ref(0)
|
|
|
|
// 根据语言获取默认国家
|
|
|
|
const getDefaultCountry = () => {
|
|
|
|
let defaultCode = 'CN' // 默认中国大陆
|
|
|
|
switch (locale.value) {
|
|
|
|
case 'zh-CN':
|
|
|
|
defaultCode = 'CN'
|
|
|
|
break
|
|
|
|
case 'zh-TW':
|
|
|
|
defaultCode = 'TW'
|
|
|
|
break
|
|
|
|
case 'ja-JP':
|
|
|
|
defaultCode = 'JP'
|
|
|
|
break
|
|
|
|
case 'en-US':
|
|
|
|
defaultCode = 'US'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
const country = countryCode.find(c => c.code === defaultCode)
|
|
|
|
return {
|
|
|
|
zone: country.zone,
|
|
|
|
name: locale.value === 'zh-CN' ? country.cn :
|
|
|
|
locale.value === 'zh-TW' ? country.tw :
|
|
|
|
locale.value === 'ja-JP' ? country.ja :
|
|
|
|
country.en
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultCountry = getDefaultCountry()
|
|
|
|
|
2025-03-07 05:46:26 +00:00
|
|
|
const selectedCountry = ref('')
|
2025-01-15 05:05:06 +00:00
|
|
|
|
2025-02-20 12:40:00 +00:00
|
|
|
onMounted(()=>{
|
|
|
|
selectedZone.value=route.query.zone || defaultCountry.zone
|
2025-03-07 05:46:26 +00:00
|
|
|
selectedCountry.value=route.query.countryName || defaultCountry.name
|
2025-01-15 05:05:06 +00:00
|
|
|
})
|
2025-01-16 07:40:06 +00:00
|
|
|
const vanSwipeRef=ref(null)
|
|
|
|
const getCode =async () => {
|
2025-01-21 03:46:47 +00:00
|
|
|
loadingRef.value.loading1=true
|
2025-01-20 03:42:25 +00:00
|
|
|
const res=await senCode({
|
|
|
|
telNum:phoneNum.value,
|
|
|
|
zone:selectedZone.value
|
|
|
|
})
|
|
|
|
loadingRef.value.loading1=false
|
|
|
|
if (res.status===0){
|
2025-01-21 07:59:59 +00:00
|
|
|
|
2025-01-20 03:42:25 +00:00
|
|
|
|
2025-01-21 03:46:47 +00:00
|
|
|
}
|
2025-01-21 07:59:59 +00:00
|
|
|
pane.value = 1
|
|
|
|
vanSwipeRef.value?.swipeTo(pane.value)
|
2025-03-02 06:10:24 +00:00
|
|
|
|
2025-01-21 07:59:59 +00:00
|
|
|
startCountdown();
|
2025-01-15 05:05:06 +00:00
|
|
|
}
|
|
|
|
const goBack = () => {
|
|
|
|
code.value = ''
|
|
|
|
pane.value = 0
|
2025-01-16 07:40:06 +00:00
|
|
|
vanSwipeRef.value?.swipeTo(pane.value)
|
2025-01-15 05:05:06 +00:00
|
|
|
}
|
2025-01-17 06:07:19 +00:00
|
|
|
const goLogin =async () => {
|
2025-01-20 05:59:50 +00:00
|
|
|
loadingRef.value.loading2=true
|
2025-01-17 06:07:19 +00:00
|
|
|
const res=await userLogin({
|
|
|
|
telNum:phoneNum.value,
|
|
|
|
zone:selectedZone.value,
|
|
|
|
code:code.value
|
|
|
|
})
|
|
|
|
if (res.status===0){
|
|
|
|
userInfo.value=res.data.accountInfo
|
|
|
|
token.value=res.data.token
|
2025-01-20 05:59:50 +00:00
|
|
|
|
2025-02-13 03:53:24 +00:00
|
|
|
if (res.data?.accountInfo?.userExtend?.isReal===0){
|
2025-02-14 08:47:56 +00:00
|
|
|
await router.push({
|
|
|
|
path: '/realAuth',
|
|
|
|
query:{
|
|
|
|
statusCode:0
|
|
|
|
}
|
2025-02-17 05:33:31 +00:00
|
|
|
})
|
|
|
|
}else if (res.data.isJumpFdd){
|
|
|
|
const res1=await fddCheck()
|
|
|
|
if (res1.status===0){
|
|
|
|
window.location.href=res1.data.h5Url
|
|
|
|
}
|
2025-03-02 03:09:06 +00:00
|
|
|
}else {
|
2025-01-20 05:59:50 +00:00
|
|
|
await router.push('/');
|
2025-01-17 06:07:19 +00:00
|
|
|
}
|
|
|
|
}
|
2025-01-20 05:59:50 +00:00
|
|
|
loadingRef.value.loading2=false
|
2025-01-17 06:07:19 +00:00
|
|
|
}
|
2025-02-25 07:24:09 +00:00
|
|
|
const isKeyboardVisible = ref(false)
|
|
|
|
const windowHeight = ref(window.innerHeight)
|
2025-03-02 06:10:24 +00:00
|
|
|
const isFocused = ref(false)
|
2025-02-25 07:24:09 +00:00
|
|
|
onMounted(() => {
|
|
|
|
// 记录初始窗口高度
|
|
|
|
windowHeight.value = window.innerHeight
|
|
|
|
|
|
|
|
// 监听窗口大小变化
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
// 如果当前高度明显小于初始高度,认为键盘已打开
|
|
|
|
isKeyboardVisible.value = window.innerHeight < windowHeight.value * 0.8
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
window.removeEventListener('resize', () => {})
|
|
|
|
})
|
2025-01-09 11:57:50 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-03-02 05:57:52 +00:00
|
|
|
<div class="w-[100vw] bg-[url('@/static/images/asdfsdd.png')] bg-bottom bg-cover grow-1 px-[31px] pt-[86px]">
|
2025-01-10 01:56:19 +00:00
|
|
|
<div class="w-full flex justify-center mb-[100px]">
|
|
|
|
<img class="h-[105px] w-[189px]" src="@/static/images/ghfggff.png" alt="">
|
|
|
|
</div>
|
2025-01-16 07:40:06 +00:00
|
|
|
<van-swipe ref="vanSwipeRef" :show-indicators="false" :touchable="false" :lazy-render="true" :loop="false">
|
|
|
|
<van-swipe-item >
|
2025-02-17 02:52:10 +00:00
|
|
|
<div v-if="pane===0">
|
2025-01-16 07:40:06 +00:00
|
|
|
<div class="">
|
|
|
|
<div class="w-full flex justify-between" @click="goToPage">
|
|
|
|
<div class="text-[16px] text-[#000]">
|
|
|
|
{{ selectedCountry }}
|
|
|
|
</div>
|
|
|
|
<div><van-icon color="#777" name="arrow" size="14" /></div>
|
|
|
|
</div>
|
|
|
|
<div class="border-b-[1.7px] mt-[8px]">
|
|
|
|
<van-field v-model="phoneNum" clearable :placeholder="$t('login.phonePlaceholder')">
|
|
|
|
<template #label>
|
|
|
|
<div class="text-[16px] text-[#1A1A1A] flex align-center justify-start">
|
|
|
|
+{{ selectedZone }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</van-field>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="mt-[55px]">
|
2025-02-25 09:00:07 +00:00
|
|
|
<van-button :loading="loadingRef.loading1" v-if="phoneNum" :loading-text="$t('login.getCode')" color="#2B53AC" block style="height: 48px" @click="getCode">{{ $t('login.getCode') }}</van-button>
|
|
|
|
<van-button v-else type="primary" color="#D3D3D3" block style="height: 48px">{{ $t('login.getCode') }}</van-button>
|
2025-01-10 01:56:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2025-01-16 07:40:06 +00:00
|
|
|
</van-swipe-item>
|
|
|
|
<van-swipe-item>
|
2025-02-17 02:52:10 +00:00
|
|
|
<div v-if="pane===1">
|
2025-01-16 07:40:06 +00:00
|
|
|
<div class="flex mb-[16px]">
|
|
|
|
<div class="text-[16px] text-[#BDBDBD] mr-[10px]">{{ $t('login.hasSendTo') }}</div>
|
|
|
|
<div class="text-[16px] text-[#000]">+{{ selectedZone }} {{ phoneNum }}</div>
|
|
|
|
</div>
|
2025-03-02 06:10:24 +00:00
|
|
|
<div class="relative">
|
2025-03-02 09:21:17 +00:00
|
|
|
<van-password-input
|
|
|
|
:value="code"
|
|
|
|
:gutter="10"
|
|
|
|
:mask="false"
|
2025-03-02 06:10:24 +00:00
|
|
|
:focused="isFocused"
|
2025-03-02 05:57:52 +00:00
|
|
|
/>
|
2025-03-02 09:21:17 +00:00
|
|
|
<input
|
|
|
|
v-model="code"
|
|
|
|
type="tel"
|
|
|
|
maxlength="6"
|
2025-03-02 06:10:24 +00:00
|
|
|
ref="codeInput"
|
2025-03-02 09:21:17 +00:00
|
|
|
class="opacity-0 absolute top-0 left-0 h-full w-full"
|
2025-03-02 05:57:52 +00:00
|
|
|
@input="code = $event.target.value.replace(/\D/g, '').slice(0, 6)"
|
2025-03-02 06:10:24 +00:00
|
|
|
@focus="isFocused = true"
|
|
|
|
@blur="isFocused = false"
|
2025-03-02 05:57:52 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2025-02-25 09:00:07 +00:00
|
|
|
<div class="flex justify-between">
|
|
|
|
<div :class="`${countdown>0?'text-#BDBDBD':'text-#2B53AC'} text-14px`">
|
|
|
|
{{ $t('login.reSend') }}<span v-if="countdown>0">({{countdown}})</span>
|
|
|
|
</div>
|
|
|
|
<div @click="goBack" class="text-#2B53AC text-14px">
|
|
|
|
{{ $t('login.back') }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-01-16 07:40:06 +00:00
|
|
|
<div class="mt-[17px]">
|
2025-02-25 09:00:07 +00:00
|
|
|
<van-button v-if="code.length === 6" type="primary" block :loading="loadingRef.loading2" :loading-text="$t('login.login')" style="height: 48px" @click="goLogin">{{ $t('login.login') }}</van-button>
|
2025-01-16 07:40:06 +00:00
|
|
|
<van-button v-else type="primary" color="#D3D3D3" block style="height: 48px">{{ $t('login.login') }}</van-button>
|
|
|
|
</div>
|
2025-01-10 01:56:19 +00:00
|
|
|
</div>
|
2025-01-16 07:40:06 +00:00
|
|
|
</van-swipe-item>
|
|
|
|
</van-swipe>
|
2025-02-25 07:24:09 +00:00
|
|
|
<div v-if="!isKeyboardVisible" class="text-center text-14px absolute left-1/2 transform translate-x--1/2 bottom-20px">
|
2025-02-25 09:00:07 +00:00
|
|
|
{{ $t('login.agreement') }}<span class="text-#3454AF " @click="$router.push('/privacyPolicy')">{{ $t('login.privacyPolicy') }}</span>
|
2025-02-24 06:05:49 +00:00
|
|
|
</div>
|
2025-01-09 11:57:50 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2025-01-10 01:56:19 +00:00
|
|
|
<style scoped lang="scss">
|
2025-01-15 05:05:06 +00:00
|
|
|
:deep(.van-cell.van-field) {
|
2025-01-10 01:56:19 +00:00
|
|
|
padding-left: 0;
|
|
|
|
}
|
2025-01-15 05:05:06 +00:00
|
|
|
|
|
|
|
:deep(.van-password-input) {
|
2025-01-10 01:56:19 +00:00
|
|
|
margin: 0;
|
|
|
|
}
|
2025-01-15 05:05:06 +00:00
|
|
|
|
|
|
|
:deep(.van-password-input__item) {
|
2025-01-10 01:56:19 +00:00
|
|
|
border: 1px solid #E5E5E5;
|
|
|
|
width: 41px;
|
|
|
|
height: 41px;
|
|
|
|
}
|
|
|
|
</style>
|