WEB/src/api/wechat/wechat.ts
liufumingren fc5a80717e feat(微信小程序): 授权页支持主域名校验、代注册入口与左菜单+右明细结构
- 主域名校验:复用 frontBrand 导出 isMainDomainHost/normalizeFrontHost/getMainDomainHosts,非主域名禁用授权/代注册并提示
- 新增「代注册小程序」按钮:wechat.getRegisterUrl 取链接,在新小窗打开
- 已授权改为左菜单+右明细(基础信息/认证状态/备案配置/支付配置/发布/微信用户),左右各自滚动、边框到底
- 基础信息改为「名称:不可编辑输入框」;头像只显示图片;隐藏启用状态/所属仓库/记录ID
- 修正 auth_time(Unix 秒)与 ISO 时间本地化;func_info JSON 解析为功能标签
2026-09-22 02:39:47 +08:00

68 lines
2.0 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 '@/utils/request'
const v = '1.0'
/**
* 微信授权相关接口(module wechat)
*
* wechat.getAuthUrl —— 获取微信授权链接:前端拿到链接后在**新小窗口**中打开,
* 用户完成授权后由后端接收微信回调并落库,前端再调用业务侧查询接口刷新。
*/
export type WeChatAuthUrlPayload = {
/** 授权链接(后端返回的字段名可能是 url / auth_url / authorize_url 等,取值时做兼容) */
url?: string
auth_url?: string
authorize_url?: string
/** 授权状态校验串 */
state?: string
[key: string]: unknown
}
/**
* 获取微信授权链接(由用户点击「去授权」时调用,避免页面加载即跳转/弹窗被拦截)。
* 返回值中链接字段名做多形态兼容,取值见页面 pickUrl()。
*/
export function wechatGetAuthUrl(
data: Record<string, unknown> = {}
): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record<string, unknown>> {
return request({
url: '/system',
method: 'post',
params: {
method: 'wechat.getAuthUrl',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
/**
* 获取「代注册小程序」链接(第三方平台快速创建小程序):
* 同样由用户点击按钮后才请求,并在新小窗口中打开;注册完成后调用业务侧查询接口刷新。
* 若后端方法名不同,仅需改此处 method。
*/
export function wechatGetRegisterUrl(
data: Record<string, unknown> = {}
): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record<string, unknown>> {
return request({
url: '/system',
method: 'post',
params: {
method: 'wechat.getRegisterUrl',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
export const wechat = {
getAuthUrl: wechatGetAuthUrl,
getRegisterUrl: wechatGetRegisterUrl
}
export default wechat