删除过时的部署管理端触发词文档,并更新相关索引以反映新的触发词约定,确保文档一致性和准确性。
This commit is contained in:
@@ -16,7 +16,14 @@
|
||||
* 浏览导师页 → browse_mentor
|
||||
*/
|
||||
|
||||
const app = getApp()
|
||||
function getAppInstance() {
|
||||
try {
|
||||
const a = getApp()
|
||||
return a && a.globalData ? a : null
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const RULE_COOLDOWN_KEY = 'rule_engine_cooldown'
|
||||
const COOLDOWN_MS = 60 * 1000
|
||||
@@ -60,11 +67,14 @@ function setCooldown(ruleId) {
|
||||
}
|
||||
|
||||
function getUserInfo() {
|
||||
return app.globalData.userInfo || {}
|
||||
const app = getAppInstance()
|
||||
return app ? (app.globalData.userInfo || {}) : {}
|
||||
}
|
||||
|
||||
async function loadRules() {
|
||||
if (_cachedRules && Date.now() - _cacheTs < CACHE_TTL) return _cachedRules
|
||||
const app = getAppInstance()
|
||||
if (!app) return _cachedRules || []
|
||||
try {
|
||||
const res = await app.request({ url: '/api/miniprogram/user-rules', method: 'GET', silent: true })
|
||||
if (res && res.success && res.rules) {
|
||||
@@ -90,7 +100,8 @@ function getRuleInfo(rules, triggerName) {
|
||||
// VIP 用户不触发:统一由 checkVipContactRequiredAndGuide 引导到 profile-edit,避免与主流程冲突
|
||||
function checkRule_FillAvatar(rules) {
|
||||
if (!isRuleEnabled(rules, '注册')) return null
|
||||
if (app.globalData.isVip) return null
|
||||
const app = getAppInstance()
|
||||
if (app && app.globalData.isVip) return null
|
||||
const user = getUserInfo()
|
||||
if (!user.id) return null
|
||||
const avatar = user.avatar || user.avatarUrl || ''
|
||||
@@ -147,7 +158,8 @@ function checkRule_ShareAfter5Chapters(rules) {
|
||||
if (!isRuleEnabled(rules, '累计浏览5章节')) return null
|
||||
const user = getUserInfo()
|
||||
if (!user.id) return null
|
||||
const readCount = (typeof app.getReadCount === 'function' ? app.getReadCount() : (app.globalData.readCount || 0))
|
||||
const app = getAppInstance()
|
||||
const readCount = app ? (typeof app.getReadCount === 'function' ? app.getReadCount() : (app.globalData.readCount || 0)) : 0
|
||||
if (readCount < 5) return null
|
||||
if (isInCooldown('share_after_5')) return null
|
||||
setCooldown('share_after_5')
|
||||
@@ -166,7 +178,8 @@ function checkRule_FillVipInfo(rules) {
|
||||
if (!isRuleEnabled(rules, '完成付款')) return null
|
||||
const user = getUserInfo()
|
||||
if (!user.id) return null
|
||||
if (!(app.globalData.hasFullBook || app.globalData.hasPurchasedFull)) return null
|
||||
const app = getAppInstance()
|
||||
if (!app || !(app.globalData.hasFullBook || app.globalData.hasPurchasedFull)) return null
|
||||
if (user.wechatId && user.address) return null
|
||||
if (isInCooldown('fill_vip_info')) return null
|
||||
setCooldown('fill_vip_info')
|
||||
@@ -218,7 +231,8 @@ function checkRule_Withdraw(rules) {
|
||||
if (!isRuleEnabled(rules, '收益满50元')) return null
|
||||
const user = getUserInfo()
|
||||
if (!user.id) return null
|
||||
const earnings = app.globalData.totalEarnings || 0
|
||||
const app = getAppInstance()
|
||||
const earnings = app ? (app.globalData.totalEarnings || 0) : 0
|
||||
if (earnings < 50) return null
|
||||
if (isInCooldown('withdraw_50')) return null
|
||||
setCooldown('withdraw_50')
|
||||
@@ -280,6 +294,8 @@ function executeRule(rule, pageInstance) {
|
||||
function _trackRuleAction(ruleId, action) {
|
||||
const userId = getUserInfo().id
|
||||
if (!userId) return
|
||||
const app = getAppInstance()
|
||||
if (!app) return
|
||||
app.request({
|
||||
url: '/api/miniprogram/track',
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user