小程序修改

This commit is contained in:
2026-07-12 19:44:36 +08:00
parent 3b4833b51a
commit e2dfb08de3
45 changed files with 2028 additions and 347 deletions
+8 -1
View File
@@ -1,6 +1,7 @@
import type { WechatLoginResult } from '@dukang/shared-types';
import Taro from '@tarojs/taro';
import { request } from './api';
import { syncMiniWechatProfile } from './mini-wechat-profile';
/** 小程序微信授权登录:Taro.login → /auth/login/wechat */
export async function loginWithWechat(): Promise<WechatLoginResult> {
@@ -8,8 +9,14 @@ export async function loginWithWechat(): Promise<WechatLoginResult> {
if (!res.code) {
throw new Error(res.errMsg || '微信登录失败,未获取到 code');
}
return request<WechatLoginResult>('/auth/login/wechat', {
const result = await request<WechatLoginResult>('/auth/login/wechat', {
method: 'POST',
data: { code: res.code, platform: 'mini' },
});
if (result.accessToken) {
await syncMiniWechatProfile();
}
return result;
}
export { bindWechatForUser } from './pay-wechat';