import request from 'Plugins/axios'
import type { LoginData, RegisterData, CaptchaData, CheckCaptchaData } from 'Types/api'
import type { UserBaseInfo } from 'Types/settings'

/** 登录 POST */
// export const $authLogin = async (data: LoginDto): Promise<AxiosResponse<ResponseData<LoginRespData>>> => request.post('/user/login', data)
// export async function $authLogin(data?: LoginDto, options?: AxiosRequestConfig) {
//   return request({
//     url: '/user/login',
//     method: 'POST',
//     headers: {
//       'Content-Type': 'application/json',
//     },
//     data,
//     ...(options || {}),
//   })
// }

export const apiLogin = async (data: LoginData): AxiosResponseDataType<LoginInfoRespData> => request.post('/jeecgboot/vendor/user/login', data)

export const apiRegister = async (data: RegisterData): AxiosResponseDataType<null> => request.post('/jeecgboot/vendor/user/register', data)

// 发送验证码 验证码类型，供应商用户[登录（s_login）、注册（s_register）、忘记密码（s_forgot_password）]
export const apiSendCaptcha = async (data: CaptchaData): AxiosResponseDataType<null> => request.post('/jeecgboot/shop/captcha/sms/send', data)

// 验证验证码
export const apiCheckCaptcha = async (data: CheckCaptchaData): AxiosResponseDataType<null> => request.post('/jeecgboot/shop/captcha/sms/verify', data)
// 退出登录
export const apiLogout = async (): AxiosResponseDataType<null> => request.get('/jeecgboot/vendor/user/logout')

// 用户信息
export const apiUserInfo = async (): AxiosResponseDataType<UserBaseInfo> => request.get('/jeecgboot/vendor/user/userinfo')
// 编辑用户信息
export const apiUpdateUserInfo = async (data: UserBaseInfo): AxiosResponseDataType<UserBaseInfo> =>
  request.post('/jeecgboot/vendor/user/userinfo', data)

export type ChangePasswordData = {
  phoneNumber?: string
  token?: string
  oldPassword?: string
  newPassword?: string
}
// 修改密码
export const apiChangePassword = async (data: ChangePasswordData): AxiosResponseDataType<UserBaseInfo> =>
  request.post('/jeecgboot/vendor/user/changePassword', data)
// 提交公司信息
export const submitCompanyApi = async (data: any): AxiosResponseDataType<any> => request.post('/jeecgboot/vendor/user/submitBusinessInfo', data)
// 提交公司信息
export const getCompanyInfoApi = async (data: any): AxiosResponseDataType<any> => request.get('/jeecgboot/shop/ocr/BusinessInfo', data)
