Commit ffd3b679 authored by youjie's avatar youjie

注册

parent eb3caa3c
......@@ -142,52 +142,6 @@ export interface DistributorLoginResultDto {
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 {
*/
static async distributorSelfRegisterAsync(
data: DistributorSelfRegisterDto
): Promise<DistributorSelfRegisterResultDto> {
): Promise<DistributorLoginResultDto> {
const response = await OtaRequest.post(
'/member-auth/self-register',
data,
......@@ -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 = {
export interface UserLoginResult {
status: 'ERROR' | 'CHOSEN' | 'SUCCESS' | 'UNSWEPT' | 'SCANNING'
verify: boolean
verify?: boolean
data?: any[],
applicationStatus?: string
}
......@@ -70,11 +70,10 @@ export const useUserStore = defineStore('user', {
try {
// 使用新的 UserService 登录
const response = await UserService.distributorLoginAsync(email, password, tenantId, reType, openId)
// 登录成功,保存用户信息
this.token = response.token || ''
this.userInfo = response.userInfo
this.userInfo = response.userInfo || {}
this.memberData = response.memberData
return {
status: 'SUCCESS',
verify: false,
......@@ -196,16 +195,16 @@ export const useUserStore = defineStore('user', {
* 注册
* @param data 注册信息
*/
async registerDistributorAsync(data: DistributorSelfRegisterDto): Promise<RegisterResult> {
async registerDistributorAsync(data: DistributorSelfRegisterDto): Promise<UserLoginResult> {
try {
const response = await UserService.distributorSelfRegisterAsync(data)
console.log('Register response:', response)
this.token = response.token || ''
this.userInfo = response.userInfo || {}
this.memberData = response.memberData
return {
success: true,
message: response.message || i18n.global.t('login.registerSuccess'),
distributorId: response.distributorId,
status: response.status,
data: response
status: 'SUCCESS',
data: [response]
}
} catch (error: any) {
console.error('Register error:', error)
......@@ -214,15 +213,12 @@ export const useUserStore = defineStore('user', {
if (error.error) {
const errorInfo = error.error
const errorMessage = errorInfo.message || i18n.global.t('login.registerFailed')
return {
success: false,
message: errorMessage
}
ResultMessage.Error(errorMessage)
} else {
return {
success: false,
message: error.message || i18n.global.t('httpError.networkError')
}
ResultMessage.Error(error.message || i18n.global.t('httpError.networkError'))
}
return {
status: 'ERROR',
}
}
},
......
......@@ -623,7 +623,6 @@ const handleSubmit = async () => {
loading.value = true
try {
let result
// 未登录用户自助注册
const registerData: DistributorSelfRegisterDto = {
tenantId: formData.tenantId || 'default', // TODO: 从配置获取
......@@ -645,13 +644,14 @@ const handleSubmit = async () => {
confirmPassword: formData.confirmPassword,//确认密码 必需 与密码一致
}
result = await userStore.registerDistributorAsync(registerData)
if (result.success) {
Message.success(result.message)
// router.push('/login')
await handleAccountLogin()
} else {
Message.error(result.message)
const response = await userStore.registerDistributorAsync(registerData)
if (response.status== 'SUCCESS') {
Message.success(t('login.loginSuccess'))
const forward = localStorage.getItem('forward')
localStorage.removeItem('forward')
router.push({
path: forward ? forward : '/',
})
}
} catch (error: any) {
console.error('提交失败:', error)
......@@ -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)=>{
if(newVal!=oldVal){
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