Commit ffd3b679 authored by youjie's avatar youjie

注册

parent eb3caa3c
...@@ -142,52 +142,6 @@ export interface DistributorLoginResultDto { ...@@ -142,52 +142,6 @@ export interface DistributorLoginResultDto {
userInfo?: null; userInfo?: null;
} }
/**
* 注册返回结果
*/
export interface DistributorSelfRegisterResultDto {
/*** 出生日期*/
birthday?: Date | null;
/*** 确认密码*/
confirmPassword: string;
/*** 分销商推广码*/
distributorCode?: null | string;
/*** 分销商ID*/
distributorID?: number;
/*** 电子邮箱(需要判断唯一,作为登录账号)*/
email: string;
/*** 授权登录 对应的账号名称*/
externalName?: null | string;
/*** 勾選「我願意接收優惠與電子報」 1是*/
isReceivePush?: number;
/*** LINE ID*/
lineID?: null | string;
/*** 会员昵称*/
name?: null | string;
/*** 授权登录唯一ID*/
openID?: null | string;
/*** 父级会员ID*/
parentID?: null | string;
/*** 密码*/
password: string;
/*** 电话*/
phone?: null | string;
/*** 电话区号*/
phoneCode?: null | string;
/*** 居住地區*/
residentialArea?: null | string;
/*** 注册类型 0邮箱验证码 1谷歌授权 3LINE授权 7FaceBook授权*/
reType?: number;
/*** 性别 1男 2女*/
sex?: number;
/*** 临时令牌token*/
temporaryToken?: null | string;
/*** 租户ID(手动传入,用于多租户隔离)*/
tenantID: string;
/*** 微信ID*/
wechatID?: null | string;
}
/** /**
* 邮箱验证请求参数 * 邮箱验证请求参数
*/ */
...@@ -297,7 +251,7 @@ class UserService { ...@@ -297,7 +251,7 @@ class UserService {
*/ */
static async distributorSelfRegisterAsync( static async distributorSelfRegisterAsync(
data: DistributorSelfRegisterDto data: DistributorSelfRegisterDto
): Promise<DistributorSelfRegisterResultDto> { ): Promise<DistributorLoginResultDto> {
const response = await OtaRequest.post( const response = await OtaRequest.post(
'/member-auth/self-register', '/member-auth/self-register',
data, data,
...@@ -307,7 +261,7 @@ class UserService { ...@@ -307,7 +261,7 @@ class UserService {
} }
} }
) )
return response as unknown as DistributorSelfRegisterResultDto return response as unknown as DistributorLoginResultDto
} }
/** /**
* 登录 * 登录
......
...@@ -23,7 +23,7 @@ const st: StorageLike = { ...@@ -23,7 +23,7 @@ const st: StorageLike = {
export interface UserLoginResult { export interface UserLoginResult {
status: 'ERROR' | 'CHOSEN' | 'SUCCESS' | 'UNSWEPT' | 'SCANNING' status: 'ERROR' | 'CHOSEN' | 'SUCCESS' | 'UNSWEPT' | 'SCANNING'
verify: boolean verify?: boolean
data?: any[], data?: any[],
applicationStatus?: string applicationStatus?: string
} }
...@@ -70,11 +70,10 @@ export const useUserStore = defineStore('user', { ...@@ -70,11 +70,10 @@ export const useUserStore = defineStore('user', {
try { try {
// 使用新的 UserService 登录 // 使用新的 UserService 登录
const response = await UserService.distributorLoginAsync(email, password, tenantId, reType, openId) const response = await UserService.distributorLoginAsync(email, password, tenantId, reType, openId)
// 登录成功,保存用户信息 // 登录成功,保存用户信息
this.token = response.token || '' this.token = response.token || ''
this.userInfo = response.userInfo this.userInfo = response.userInfo || {}
this.memberData = response.memberData
return { return {
status: 'SUCCESS', status: 'SUCCESS',
verify: false, verify: false,
...@@ -196,16 +195,16 @@ export const useUserStore = defineStore('user', { ...@@ -196,16 +195,16 @@ export const useUserStore = defineStore('user', {
* 注册 * 注册
* @param data 注册信息 * @param data 注册信息
*/ */
async registerDistributorAsync(data: DistributorSelfRegisterDto): Promise<RegisterResult> { async registerDistributorAsync(data: DistributorSelfRegisterDto): Promise<UserLoginResult> {
try { try {
const response = await UserService.distributorSelfRegisterAsync(data) const response = await UserService.distributorSelfRegisterAsync(data)
console.log('Register response:', response) console.log('Register response:', response)
this.token = response.token || ''
this.userInfo = response.userInfo || {}
this.memberData = response.memberData
return { return {
success: true, status: 'SUCCESS',
message: response.message || i18n.global.t('login.registerSuccess'), data: [response]
distributorId: response.distributorId,
status: response.status,
data: response
} }
} catch (error: any) { } catch (error: any) {
console.error('Register error:', error) console.error('Register error:', error)
...@@ -214,15 +213,12 @@ export const useUserStore = defineStore('user', { ...@@ -214,15 +213,12 @@ export const useUserStore = defineStore('user', {
if (error.error) { if (error.error) {
const errorInfo = error.error const errorInfo = error.error
const errorMessage = errorInfo.message || i18n.global.t('login.registerFailed') const errorMessage = errorInfo.message || i18n.global.t('login.registerFailed')
return { ResultMessage.Error(errorMessage)
success: false,
message: errorMessage
}
} else { } else {
return { ResultMessage.Error(error.message || i18n.global.t('httpError.networkError'))
success: false,
message: error.message || i18n.global.t('httpError.networkError')
} }
return {
status: 'ERROR',
} }
} }
}, },
......
...@@ -623,7 +623,6 @@ const handleSubmit = async () => { ...@@ -623,7 +623,6 @@ const handleSubmit = async () => {
loading.value = true loading.value = true
try { try {
let result
// 未登录用户自助注册 // 未登录用户自助注册
const registerData: DistributorSelfRegisterDto = { const registerData: DistributorSelfRegisterDto = {
tenantId: formData.tenantId || 'default', // TODO: 从配置获取 tenantId: formData.tenantId || 'default', // TODO: 从配置获取
...@@ -645,13 +644,14 @@ const handleSubmit = async () => { ...@@ -645,13 +644,14 @@ const handleSubmit = async () => {
confirmPassword: formData.confirmPassword,//确认密码 必需 与密码一致 confirmPassword: formData.confirmPassword,//确认密码 必需 与密码一致
} }
result = await userStore.registerDistributorAsync(registerData) const response = await userStore.registerDistributorAsync(registerData)
if (result.success) { if (response.status== 'SUCCESS') {
Message.success(result.message) Message.success(t('login.loginSuccess'))
// router.push('/login') const forward = localStorage.getItem('forward')
await handleAccountLogin() localStorage.removeItem('forward')
} else { router.push({
Message.error(result.message) path: forward ? forward : '/',
})
} }
} catch (error: any) { } catch (error: any) {
console.error('提交失败:', error) console.error('提交失败:', error)
...@@ -666,28 +666,6 @@ const handleSubmit = async () => { ...@@ -666,28 +666,6 @@ const handleSubmit = async () => {
} }
} }
const handleAccountLogin = async () => {
loading.value = true
try {
const result = await userStore.setUserPasswordLoginAsync(
formData.email,
formData.password,
systemConfigStore.tenantId || '',
formData.reType || 0,
'',
)
console.log('登录成功:', result)
currentStep.value = 3
if (result.status === 'SUCCESS') {
}
} catch (error: any) {
Message.error(error.message)
} finally {
loading.value = false
}
}
watch(()=>currentStep.value,(newVal,oldVal)=>{ watch(()=>currentStep.value,(newVal,oldVal)=>{
if(newVal!=oldVal){ if(newVal!=oldVal){
loginPage.value.scrollTop = 0 loginPage.value.scrollTop = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment