修改授权直接获取手机号逻辑

This commit is contained in:
张成
2025-08-24 16:10:00 +08:00
parent dec7530b1b
commit 6400149663
2 changed files with 23 additions and 14 deletions

View File

@@ -36,7 +36,7 @@ export interface VerifyCodeResponse {
}
// 微信授权登录
export const wechat_auth_login = async (): Promise<LoginResponse> => {
export const wechat_auth_login = async (phone_code?: string): Promise<LoginResponse> => {
try {
// 先进行微信登录获取code
const login_result = await Taro.login();
@@ -48,15 +48,12 @@ export const wechat_auth_login = async (): Promise<LoginResponse> => {
};
}
// 使用 httpService 调用微信授权接口
const auth_response = await httpService.post('/user/wx_auth', {
code: login_result.code
// 使用 httpService 调用微信授权接口传递手机号code
const auth_response = await httpService.post('user/wx_auth', {
code: login_result.code,
phone_code: phone_code // 传递手机号加密code
});
if (auth_response.code === 0) {
return {
success: true,
@@ -89,7 +86,7 @@ export interface PhoneLoginParams {
export const phone_auth_login = async (params: PhoneLoginParams): Promise<LoginResponse> => {
try {
// 使用 httpService 调用验证验证码接口
const verify_response = await httpService.post('/user/sms/verify', {
const verify_response = await httpService.post('user/sms/verify', {
phone: params.phone,
code: params.verification_code
});
@@ -127,7 +124,7 @@ export const phone_auth_login = async (params: PhoneLoginParams): Promise<LoginR
// 发送短信验证码
export const send_sms_code = async (phone: string): Promise<SmsResponse> => {
try {
const response = await httpService.post('/user/sms/send', {
const response = await httpService.post('user/sms/send', {
phone: phone
});
@@ -155,7 +152,7 @@ export const send_sms_code = async (phone: string): Promise<SmsResponse> => {
// 验证短信验证码
export const verify_sms_code = async (phone: string, code: string): Promise<VerifyCodeResponse> => {
try {
const response = await httpService.post('/user/sms/verify', {
const response = await httpService.post('user/sms/verify', {
phone: phone,
code: code
});