consumer模块完成度95%,能编译在安卓端运行,在解决数据获取和页面布局问题

This commit is contained in:
cyh666666
2026-02-27 08:20:43 +08:00
parent e606c597ca
commit b9acce6c35
1554 changed files with 23471 additions and 8551 deletions

View File

@@ -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>