consumerm模块完成度90%,完善消费者和商家端数据库表,商品、聊天、订单数据对接好了supabase,和商家端对接了聊天功能,安卓端编译通过了css样式,剩余几个页面在处理函数规范问题

This commit is contained in:
cyh666666
2026-02-24 17:17:49 +08:00
parent e2f1dfb097
commit e606c597ca
174 changed files with 37917 additions and 4444 deletions

View File

@@ -28,16 +28,18 @@ export async function ensureUserProfile(sessionUser: UTSJSONObject): Promise<Use
console.log('ensureUserProfile check ak_users:', {
status: checkRes.status,
hasData: checkRes.data != null,
hasError: (checkRes as any).error != null,
error: (checkRes as any).error
hasData: checkRes.data != null
})
if (checkRes.status >= 200 && checkRes.status < 300 && checkRes.data != null) {
// 用户已存在返回现有资料H5 下 checkRes.data 可能是 plain object不一定是 UTSJSONObject
const existingUser = (typeof (checkRes.data as any).getString === 'function')
? (checkRes.data as UTSJSONObject)
: new UTSJSONObject(checkRes.data as any)
const data = checkRes.data
let existingUser: UTSJSONObject
if (data instanceof UTSJSONObject) {
existingUser = data
} else {
existingUser = new UTSJSONObject(data)
}
return {
id: existingUser.getString('id') ?? '',
username: existingUser.getString('username') ?? '',
@@ -67,17 +69,13 @@ export async function ensureUserProfile(sessionUser: UTSJSONObject): Promise<Use
.single()
.execute()
console.log('ensureUserProfile insert ak_users:', {
status: insertRes.status,
hasData: insertRes.data != null,
hasError: (insertRes as any).error != null,
error: (insertRes as any).error
})
console.log('ensureUserProfile insert ak_users status:', insertRes.status)
if (insertRes.status >= 200 && insertRes.status < 300 && insertRes.data != null) {
const newUser = (typeof (insertRes.data as any).getString === 'function')
? (insertRes.data as UTSJSONObject)
: new UTSJSONObject(insertRes.data as any)
const rawData = insertRes.data
const newUser = (rawData instanceof UTSJSONObject)
? (rawData as UTSJSONObject)
: new UTSJSONObject(rawData)
return {
id: newUser.getString('id') ?? '',
username: newUser.getString('username') ?? '',

View File

@@ -1,5 +1,5 @@
import supa, { supaReady } from '@/components/supadb/aksupainstance.uts'
import type { UserProfile, UserStats } from '@/pages/user/types.uts'
import type { UserProfile, UserStats } from '@/types/mall-types.uts'
import type { DeviceInfo } from '@/pages/sense/types.uts'
import { SenseDataService, type DeviceParams } from '@/pages/sense/senseDataService.uts'
import { reactive } from 'vue'
@@ -55,13 +55,13 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
const sessionInfo = supa.getSession()
if (sessionInfo.user == null) {
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false // 未登录
return null
}
const userId = sessionInfo.user?.getString("id")
if (userId == null) {
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false // 未登录
return null
} // 查询 ak_users 表补全 profile
@@ -88,13 +88,13 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
return createdProfile
} else {
console.error('创建用户资料失败')
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false
return null
}
} else {
console.error('会话用户信息为空')
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false
return null
}
@@ -121,7 +121,7 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
state.isLoggedIn = true // 登录成功
return profile
} else {
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false // 未登录
return null
}
@@ -130,7 +130,7 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
// 登出并清空用户信息
export function logout() {
supa.signOut()
state.userProfile = { username: '', email: '' }
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false // 登出
}

File diff suppressed because it is too large Load Diff

View File

@@ -179,7 +179,7 @@ export function setClipboard(text: string): void {
* @returns 格式化后的相对时间字符串
*/
export function formatTime(dateStr: string): string {
if (!dateStr) return ''
if (dateStr == '') return ''
try {
const date = new Date(dateStr)
const now = new Date()