89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
import request from "@/sheep/utils/request"
|
|
import { encryption } from "@/sheep/utils/encryption"
|
|
|
|
// 将 Basic Auth 字符串提取为常量
|
|
const BASIC_AUTH = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
|
|
|
|
export default {
|
|
// 获取用户信息
|
|
userInfo: (): Promise<any> =>
|
|
request({
|
|
url: "/admin/user/info",
|
|
method: "GET",
|
|
}),
|
|
|
|
// 浙政钉授权登录
|
|
auth: (token: string): Promise<any> =>
|
|
request({
|
|
url: "/thirdparty/thirdPartyOAth2/zzdsso",
|
|
method: "POST",
|
|
data: { token },
|
|
}),
|
|
|
|
// 诗画授权登录
|
|
authsh: (data: { accountId: string; sessionId: string }): Promise<any> =>
|
|
request({
|
|
url: "/thirdparty/thirdPartyOAth2/shjnsso",
|
|
method: "POST",
|
|
data,
|
|
}),
|
|
|
|
// 刷新token
|
|
// refreshToken: (params: { refreshToken: string }) =>
|
|
// request({
|
|
// url: `/sys/auth/refresh-token`,
|
|
// method: "POST",
|
|
// params,
|
|
// }),
|
|
|
|
// 账号密码登录
|
|
login: (params: any) => {
|
|
const { username, password, randomStr, code, grant_type, scope } = params
|
|
const encPassword = encryption(password, import.meta.env.VITE_PWD_ENC_KEY)
|
|
|
|
return request({
|
|
url: `/auth/oauth2/token`,
|
|
method: "POST",
|
|
params: {
|
|
username,
|
|
password,
|
|
randomStr,
|
|
code,
|
|
grant_type,
|
|
scope,
|
|
},
|
|
data: { password },
|
|
header: {
|
|
skipToken: true,
|
|
Authorization: BASIC_AUTH,
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
})
|
|
},
|
|
// 判断是否是商户角色
|
|
isMerchant: (): Promise<any> =>
|
|
request({
|
|
url: "/admin/role/isMchUser",
|
|
method: "GET",
|
|
}),
|
|
// 判断用户移动端角色
|
|
userRole: () =>
|
|
request({
|
|
url: "/admin/role/app/user-role",
|
|
method: "GET",
|
|
}),
|
|
// 根据手机号发送验证码
|
|
getMobilePhoneCode: (mobilePhone: string) =>
|
|
request({
|
|
url: `/thirdparty/thirdPartyOAth2/loginSms?mobilePhone=${mobilePhone}`,
|
|
method: "POST",
|
|
}),
|
|
// 设备认证
|
|
verifyDevice: (data: { mobilePhone: string; code: string }) =>
|
|
request({
|
|
url: "/thirdparty/thirdPartyOAth2/verify-device",
|
|
method: "POST",
|
|
data,
|
|
}),
|
|
}
|