diff --git a/src/api/setting.warehouse/settingwarehouse.ts b/src/api/setting.warehouse/settingwarehouse.ts index 31ea1efd..ae8dac77 100644 --- a/src/api/setting.warehouse/settingwarehouse.ts +++ b/src/api/setting.warehouse/settingwarehouse.ts @@ -469,11 +469,53 @@ export function settingWarehouseSaveFrontCert( } as any) } +/** 当前仓库已授权的微信小程序信息(setting.warehouse.getweChatApp 响应;字段名以后端为准,前端做多形态兼容) */ +export type SettingWarehouseWeChatApp = { + warehouse_id?: number + /** 小程序 AppID */ + app_id?: string + /** 小程序 AppSecret */ + app_secret?: string + /** 小程序名称 */ + nick_name?: string + /** 小程序原始ID(gh_ 开头) */ + original_id?: string + /** 第三方平台授权码 */ + authorization_code?: string + /** 授权时间 */ + authorized_at?: string | null + updated_at?: string | null + [key: string]: unknown +} + +/** + * 查询当前仓库已授权的微信小程序信息(微信小程序配置页使用)。 + * 未授权时返回空配置(无小程序相关字段),前端据此提示「需要授权」并展示「去授权」入口。 + */ +export function settingWarehouseGetWeChatApp( + data: Record = {} +): Promise< + { code?: number; message?: string; data?: SettingWarehouseWeChatApp } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'setting.warehouse.getweChatApp', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + export const settingWarehouse = { getSettings: settingWarehouseGetSettings, getFieldMeta: settingWarehouseGetFieldMeta, saveSettings: settingWarehouseSaveSettings, getFrontConfig: settingWarehouseGetFrontConfig, saveFrontConfig: settingWarehouseSaveFrontConfig, - saveFrontCert: settingWarehouseSaveFrontCert + saveFrontCert: settingWarehouseSaveFrontCert, + getWeChatApp: settingWarehouseGetWeChatApp } diff --git a/src/api/wechat/wechat.ts b/src/api/wechat/wechat.ts new file mode 100644 index 00000000..eee05ae0 --- /dev/null +++ b/src/api/wechat/wechat.ts @@ -0,0 +1,45 @@ +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 +} + +/** + * 获取微信授权链接(由用户点击「去授权」时调用,避免页面加载即跳转/弹窗被拦截)。 + * 返回值中链接字段名做多形态兼容,取值见页面 pickAuthUrl()。 + */ +export function wechatGetAuthUrl( + data: Record = {} +): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getAuthUrl', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +export const wechat = { + getAuthUrl: wechatGetAuthUrl +} + +export default wechat diff --git a/src/router/map.ts b/src/router/map.ts index 2ded45f4..422c2f98 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -51,6 +51,9 @@ export const componentMap: Record = { /** 与后端菜单 component 字段兼容:部分环境为老路径 system/setting/basicManagement/index → 强制指向 newview(含投递计划/报表定义) */ 'system/setting/basicManagement/index': () => import('@/views/system/setting/basicManagement/newview/index.vue'), 'system/setting/basicManagement': () => import('@/views/system/setting/basicManagement/newview/index.vue'), + /** 微信小程序配置(备用独立页;与基础管理内「微信小程序」标签页共用表单组件) */ + 'system/setting/miniprogram/index': () => import('@/views/system/setting/miniprogram/index.vue'), + 'system/setting/miniprogram': () => import('@/views/system/setting/miniprogram/index.vue'), 'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'), // 'role/index': () => import('@/views/system/setting/role/index.vue'), // 'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'), diff --git a/src/views/system/setting/basicManagement/newview/config/template-config.ts b/src/views/system/setting/basicManagement/newview/config/template-config.ts index b90c54d8..cb99b282 100644 --- a/src/views/system/setting/basicManagement/newview/config/template-config.ts +++ b/src/views/system/setting/basicManagement/newview/config/template-config.ts @@ -22,6 +22,7 @@ import DetailPanel from './components/DetailPanel.vue' import LogPanel from './components/LogPanel.vue' import WarehouseSettingsForm from '../pages/WarehouseSettingsForm.vue' import FrontConfigForm from '../pages/FrontConfigForm.vue' +import MiniProgramConfigForm from '../pages/MiniProgramConfigForm.vue' import ApiAppFormDialog from '../pages/ApiAppFormDialog.vue' import DeliveryPlanFormDialog from '../pages/DeliveryPlanFormDialog.vue' import DefinitionFormDialog from '../pages/DefinitionFormDialog.vue' @@ -57,6 +58,7 @@ export const COMPONENT_REGISTRY: Record = { LogPanel, WarehouseSettingsForm, FrontConfigForm, + MiniProgramConfigForm, ApiAppFormDialog, DeliveryPlanFormDialog, DeliveryPlanCopyDialog, @@ -1644,6 +1646,22 @@ export const tabPages: TabPageRawConfig[] = [ confirmButtonText: '删除' } ] + }, + + // ===== 标签页六:微信小程序配置(备用,表单项页面;独立页入口见 views/system/setting/miniprogram/index.vue) ===== + { + name: 'miniProgram', + label: '微信小程序', + viewType: 'form', + formPage: MiniProgramConfigForm, + scanBoxCacheKey: 'basic-settings-miniprogram', + scanBoxFieldKeys: [], + tableColumnKeys: [], + upperTableDefaults: { + title: '', + showSelection: false + }, + detailSections: [] } ] diff --git a/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue b/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue new file mode 100644 index 00000000..b3b59587 --- /dev/null +++ b/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue @@ -0,0 +1,605 @@ + + + + + + diff --git a/src/views/system/setting/miniprogram/index.vue b/src/views/system/setting/miniprogram/index.vue new file mode 100644 index 00000000..85558478 --- /dev/null +++ b/src/views/system/setting/miniprogram/index.vue @@ -0,0 +1,48 @@ + + + + + +