import request from '@/utils/request';
import type { ApiResult } from '@/api';
/**
 * 微信公众号授权登录
 */
export async function getCode() {
  const res = await request.get<ApiResult<unknown>>('/wx-official/code');
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 微信公众号授权登录
 */
export async function wxOfficialLogin() {
  const res = await request.get<ApiResult<unknown>>('/wx-official');
  console.log(res.data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
