解决登录显示、首页显示bug
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import { AkReq } from '@/uni_modules/ak-req/index.uts'
|
||||
import { PUSH_SERVER_URL } from '@/ak/config.uts'
|
||||
@@ -115,6 +116,52 @@
|
||||
const isPasswordVisible = ref<boolean>(false)
|
||||
const isConfirmPasswordVisible = ref<boolean>(false)
|
||||
const logoUrl = ref<string>('/static/logo.png')
|
||||
const registerMode = ref<string>('consumer')
|
||||
|
||||
const getOptionText = (opts: UTSJSONObject, key: string): string => {
|
||||
try {
|
||||
const value = opts.getString(key)
|
||||
if (value != null && value != '') {
|
||||
return value
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
const rawValue = opts[key]
|
||||
if (rawValue != null) {
|
||||
return '' + rawValue
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const getRegisterRole = (): string => {
|
||||
if (registerMode.value == 'delivery') {
|
||||
return 'delivery'
|
||||
}
|
||||
if (registerMode.value == 'merchant') {
|
||||
return 'merchant'
|
||||
}
|
||||
return 'customer'
|
||||
}
|
||||
|
||||
onLoad((opts) => {
|
||||
if (opts != null) {
|
||||
const optsObj = opts as UTSJSONObject
|
||||
const mode = getOptionText(optsObj, 'mode')
|
||||
if (mode == 'delivery') {
|
||||
registerMode.value = 'delivery'
|
||||
uni.setNavigationBarTitle({ title: '服务人员注册' })
|
||||
} else if (mode == 'merchant') {
|
||||
registerMode.value = 'merchant'
|
||||
uni.setNavigationBarTitle({ title: '商家注册' })
|
||||
} else {
|
||||
registerMode.value = 'consumer'
|
||||
uni.setNavigationBarTitle({ title: '用户注册' })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const handleProtocolChange = (e: UniCheckboxGroupChangeEvent): void => {
|
||||
protocol.value = protocol.value == false
|
||||
@@ -202,9 +249,7 @@
|
||||
// 使用 Supabase Auth:邮箱 + 密码注册
|
||||
const options = new UTSJSONObject()
|
||||
const metaData = new UTSJSONObject()
|
||||
// 【核心修改】:商家端注册时,固定声明 user_role 为 'merchant'
|
||||
// 该元数据会被 Supabase Auth 存储,并由数据库触发器自动同步到 ak_users 业务表的 role 字段
|
||||
metaData.set('user_role', 'merchant')
|
||||
metaData.set('user_role', getRegisterRole())
|
||||
options.set('data', metaData)
|
||||
|
||||
const result = await supa.signUp(email.value.trim(), password.value, options)
|
||||
@@ -296,8 +341,14 @@
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
let url = '/pages/user/login'
|
||||
if (registerMode.value == 'delivery') {
|
||||
url = '/pages/user/login?mode=delivery'
|
||||
} else if (registerMode.value == 'merchant') {
|
||||
url = '/pages/user/login?mode=merchant'
|
||||
}
|
||||
uni.redirectTo({
|
||||
url: '/pages/user/login'
|
||||
url
|
||||
})
|
||||
}, 1500)
|
||||
} catch (err) {
|
||||
@@ -325,8 +376,14 @@
|
||||
}
|
||||
|
||||
const navigateToLogin = (): void => {
|
||||
let url = '/pages/user/login'
|
||||
if (registerMode.value == 'delivery') {
|
||||
url = '/pages/user/login?mode=delivery'
|
||||
} else if (registerMode.value == 'merchant') {
|
||||
url = '/pages/user/login?mode=merchant'
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/login'
|
||||
url
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user