Files
MBTI_wang/miniprogram/utils/miniprogramAuditGate.js
卡若 ce55c48c64 feat: 同步今日小程序与后台迭代版本
集中提交今日 API、管理端、小程序与部署文档调整,确保 Gitea 主分支与本地最新开发版本一致。

Made-with: Cursor
2026-04-20 11:07:55 +08:00

47 lines
1.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面相审核用户口语「审核模式」常指其一
*/
function isAuditHideAiMode(gd) {
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 = {
isAuditHideAiMode,
redirectIfMiniprogramAudit,
ensureRuntimeThenGate
}