Files
pj_h5_cloud/src/sheep/api/user.ts
T
2026-05-08 22:24:46 +08:00

115 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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",
}),
// 浙政钉授权登录(token:旧 uabaseToken;authCode:开放平台 H5 getAuthCode)
auth: (payload: { token?: string; authCode?: string }): Promise<any> =>
request({
url: "/thirdparty/thirdPartyOAth2/zzdsso",
method: "POST",
data: payload,
}),
zzdLoginSms: (mobilePhone: string): Promise<any> =>
request({
url: `/thirdparty/thirdPartyOAth2/loginSms?mobilePhone=${encodeURIComponent(mobilePhone.trim())}`,
method: "POST",
}),
zzdSsoConfirmPhone: (data: { bindSessionId: string; mobilePhone: string; smsCode: string }): Promise<any> =>
request({
url: "/thirdparty/thirdPartyOAth2/zzdsso/confirmPhone",
method: "POST",
data,
}),
// 诗画授权登录
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",
}),
// 判断是否是共富商城商户角色
isMallMchUser: (): Promise<any> =>
request({
url: "/admin/role/isMallMchUser",
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,
}),
// 用户修改个人资料
appModifyUser: (data: any) =>
request({
url: "/admin/user/app/modify",
method: "POST",
data,
}),
}