Files
MBTI_wang/miniprogram/utils/miniprogramAuditGate.js
Ghost d07235b64c feat: 小程序 AI 底栏与聊天页、出站推送调试与 tabbar 迁移
- 自定义 tabBar:AI 入口图标与样式,相关页面与审核门控调整

- API:MpTabbar、出站推送 Hook、后台设置与迁移 SQL(含 FAB 居中排序)

- 管理端:推送 Hook 面板、出站推送调试工具与生产环境注释说明

Made-with: Cursor
2026-04-20 15:29:10 +08:00

73 lines
2.3 KiB
JavaScript
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.

/**
* 超管审核相关:隐藏神仙 AI Tab/入口;提审模式下另由后端/各页关闭虚拟商品与「了解自己」深度套餐。
* - miniprogramAuditMode提审专用含虚拟支付合规
* - maintenanceMode / reviewMode面相审核用户口语「审核模式」常指其一
*/
/** 临时:为 true 时在客户端忽略审核/提审隐藏逻辑。平时必须为 false由 runtime 与后端 miniprogramAuditMode 等决定展示 */
const TEMP_FORCE_SHOW_ALL_HIDDEN_UI = false
/**
* 在 getRuntimeConfig 写入 globalData 之后调用:把审核相关开关置为关闭,供各页与 TabBar 使用。
*/
function applyAuditUiOverride(app) {
if (!TEMP_FORCE_SHOW_ALL_HIDDEN_UI || !app || !app.globalData) return
app.globalData.reviewMode = false
app.globalData.maintenanceMode = false
app.globalData.miniprogramAuditMode = false
}
/** 是否因审核/面相权限隐藏中间凸起 Tab拍摄 */
function shouldHideTabBarHighlightFab(gd) {
if (TEMP_FORCE_SHOW_ALL_HIDDEN_UI) return false
if (!gd) return false
const ep = gd.enterprisePermissions
const faceOff = !!(ep && ep.face === false)
return !!(gd.reviewMode || gd.maintenanceMode) || faceOff
}
function isAuditHideAiMode(gd) {
if (TEMP_FORCE_SHOW_ALL_HIDDEN_UI) return false
if (!gd) return false
return !!(gd.miniprogramAuditMode || gd.maintenanceMode || gd.reviewMode)
}
function redirectIfMiniprogramAudit(message) {
const app = getApp()
const gd = app && app.globalData
if (!isAuditHideAiMode(gd)) return false
wx.showToast({ title: message || '功能升级中', icon: 'none' })
setTimeout(() => {
wx.switchTab({ url: '/pages/index/index' })
}, 300)
return true
}
/**
* 先拉 runtime若存在再若提审则踢回首页否则执行 callback。
*/
function ensureRuntimeThenGate(callback) {
const app = getApp()
const run = () => {
if (isAuditHideAiMode(app.globalData)) {
redirectIfMiniprogramAudit()
return
}
if (typeof callback === 'function') callback()
}
if (app && typeof app.getRuntimeConfig === 'function') {
app.getRuntimeConfig().then(run).catch(run)
return
}
run()
}
module.exports = {
TEMP_FORCE_SHOW_ALL_HIDDEN_UI,
applyAuditUiOverride,
shouldHideTabBarHighlightFab,
isAuditHideAiMode,
redirectIfMiniprogramAudit,
ensureRuntimeThenGate
}