feat: 对齐规则引擎

This commit is contained in:
Alex-larget
2026-03-17 12:21:33 +08:00
parent 601044ec60
commit fcc05b6420
9 changed files with 425 additions and 37 deletions

View File

@@ -4,6 +4,7 @@
*/
const { parseScene } = require('./utils/scene.js')
const { checkAndExecute } = require('./utils/ruleEngine.js')
App({
globalData: {
@@ -209,31 +210,6 @@ App({
return code.replace(/[\s\-_]/g, '').toUpperCase().trim()
},
// 判断用户资料是否完善(昵称 + 头像)
_isProfileIncomplete(user) {
if (!user) return true
const nickname = (user.nickname || '').trim()
const avatar = (user.avatar || '').trim()
const isDefaultNickname = !nickname || nickname === '微信用户'
const noAvatar = !avatar
return isDefaultNickname || noAvatar
},
// 登录后若资料未完善,引导跳转到头像昵称引导页
_ensureProfileCompletedAfterLogin(user) {
try {
if (!user || !this._isProfileIncomplete(user)) return
const pages = getCurrentPages()
const current = pages[pages.length - 1]
// 避免在头像昵称页或资料编辑页内重复跳转
if (current && (current.route === 'pages/avatar-nickname/avatar-nickname' || current.route === 'pages/profile-edit/profile-edit')) return
wx.showToast({ title: '请先完善头像和昵称', icon: 'none', duration: 2000 })
wx.navigateTo({ url: '/pages/avatar-nickname/avatar-nickname' })
} catch (e) {
console.warn('[App] 跳转资料编辑页失败:', e)
}
},
// 根据业务 id 从 bookData 查 mid用于跳转
getSectionMid(sectionId) {
const list = this.globalData.bookData || []
@@ -521,8 +497,8 @@ App({
this.bindReferralCode(pendingRef)
}
// 登录后引导完善资料
this._ensureProfileCompletedAfterLogin(user)
// 登录后引导完善资料(规则引擎接管,完善头像吸收到规则引擎)
checkAndExecute('after_login', null)
}
return res.data
@@ -583,8 +559,8 @@ App({
this.bindReferralCode(pendingRef)
}
// 登录后引导完善资料
this._ensureProfileCompletedAfterLogin(user)
// 登录后引导完善资料(规则引擎接管)
checkAndExecute('after_login', null)
}
return res.data.openId
}
@@ -637,8 +613,8 @@ App({
this.bindReferralCode(pendingRef)
}
// 登录后引导完善资料
this._ensureProfileCompletedAfterLogin(user)
// 登录后引导完善资料(规则引擎接管)
checkAndExecute('after_login', null)
return res.data
}