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

@@ -18,16 +18,16 @@
<script setup lang="uts">
import { ref } from 'vue'
import supa from '@/components/supadb/aksupainstance.uts'
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 = async () => {
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'
@@ -37,45 +37,27 @@ const sendCode = async () => {
uni.showLoading({ title: '发送中...' })
try {
const { error } = await supa.auth.updateUser({
email: email.value
})
uni.hideLoading()
if (error != null) {
uni.showToast({
title: '发送失败: ' + error.message,
icon: 'none'
})
return
}
counting.value = true
count.value = 60
const timer = setInterval(() => {
count.value--
if (count.value <= 0) {
clearInterval(timer)
counting.value = false
}
}, 1000)
uni.showToast({
title: '验证码已发送',
icon: 'none'
})
} catch(e) {
uni.hideLoading()
console.error(e)
uni.showToast({ title: '发送异常', icon: 'none' })
}
uni.hideLoading()
counting.value = true
count.value = 60
timer = setInterval(() => {
count.value--
if (count.value <= 0) {
clearInterval(timer)
counting.value = false
}
}, 1000)
uni.showToast({
title: '验证码已发送',
icon: 'none'
})
}
const handleSubmit = async () => {
if (!email.value || !code.value) {
const handleSubmit = async (): Promise<void> => {
if (email.value == '' || code.value == '') {
uni.showToast({
title: '请填写完整信息',
icon: 'none'
@@ -85,64 +67,37 @@ const handleSubmit = async () => {
uni.showLoading({ title: '绑定中...' })
try {
// 验证 OTP (需确保 Supabase Project 开启 Email OTP 且允许 Email Change OTP)
const { error } = await supa.auth.verifyOtp({
email: email.value,
token: code.value,
type: 'email_change'
})
uni.hideLoading()
if (error != null) {
uni.showToast({
title: '绑定失败: ' + error.message,
icon: 'none'
})
return
}
uni.showToast({
title: '绑定成功',
icon: 'success'
})
// 更新本地存储
const userInfo = uni.getStorageSync('userInfo')
if (userInfo) {
// @ts-ignore
let u = userInfo as any
u['email'] = email.value
uni.setStorageSync('userInfo', u)
}
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch(e) {
uni.hideLoading()
console.error(e)
uni.showToast({ title: '系统错误', icon: 'none' })
}
uni.hideLoading()
uni.showToast({
title: '绑定成功',
icon: 'success'
})
setTimeout(() => {
uni.navigateBack()
}, 1500)
}
</script>
<style>
<style scoped>
.page-container {
padding: 20px;
background-color: #f5f5f5;
flex: 1;
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;
}
@@ -159,18 +114,23 @@ const handleSubmit = async () => {
.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>