import { fetch, fetchSso, fetchSso1 } from '@/core/request'; // const headers = { // cookieType: 'admin', // }; const headers = { 'TOKEN-TYPE': 'YW', }; // let basurl = 'http://172.18.0.247:9200' // let basurl = '' const basurl = ''; // 登录方法 export function login(username, password, captchaVerification, captchaCode, socialType, socialCode, socialState) { const data = { username, password, captchaVerification, captchaCode, // 社交相关 socialType, socialCode, socialState, }; return fetchSso({ url: `${basurl}/sso/auth/login`, method: 'post', data, }); } export function mxlogin(username, password, captchaVerification, socialType, socialCode, socialState) { const data = { username, password, captchaVerification, // 社交相关 socialType, socialCode, socialState, }; return fetchSso1({ url: `${basurl}/sso/starAuth/login`, method: 'post', data, }); } export function getVerify() { return fetchSso({ url: `${basurl}/sso/verify/get`, method: 'post', }); } // 初始化 export function init() { return fetchSso({ headers, url: 'mhzc/admin/user/init', method: 'post', }); } // 退出方法 export function logout() { return fetchSso({ url: 'sso/auth/logout', method: 'post', }); } // 注册 export function yhzhuce(params) { return fetchSso({ headers, url: `${basurl}/mhzc/user/register`, data: JSON.stringify(params), method: 'post', }); } // 发送验证码 export function sendMsg(params) { return fetchSso({ headers, url: `${basurl}/sso/auth/sendMsg`, data: JSON.stringify(params), method: 'post', }); } // 验证码登录 export function loginBySMS(params) { return fetchSso({ headers, url: `${basurl}/sso/auth/loginBySMS`, data: JSON.stringify(params), method: 'post', }); } export function mxlogout() { return fetchSso1({ url: 'sso/starAuth/logout', method: 'post', }); } export function mhLogout() { return fetchSso({ url: '/sso/auth/logout', method: 'post', }); } // 修改密码(用户自助) export function changePassword(params) { return fetchSso({ headers, url: `${basurl}/sso/auth/changePassword`, data: JSON.stringify(params), method: 'post', }); } // 获取重定向地址 export function getRedirectUri() { return fetchSso({ url: `/sso/auth/getRedirectUri`, method: 'post', }); } // 修改密码 export function resetPassword(params) { return fetchSso({ headers, url: 'mhzc/admin/user/resetPassword', data: JSON.stringify(params), method: 'post', }); } //获取验证码 export function Getqrcode() { return fetchSso({ url: `${basurl}/sso/did/pub/login/qrcode`, method: 'post', }); } // 获取图形验证码 export function getCaptcha() { return fetchSso({ url: `${basurl}/sso/verify/captcha`, method: 'post', }); } //获取登录回调响应结果 export function backresultlogin(params) { return fetchSso({ url: `${basurl}/sso/did/pub/backresult/login?reqId=${params}`, method: 'get', }); } //绑定手机号 export function didBindPhone(params) { return fetchSso({ url: `${basurl}/sso/auth/didBindPhone`, method: 'post', data: JSON.stringify(params), }); } //认证获取验证码 export function Getrzqrcode() { return fetchSso({ url: `${basurl}/sso/did/busilice/qrcode`, method: 'post', }); } //认证获取登录回调响应结果 export function rzbackresultlogin(params) { return fetchSso({ url: `${basurl}/sso/did/pub/backresult/busi?reqId=${params}`, method: 'get', }); } // ========== OAUTH 2.0 相关 ========== export function authorize(responseType, clientId, redirectUri, state, autoApprove, checkedScopes, uncheckedScopes) { // 构建 scopes const scopes = {}; /* for (const scope of checkedScopes) { scopes[scope] = true } for (const scope of uncheckedScopes) { scopes[scope] = false } */ // 发起请求 return fetch({ url: '/sso/oauth2/authorize', headers: { 'Content-type': 'application/x-www-form-urlencoded', }, params: { response_type: responseType, client_id: clientId, redirect_uri: redirectUri, state, auto_approve: autoApprove, scope: JSON.stringify(scopes), }, method: 'post', }); } export function hasLogin() { return window.sessionStorage.getItem('yhxx'); }