完善 H5 鉴权与登录流程

This commit is contained in:
inman
2026-07-24 14:55:13 +08:00
parent 160e82197e
commit c820a56e79
18 changed files with 1130 additions and 82 deletions

View File

@@ -165,6 +165,33 @@ export async function loginMiniProgram() {
return response.user;
}
export async function loginMiniProgramWithPhone(phoneCode: string) {
const result = await Taro.login();
const response = await request<{
token: string;
h5Ticket: string;
h5TicketExpiresAt: string;
linkedLeadCount: number;
user: UserProfile;
}>("/api/public/auth/wechat-phone-login", {
method: "POST",
data: {
loginCode: result.code,
phoneCode,
source: "mini_program",
},
});
setToken(response.token);
return response;
}
export async function createH5Ticket() {
return request<{ ticket: string; expiresAt: string }>("/api/public/auth/h5-ticket", {
method: "POST",
data: {},
});
}
export async function fetchContent() {
const [site, products] = await Promise.all([
request<SiteConfig>("/api/public/site-config"),