/** @format */

import web from "@/utils/axios/web.ts";

/**
 * 第三方登录
 * @param type
 */
export const oauthLogin = (type: string) => {
	return web.request({
		url: "/auth/oauth/render/" + type,
		method: "get",
	});
};

/**
 * 获取短信验证码
 * @param data
 */
export const getSms = (data: any) => {
	return web.request({
		url: "/auth/sms/sendByTemplate/",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8",
		},
		data: data,
	});
};

/**
 * 注册
 * @param data
 */
export const register = (data: API.PhoneRegisterRequest) => {
	return web.request({
		url: "/auth/auth/user/register",
		method: "post",
		data: data,
	});
};

/**
 * 登录
 * @param data
 */
export const login = (data: API.LoginRequest) => {
	return web.request({
		url: "/auth/auth/user/login",
		method: "post",
		data: data,
	});
};

/**
 * 手机号登录
 * @param data
 */
export const loginByPhone = (data: API.LoginByPhoneRequest) => {
	return web.request({
		url: "/auth/auth/user/loginByPhone",
		method: "post",
		data: data,
	});
};
/**
 * 找回密码
 * @param data
 */
export const findPassword = (data: API.findPasswordRequest) => {
	return web.request({
		url: "/auth/auth/user/findPassword",
		method: "post",
		data: data,
	});
};
/**
 * 生成客户端id
 */
export const createClientId = () => {
	return web.request({
		url: "/auth/auth/user/createClientId",
		method: "get",
	});
};
/**
 * 获取客户端id
 * @param clientId
 */
export const getClientId = (clientId: string) => {
	return web.request({
		url: "/auth/auth/user/getClientId",
		method: "post",
		data: {
			clientId: clientId,
		},
	});
};
/**
 * 获取客户端token
 * @param clientId
 */
export const getClientToken = (clientId: string) => {
	return web.request({
		url: "/auth/auth/user/getClientToken",
		method: "post",
		params: {
			clientId: clientId,
		},
	});
};
/**
 * 生成微信登录二维码
 * @param clientId
 */
export const generateQRCode = (clientId: string) => {
	return web.request({
		url: "/wechat/wx/generateQRCode",
		method: "get",
		params: {
			clientId: clientId,
		},
	});
};
/**
 * 获取用户操蛋权限
 * @param userId
 */
export const getUserMenuPermission = (userId: string): any => {
	return web.request({
		url: "/auth/permission/selectUserPermission",
		method: "get",
		params: {
			userId: userId,
		},
	});
};
