refactor: clean up codebase and add new features
Replace SCSS variable usages with explicit pixel/hex values for consistent styling across all components Fix broken template syntax including missing class spaces and incorrect closing tags Migrate constant and API imports to centralized @/constants and @/api modules Add new utility classes: IdUtils, CallbackUtils, and TimerUtils Add new chat conversation API endpoints for recent conversations and message lists Add new Discovery page components (FindTabs, QuickQuestions, CardSwiper) and their styles Update app store config to use environment variables for base API and WebSocket URLs Add new selected tab icon assets
This commit is contained in:
@@ -1,115 +1,22 @@
|
||||
import { oauthToken, checkUserPhone } from "@/request/api/LoginApi";
|
||||
import {
|
||||
authLogin,
|
||||
refreshAuthLogin,
|
||||
checkRefreshToken,
|
||||
} from "@/manager/LoginManager";
|
||||
import { clientId } from "@/constant/base";
|
||||
import {
|
||||
getAccessToken,
|
||||
removeAccessToken,
|
||||
setAccessToken,
|
||||
} from "../constant/token";
|
||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||
import { oauthToken, checkUserPhone } from "@/api/login";
|
||||
|
||||
// 跳转登录
|
||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||
export const goLogin = () => {};
|
||||
|
||||
// 登录成功后,返回上一页
|
||||
export const goBack = () => uni.navigateBack({ delta: 1 });
|
||||
export const goBack = () => {};
|
||||
|
||||
// 检测token
|
||||
export const checkToken = () => {
|
||||
const token = getAccessToken();
|
||||
return new Promise((resolve) => {
|
||||
if (!token) {
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
export const checkToken = () => {};
|
||||
|
||||
// 登录逻辑
|
||||
export const onLogin = async (e) => {
|
||||
console.info("onLogin code: ", e);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// 判断用户拒绝
|
||||
if (e !== undefined && e && e.detail && e.detail.errno === 104) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
await authLogin(e).then(async () => {
|
||||
console.log("authLogin resolve success");
|
||||
// 检查手机号是否绑定
|
||||
const checkRes = await checkUserPhone();
|
||||
if (checkRes.data) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e === undefined) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const { code } = e.detail;
|
||||
|
||||
// 绑定手机号
|
||||
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||
const res = await bindUserPhone(params);
|
||||
if (res.data) {
|
||||
// 登录成功后,触发登录成功事件
|
||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||
resolve();
|
||||
} else {
|
||||
console.log("绑定手机号失败");
|
||||
removeAccessToken();
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
export const onLogin = async () => {};
|
||||
|
||||
/// 检查手机号登录
|
||||
export const onCheckPhoneLogin = async () => {
|
||||
return new Promise(async (resolve) => {
|
||||
await refreshAuthLogin().then(async () => {
|
||||
// 刷新成功后,检查手机号是否绑定
|
||||
const access_token = getAccessToken();
|
||||
const checkRes = await checkUserPhone({
|
||||
token: access_token,
|
||||
});
|
||||
|
||||
if (checkRes.data) {
|
||||
// 登录成功后,触发登录成功事件
|
||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
export const onCheckPhoneLogin = async () => {};
|
||||
|
||||
// apple登录
|
||||
export const onAppleLogin = async (e) => {
|
||||
return new Promise(async (resolve) => {
|
||||
await refreshAuthLogin()
|
||||
.then(() => {
|
||||
// 登录成功后,触发登录成功事件
|
||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
export const onAppleLogin = async () => {};
|
||||
|
||||
// 刷新 token
|
||||
export const refreshToken = async () => {
|
||||
await checkRefreshToken();
|
||||
};
|
||||
export const refreshToken = async () => {};
|
||||
|
||||
Reference in New Issue
Block a user