用户端小程序修改
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user