用户端小程序修改

This commit is contained in:
2026-07-12 20:24:03 +08:00
parent e2dfb08de3
commit b267e885be
16 changed files with 551 additions and 214 deletions
+2 -7
View File
@@ -1,22 +1,17 @@
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 */
/** 小程序微信授权登录:Taro.login → /auth/login/wechat(资料上报由调用方 saveAuth 后执行) */
export async function loginWithWechat(): Promise<WechatLoginResult> {
const res = await Taro.login();
if (!res.code) {
throw new Error(res.errMsg || '微信登录失败,未获取到 code');
}
const result = await request<WechatLoginResult>('/auth/login/wechat', {
return 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';