import request from '@/sheep/request'; import { t } from '@/locale'; const AuthUtil = { // 使用手机 + 密码登录 login: (data) => { return request({ url: '/member/auth/login', method: 'POST', data, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), successMsg: t('common.login_success'), }, }); }, // 使用手机 + 验证码登录 smsLogin: (data) => { return request({ url: '/member/auth/sms-login', method: 'POST', data, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), successMsg: t('common.login_success'), }, }); }, // 账号注册 register: (data) => { return request({ url: '/member/auth/sms-register', method: 'POST', data, custom: { showSuccess: true, loadingMsg: t('common.registering'), successMsg: t('common.register_success'), }, }); }, // 注册校验用户名是否重复 verifyUsername: (username) => { return request({ url: '/member/user/verifyUsername?username='+username, method: 'GET', }); }, // 根据用户名和手机号查询用户 verifyPhone: (username,mobile) => { return request({ url: '/member/user/getUserByUserNameWithMobile?username='+username+'&mobile='+mobile, method: 'GET', }); }, // 发送手机验证码 sendSmsCode: (mobile, scene) => { return request({ url: '/member/auth/send-sms-code', method: 'POST', data: { mobile, scene, }, custom: { loadingMsg: t('common.sending'), showSuccess: true, successMsg: t('common.send_success'), }, }); }, // 校验手机验证码 validatePhone: (mobile,code,scene) => { return request({ url: '/member/auth/validate-sms-code', method: 'POST', data: { mobile, code, scene }, }); }, // 微信公众号登录选择账号登录 selectUsernameLogin: (data) => { return request({ url: '/member/auth/select-username-login', method: 'POST', data, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), successMsg: t('common.login_success'), }, }); }, // 微信公众号注册 officialRegister: (data) => { return request({ url: '/member/auth/social-register', method: 'POST', data, custom: { showSuccess: true, loadingMsg: t('common.registering'), successMsg: t('common.register_success'), }, }); }, // 微信公众号首次登录校验手机 OfficialEnterLogin: (reqVO, registerReqVO) => { return request({ url: '/member/auth/social-login-validate-sms-code', method: 'POST', data: { reqVO, registerReqVO }, }); }, // 登出系统 logout: () => { return request({ url: '/member/auth/logout', method: 'POST', }); }, // 刷新令牌 refreshToken: (refreshToken) => { return request({ url: '/member/auth/refresh-token', method: 'POST', params: { refreshToken }, custom: { loading: false, // 不用加载中 showError: false, // 不展示错误提示 }, }); }, // 社交授权的跳转 socialAuthRedirect: (type, redirectUri) => { return request({ url: '/member/auth/social-auth-redirect', method: 'GET', params: { type, redirectUri, }, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), }, }); }, // 社交快捷登录 socialLogin: (type, code, state) => { return request({ url: '/member/auth/social-login', method: 'POST', data: { type, code, state, }, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), }, }); }, // 微信小程序的一键登录 weixinMiniAppLogin: (phoneCode, loginCode, state) => { return request({ url: '/member/auth/weixin-mini-app-login', method: 'POST', data: { phoneCode, loginCode, state }, custom: { showSuccess: true, loadingMsg: t('common.logging_in'), successMsg: t('common.login_success'), }, }); }, // 创建微信 JS SDK 初始化所需的签名 createWeixinMpJsapiSignature: (url) => { return request({ url: '/member/auth/create-weixin-jsapi-signature', method: 'POST', params: { url }, custom: { showError: false, showLoading: false, }, }) }, // 获得消费者跳转到平台或者商户的链接 getConsumerRedirectUrl: () => { return request({ url: '/member/auth/redirectLogin', method: 'GET', }); } }; export default AuthUtil;