import { baseUrl } from '@/config/env';
import { BaseService } from '@/cool/index';

export class CommonService extends BaseService {
	/**
	 * 文件上传
	 *
	 * @returns
	 * @memberof CommonService
	 */
	upload() {
		return {
			url: baseUrl + '/upload/save-img'
		};
	}

	/**
	 * sass平台登录
	 *
	 * @param {*} { username, password, captchaId, verifyCode }
	 * @returns
	 * @memberof CommonService
	 */
	sassLogin({ mobile, password }) {
		return this.request({
			url: '/staff/login',
			method: 'GET',
			params: {
				mobile,
				password
			}
		});
	}

	/**
	 * 用户登录
	 *
	 * @param {*} { username, password, captchaId, verifyCode }
	 * @returns
	 * @memberof CommonService
	 */
	userLogin({ mobile, password }) {
		return this.request({
			url: '/auth/login',
			method: 'GET',
			params: {
				mobile,
				password
			}
		});
	}

	/**
	 * 用户退出
	 */
	userLogout() {
		return this.request({
			url: '/comm/logout',
			method: 'POST'
		});
	}

	/**
	 * sass登录信息
	 *
	 * @returns
	 * @memberof CommonService
	 */
	sassInfo() {
		return this.request({
			url: '/staff/login-detail'
		});
	}

	/**
	 * 商户信息
	 *
	 * @returns
	 * @memberof CommonService
	 */
	shopInfo() {
		return this.request({
			url: '/merchant/detail'
		});
	}

	/**
	 * 员工登录信息
	 *
	 * @returns
	 * @memberof CommonService
	 */
	userInfo() {
		return this.request({
			url: '/admin/login-detail'
		});
	}

	/**
	 * 用户信息修改
	 *
	 * @param {*} params
	 * @returns
	 * @memberof CommonService
	 */
	userUpdate(params) {
		return this.request({
			url: '/comm/person-update',
			method: 'POST',
			data: {
				...params
			}
		});
	}

	/**
	 * 权限信息
	 *
	 * @returns
	 * @memberof CommonService
	 */
	permMenu() {
		return this.request({
			url: '/comm/permmenu'
			// url: '/admin/get-login-auth'
		});
	}

	/**
	 * 图片验证码 svg
	 *
	 * @param {*} { height, width }
	 * @returns
	 * @memberof CommonService
	 */
	captcha({ height, width }) {
		return this.request({
			url: '/comm/captcha',
			params: {
				height,
				width
			}
		});
	}

	/**
	 * 节日信息
	 *
	 * @returns
	 * @memberof CommonService
	 */
	fest() {
		return this.request({
			url: '/fest/list'
		});
	}
}

export default new CommonService();
