完善 H5 鉴权与登录流程
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user