注册修改为绑定
This commit is contained in:
@@ -113,7 +113,7 @@ class UserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行静默登录流程:微信登录->个人服务器登录->进入基础界面->签到/注册
|
||||
* 执行静默登录流程:微信登录->个人服务器登录->进入基础界面->签到/绑定
|
||||
* @returns 登录结果
|
||||
*/
|
||||
async wxLogin(): Promise<{
|
||||
@@ -293,14 +293,59 @@ class UserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param registerInfo 注册信息
|
||||
* @returns 注册结果和员工信息
|
||||
* 用户绑定
|
||||
* @param registerInfo 绑定信息
|
||||
* @returns 绑定结果和员工信息
|
||||
*/
|
||||
async register(registerInfo: { name: string; phone: string }): Promise<{ success: boolean; employeeInfo: EmployeeInfo; message?: string }> {
|
||||
return apiService.userRegister(registerInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑微信
|
||||
* 清除当前用户的openid绑定,允许重新注册其他账号
|
||||
* @returns 解绑结果
|
||||
*/
|
||||
async unbindWechat(): Promise<{ success: boolean; message?: string }> {
|
||||
try {
|
||||
console.log('开始解绑微信流程');
|
||||
|
||||
// 调用API解绑
|
||||
const result = await apiService.unbindWechat();
|
||||
|
||||
if (result.success) {
|
||||
console.log('微信解绑成功');
|
||||
|
||||
// 清除本地存储的登录信息
|
||||
wx.removeStorageSync('userInfo');
|
||||
wx.removeStorageSync('token');
|
||||
wx.removeStorageSync('openid');
|
||||
wx.removeStorageSync('session_key');
|
||||
|
||||
// 清除全局数据
|
||||
const app = getApp<any>();
|
||||
app.globalData.userInfo = null;
|
||||
app.globalData.token = null;
|
||||
app.globalData.openid = null;
|
||||
app.globalData.isLoggedIn = false;
|
||||
|
||||
console.log('本地登录信息已清除');
|
||||
|
||||
// 解绑成功后跳转到主界面
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('解绑微信失败:', error);
|
||||
return { success: false, message: '解绑微信失败,请重试' };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户权限列表
|
||||
* @returns 权限列表
|
||||
|
Reference in New Issue
Block a user