Merge remote-tracking branch 'origin/cyh666666/consumer'
This commit is contained in:
@@ -19,14 +19,15 @@
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const email = ref('')
|
||||
const code = ref('')
|
||||
const counting = ref(false)
|
||||
const count = ref(60)
|
||||
const email = ref<string>('')
|
||||
const code = ref<string>('')
|
||||
const counting = ref<boolean>(false)
|
||||
const count = ref<number>(60)
|
||||
let timer: number = 0
|
||||
|
||||
const sendCode = () => {
|
||||
const sendCode = async (): Promise<void> => {
|
||||
if (counting.value) return
|
||||
if (!email.value || !email.value.includes('@')) {
|
||||
if (email.value == '' || email.value.includes('@') == false) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的邮箱',
|
||||
icon: 'none'
|
||||
@@ -34,10 +35,14 @@ const sendCode = () => {
|
||||
return
|
||||
}
|
||||
|
||||
uni.showLoading({ title: '发送中...' })
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
counting.value = true
|
||||
count.value = 60
|
||||
|
||||
const timer = setInterval(() => {
|
||||
timer = setInterval(() => {
|
||||
count.value--
|
||||
if (count.value <= 0) {
|
||||
clearInterval(timer)
|
||||
@@ -51,8 +56,8 @@ const sendCode = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!email.value || !code.value) {
|
||||
const handleSubmit = async (): Promise<void> => {
|
||||
if (email.value == '' || code.value == '') {
|
||||
uni.showToast({
|
||||
title: '请填写完整信息',
|
||||
icon: 'none'
|
||||
@@ -60,48 +65,39 @@ const handleSubmit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Call API to bind email
|
||||
uni.showLoading({ title: '提交中...' })
|
||||
uni.showLoading({ title: '绑定中...' })
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 更新本地存储的用户信息
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (userInfo) {
|
||||
// @ts-ignore
|
||||
userInfo.email = email.value
|
||||
uni.setStorageSync('userInfo', userInfo)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}, 1000)
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 0 15px;
|
||||
margin-bottom: 30px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.input-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 50px;
|
||||
padding: 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
@@ -118,18 +114,23 @@ const handleSubmit = () => {
|
||||
.input {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.code-btn {
|
||||
color: #007aff;
|
||||
font-size: 14px;
|
||||
font-size: 12px;
|
||||
color: #ff4444;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ff4444;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 25px;
|
||||
background-color: #ff4444;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const phone = ref('')
|
||||
const code = ref('')
|
||||
const counting = ref(false)
|
||||
const count = ref(60)
|
||||
const phone = ref<string>('')
|
||||
const code = ref<string>('')
|
||||
const counting = ref<boolean>(false)
|
||||
const count = ref<number>(60)
|
||||
let timer: number = 0
|
||||
|
||||
const sendCode = () => {
|
||||
const sendCode = async (): Promise<void> => {
|
||||
if (counting.value) return
|
||||
if (!phone.value || phone.value.length !== 11) {
|
||||
if (phone.value == '' || phone.value.length != 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none'
|
||||
@@ -34,10 +35,14 @@ const sendCode = () => {
|
||||
return
|
||||
}
|
||||
|
||||
uni.showLoading({ title: '发送中...' })
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
counting.value = true
|
||||
count.value = 60
|
||||
|
||||
const timer = setInterval(() => {
|
||||
timer = setInterval(() => {
|
||||
count.value--
|
||||
if (count.value <= 0) {
|
||||
clearInterval(timer)
|
||||
@@ -51,8 +56,8 @@ const sendCode = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!phone.value || !code.value) {
|
||||
const handleSubmit = async (): Promise<void> => {
|
||||
if (phone.value == '' || code.value == '') {
|
||||
uni.showToast({
|
||||
title: '请填写完整信息',
|
||||
icon: 'none'
|
||||
@@ -60,27 +65,25 @@ const handleSubmit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Call API to bind phone
|
||||
uni.showLoading({ title: '提交中...' })
|
||||
uni.showLoading({ title: '绑定中...' })
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
const userInfoRaw = uni.getStorageSync('userInfo')
|
||||
if (userInfoRaw != null) {
|
||||
const userInfo = userInfoRaw as UTSJSONObject
|
||||
userInfo.set('phone', phone.value)
|
||||
uni.setStorageSync('userInfo', userInfo)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 更新本地存储的用户信息
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (userInfo) {
|
||||
// @ts-ignore
|
||||
userInfo.phone = phone.value
|
||||
uni.setStorageSync('userInfo', userInfo)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}, 1000)
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -88,10 +91,7 @@ const handleSubmit = () => {
|
||||
.page-container {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
flex: 1;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 0 15px;
|
||||
@@ -132,4 +132,4 @@ const handleSubmit = () => {
|
||||
border-radius: 25px;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
try {
|
||||
const sessionInfo = supa.getSession()
|
||||
if (sessionInfo != null && sessionInfo.user != null) {
|
||||
uni.reLaunch({ url: '/pages/mall/consumer/index' })
|
||||
uni.reLaunch({ url: '/pages/main/index' })
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -62,8 +62,9 @@
|
||||
|
||||
<style>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%);
|
||||
/* min-height: 100vh; UVUE不支持vh */
|
||||
flex: 1;
|
||||
background-color: #f5f7fa; /* UVUE不支持渐变 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -73,33 +74,42 @@
|
||||
.splash {
|
||||
width: 100%;
|
||||
max-width: 640rpx;
|
||||
background: #ffffff;
|
||||
background-color: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 12rpx 48rpx rgba(0, 0, 0, 0.08);
|
||||
box-shadow: 0 12rpx 48rpx rgba(0, 0, 0, 0.08); /* 可能也不支持box-shadow, 视版本而定 */
|
||||
padding: 48rpx 40rpx;
|
||||
display: flex;
|
||||
flex-direction: column; /* 添加 flex-direction: column 以兼容 gap polyfill */
|
||||
|
||||
flex-direction: column;
|
||||
gap: 32rpx;
|
||||
/* gap: 32rpx; UVUE 不支持 gap */
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
/* gap: 20rpx; */
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 24rpx;
|
||||
background: linear-gradient(135deg, #ff6b6b, #ff9f43);
|
||||
background-color: #ff6b6b; /* UVUE不支持CSS线性渐变 */
|
||||
margin-right: 20rpx; /* 替代 gap */
|
||||
}
|
||||
|
||||
.brand-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
/* gap: 8rpx; */
|
||||
}
|
||||
/* 替代 gap: 8rpx */
|
||||
.brand-name {
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-size: 36rpx;
|
||||
@@ -116,23 +126,36 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
/* gap: 12rpx; */
|
||||
text-align: center;
|
||||
margin-top: 32rpx; /* 替代父级 gap */
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
/* 替代 gap: 12rpx */
|
||||
.status-text {
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 50%;
|
||||
border: 8rpx solid #f3f4f6;
|
||||
border-radius: 44rpx; /* 如果不支持 50%,可以用 44rpx */
|
||||
border-width: 8rpx;
|
||||
border-style: solid;
|
||||
border-color: #f3f4f6;
|
||||
border-top-color: #ff6b6b;
|
||||
animation: spin 1s linear infinite;
|
||||
/* animation: spin 1s linear infinite; UVUE CSS动画需要特定写法或 transform */
|
||||
/* transform: rotate(360deg); */
|
||||
/* transition-duration: 1000ms; */
|
||||
|
||||
/* 简单的无限旋转在原生 CSS 中可能需要写关键帧但 App-UVUE 支持有限,
|
||||
这里暂时保留样式但不指望它自动动起来,或者应该用 loading 组件 */
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 30rpx;
|
||||
color: #111827;
|
||||
font-weight: 600;
|
||||
font-weight: 700; /* 600不支持 -> 700 */
|
||||
}
|
||||
|
||||
.status-sub {
|
||||
@@ -143,8 +166,12 @@
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
/* gap: 16rpx; */
|
||||
}
|
||||
/* 替代 gap */
|
||||
.action {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.action {
|
||||
width: 100%;
|
||||
@@ -152,7 +179,7 @@
|
||||
padding: 24rpx;
|
||||
border-radius: 16rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.action.primary {
|
||||
@@ -166,6 +193,7 @@
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
/*
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
@@ -174,4 +202,5 @@
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
*/
|
||||
</style>
|
||||
|
||||
@@ -1,686 +1,377 @@
|
||||
<template>
|
||||
<view class="page-wrapper">
|
||||
<!-- Top section with language switch -->
|
||||
<view class="top-section"> <view class="language-switch">
|
||||
<view class="top-section">
|
||||
<view class="language-switch">
|
||||
<button class="language-btn" @click="toggleLanguage">
|
||||
{{ currentLocale === 'zh-CN' ? 'EN' : '中' }}
|
||||
{{ currentLocale === 'zh-CN' ? 'EN' : '中文' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Main content section -->
|
||||
<view class="main-section">
|
||||
<scroll-view direction="vertical" class="user-center-container">
|
||||
<!-- Header with user info -->
|
||||
<view class="user-header">
|
||||
<view class="user-info">
|
||||
<image class="user-avatar" :src="userAvatar" mode="aspectFill"></image>
|
||||
<view class="user-details">
|
||||
<text class="user-name">{{ profile.username ?? $t('user.center.unnamed') }}</text>
|
||||
<view class="edit-profile-link" @click="navigateToProfile">
|
||||
<text class="edit-text">{{ $t('user.center.edit_profile') }}</text>
|
||||
<text class="edit-icon">✏️</text>
|
||||
<view class="user-info">
|
||||
<image class="user-avatar" :src="userAvatar" mode="aspectFill"></image>
|
||||
<view class="user-details">
|
||||
<text class="user-name">{{ profile != null && profile.username != null ? profile.username : '未命名用户' }}</text>
|
||||
<view class="edit-profile-link" @click="navigateToProfile">
|
||||
<text class="edit-text">编辑资料</text>
|
||||
<text class="edit-icon">✏️</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-container">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.trainings }}</text>
|
||||
<text class="stat-label">训练</text>
|
||||
</view>
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.points }}</text>
|
||||
<text class="stat-label">积分</text>
|
||||
</view>
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.streak }}</text>
|
||||
<text class="stat-label">连续</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- User stats -->
|
||||
<view class="stats-container">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.trainings }}</text>
|
||||
<text class="stat-label">{{ $t('user.center.trainings') }}</text>
|
||||
</view>
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.points }}</text>
|
||||
<text class="stat-label">{{ $t('user.center.points') }}</text>
|
||||
</view>
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ userStats.streak }}</text>
|
||||
<text class="stat-label">{{ $t('user.center.streak') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Main menu sections -->
|
||||
<view class="menu-sections">
|
||||
<!-- Training section -->
|
||||
<view class="menu-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ $t('user.center.training') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-items">
|
||||
<view class="menu-item" @click="navigateTo('/pages/training/records')"> <view class="menu-icon training-records">📊</view>
|
||||
<text class="menu-text">{{ $t('user.center.training_records') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
<view class="menu-sections">
|
||||
<view class="menu-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">设置</text>
|
||||
</view>
|
||||
|
||||
<view class="section-items">
|
||||
<view class="menu-item" @click="navigateTo('/pages/settings/app')">
|
||||
<view class="menu-icon app-settings">⚙️</view>
|
||||
<text class="menu-text">应用设置</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/settings/about')">
|
||||
<view class="menu-icon about">ℹ️</view>
|
||||
<text class="menu-text">关于</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/user/notifications')">
|
||||
<view class="menu-icon notifications">🔔</view>
|
||||
<text class="menu-text">通知</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu-item" @click="navigateTo('/pages/training/plans')">
|
||||
<view class="menu-icon training-plans">📋</view>
|
||||
<text class="menu-text">{{ $t('user.center.training_plans') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/training/reports')">
|
||||
<view class="menu-icon reports">📈</view>
|
||||
<text class="menu-text">{{ $t('user.center.reports') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Account section -->
|
||||
<view class="menu-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ $t('user.center.account') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-items"> <view class="menu-item" @click="navigateTo('/pages/user/profile')">
|
||||
<view class="menu-icon profile">👤</view>
|
||||
<text class="menu-text">{{ $t('user.center.profile') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/user/devices')">
|
||||
<view class="menu-icon devices">📱</view>
|
||||
<text class="menu-text">{{ $t('user.center.devices') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/user/notifications')">
|
||||
<view class="menu-icon notifications">🔔</view>
|
||||
<text class="menu-text">{{ $t('user.center.notifications') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Settings section -->
|
||||
<view class="menu-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ $t('user.center.settings') }}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-items"> <view class="menu-item" @click="navigateTo('/pages/settings/app')">
|
||||
<view class="menu-icon app-settings">⚙️</view>
|
||||
<text class="menu-text">{{ $t('user.center.app_settings') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="navigateTo('/pages/settings/about')">
|
||||
<view class="menu-icon about">ℹ️</view>
|
||||
<text class="menu-text">{{ $t('user.center.about') }}</text>
|
||||
<text class="menu-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view> <!-- Logout button -->
|
||||
<button class="logout-button" @click="showLogoutConfirm">
|
||||
{{ $t('user.center.logout') }}
|
||||
</button>
|
||||
</view>
|
||||
<button class="logout-button" @click="showLogoutConfirm">退出登录</button>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- Bottom section -->
|
||||
<view class="bottom-section">
|
||||
<!-- Footer content or spacing -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="uts">
|
||||
import { AkReqOptions, AkReqResponse, AkReqError } from '@/uni_modules/ak-req/index.uts';
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import type { UserProfile,UserStats } from './types.uts';
|
||||
import { setUserProfile } from '@/utils/store.uts';
|
||||
import { AkSupaSelectOptions } from '@/components/supadb/aksupa.uts'
|
||||
import { switchLocale, getCurrentLocale } from '@/utils/utils.uts';
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { supabaseService } from '@/utils/supabaseService.uts'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isLoading: true,
|
||||
userStats: {
|
||||
trainings: 0,
|
||||
points: 0,
|
||||
streak: 0
|
||||
} as UserStats,
|
||||
profile: {
|
||||
username: '',
|
||||
email: ''
|
||||
} as UserProfile,
|
||||
userAvatar: '/static/default-avatar.png',
|
||||
currentLocale: getCurrentLocale()
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
onShow() {
|
||||
this.loadProfile();
|
||||
this.loadUserStats();
|
||||
}, methods: {
|
||||
toggleLanguage() {
|
||||
const newLocale = this.currentLocale === 'zh-CN' ? 'en-US' : 'zh-CN';
|
||||
switchLocale(newLocale);
|
||||
this.currentLocale = newLocale;
|
||||
type ProfileType = {
|
||||
id: string
|
||||
username: string | null
|
||||
email: string | null
|
||||
avatar_url: string | null
|
||||
}
|
||||
|
||||
type UserStatsType = {
|
||||
trainings: number
|
||||
points: number
|
||||
streak: number
|
||||
}
|
||||
|
||||
const profile = ref<ProfileType | null>(null)
|
||||
const userStats = ref<UserStatsType>({
|
||||
trainings: 0,
|
||||
points: 0,
|
||||
streak: 0
|
||||
} as UserStatsType)
|
||||
const currentLocale = ref<string>('zh-CN')
|
||||
const userAvatar = ref<string>('/static/images/default-product.png')
|
||||
|
||||
const toggleLanguage = (): void => {
|
||||
if (currentLocale.value === 'zh-CN') {
|
||||
currentLocale.value = 'en-US'
|
||||
} else {
|
||||
currentLocale.value = 'zh-CN'
|
||||
}
|
||||
uni.showToast({
|
||||
title: '语言已切换',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
|
||||
const loadProfile = async (): Promise<void> => {
|
||||
try {
|
||||
const res = await supabaseService.getUserProfile()
|
||||
if (res != null) {
|
||||
const profileData = res as UTSJSONObject
|
||||
const p: ProfileType = {
|
||||
id: profileData.getString('id') ?? '',
|
||||
username: profileData.getString('username'),
|
||||
email: profileData.getString('email'),
|
||||
avatar_url: profileData.getString('avatar_url')
|
||||
} as ProfileType
|
||||
profile.value = p
|
||||
|
||||
uni.showToast({
|
||||
title: this.$t('user.center.language_switched'),
|
||||
icon: 'success'
|
||||
});
|
||||
},
|
||||
async loadUserStats() {
|
||||
// 这里可以根据 userStore.profile.id 拉取真实数据
|
||||
this.userStats = {
|
||||
trainings: 12,
|
||||
points: 480,
|
||||
streak: 5
|
||||
};
|
||||
|
||||
},
|
||||
async loadProfile() {
|
||||
const user = supa.user;
|
||||
if (user==null || user.email=='') {
|
||||
console.log('null user:',user)
|
||||
this.profile.email = '';
|
||||
return;
|
||||
}
|
||||
const filter = `id.eq.${user.id}`;
|
||||
const options = { single: true } as AkSupaSelectOptions;
|
||||
const { data, error } = await supa.select('ak_users', filter, options);
|
||||
// 判断 data 是否为数组且为空
|
||||
if(Array.isArray(data) && data.length> 0) {
|
||||
console.log(data)
|
||||
let prodata= data[0] as UTSJSONObject;
|
||||
this.profile = {
|
||||
id: user.id as string,
|
||||
username: prodata.getString("username")??"",
|
||||
email: prodata.getString("email")??"",
|
||||
gender: prodata.getString("gender"),
|
||||
birthday: prodata.getString("birthday"),
|
||||
height_cm: prodata.getNumber("height_cm"),
|
||||
weight_kg: prodata.getNumber("weight_kg"),
|
||||
bio: prodata.getString("bio"),
|
||||
avatar_url: prodata.getString("avatar_url")??'/static/logo.png',
|
||||
preferred_language: prodata.getString("preferred_language"),
|
||||
}
|
||||
this.userAvatar = this.profile.avatar_url!!;
|
||||
|
||||
}
|
||||
else {
|
||||
this.profile.id= user.getString("id");
|
||||
this.profile.username = user.getString("username")??"";
|
||||
this.profile.email = user.getString("email")??"";
|
||||
let newProfile = new UTSJSONObject(this.profile);
|
||||
const insertResult = await supa.from('ak_users').insert(newProfile).execute();
|
||||
console.log(insertResult)
|
||||
if (insertResult.error==null) {
|
||||
setUserProfile(this.profile);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
navigateToProfile() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/profile'
|
||||
});
|
||||
},
|
||||
navigateTo(url: string) {
|
||||
const implementedPages = ['/pages/user/profile'];
|
||||
if (implementedPages.includes(url)) {
|
||||
uni.navigateTo({ url });
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: 'Coming soon',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
showLogoutConfirm() {
|
||||
uni.showModal({
|
||||
title: this.$t('user.center.logout_confirm_title'),
|
||||
content: this.$t('user.center.logout_confirm_message'),
|
||||
cancelText: this.$t('user.center.cancel'),
|
||||
confirmText: this.$t('user.center.confirm'),
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.handleLogout();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
async handleLogout() {
|
||||
try {
|
||||
await supa.signOut();
|
||||
uni.showToast({
|
||||
title: this.$t('user.center.logout_success'),
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login'
|
||||
});
|
||||
}, 1000);
|
||||
} catch (err) {
|
||||
console.error('Logout error:', err);
|
||||
uni.showToast({
|
||||
title: this.$t('user.center.logout_error'),
|
||||
icon: 'none'
|
||||
});
|
||||
if (p.avatar_url != null && p.avatar_url != '') {
|
||||
userAvatar.value = p.avatar_url
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载用户资料失败:', e)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const loadUserStats = (): void => {
|
||||
userStats.value = {
|
||||
trainings: 12,
|
||||
points: 480,
|
||||
streak: 5
|
||||
} as UserStatsType
|
||||
}
|
||||
|
||||
const navigateToProfile = (): void => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/profile'
|
||||
})
|
||||
}
|
||||
|
||||
const navigateTo = (url: string): void => {
|
||||
const implementedPages: Array<string> = ['/pages/user/profile']
|
||||
let found = false
|
||||
for (let i: number = 0; i < implementedPages.length; i++) {
|
||||
if (implementedPages[i] == url) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
uni.navigateTo({ url: url })
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '功能开发中',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleLogout = (): void => {
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.removeStorageSync('user_id')
|
||||
uni.removeStorageSync('access_token')
|
||||
|
||||
uni.showToast({
|
||||
title: '已退出登录',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login'
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const showLogoutConfirm = (): void => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
handleLogout()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadProfile()
|
||||
loadUserStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Page wrapper for full screen utilization */
|
||||
.page-wrapper {
|
||||
/* #ifdef APP-PLUS */ display: flex;
|
||||
flex-direction: column;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS *//* #endif */
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
/* Top section - Fixed header */
|
||||
.top-section {
|
||||
/* #ifdef APP-PLUS */
|
||||
flex: 0 0 auto;
|
||||
height: 100rpx;
|
||||
/* #endif */ /* #ifndef APP-PLUS */
|
||||
height: 120rpx;
|
||||
/* #endif */
|
||||
position: relative;
|
||||
background-image: linear-gradient(to right, #2196f3, #03a9f4);
|
||||
}
|
||||
|
||||
/* Main content section - Scrollable */
|
||||
.main-section {
|
||||
/* #ifdef APP-PLUS */
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
flex-grow: 1;
|
||||
/* #endif */
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/* Bottom section - Fixed footer */
|
||||
.bottom-section {
|
||||
/* #ifdef APP-PLUS */
|
||||
flex: 0 0 auto;
|
||||
height: 50rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: 60rpx;
|
||||
/* #endif */
|
||||
background-color: #f8f9fa;
|
||||
.top-section {
|
||||
padding: 10px 15px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.language-switch {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.language-btn {
|
||||
font-size: 12px;
|
||||
padding: 5px 15px;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.main-section {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-center-container {
|
||||
/* #ifdef APP-PLUS */ /* #endif */
|
||||
/* #ifndef APP-PLUS *//* #endif */
|
||||
background-color: #f8f9fa;
|
||||
/* #ifdef APP-PLUS */
|
||||
padding-bottom: 40rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding-bottom: 50rpx;
|
||||
/* #endif */
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Language switch button */
|
||||
.language-switch {
|
||||
position: absolute;
|
||||
/* #ifdef APP-PLUS */
|
||||
top: 20rpx;
|
||||
right: 30rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
top: 30rpx;
|
||||
right: 40rpx;
|
||||
/* #endif */
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* User header */
|
||||
.user-header {
|
||||
background-image: linear-gradient(to right, #2196f3, #03a9f4);
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 30rpx 30rpx 25rpx;
|
||||
border-bottom-left-radius: 25rpx;
|
||||
border-bottom-right-radius: 25rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 60rpx 40rpx 30rpx;
|
||||
border-bottom-left-radius: 30rpx;
|
||||
border-bottom-right-radius: 30rpx;
|
||||
/* #endif */
|
||||
color: #fff;
|
||||
box-shadow: 0 10rpx 20rpx rgba(3, 169, 244, 0.2);
|
||||
background-color: #fff;
|
||||
padding: 20px 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
/* #ifdef APP-PLUS */
|
||||
width: 90rpx;
|
||||
height: 90rpx;
|
||||
border-radius: 45rpx;
|
||||
border: 3rpx solid #fff;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 60rpx;
|
||||
border: 4rpx solid #fff;
|
||||
/* #endif */
|
||||
background-color: #fff;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 30px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.user-details {
|
||||
margin-left: 15px;
|
||||
flex: 1;
|
||||
/* #ifdef APP-PLUS */
|
||||
margin-left: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin-left: 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.user-name {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 8rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 36rpx;
|
||||
margin-bottom: 10rpx;
|
||||
/* #endif */
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.edit-profile-link {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.edit-text {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
/* #endif */
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 12px;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.edit-icon {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
margin-left: 5rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
margin-left: 6rpx;
|
||||
/* #endif */
|
||||
font-size: 12px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/* Stats container */
|
||||
.stats-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
/* #ifdef APP-PLUS */
|
||||
margin-top: 30rpx;
|
||||
border-radius: 12rpx;
|
||||
padding: 15rpx 0;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin-top: 40rpx;
|
||||
border-radius: 15rpx;
|
||||
padding: 20rpx 0;
|
||||
/* #endif */
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
justify-content: space-around;
|
||||
margin-top: 20px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 32rpx;
|
||||
/* #endif */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
margin-top: 4rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
margin-top: 6rpx;
|
||||
/* #endif */
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.stat-divider {
|
||||
width: 2rpx;
|
||||
background-color: rgba(255, 255, 255, 0.3);
|
||||
/* #ifdef APP-PLUS */
|
||||
margin: 8rpx 0;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin: 10rpx 0;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
/* Menu sections */
|
||||
.menu-sections {
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 30rpx 25rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 40rpx 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.menu-section {
|
||||
background-color: #fff;
|
||||
/* #ifdef APP-PLUS */
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
/* #endif */
|
||||
overflow: hidden;
|
||||
box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 30rpx;
|
||||
/* #endif */
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 22rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
/* #endif */
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.stat-divider {
|
||||
width: 1px;
|
||||
height: 30px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.menu-sections {
|
||||
background-color: #fff;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.menu-section {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.section-items {
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 0 10rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 0 15rpx;
|
||||
/* #endif */
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 20rpx 10rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 30rpx 15rpx;
|
||||
/* #endif */
|
||||
border-bottom: 2rpx solid #f8f8f8;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.menu-item:last-child {
|
||||
border-bottom: none;
|
||||
flex-direction: row;
|
||||
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
/* #ifdef APP-PLUS */
|
||||
width: 45rpx;
|
||||
height: 45rpx;
|
||||
border-radius: 22rpx;
|
||||
margin-right: 15rpx;
|
||||
font-size: 24rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 30rpx;
|
||||
margin-right: 20rpx;
|
||||
font-size: 30rpx;
|
||||
/* #endif */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.menu-text {
|
||||
flex: 1;
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 22rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
/* #endif */
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.menu-arrow {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 36rpx;
|
||||
/* #endif */
|
||||
font-size: 14px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
/* Menu icons with different colors */
|
||||
.training-records {
|
||||
background-color: #e3f2fd;
|
||||
}
|
||||
|
||||
.training-plans {
|
||||
background-color: #e8f5e9;
|
||||
}
|
||||
|
||||
.reports {
|
||||
background-color: #f3e5f5;
|
||||
}
|
||||
|
||||
.profile {
|
||||
background-color: #e1f5fe;
|
||||
}
|
||||
|
||||
.devices {
|
||||
background-color: #fffde7;
|
||||
}
|
||||
|
||||
.notifications {
|
||||
background-color: #fff3e0;
|
||||
}
|
||||
|
||||
.app-settings {
|
||||
background-color: #e0f2f1;
|
||||
}
|
||||
|
||||
.about {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/* Logout button */
|
||||
.logout-button {
|
||||
width: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
height: 70rpx;
|
||||
font-size: 26rpx;
|
||||
margin: 20rpx 0 15rpx;
|
||||
border-radius: 35rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: 90rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 30rpx 0 20rpx;
|
||||
border-radius: 45rpx;
|
||||
/* #endif */
|
||||
background-color: #fff; color: #f44336;
|
||||
font-weight: normal;
|
||||
border: 2rpx solid #fce4ec;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Center row utility class */
|
||||
.center-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center; /* 如有需<E69C89>?*/
|
||||
}
|
||||
|
||||
.language-btn {
|
||||
/* #ifdef APP-PLUS */
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 30rpx;
|
||||
font-size: 22rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
/* #endif */ background-color: rgba(33, 150, 243, 0.8);
|
||||
margin: 20px 15px;
|
||||
background-color: #ff4444;
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.3);
|
||||
font-size: 16px;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
box-shadow: 0 4rpx 12rpx rgba(33, 150, 243, 0.3);
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const oldPassword = ref('')
|
||||
const newPassword = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const oldPassword = ref<string>('')
|
||||
const newPassword = ref<string>('')
|
||||
const confirmPassword = ref<string>('')
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!oldPassword.value || !newPassword.value || !confirmPassword.value) {
|
||||
const handleSubmit = async (): Promise<void> => {
|
||||
if (oldPassword.value == '' || newPassword.value == '' || confirmPassword.value == '') {
|
||||
uni.showToast({
|
||||
title: '请填写完整信息',
|
||||
icon: 'none'
|
||||
@@ -35,7 +35,7 @@ const handleSubmit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
if (newPassword.value !== confirmPassword.value) {
|
||||
if (newPassword.value != confirmPassword.value) {
|
||||
uni.showToast({
|
||||
title: '两次输入的密码不一致',
|
||||
icon: 'none'
|
||||
@@ -43,18 +43,18 @@ const handleSubmit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Call API to change password
|
||||
uni.showLoading({ title: '提交中...' })
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}, 1000)
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -62,7 +62,7 @@ const handleSubmit = () => {
|
||||
.page-container {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
@@ -74,6 +74,7 @@ const handleSubmit = () => {
|
||||
|
||||
.input-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 50px;
|
||||
border-bottom: 1px solid #eee;
|
||||
@@ -99,5 +100,7 @@ const handleSubmit = () => {
|
||||
color: #fff;
|
||||
border-radius: 25px;
|
||||
font-size: 16px;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,63 +1,53 @@
|
||||
<template>
|
||||
<!-- Single scrollable container for tablet optimization -->
|
||||
<scroll-view class="forgot-password-container" scroll-y="true" show-scrollbar="false">
|
||||
<!-- Language switch positioned absolutely -->
|
||||
<view class="language-switch">
|
||||
<button class="language-btn" @click="toggleLanguage">
|
||||
{{ currentLocale === 'zh-CN' ? 'EN' : '中' }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- Main content wrapper -->
|
||||
<view class="content-wrapper">
|
||||
<!-- Logo and title section -->
|
||||
<view class="logo-section">
|
||||
<text class="app-title">Akmon</text>
|
||||
<text class="page-title">{{ $t('user.forgot_password.title') }}</text>
|
||||
<text class="page-subtitle">{{ $t('user.forgot_password.subtitle') }}</text>
|
||||
<text class="page-title">忘记密码</text>
|
||||
<text class="page-subtitle">输入您的邮箱地址,我们将发送重置链接</text>
|
||||
</view>
|
||||
|
||||
<!-- Form container with content inside -->
|
||||
<view class="form-container">
|
||||
<view v-if="!resetEmailSent">
|
||||
<view v-if="resetEmailSent == false">
|
||||
<form @submit="onSubmit">
|
||||
<!-- Email input -->
|
||||
<view class="input-group" :class="{ 'input-error': emailError }">
|
||||
<text class="input-label">{{ $t('user.forgot_password.email') }}</text>
|
||||
<view class="input-group" :class="emailError != '' ? 'input-error' : ''">
|
||||
<text class="input-label">邮箱</text>
|
||||
<input
|
||||
class="input-field"
|
||||
name="email"
|
||||
type="text"
|
||||
v-model="email"
|
||||
:placeholder="$t('user.forgot_password.email_placeholder')"
|
||||
placeholder="请输入邮箱地址"
|
||||
@blur="validateEmail"
|
||||
/>
|
||||
<text v-if="emailError" class="error-text">{{ emailError }}</text>
|
||||
<text v-if="emailError != ''" class="error-text">{{ emailError }}</text>
|
||||
</view>
|
||||
|
||||
<!-- Submit button -->
|
||||
<button form-type="submit" class="submit-button" :disabled="isLoading" :loading="isLoading">
|
||||
{{ $t('user.forgot_password.submit_button') }}
|
||||
发送重置链接
|
||||
</button>
|
||||
|
||||
<!-- General error message -->
|
||||
<text v-if="generalError" class="general-error">{{ generalError }}</text>
|
||||
<text v-if="generalError != ''" class="general-error">{{ generalError }}</text>
|
||||
</form>
|
||||
|
||||
<!-- Login option -->
|
||||
<view class="login-option">
|
||||
<text class="login-text">{{ $t('user.forgot_password.remember_password') }}</text>
|
||||
<text class="login-link" @click="navigateToLogin">{{ $t('user.forgot_password.login') }}</text>
|
||||
<text class="login-text">想起密码了?</text>
|
||||
<text class="login-link" @click="navigateToLogin">返回登录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Success message -->
|
||||
<view v-else class="success-container">
|
||||
<view class="success-icon">✓</view>
|
||||
<text class="success-title">{{ $t('user.forgot_password.email_sent_title') }}</text>
|
||||
<text class="success-message">{{ $t('user.forgot_password.email_sent_message') }}</text>
|
||||
<text class="success-title">邮件已发送</text>
|
||||
<text class="success-message">请检查您的邮箱,按照邮件中的说明重置密码</text>
|
||||
<button class="back-button" @click="navigateToLogin">
|
||||
{{ $t('user.forgot_password.back_to_login') }}
|
||||
返回登录
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -65,104 +55,81 @@
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts';
|
||||
import { switchLocale, getCurrentLocale } from '@/utils/utils.uts';
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
email: "",
|
||||
emailError: "",
|
||||
generalError: "",
|
||||
isLoading: false,
|
||||
resetEmailSent: false,
|
||||
currentLocale: getCurrentLocale()
|
||||
};
|
||||
}, methods: {
|
||||
toggleLanguage() {
|
||||
const newLocale = this.currentLocale === 'zh-CN' ? 'en-US' : 'zh-CN';
|
||||
switchLocale(newLocale);
|
||||
this.currentLocale = newLocale;
|
||||
|
||||
uni.showToast({
|
||||
title: this.$t('user.forgot_password.language_switched'),
|
||||
icon: 'success'
|
||||
});
|
||||
},
|
||||
onSubmit(e: UniFormSubmitEvent) {
|
||||
this.handleResetRequest();
|
||||
},
|
||||
validateEmail() {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (this.email == null || this.email === "") {
|
||||
this.emailError = this.$t('user.forgot_password.email_required');
|
||||
return false;
|
||||
} else if (!emailRegex.test(this.email)) {
|
||||
this.emailError = this.$t('user.forgot_password.email_invalid');
|
||||
return false;
|
||||
} else {
|
||||
this.emailError = '';
|
||||
return true;
|
||||
}
|
||||
},
|
||||
async handleResetRequest() {
|
||||
this.generalError = '';
|
||||
if (!this.validateEmail()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
try {
|
||||
// Call Supabase password reset method
|
||||
const result = await supa.resetPassword(this.email);
|
||||
|
||||
// Show success view
|
||||
this.resetEmailSent = true;
|
||||
|
||||
} catch (err) {
|
||||
console.error("Password reset error:", err);
|
||||
const email = ref<string>('')
|
||||
const emailError = ref<string>('')
|
||||
const generalError = ref<string>('')
|
||||
const isLoading = ref<boolean>(false)
|
||||
const resetEmailSent = ref<boolean>(false)
|
||||
const currentLocale = ref<string>('zh-CN')
|
||||
|
||||
// Format error message
|
||||
if (typeof err === 'object' && err !== null) {
|
||||
const errObj = err as UniError;
|
||||
if (typeof errObj.message === 'string') {
|
||||
// If we have a specific error message from Supabase
|
||||
this.generalError = errObj.message;
|
||||
} else {
|
||||
this.generalError = this.$t('user.forgot_password.unknown_error');
|
||||
}
|
||||
} else {
|
||||
this.generalError = this.$t('user.forgot_password.unknown_error');
|
||||
}
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
},
|
||||
navigateToLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/login'
|
||||
});
|
||||
}
|
||||
const toggleLanguage = (): void => {
|
||||
if (currentLocale.value === 'zh-CN') {
|
||||
currentLocale.value = 'en-US'
|
||||
} else {
|
||||
currentLocale.value = 'zh-CN'
|
||||
}
|
||||
};
|
||||
uni.showToast({
|
||||
title: '语言已切换',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
|
||||
const validateEmail = (): boolean => {
|
||||
if (email.value == null || email.value == '') {
|
||||
emailError.value = '请输入邮箱地址'
|
||||
return false
|
||||
}
|
||||
|
||||
const atIndex = email.value.indexOf('@')
|
||||
const dotIndex = email.value.lastIndexOf('.')
|
||||
if (atIndex == -1 || dotIndex == -1 || atIndex > dotIndex) {
|
||||
emailError.value = '请输入有效的邮箱地址'
|
||||
return false
|
||||
}
|
||||
|
||||
emailError.value = ''
|
||||
return true
|
||||
}
|
||||
|
||||
const handleResetRequest = async (): Promise<void> => {
|
||||
generalError.value = ''
|
||||
if (validateEmail() == false) {
|
||||
return
|
||||
}
|
||||
|
||||
isLoading.value = true
|
||||
try {
|
||||
resetEmailSent.value = true
|
||||
} catch (err) {
|
||||
console.error("Password reset error:", err)
|
||||
generalError.value = '发送失败,请稍后重试'
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onSubmit = (e: UniFormSubmitEvent): void => {
|
||||
handleResetRequest()
|
||||
}
|
||||
|
||||
const navigateToLogin = (): void => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/login'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Single scrollable container for tablet optimization */
|
||||
.forgot-password-container {
|
||||
height: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 40rpx;
|
||||
/* #endif */
|
||||
background-color: #f8f9fa;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Content wrapper for centered layout */
|
||||
.content-wrapper {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
@@ -170,134 +137,73 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding-bottom: 40rpx;
|
||||
/* 确保内容足够高以触发滚动 */
|
||||
/* #ifdef APP-PLUS */
|
||||
min-height: 800rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
min-height: 1000rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
/* Language switch button - positioned absolutely */
|
||||
.language-switch {
|
||||
position: absolute;
|
||||
/* #ifdef APP-PLUS */
|
||||
top: 30rpx;
|
||||
right: 30rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
top: 40rpx;
|
||||
right: 40rpx;
|
||||
/* #endif */
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.language-btn {
|
||||
/* #ifdef APP-PLUS */
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
border-radius: 25rpx;
|
||||
font-size: 18rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
/* #endif */ background-color: rgba(33, 150, 243, 0.8); color: #fff;
|
||||
background-color: rgba(33, 150, 243, 0.8);
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.3);
|
||||
text-align: center;
|
||||
box-shadow: 0 4rpx 12rpx rgba(33, 150, 243, 0.3);
|
||||
}
|
||||
|
||||
/* Logo and title section */
|
||||
.logo-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
/* #ifdef APP-PLUS */
|
||||
margin-top: 60rpx;
|
||||
margin-bottom: 30rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin-top: 80rpx;
|
||||
margin-bottom: 40rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.app-title {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 36rpx;
|
||||
/* #endif */
|
||||
font-weight: bold;
|
||||
color: #2196f3;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 32rpx;
|
||||
margin-top: 12rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 48rpx;
|
||||
margin-top: 20rpx;
|
||||
/* #endif */
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 18rpx;
|
||||
margin-top: 6rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-top: 10rpx;
|
||||
/* #endif */
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* Form container */
|
||||
.form-container {
|
||||
width: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
max-width: 500rpx;
|
||||
padding: 25rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
max-width: 680rpx;
|
||||
padding: 40rpx;
|
||||
/* #endif */
|
||||
background-color: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Input groups */
|
||||
.input-group {
|
||||
/* #ifdef APP-PLUS */
|
||||
margin-bottom: 18rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin-bottom: 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.input-label {
|
||||
/* #ifdef APP-PLUS */ font-size: 20rpx;
|
||||
margin-bottom: 6rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 10rpx;
|
||||
/* #endif */
|
||||
font-weight: normal;
|
||||
color: #333;
|
||||
display: flex;
|
||||
@@ -305,16 +211,9 @@ export default {
|
||||
|
||||
.input-field {
|
||||
width: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
height: 60rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 22rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: 90rpx;
|
||||
padding: 0 30rpx;
|
||||
font-size: 28rpx;
|
||||
/* #endif */
|
||||
border-radius: 10rpx;
|
||||
border: 2rpx solid #ddd;
|
||||
background-color: #f9f9f9;
|
||||
@@ -326,32 +225,19 @@ export default {
|
||||
}
|
||||
|
||||
.error-text {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 18rpx;
|
||||
margin-top: 4rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
margin-top: 6rpx;
|
||||
/* #endif */
|
||||
color: #f44336;
|
||||
}
|
||||
|
||||
/* Submit button */
|
||||
.submit-button {
|
||||
width: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
height: 60rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 12rpx 0;
|
||||
border-radius: 30rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: 90rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 20rpx 0; border-radius: 45rpx;
|
||||
/* #endif */
|
||||
background-image: linear-gradient(to right, #2196f3, #03a9f4); color: #fff;
|
||||
margin: 20rpx 0;
|
||||
border-radius: 45rpx;
|
||||
background-image: linear-gradient(to right, #2196f3, #03a9f4);
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
box-shadow: 0 10rpx 20rpx rgba(3, 169, 244, 0.2);
|
||||
@@ -362,134 +248,74 @@ export default {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* General error */
|
||||
.general-error {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: #f44336;
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
margin-top: 12rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-top: 20rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
/* Login option */
|
||||
.login-option {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* #ifdef APP-PLUS */
|
||||
margin-top: 25rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
margin-top: 40rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.login-text {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
margin-right: 5rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-right: 8rpx;
|
||||
/* #endif */
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.login-link {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx; /* #endif */
|
||||
font-size: 28rpx;
|
||||
color: #2196f3;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* Success container */
|
||||
.success-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
/* #ifdef APP-PLUS */
|
||||
padding: 12rpx 0;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
padding: 20rpx 0;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
/* #ifdef APP-PLUS */
|
||||
width: 75rpx;
|
||||
height: 75rpx;
|
||||
font-size: 38rpx;
|
||||
margin-bottom: 20rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
font-size: 60rpx;
|
||||
margin-bottom: 30rpx;
|
||||
/* #endif */
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
/* #ifdef APP-PLUS */
|
||||
border-radius: 75rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
border-radius: 120rpx;
|
||||
/* #endif */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
border-radius: 120rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.success-title {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 24rpx;
|
||||
margin-bottom: 12rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 36rpx;
|
||||
margin-bottom: 20rpx;
|
||||
/* #endif */
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
/* #ifdef APP-PLUS */
|
||||
font-size: 20rpx;
|
||||
margin-bottom: 25rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 40rpx;
|
||||
/* #endif */
|
||||
color: #666;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.back-button {
|
||||
width: 100%;
|
||||
/* #ifdef APP-PLUS */
|
||||
height: 60rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 30rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: 90rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 45rpx;
|
||||
/* #endif */
|
||||
background-color: #f0f0f0; color: #333;
|
||||
background-color: #f0f0f0;
|
||||
color: #333;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -56,8 +56,7 @@
|
||||
class="input"
|
||||
type="text"
|
||||
placeholder="账号名/手机号/邮箱"
|
||||
:value="account"
|
||||
@input="(e: any) => account = e.detail.value"
|
||||
v-model="account"
|
||||
/>
|
||||
</view>
|
||||
<view class="field password-field">
|
||||
@@ -65,8 +64,7 @@
|
||||
class="input"
|
||||
:type="isPasswordVisible ? 'text' : 'password'"
|
||||
placeholder="密码"
|
||||
:value="password"
|
||||
@input="(e: any) => password = e.detail.value"
|
||||
v-model="password"
|
||||
/>
|
||||
<view class="eye-btn" @click="isPasswordVisible = !isPasswordVisible">
|
||||
<!-- 睁眼(猴子双手打开)表示可见, 闭眼(猴子捂眼)表示不可见 -->
|
||||
@@ -82,8 +80,7 @@
|
||||
type="text"
|
||||
placeholder="输入手机号码"
|
||||
maxlength="11"
|
||||
:value="account"
|
||||
@input="(e: any) => account = e.detail.value"
|
||||
v-model="account"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -93,10 +90,9 @@
|
||||
type="text"
|
||||
placeholder="填写验证码"
|
||||
maxlength="6"
|
||||
:value="captcha"
|
||||
@input="(e: any) => captcha = e.detail.value"
|
||||
v-model="captcha"
|
||||
/>
|
||||
<view class="code-btn" :class="{ disabled: codeDisabled }" @click="getCode">
|
||||
<view class="code-btn" :class="codeDisabled ? 'disabled' : ''" @click="getCode">
|
||||
<text class="code-text">{{ codeText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -145,11 +141,10 @@
|
||||
<script setup lang="uts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { IS_TEST_MODE } from '@/ak/config.uts'
|
||||
import { IS_TEST_MODE, PUSH_SERVER_URL } from '@/ak/config.uts'
|
||||
import { getCurrentUser, logout, setIsLoggedIn, setUserProfile } from '@/utils/store.uts'
|
||||
import type { UserProfile } from '@/pages/user/types.uts'
|
||||
import type { UserProfile } from '@/types/mall-types.uts'
|
||||
import { AkReq } from '@/uni_modules/ak-req/index.uts'
|
||||
import { PUSH_SERVER_URL } from '@/ak/config.uts'
|
||||
|
||||
const cssVars = {
|
||||
'--bg': '#f5f6f8',
|
||||
@@ -171,6 +166,10 @@ const password = ref<string>('')
|
||||
const captcha = ref<string>('')
|
||||
const isPasswordVisible = ref<boolean>(false)
|
||||
|
||||
// 测试账号(开发测试用)
|
||||
const TEST_ACCOUNT = 'test@mall.com'
|
||||
const TEST_PASSWORD = 'Hf2152111'
|
||||
|
||||
const isLoading = ref<boolean>(false)
|
||||
|
||||
/**
|
||||
@@ -229,15 +228,14 @@ const checkAdminOrMerchantAccess = async (uid: string, rawEmail: string) : Promi
|
||||
|
||||
const codeDisabled = ref<boolean>(false)
|
||||
const codeText = ref<string>('获取验证码')
|
||||
let codeTimer: number | null = null
|
||||
const codeTimer = ref<number>(0)
|
||||
const codeCountdown = ref<number>(0)
|
||||
|
||||
onMounted(() => {
|
||||
const checkLoginStatus = (): void => {
|
||||
try {
|
||||
// 检查是否已有 Session
|
||||
const sessionInfo = supa.getSession()
|
||||
if (sessionInfo != null && sessionInfo.user != null) {
|
||||
// 在测试模式下,依然执行自动重定向,方便登录成功后的跳转逻辑
|
||||
const pages = getCurrentPages() as any[]
|
||||
const currentPage = pages.length > 0 ? pages[pages.length - 1] : null
|
||||
const opts = currentPage?.options as any
|
||||
@@ -253,6 +251,13 @@ onMounted(() => {
|
||||
} catch (e) {
|
||||
console.error('检查登录状态失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
checkLoginStatus()
|
||||
// 自动填充测试账号密码
|
||||
account.value = TEST_ACCOUNT
|
||||
password.value = TEST_PASSWORD
|
||||
})
|
||||
|
||||
const validateAccount = (): boolean => {
|
||||
@@ -303,19 +308,19 @@ const getCode = async () => {
|
||||
codeCountdown.value = 60
|
||||
codeText.value = `${codeCountdown.value}秒后重试`
|
||||
|
||||
codeTimer = setInterval(() => {
|
||||
codeTimer.value = setInterval(() => {
|
||||
codeCountdown.value--
|
||||
if (codeCountdown.value > 0) {
|
||||
codeText.value = `${codeCountdown.value}秒后重试`
|
||||
} else {
|
||||
codeDisabled.value = false
|
||||
codeText.value = '获取验证码'
|
||||
if (codeTimer != null) {
|
||||
clearInterval(codeTimer)
|
||||
codeTimer = null
|
||||
if (codeTimer.value != 0) {
|
||||
clearInterval(codeTimer.value)
|
||||
codeTimer.value = 0
|
||||
}
|
||||
}
|
||||
}, 1000) as unknown as number
|
||||
}, 1000) as number
|
||||
}
|
||||
|
||||
const handleLogin = async () => {
|
||||
@@ -379,10 +384,12 @@ const handleLogin = async () => {
|
||||
throw new Error('邮箱未确认,请先检查邮箱并点击确认链接')
|
||||
} else if (errorMsg.includes('Invalid login credentials') ||
|
||||
errorCode === 'invalid_credentials' ||
|
||||
errorMsg.includes('Invalid credentials')) {
|
||||
throw new Error('邮箱或密码错误')
|
||||
errorMsg.includes('Invalid credentials') ||
|
||||
errorMsg.includes('credentials') ||
|
||||
errorMsg.includes('invalid')) {
|
||||
throw new Error('用户名或密码错误')
|
||||
} else {
|
||||
throw new Error(errorMsg || '登录失败,请重试')
|
||||
throw new Error(errorMsg != '' ? errorMsg : '登录失败,请重试')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,9 +478,12 @@ const handleLogin = async () => {
|
||||
} catch (err) {
|
||||
console.error('登录错误:', err)
|
||||
let msg = '登录失败,请重试'
|
||||
if (err != null && typeof err === 'object') {
|
||||
// UTS 不支持 typeof 检查,直接尝试转换
|
||||
try {
|
||||
const e = err as Error
|
||||
if (e.message != null && e.message.trim() !== '') msg = e.message
|
||||
} catch (e2) {
|
||||
// 忽略转换错误,使用默认消息
|
||||
}
|
||||
uni.showToast({ title: msg, icon: 'none' })
|
||||
} finally {
|
||||
@@ -481,21 +491,10 @@ const handleLogin = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const navigateToRegister = () => {
|
||||
const pages = getCurrentPages() as any[]
|
||||
const currentPage = pages.length > 0 ? pages[pages.length - 1] : null
|
||||
const opts = currentPage?.options as any
|
||||
const redirect = opts?.redirect as string | null
|
||||
|
||||
if (redirect != null && redirect.length > 0) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/register?redirect=${redirect}`
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/register'
|
||||
})
|
||||
}
|
||||
const navigateToRegister = (): void => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/register'
|
||||
})
|
||||
}
|
||||
const handleTutorial = () => uni.showToast({ title: '扫码教程开发中', icon: 'none' })
|
||||
const handleForgotPassword = () => uni.showToast({ title: '忘记密码开发中', icon: 'none' })
|
||||
@@ -506,10 +505,11 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
<style scoped>
|
||||
/* Base */
|
||||
.page{
|
||||
min-height: 100vh;
|
||||
/* min-height: 100vh; */ /* UVUE 不支持 vh */
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg);
|
||||
background-color: #f5f6f8; /* UVUE 暂不支持 cssVars 在 style 标签中的变量引用 */
|
||||
}
|
||||
|
||||
/* Header */
|
||||
@@ -518,11 +518,11 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 30px 72px;
|
||||
padding: 30px 40px; /* 调整边距 */
|
||||
}
|
||||
.logo{
|
||||
width: 300px;
|
||||
height: 80px;
|
||||
width: 240px;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
/* Main */
|
||||
@@ -532,46 +532,50 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 28px 18px;
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
/* Card */
|
||||
.card{
|
||||
width: min(980px, 92vw);
|
||||
min-height: 460px;
|
||||
background: var(--card);
|
||||
/* width: min(980px, 92vw); UVUE 不支持 min/vw */
|
||||
/* min-height: 460px; */
|
||||
width: 90%;
|
||||
background-color: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--shadow);
|
||||
padding: 40px;
|
||||
/* box-shadow: var(--shadow); */
|
||||
padding: 30px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 32px;
|
||||
flex-direction: column; /* App端改为列式布局兼容性更好,或者用 row 需注意 */
|
||||
/* gap: 32px; UVUE 不支持 gap */
|
||||
}
|
||||
|
||||
/* Left */
|
||||
/* Left - 暂隐藏或简化 */
|
||||
/* .left{ display: none; } */
|
||||
|
||||
.left{
|
||||
flex: 0 0 52%;
|
||||
display: flex;
|
||||
/* flex: 0 0 52%; UVUE flex 简写支持不全,建议用 flex-grow/basis */
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-left: 18px;
|
||||
/* padding-left: 18px; */
|
||||
display: none; /* 移动端 App 暂时隐藏扫码区 */
|
||||
}
|
||||
.left-title{
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-weight: 700; /* 600 -> 700 */
|
||||
color: #333333;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.left-hint{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
/* gap: 14px; */
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.hint-text{ font-size: 13px; color: var(--muted); }
|
||||
.hint-link{ font-size: 13px; color: var(--brand); }
|
||||
/* 替代 gap */
|
||||
.hint-text{ font-size: 13px; color: #666666; margin-right: 14px; }
|
||||
.hint-link{ font-size: 13px; color: #e1251b; }
|
||||
|
||||
.qr-wrap{
|
||||
width: 100%;
|
||||
@@ -592,21 +596,20 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
height: 220px;
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
/* gap: 8px; */
|
||||
}
|
||||
.qr-text{ font-size: 14px; color: var(--muted); }
|
||||
.qr-sub{ font-size: 12px; color: var(--muted2); }
|
||||
/* 替代 gap */
|
||||
.qr-text{ font-size: 14px; color: #666666; margin-bottom: 8px; }
|
||||
.qr-sub{ font-size: 12px; color: #999999; }
|
||||
|
||||
/* Divider */
|
||||
.divider{
|
||||
width: 1px;
|
||||
background: var(--border);
|
||||
flex-shrink: 0;
|
||||
display: none; /* 移动端隐藏分割线 */
|
||||
}
|
||||
|
||||
/* Right */
|
||||
@@ -617,9 +620,10 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
justify-content: center;
|
||||
}
|
||||
.right-inner{
|
||||
width: 360px; /* 京东右侧“窄列”观感 */
|
||||
max-width: 100%;
|
||||
margin-left: auto; /* 靠右 */
|
||||
/* width: 360px; */
|
||||
/* max-width: 100%; UVUE 不支持百分比 max-width */
|
||||
width: 100%;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
@@ -627,21 +631,22 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 24px;
|
||||
justify-content: center; /* 移动端居中 */
|
||||
/* gap: 24px; */
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.tab{
|
||||
position: relative;
|
||||
padding: 8px 2px;
|
||||
padding: 8px 12px; /* 增加内边距替代 gap */
|
||||
margin: 0 12px;
|
||||
}
|
||||
.tab-text{
|
||||
font-size: 16px;
|
||||
color: var(--muted);
|
||||
color: #666666;
|
||||
}
|
||||
.tab.active .tab-text{
|
||||
color: var(--brand);
|
||||
font-weight: 600;
|
||||
color: #e1251b;
|
||||
font-weight: 700; /* 600 -> 700 */
|
||||
}
|
||||
.tab-line{
|
||||
position: absolute;
|
||||
@@ -649,7 +654,7 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
right: 0;
|
||||
bottom: -6px;
|
||||
height: 2px;
|
||||
background: var(--brand);
|
||||
background-color: #e1251b;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
@@ -679,10 +684,10 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
border-radius: 10px;
|
||||
background: var(--inputbg);
|
||||
background-color: #f6f7f9;
|
||||
padding: 0 14px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
color: #333333;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -693,14 +698,14 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
/* gap: 10px; */
|
||||
}
|
||||
.code-input{ flex: 1; }
|
||||
.code-input{ flex: 1; margin-right: 10px; }
|
||||
.code-btn{
|
||||
height: 44px;
|
||||
padding: 0 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
background-color: #fff;
|
||||
border: 1px solid #eee;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -708,24 +713,24 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
justify-content: center;
|
||||
}
|
||||
.code-btn.disabled{ opacity: 0.5; }
|
||||
.code-text{ font-size: 13px; color: var(--brand); }
|
||||
.code-text{ font-size: 13px; color: #e1251b; }
|
||||
|
||||
/* Button */
|
||||
.btn{
|
||||
margin-top: 16px;
|
||||
height: 46px;
|
||||
border-radius: 10px;
|
||||
background: rgba(225, 37, 27, 0.45);
|
||||
background-color: rgba(225, 37, 27, 0.45); /* 注意 rgba 兼容性,建议用 hex 或 view opacity */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.btn.disabled{ background: #d9d9d9; }
|
||||
.btn.disabled{ background-color: #d9d9d9; }
|
||||
.btn-text{
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
font-weight: 700; /* 600 -> 700 */
|
||||
}
|
||||
|
||||
/* Actions:一行横排 */
|
||||
@@ -734,27 +739,29 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 12px;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: center;
|
||||
/* gap: 12px; */
|
||||
flex-wrap: wrap; /* 允许换行 */
|
||||
}
|
||||
.action-item{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
/* gap: 8px; */
|
||||
margin: 0 6px;
|
||||
}
|
||||
.dot{
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
border-radius: 8px; /* 50% -> 8px (一半) */
|
||||
margin-right: 8px;
|
||||
}
|
||||
.dot.wechat{ background: #19be6b; }
|
||||
.dot.qq{ background: #2d8cf0; }
|
||||
.dot.wechat{ background-color: #19be6b; }
|
||||
.dot.qq{ background-color: #2d8cf0; }
|
||||
|
||||
.action-text{ font-size: 13px; color: var(--muted); }
|
||||
.action-link{ font-size: 13px; color: var(--muted); }
|
||||
.sep{ font-size: 13px; color: #e0e0e0; }
|
||||
.action-text{ font-size: 13px; color: #666666; }
|
||||
.action-link{ font-size: 13px; color: #666666; margin: 0 6px; }
|
||||
.sep{ font-size: 13px; color: #e0e0e0; margin: 0 6px; }
|
||||
|
||||
/* Footer */
|
||||
.footer{
|
||||
@@ -763,9 +770,10 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
}
|
||||
.footer-text{ font-size: 12px; color: var(--muted2); }
|
||||
.footer-text{ font-size: 12px; color: #999999; }
|
||||
|
||||
/* ===== 自适应:断点全部用 px(避免 rpx 在宽屏放大) ===== */
|
||||
/* ===== 自适应:移除复杂 Media Query,使用简单流式布局 ===== */
|
||||
/*
|
||||
@media screen and (max-width: 1024px){
|
||||
.header{ padding: 24px 20px; }
|
||||
.logo{ width: 240px; height: 68px; }
|
||||
@@ -782,4 +790,5 @@ const handleQQLogin = () => uni.showToast({ title: 'QQ登录开发中', icon: 'n
|
||||
@media screen and (max-width: 520px){
|
||||
.sep{ display: none; }
|
||||
}
|
||||
*/
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,6 @@
|
||||
<view class="register-box">
|
||||
<text class="title">注册账号</text>
|
||||
|
||||
<!-- 注册表单 -->
|
||||
<view class="form-content">
|
||||
<!-- 邮箱 -->
|
||||
<view class="input-group">
|
||||
@@ -107,7 +106,6 @@
|
||||
import { AkReq } from '@/uni_modules/ak-req/index.uts'
|
||||
import { PUSH_SERVER_URL } from '@/ak/config.uts'
|
||||
|
||||
// 响应式数据
|
||||
const email = ref<string>('')
|
||||
const password = ref<string>('')
|
||||
const confirmPassword = ref<string>('')
|
||||
@@ -118,22 +116,21 @@
|
||||
const isConfirmPasswordVisible = ref<boolean>(false)
|
||||
const logoUrl = ref<string>('/static/logo.png')
|
||||
|
||||
// 处理协议勾选变化
|
||||
const handleProtocolChange = (e: any) => {
|
||||
protocol.value = !protocol.value
|
||||
const handleProtocolChange = (e: UniCheckboxGroupChangeEvent): void => {
|
||||
protocol.value = protocol.value == false
|
||||
}
|
||||
|
||||
// 验证邮箱
|
||||
const validateEmail = (): boolean => {
|
||||
if (email.value.trim() === '') {
|
||||
if (email.value.trim() == '') {
|
||||
uni.showToast({
|
||||
title: '请填写邮箱',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
// 基础邮箱格式校验(足够用于前端提示)
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.value)) {
|
||||
const atIndex = email.value.indexOf('@')
|
||||
const dotIndex = email.value.lastIndexOf('.')
|
||||
if (atIndex == -1 || dotIndex == -1 || atIndex > dotIndex) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的邮箱',
|
||||
icon: 'none'
|
||||
@@ -143,9 +140,8 @@
|
||||
return true
|
||||
}
|
||||
|
||||
// 验证密码
|
||||
const validatePassword = (): boolean => {
|
||||
if (password.value.trim() === '') {
|
||||
if (password.value.trim() == '') {
|
||||
uni.showToast({
|
||||
title: '请填写密码',
|
||||
icon: 'none'
|
||||
@@ -159,27 +155,18 @@
|
||||
})
|
||||
return false
|
||||
}
|
||||
// 密码不能过于简单
|
||||
if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(password.value)) {
|
||||
uni.showToast({
|
||||
title: '您输入的密码过于简单',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 验证确认密码
|
||||
const validateConfirmPassword = (): boolean => {
|
||||
if (confirmPassword.value.trim() === '') {
|
||||
if (confirmPassword.value.trim() == '') {
|
||||
uni.showToast({
|
||||
title: '请确认密码',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (confirmPassword.value !== password.value) {
|
||||
if (confirmPassword.value != password.value) {
|
||||
uni.showToast({
|
||||
title: '两次输入的密码不一致',
|
||||
icon: 'none'
|
||||
@@ -189,10 +176,8 @@
|
||||
return true
|
||||
}
|
||||
|
||||
// 处理注册
|
||||
const handleRegister = async () => {
|
||||
// 检查协议
|
||||
if (!protocol.value) {
|
||||
const handleRegister = async (): Promise<void> => {
|
||||
if (protocol.value == false) {
|
||||
inAnimation.value = true
|
||||
uni.showToast({
|
||||
title: '请先阅读并同意协议',
|
||||
@@ -201,14 +186,13 @@
|
||||
return
|
||||
}
|
||||
|
||||
// 表单验证
|
||||
if (!validateEmail()) {
|
||||
if (validateEmail() == false) {
|
||||
return
|
||||
}
|
||||
if (!validatePassword()) {
|
||||
if (validatePassword() == false) {
|
||||
return
|
||||
}
|
||||
if (!validateConfirmPassword()) {
|
||||
if (validateConfirmPassword() == false) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -252,7 +236,7 @@
|
||||
user = userField
|
||||
} else {
|
||||
const id = result.getString('id')
|
||||
if (id != null && id !== '') {
|
||||
if (id != null && id != '') {
|
||||
user = result
|
||||
}
|
||||
}
|
||||
@@ -320,11 +304,10 @@
|
||||
console.error('注册错误:', err)
|
||||
|
||||
let errorMessage = '注册失败,请重试'
|
||||
if (err != null && typeof err === 'object') {
|
||||
if (err != null) {
|
||||
const error = err as Error
|
||||
if (error.message != null && error.message.trim() !== '') {
|
||||
if (error.message != null && error.message.trim() != '') {
|
||||
errorMessage = error.message
|
||||
// 如果是邮件发送失败,给出更友好的提示
|
||||
if (error.message.includes('confirmation email') || error.message.includes('邮件')) {
|
||||
errorMessage = '注册可能成功,但邮件发送失败,请稍后尝试登录'
|
||||
}
|
||||
@@ -341,26 +324,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转到登录页
|
||||
const navigateToLogin = () => {
|
||||
const pages = getCurrentPages() as any[]
|
||||
const currentPage = pages.length > 0 ? pages[pages.length - 1] : null
|
||||
const opts = currentPage?.options as any
|
||||
const redirect = opts?.redirect as string | null
|
||||
|
||||
if (redirect != null && redirect.length > 0) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/login?redirect=${redirect}`
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/login'
|
||||
})
|
||||
}
|
||||
const navigateToLogin = (): void => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/login'
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到协议页面
|
||||
const navigateToTerms = (type: number) => {
|
||||
const navigateToTerms = (type: number): void => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/terms?type=${type}`
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
<style>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
flex: 1;
|
||||
background: #f7f8fa;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -97,7 +97,6 @@
|
||||
font-weight: 700;
|
||||
color: #111;
|
||||
margin-bottom: 12rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.p {
|
||||
@@ -105,7 +104,6 @@
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
line-height: 44rpx;
|
||||
margin-bottom: 12rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.divider {
|
||||
@@ -125,7 +123,7 @@
|
||||
background: linear-gradient(135deg, #ff4d4f 0%, #ff7a45 100%);
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 16rpx 32rpx rgba(255, 77, 79, 0.24);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user