|
|
|
@ -14,10 +14,10 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- Logo --> |
|
|
|
<image class="logo" src="/static/logo.png" mode="aspectFit"></image> |
|
|
|
<!-- <image class="logo" src="/static/logo.png" mode="aspectFit"></image> --> |
|
|
|
|
|
|
|
<!-- 欢迎语 --> |
|
|
|
<text class="welcome-text">登录</text> |
|
|
|
<text class="welcome-text">登录DeepChart</text> |
|
|
|
|
|
|
|
<!-- 邮箱/手机号切换 --> |
|
|
|
<view class="switch-container"> |
|
|
|
@ -45,7 +45,11 @@ |
|
|
|
/> |
|
|
|
<view v-else class="phone-input-container"> |
|
|
|
<view class="country-code-selector" @click="showCountryPicker"> |
|
|
|
<image class="country-flag-img" :src="selectedCountry.flag" mode="aspectFit"></image> |
|
|
|
<image |
|
|
|
class="country-flag-img" |
|
|
|
:src="selectedCountry.flag" |
|
|
|
mode="aspectFit" |
|
|
|
></image> |
|
|
|
<text class="country-code">{{ selectedCountry.code }}</text> |
|
|
|
<text class="arrow-down">▼</text> |
|
|
|
</view> |
|
|
|
@ -97,7 +101,7 @@ |
|
|
|
<script setup> |
|
|
|
import { ref } from "vue"; |
|
|
|
// 导入完整的国家列表 |
|
|
|
import countryList from './list.js'; |
|
|
|
import countryList from "./list.js"; |
|
|
|
|
|
|
|
const email = ref(""); |
|
|
|
const phone = ref(""); |
|
|
|
@ -106,24 +110,31 @@ const switchType = ref("Email"); // 默认是邮箱注册 |
|
|
|
const { safeAreaInsets } = uni.getSystemInfoSync(); |
|
|
|
|
|
|
|
// 使用从list.js导入的完整国家列表数据 |
|
|
|
const countries = ref(countryList.list.map(item => ({ |
|
|
|
const countries = ref( |
|
|
|
countryList.list.map((item) => ({ |
|
|
|
name: item.name, |
|
|
|
code: `+${item.tel}`, |
|
|
|
flag: item.flag, |
|
|
|
short: item.short, |
|
|
|
en: item.en |
|
|
|
}))); |
|
|
|
en: item.en, |
|
|
|
})) |
|
|
|
); |
|
|
|
|
|
|
|
// 默认选中的国家(中国) |
|
|
|
const selectedCountry = ref(countries.value.find(country => country.short === 'CN') || countries.value[0]); |
|
|
|
const selectedCountry = ref( |
|
|
|
countries.value.find((country) => country.short === "CN") || |
|
|
|
countries.value[0] |
|
|
|
); |
|
|
|
|
|
|
|
// 显示国家选择器 |
|
|
|
function showCountryPicker() { |
|
|
|
uni.showActionSheet({ |
|
|
|
itemList: countries.value.map(country => `${country.name} ${country.code}`), |
|
|
|
itemList: countries.value.map( |
|
|
|
(country) => `${country.name} ${country.code}` |
|
|
|
), |
|
|
|
success: function (res) { |
|
|
|
selectedCountry.value = countries.value[res.tapIndex]; |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@ -175,11 +186,48 @@ function register() { |
|
|
|
function loginWithApple() { |
|
|
|
// Apple登录逻辑 |
|
|
|
console.log("通过Apple登录"); |
|
|
|
uni.login({ |
|
|
|
provider: "apple", |
|
|
|
success: function (loginRes) { |
|
|
|
// 登录成功 |
|
|
|
uni.getUserInfo({ |
|
|
|
provider: "apple", |
|
|
|
success: function (info) { |
|
|
|
// 获取用户信息成功, info.authResult中保存登录认证数据 |
|
|
|
console.log(info); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
// 登录授权失败 |
|
|
|
// err.code错误码参考`授权失败错误码(code)说明` |
|
|
|
console.log(err); |
|
|
|
|
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function loginWithGoogle() { |
|
|
|
// Google登录逻辑 |
|
|
|
console.log("通过Google登录"); |
|
|
|
uni.login({ |
|
|
|
provider: "google", |
|
|
|
success: function (loginRes) { |
|
|
|
// 登录成功 |
|
|
|
uni.getUserInfo({ |
|
|
|
provider: "google", |
|
|
|
success: function (info) { |
|
|
|
// 获取用户信息成功, info.authResult保存用户信息 |
|
|
|
console.log(info); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
// 登录授权失败 |
|
|
|
// err.code是错误码 |
|
|
|
console.log(err); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function goToRegistration() { |
|
|
|
@ -194,12 +242,11 @@ function onPhoneInput(e) { |
|
|
|
const value = e.detail.value; |
|
|
|
// 使用 isNaN 检查是否为有效数字 |
|
|
|
if (isNaN(value)) { |
|
|
|
phone.value = ''; |
|
|
|
phone.value = ""; |
|
|
|
} else { |
|
|
|
phone.value = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
@ -258,8 +305,8 @@ function onPhoneInput(e) { |
|
|
|
font-weight: bold; |
|
|
|
color: #333333; |
|
|
|
margin-bottom: 60rpx; |
|
|
|
text-align: left; |
|
|
|
align-self: flex-start; |
|
|
|
/* text-align: left; */ |
|
|
|
/* align-self: flex-start; */ |
|
|
|
} |
|
|
|
.switch-container { |
|
|
|
display: flex; |
|
|
|
|