feat: 小程序与管理端迭代(神仙AI、了解自己CRM、AI测试入口、报表与分润等)

Made-with: Cursor
This commit is contained in:
卡若
2026-04-17 19:46:48 +08:00
parent cf835ea585
commit 7108f28280
239 changed files with 21061 additions and 2175 deletions

View File

@@ -0,0 +1,36 @@
// utils/resultSectionScrollSync.js
// 四测结果页共享scroll 节流 + 计算当前 activeSection回写 chip 高亮
// 用法:
// const scrollSync = require('../../utils/resultSectionScrollSync')
// <scroll-view ... bindscroll="onScroll" />
// onScroll(e) { scrollSync.onScroll(this, e) }
const THROTTLE_MS = 140
// chip 条 + 安全间距,单位 pxboundingClientRect 返回 px
const OFFSET_TOP = 70
function onScroll(page, _e) {
if (!page || !page.data || !Array.isArray(page.data.sectionNav) || !page.data.sectionNav.length) return
const now = Date.now()
if (page._scrollThrottleAt && now - page._scrollThrottleAt < THROTTLE_MS) return
page._scrollThrottleAt = now
const ids = page.data.sectionNav.map((item) => item.id).filter(Boolean)
if (!ids.length) return
const query = wx.createSelectorQuery().in(page)
ids.forEach((id) => query.select('#' + id).boundingClientRect())
query.exec((res) => {
let current = ids[0]
for (let i = 0; i < ids.length; i++) {
const r = res[i]
if (r && typeof r.top === 'number' && r.top - OFFSET_TOP <= 0) {
current = ids[i]
}
}
if (current && current !== page.data.activeSection) {
page.setData({ activeSection: current })
}
})
}
module.exports = { onScroll }