Browse Source

Merge remote-tracking branch 'origin/fix/mp-weixin-key-bug' into merge/cfclub-all-20261031

# Conflicts:
#	cfc-backend/src/test/java/com/etotem/cfc/unit/RepeatTaskGeneratorPassThroughTest.java
#	cfc-frontend/pages/health/indicator-quicklook.vue
#	cfc-frontend/pages/health/report-list.vue
#	cfc-frontend/pages/promotion/team.vue
#	cfc-frontend/pages/wealth/index.vue
Agnes Agent 2 tuần trước cách đây
mục cha
commit
41286295c0

+ 2 - 2
AGENTS.md

@@ -75,7 +75,7 @@ opencode web --port 4090 --hostname 127.0.0.1
 - **新增接口前:** 必须先查阅 `docs/superpowers/api/API_REFERENCE.md`,确认无重复/相似接口才新增
 - **废弃接口:** 标记 `410 Gone` 并注释说明,不直接删除;清理时机确认无前端调用后
 - **AI 服务统一走 LangGraph:** 所有 AI 能力(对话/问卷/画像/推荐/解析)基于 `cfc-langgraph` Python 服务(FastAPI + LangGraph + ChromaDB RAG,端口 9000,生产 `ai.etotem.com.cn`);Java 侧通过 `AiGateway` 调用(熔断 + 超时 + Fallback),禁止绕过 AiGateway 直接对接第三方 LLM;新增 AI 功能优先以 LangGraph graph 形式实现
-- **小程序限制:** 禁止可选链 `?.`(用 `&&` 替代)、禁止 CSS Grid(用 flexbox)、禁止 `:key` 表达式(用方法调用代替)、禁止直接 `new Date(string)`(用 `parseDate()`)
+- **小程序限制:** 禁止可选链 `?.`(用 `&&` 替代)、禁止 CSS Grid(用 flexbox)、禁止 `:key` 运算符表达式与方法调用(`:key` 只能写条目真实属性或循环索引别名;组合键在 loadData 预计算为 `_key`)、禁止直接 `new Date(string)`(用 `parseDate()`)
 - **新增Controller/Service:** 检查类名是否与其他包重名(Spring Bean Name 冲突)
 - **新增路由:** 运行 `grep -rn '@Mapping' cfc-backend/src/.../controller/ | grep -oP '@\w+Mapping\("\K[^"]*' | sort -u` 检查重复
 
@@ -422,7 +422,7 @@ cd cfc-langgraph && .venv/Scripts/python.exe -m uvicorn local_report_app:app --h
 
 - 禁止可选链 `?.`(用 `&&` 替代)
 - 禁止 CSS Grid(用 flexbox)
-- 禁止 `:key` 表达式(如 `:key="item.id || item.circleId"`,微信小程序模板编译器不支持带运算符的 `:key` 绑定 → 改用方法调用 `:key="getItemKey(item)"`)
+- 禁止 `:key` 运算符表达式(`item.id || item.circleId`),**也禁止改用方法调用**(`:key="getItemKey(item)"`)。uni-app 会把 `:key` 表达式当作运行时找回条目的属性路径,方法调用使 `find(v => v['getItemKey(item)'] === value)` 恒失败 → v-for 作用域内传条目变量的事件与 `v-model` 收到 `undefined`(`Cannot read properties of undefined (reading 'id')`)。`:key` 只能写条目真实属性(`item.id`)或循环索引别名(`idx`);组合键在数据加载处预计算为 `_key`
 - 禁止直接 `new Date(string)` 解析日期字符串(部分 iOS 的 JavaScriptCore 不支持空格分隔格式如 `"2026-08-22 14:00"` → 统一用 `utils/format.js` 的 `parseDate()`)
 - Vue 2 Options API,禁止 Composition API
 

+ 2 - 2
cfc-frontend/AGENTS.md

@@ -175,7 +175,7 @@ pages.json 中定义 5 个 TabBar 页面(TabBar 文案,非五维维度名)
 - **NEVER** 在 WXML/Vue 模板中使用可选链 `?.`,微信小程序不支持 → 使用 `&&` 代替(如 `currentWish?.title` 改为 `currentWish && currentWish.title`)
 - **NEVER** 在 `:class` 绑定中调用方法(如 `:class="getStatusClass(item)"`),微信小程序模板编译器不支持带参数的方法调用 → 改用内联表达式(如 `:class="'status-' + item._cssClass"`)或计算属性
 - **NEVER** 在 CSS 类名、选择器中使用中文(如 `.val-偏高`、`.badge-低风险`),微信小程序 wxss 编译器不支持中文类名 → 使用英文(如 `.val-high`、`.badge-low`),数据中的中文状态通过 `_cssClass` 字段映射
-- **NEVER** 在 `:key` 中使用表达式(如 `:key="item.id || item.circleId"`),微信小程序模板编译器不支持带运算符的 `:key` 绑定 → 改用方法调用(如 `:key="getItemKey(item)"`,在 methods 中定义 `getItemKey(item) { return item.id || item.circleId }`)
+- **NEVER** 在 `:key` 中使用运算符表达式,**也不要改用方法调用**。运算符表达式(`item.id || item.circleId`)微信小程序模板编译器不支持;而「方法调用」(`:key="getItemKey(item)"`)虽能编译通过,但 uni-app 会把 `:key` 表达式当作**运行时找回条目的属性路径**——编译成 `argsPath=['reports','getReportKey(item)',item.m8]`,运行时 `find(v => v['getReportKey(item)'] === value)` 恒失败 → 该 v-for 作用域内**所有传条目变量的事件**(`@click="onRowClick(item)"`、`@tap="toggleWeek(w.id)"`)和 `v-model="row.name"` 都会收到 `undefined`,报 `Cannot read properties of undefined (reading 'id')`。`:key` 只能写**条目真实属性**(`:key="item.id"`)或**循环索引别名**(`:key="idx"`);需要 `a || b` 这类组合键时,在数据加载处预计算为条目真实字段(`list[i]._key = list[i].id || list[i].circleId`),模板写 `:key="item._key"`。`scripts/audit-mp-antipatterns.js` 已对此设 ERROR 门禁。
 - **NEVER** 直接用 `new Date(string)` 解析日期字符串。部分 iOS(JavaScriptCore)的 `new Date()` 只支持 `yyyy/MM/dd`、`yyyy/MM/dd HH:mm:ss`、`yyyy-MM-dd`、`yyyy-MM-ddTHH:mm:ss`、`yyyy-MM-ddTHH:mm:ss+HH:mm` 格式,后端常见的 `"2026-08-22 14:00"`(空格分隔的 MySQL DATETIME 风格)和 Java 的 `"Sat Aug 22 14:00:00 CST 2026"` 会解析失败返回 Invalid Date → 一律使用 `utils/format.js` 的 `parseDate()`,它会自动归一化上述两种格式并返回 `Date|null`(如 `var d = parseDate(item.startTime); if (!d) return`)
 - **NEVER** 新增 `uni.getSystemInfoSync()` 调用。该 API 已在微信基础库 2.20.1+ 弃用,开发者工具会持续告警(`getSystemInfoSync is deprecated`)→ 改用 `uni.getWindowInfo()`(取 `windowWidth`/`pixelRatio`/`safeArea` 等窗口信息)或 `uni.getDeviceInfo()`(取 `system`/`brand`/`model` 等设备信息)。已有兼容代码(`components/mp-html/` 内的 `uni.canIUse('getWindowInfo')` 兜底)保持不变。参考替换:`uni.getSystemInfoSync().pixelRatio` → `uni.getWindowInfo().pixelRatio`
 - **NEVER** 给 `props` 传可能为非数组的值而不做兜底。组件接收 `Array` 类型 prop 时,父组件传值必须保证是数组(`|| []` 兜底 + `Array.isArray` 校验),否则触发 `Invalid prop: type check failed for prop "xxx". Expected Array, got Object` 告警。典型场景:接口返回结构不确定(`res.data.list` 可能为 `Object`)时,用 `var arr = (res.data && res.data.list) || (res.data instanceof Array ? res.data : [])` 三态兼容
@@ -253,7 +253,7 @@ node scripts/audit-mp-antipatterns.js            # ERROR 归零才算通过(
 node scripts/audit-mp-antipatterns.js --json     # 机器可读,便于脚本处理
 ```
 
-ERROR 级(必须修):模板 `?.`、`:key` 运算符表达式、CSS 中文选择器、`uni.getSystemInfoSync()`、`transition: all`、`v-for` 缺 `:key`、日期用 `toLocale*String` 格式化。
+ERROR 级(必须修):模板 `?.`、`:key` 运算符表达式、`:key` 方法调用且作用域内事件/v-model 传条目变量(运行时 handler 恒收 `undefined`)、CSS 中文选择器、`uni.getSystemInfoSync()`、`transition: all`、`v-for` 缺 `:key`、日期用 `toLocale*String` 格式化。
 WARN 级(人工确认):`new Date(<非字面量>)`(应改 `parseDate()`)、`:class/:style` 内带参方法调用(uni-app 渲染函数下可用,但 WXML 原生表达式不支持,AGENTS.md 列为禁用项)。
 
 ### 修改 `remove-scoped.js` 的风险

+ 2 - 8
cfc-frontend/components/ContentSharePoster.vue

@@ -8,7 +8,7 @@
         <view class="tpl-options">
           <view
             v-for="tpl in serverTemplates"
-            :key="getTplKey(tpl)"
+            :key="tpl.id"
             class="tpl-option"
             :class="{ 'tpl-active': activeTemplateId === tpl.id }"
             @click="switchTemplate(tpl)"
@@ -24,7 +24,7 @@
         <view class="bg-options">
           <view
             v-for="(c, i) in bgOptions"
-            :key="getBgKey(i)"
+            :key="i"
             class="bg-option"
             :class="{ 'bg-active': bgColor === c }"
             :style="{ background: c }"
@@ -135,12 +135,6 @@ export default {
     }
   },
   methods: {
-    getTplKey(tpl) {
-      return 'tpl_' + tpl.id
-    },
-    getBgKey(i) {
-      return 'bg_' + i
-    },
     // 海报画布文字按用户字号系数放大(画布有固定排版,放大区间比页面更保守,防止溢出裁切)
     _fs(size) {
       var scale = getFontScale()

+ 3 - 7
cfc-frontend/pages/health/components/ComprehensiveSurvey.vue

@@ -297,7 +297,7 @@
             <text class="group-arrow">{{ expandedGroups.indexOf(group.key) >= 0 ? '收起' : '展开' }}</text>
           </view>
           <view v-if="expandedGroups.indexOf(group.key) >= 0" class="chip-row-wrap">
-            <view v-for="(item, ii) in group.items" :key="getDiseaseKey(gi, ii)" class="chip-item-wrap"
+            <view v-for="(item, ii) in group.items" :key="ii" class="chip-item-wrap"
                   :class="{ 'chip-active': selectedDiseaseNames.indexOf(item.name) >= 0 }"
                   @tap="toggleDisease(item.name)">
               <text>{{ item.name }}</text>
@@ -314,7 +314,7 @@
         </view>
         <view class="card" v-if="innerForm.selectedDiseases.length > 0">
           <view class="card-head"><text class="card-title">已选疾病({{ innerForm.selectedDiseases.length }})</text></view>
-          <view v-for="(item, si) in innerForm.selectedDiseases" :key="getSelKey(si)" class="sel-row">
+          <view v-for="(item, si) in innerForm.selectedDiseases" :key="si" class="sel-row">
             <text class="sel-name">{{ item.name }}</text>
             <picker mode="date" fields="month" :value="item.diagnosedAt || currentMonth" :end="monthEnd" @change="onDiagChange(si, $event)">
               <view class="sel-diag">{{ item.diagnosedAt ? item.diagnosedAt : '设确诊时间' }}</view>
@@ -414,7 +414,7 @@
           </view>
           <text class="unit-hint" v-if="innerForm.noMedication">已标记无长期用药,可跳过药物填写</text>
         </view>
-        <view v-if="!innerForm.noMedication" v-for="(row, idx) in innerForm.medRows" :key="getMedKey(idx)" class="card">
+        <view v-if="!innerForm.noMedication" v-for="(row, idx) in innerForm.medRows" :key="idx" class="card">
           <view class="card-head"><text class="card-title">用药 {{ idx + 1 }}</text>
             <text class="card-del" @tap="removeMed(idx)">删除</text>
           </view>
@@ -981,10 +981,6 @@ export default {
       var v = { normal: '4.5', high: '6.2' }[key]
       this.$set(this.innerForm, 'lipidCholesterol', v); this.lipidQuick = key
     },
-    // ===== v-for key 方法(微信小程序 :key 不支持表达式,须用方法调用) =====
-    getDiseaseKey: function(gi, ii) { return 'g' + gi + '-' + ii },
-    getSelKey: function(si) { return 's' + si },
-    getMedKey: function(idx) { return 'm' + idx },
     // ===== 疾病 =====
     findGroupKey: function(name) {
       for (var i = 0; i < DISEASE_GROUPS.length; i++) {

+ 2 - 4
cfc-frontend/pages/health/components/MedicalHistoryStep.vue

@@ -41,7 +41,7 @@
       <!-- 已选疾病 + 确诊时间 -->
       <view v-if="inner.selectedDiseases.length > 0" class="selected-area">
         <view class="selected-title">已选疾病</view>
-        <view v-for="(item, si) in inner.selectedDiseases" :key="getSelKey(si)" class="sel-row">
+        <view v-for="(item, si) in inner.selectedDiseases" :key="si" class="sel-row">
           <text class="sel-name">{{ item.name }}</text>
           <picker mode="date" fields="month" :value="item.diagnosedAt || currentMonth" :end="monthEnd" @change="onDiagChange(si, $event)">
             <view class="sel-diag">{{ item.diagnosedAt ? item.diagnosedAt : '设确诊时间' }}</view>
@@ -57,7 +57,7 @@
         <text class="card-title">在服药物/治疗</text>
         <text class="card-count">{{ inner.medRows.length }} 条</text>
       </view>
-      <view v-for="(med, idx) in inner.medRows" :key="getMedKey(idx)" class="med-row">
+      <view v-for="(med, idx) in inner.medRows" :key="idx" class="med-row">
         <view class="med-line">
           <input class="med-name" type="text" v-model="med.name" placeholder="药物品牌,如 立普妥"
                  @input="emitInput" />
@@ -260,8 +260,6 @@ export default {
       }
       this.diseaseInput = ''
     },
-    getSelKey: function(i) { return 's' + i },
-    getMedKey: function(i) { return 'm' + i },
     removeSelected: function(idx) {
       var list = this.inner.selectedDiseases || []
       var next = list.slice(0, idx).concat(list.slice(idx + 1))

+ 1 - 4
cfc-frontend/pages/health/doa-index.vue

@@ -9,7 +9,7 @@
       </view>
 
       <!-- 家庭成员 DOA 卡片 -->
-      <view v-for="m in members" :key="getMemberKey(m)" class="member-card">
+      <view v-for="m in members" :key="m.memberId" class="member-card">
         <view class="member-header">
           <text class="member-name">{{ m.nickname }}</text>
           <text v-if="m.memberType === 'local'" class="member-tag">未登录成员</text>
@@ -77,9 +77,6 @@ export default {
     }
   },
   methods: {
-    getMemberKey(m) {
-      return m.memberId
-    },
     async loadData() {
       this.loading = true
       try {

+ 1 - 4
cfc-frontend/pages/health/doa-stage-create.vue

@@ -36,7 +36,7 @@
     <!-- 目标列表(1-3条) -->
     <view class="field">
       <text class="field-label">阶段目标(1-3 个,不同领域)</text>
-      <view v-for="(goal, idx) in form.goals" :key="getGoalKey(goal, idx)" class="goal-editor">
+      <view v-for="(goal, idx) in form.goals" :key="idx" class="goal-editor">
         <view class="goal-domain-row">
           <text class="goal-label">目标 {{ idx + 1 }} 领域</text>
           <text class="goal-remove" @click="removeGoal(idx)">✕</text>
@@ -102,9 +102,6 @@ export default {
     this.loadMembers()
   },
   methods: {
-    getGoalKey(goal, idx) {
-      return goal.domain + '_' + idx
-    },
     async loadMembers() {
       try {
         var res = await getFamilyMemberList({ visibleOnly: true })

+ 1 - 4
cfc-frontend/pages/health/doa-stage-detail.vue

@@ -24,7 +24,7 @@
       <!-- 周时间线 -->
       <view class="section">
         <text class="section-title">📅 每周计划与复盘</text>
-        <view v-for="w in stage.weeks" :key="getWeekKey(w)" class="week-card">
+        <view v-for="w in stage.weeks" :key="w.id" class="week-card">
           <view class="week-header" @click="toggleWeek(w.id)">
             <text class="week-no">第 {{ w.weekNo }} 周</text>
             <text class="week-dates">{{ formatDate(w.weekStart) }} ~ {{ formatDate(w.weekEnd) }}</text>
@@ -98,9 +98,6 @@ export default {
     this.loadDetail()
   },
   methods: {
-    getWeekKey(w) {
-      return w.id
-    },
     async loadDetail() {
       this.loading = true
       try {

+ 4 - 7
cfc-frontend/pages/health/indicator-curve.vue

@@ -40,8 +40,8 @@
         <view
           class="rank-tab"
           :class="'rank-' + activeRankTab"
-          v-for="(tab, ti) in rankTabs"
-          :key="getTabKey(tab, ti)"
+          v-for="tab in rankTabs"
+          :key="tab.value"
           @tap="onRankTabTap(tab.value)"
         >{{ tab.label }}</view>
       </view>
@@ -50,12 +50,12 @@
           class="sort-btn"
           :class="sortBy === s.value ? 'sort-active' : ''"
           v-for="s in sortOptions"
-          :key="getSortKey(s)"
+          :key="s.value"
           @tap="onSortTap(s.value)"
         >{{ s.label }}</view>
       </view>
       <view class="rank-list" v-if="rankItems.length > 0">
-        <view class="rank-item" v-for="item in rankItems" :key="getRankKey(item)">
+        <view class="rank-item" v-for="item in rankItems" :key="item.definitionId">
           <view class="rank-name-row">
             <text class="rank-name">{{ item.name }}</text>
             <text class="rank-category">{{ item.category }}</text>
@@ -140,9 +140,6 @@ export default {
     getIndicatorId: function(def) { return def ? def.definitionId : null },
     getIndicatorName: function(def) { return (def && def.name) || '' },
     getIndicatorKey: function(def) { return def ? (def.definitionId || def.name) : '' },
-    getTabKey: function(tab, i) { return tab.value || i },
-    getSortKey: function(s) { return s.value },
-    getRankKey: function(item) { return item.definitionId },
 
     loadMembers: function() {
       var self = this

+ 1 - 4
cfc-frontend/pages/orchestration/editor.vue

@@ -28,7 +28,7 @@
         </view>
 
         <!-- 节点列表 -->
-        <view v-for="(node, index) in nodes" :key="getNodeKey(index)" class="node-item">
+        <view v-for="(node, index) in nodes" :key="index" class="node-item">
           <view class="node-header">
             <view class="node-order">
               <text class="order-num">{{ index + 1 }}</text>
@@ -227,9 +227,6 @@ export default {
         this.templates = []
       }
     },
-    getNodeKey: function(index) {
-      return 'node-' + index
-    },
     getNodeTemplateName(node) {
       if (!node.task_template_ref) return '未选择模板'
       var tpl = this.templates.find(function(t) { return t.id === Number(node.task_template_ref) })

+ 1 - 4
cfc-frontend/pages/orchestration/index.vue

@@ -16,7 +16,7 @@
     <view class="flow-list">
       <view
         v-for="flow in flowList"
-        :key="getKey(flow)"
+        :key="flow.id"
         class="flow-card"
         @click="handleEdit(flow)"
       >
@@ -92,9 +92,6 @@ export default {
         this.loading = false
       }
     },
-    getKey(flow) {
-      return flow.id
-    },
     getStatusText(status) {
       const map = {
         draft: '草稿',

+ 2 - 8
cfc-frontend/pages/profile/service-role-apply.vue

@@ -44,7 +44,7 @@
         <view class="role-grid">
           <view
             v-for="(row, rowIdx) in roleRows"
-            :key="getRoleRowKey(rowIdx)"
+            :key="rowIdx"
             class="role-row"
           >
             <view
@@ -92,7 +92,7 @@
       <view class="section">
         <view class="section-title">资质证书</view>
         <view class="cert-list">
-          <view v-for="(img, idx) in form.certificateImages" :key="getCertKey(idx)" class="cert-item">
+          <view v-for="(img, idx) in form.certificateImages" :key="idx" class="cert-item">
             <image :src="img" mode="aspectFill" class="cert-preview" />
             <text class="cert-del" @click="removeCert(idx)">×</text>
           </view>
@@ -344,12 +344,6 @@ export default {
     removeCert(idx) {
       this.form.certificateImages.splice(idx, 1)
     },
-    getCertKey(idx) {
-      return 'cert-' + idx
-    },
-    getRoleRowKey(rowIdx) {
-      return 'role-row-' + rowIdx
-    },
     openAddressPicker() {
       if (this.$refs.addressPicker) {
         this.$refs.addressPicker.open()

+ 2 - 8
cfc-frontend/pages/reminder-config/index.vue

@@ -16,7 +16,7 @@
       <view class="cfg-card">
         <text class="cfg-card-title">提醒渠道</text>
         <view class="channel-list">
-          <view class="channel-item" v-for="(ch, index) in channels" :key="getChannelKey(ch, index)"
+          <view class="channel-item" v-for="(ch, index) in channels" :key="ch.type"
             :class="{
               'channel-selected': isSelected(ch.type),
               'channel-disabled': !ch.available
@@ -67,7 +67,7 @@
         </view>
         <text class="cfg-card-desc">任务正常完成时,发送表扬鼓励消息</text>
         <view class="channel-list" v-if="completionPraiseEnabled === 1" style="margin-top:20rpx">
-          <view class="channel-item" v-for="(ch, pIndex) in channels" :key="getPraiseKey(pIndex)"
+          <view class="channel-item" v-for="(ch, pIndex) in channels" :key="ch.type"
             :class="{
               'channel-selected': isPraiseSelected(ch.type),
               'channel-disabled': !ch.available
@@ -162,12 +162,6 @@ export default {
     })
   },
   methods: {
-    getChannelKey: function(ch, index) {
-      return ch.type + '_' + index
-    },
-    getPraiseKey: function(pIndex) {
-      return 'p-' + pIndex
-    },
     toggleEnabled: function() {
       this.enabled = this.enabled === 1 ? 0 : 1
     },

+ 2 - 4
cfc-frontend/pages/teacher/review-family.vue

@@ -10,7 +10,7 @@
       <view v-if="plans.length === 0" class="empty">暂无待审核方案</view>
       <view
         v-for="p in plans"
-        :key="getPlanKey(p)"
+        :key="p.id"
         class="card"
         @click="goPlan(p)"
       >
@@ -40,7 +40,7 @@
       <view v-else-if="tasks.length === 0" class="empty">暂无待审核任务</view>
 
       <view v-else>
-        <view v-for="t in tasks" :key="getTaskKey(t)" class="card">
+        <view v-for="t in tasks" :key="t.id" class="card">
           <text class="name">{{ t.title }}</text>
           <text class="meta">截止 {{ formatTime(t.deadline) }}</text>
           <view class="actions">
@@ -158,8 +158,6 @@ export default {
     isMine(p) {
       return !!p.teacherId && String(p.teacherId) === String(this.myUserId)
     },
-    getPlanKey(p) { return 'gp-' + p.id },
-    getTaskKey(t) { return 'gt-' + t.id },
     formatTime(t) {
       if (!t) return '-'
       // 项目统一时间格式:取前19位并把 ISO 的 T 换成空格,避免 toLocaleString 的浏览器差异

+ 1 - 4
cfc-frontend/pages/teacher/review-workbench.vue

@@ -14,7 +14,7 @@
     <view v-else>
       <view
         v-for="f in families"
-        :key="getFamilyKey(f)"
+        :key="f.familyId"
         class="card"
         @click="goFamily(f)"
       >
@@ -62,9 +62,6 @@ export default {
         this.loading = false
       }
     },
-    getFamilyKey(f) {
-      return 'gf-' + f.familyId
-    },
     formatTime(t) {
       if (!t) return '-'
       // 项目统一时间格式:取前19位并把 ISO 的 T 换成空格,避免 toLocaleString 的浏览器差异

+ 152 - 3
cfc-frontend/scripts/audit-mp-antipatterns.js

@@ -11,11 +11,16 @@
  *     5) `transition: all`
  *     6) `v-for` 缺 `:key`(支持跨行)
  *     7) 日期用 `toLocaleString` / `toLocaleDateString` / `toLocaleTimeString` 格式化
+ *     8) `v-for` 的 `:key` 是方法调用,且作用域内事件/v-model 传条目变量
+ *        → uni-app 把 `:key` 表达式当作「找回条目」的属性路径,方法调用会让
+ *        运行时 `find(v => v['getXxx(item)'] === value)` 恒失败,handler 收到
+ *        `undefined`(`Cannot read properties of undefined (reading 'id')`)。
+ *        `:key` 必须是条目真实属性(`item.id`)或循环索引别名(`idx`)。
  *   WARN — 需人工确认
- *     8) `new Date(<非字面量>)`:iOS 解析空格分隔/Java 格式会失败,应改 `parseDate()`
+ *     9) `new Date(<非字面量>)`:iOS 解析空格分隔/Java 格式会失败,应改 `parseDate()`
  *        (`new Date()` 与 `new Date(Date 对象)` 不计入)
- *     9) `:class` / `:style` 内带参方法调用:uni-app 渲染函数下可用,
- *        但 AGENTS.md 列为禁用项,仅提示(WXML 原生表达式不支持)
+ *     10) `:class` / `:style` 内带参方法调用:uni-app 渲染函数下可用,
+ *         但 AGENTS.md 列为禁用项,仅提示(WXML 原生表达式不支持)
  *
  * 用法: node scripts/audit-mp-antipatterns.js [--json] [--error-only]
  * 退出码: 0 无 ERROR / 1 存在 ERROR
@@ -45,6 +50,118 @@ function add(level, kind, file, line, text) {
   findings.push({ level, kind, file, line, text: String(text).trim().slice(0, 140) })
 }
 
+// ---------- 规则 8 辅助:模板标签树解析 ----------
+function escRe(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') }
+
+// 顶层逗号切分(跨越括号/引号的内容视为内部)
+function splitTop(str) {
+  const out = []
+  let depth = 0, cur = '', q = null
+  for (const ch of str) {
+    if (q) { cur += ch; if (ch === q) q = null; continue }
+    if (ch === '"' || ch === "'") { q = ch; cur += ch; continue }
+    if ('([{'.includes(ch)) depth++
+    else if (')]}'.includes(ch)) depth--
+    if (ch === ',' && depth === 0) { out.push(cur.trim()); cur = ''; continue }
+    cur += ch
+  }
+  if (cur.trim()) out.push(cur.trim())
+  return out
+}
+
+function parseAttrs(raw) {
+  const attrs = {}
+  const re = /([:@]?[A-Za-z_][\w.:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g
+  let m
+  while ((m = re.exec(raw))) {
+    const name = m[1]
+    const val = m[2] !== undefined ? m[2] : m[3]
+    if (!(name in attrs)) attrs[name] = val
+  }
+  return attrs
+}
+
+// v-for="(item, idx) in list" 或 v-for="item in list"
+function parseVFor(expr) {
+  if (!expr) return null
+  const m = String(expr).trim().match(/^\s*(?:\(([^)]*)\)|([A-Za-z_$][\w$]*))\s+(?:in|of)\s+/)
+  if (!m) return null
+  const vars = (m[1] != null ? m[1] : m[2]).split(',').map(s => s.trim()).filter(Boolean)
+  if (!vars.length) return null
+  return { item: vars[0], index: vars[1] || null }
+}
+
+// :key 是否为方法调用表达式(含 item.getId() 这类挂在条目上的方法调用)
+function isMethodCallKey(expr) {
+  return /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*\(/.test((expr || '').trim())
+}
+
+// 括号配平且调用括号延伸到末尾时才返回参数字符串,否则 null(保守不判)
+function callInner(expr) {
+  const t = String(expr).trim()
+  const i = t.indexOf('(')
+  if (i < 0) return null
+  let depth = 0
+  for (let k = i; k < t.length; k++) {
+    if (t[k] === '(') depth++
+    else if (t[k] === ')') { depth--; if (depth === 0) return k === t.length - 1 ? t.slice(i + 1, k) : null }
+  }
+  return null
+}
+
+// arg 是否是 alias 的裸引用或成员引用(含括号则编译器会预计算内联,安全)
+function refAlias(arg, aliases) {
+  for (const a of aliases) {
+    if (arg === a) return a
+    if (!arg.includes('(') && new RegExp('^' + escRe(a) + '(?:\\.[A-Za-z_$][\\w$]*|\\[[^\\]]*\\])+$').test(arg)) return a
+  }
+  return null
+}
+
+// 在元素子树内找「事件/v-model 传条目别名」的绑定
+function scanScoped(el, aliases, hits) {
+  for (const child of el.children) {
+    const inner = parseVFor(child.attrs['v-for'])
+    const childAliases = inner ? aliases.concat([inner.item]) : aliases
+    for (const [name, val] of Object.entries(child.attrs)) {
+      if (name === 'v-model') {
+        if (refAlias(val, childAliases)) hits.push({ line: child.line, via: 'v-model="' + val + '"' })
+      } else if (name.charAt(0) === '@' || name.indexOf('v-on:') === 0) {
+        const ia = callInner(val)
+        if (ia !== null && splitTop(ia).some(a => refAlias(a, childAliases))) hits.push({ line: child.line, via: name + '="' + val + '"' })
+      }
+    }
+    scanScoped(child, childAliases, hits)
+  }
+}
+
+// 解析模板为标签树(line 为源文件绝对行号)
+function parseTree(tplBody, tplOffset, src) {
+  const clean = tplBody.replace(/<!--[\s\S]*?-->/g, m => m.replace(/[^\n]/g, ' '))
+  const tagRe = /<(\/)?([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^'">])*)(\/)?>/g
+  const roots = []
+  const stack = []
+  let m
+  while ((m = tagRe.exec(clean))) {
+    const closing = !!m[1]
+    const tag = m[2]
+    const attrsRaw = m[3] || ''
+    const selfClose = !!m[4]
+    const line = src.slice(0, tplOffset + m.index).split('\n').length
+    if (closing) {
+      for (let i = stack.length - 1; i >= 0; i--) {
+        if (stack[i].tag === tag) { stack.length = i; break }
+      }
+      continue
+    }
+    const el = { tag, raw: m[0], attrs: parseAttrs(attrsRaw), children: [], line }
+    const parent = stack[stack.length - 1]
+    if (parent) parent.children.push(el); else roots.push(el)
+    if (!selfClose) stack.push(el)
+  }
+  return roots
+}
+
 for (const abs of collect(ROOT)) {
   const rel = path.relative(ROOT, abs).split(path.sep).join('/')
   if (SKIP_FILES.has(rel)) continue
@@ -92,6 +209,38 @@ for (const abs of collect(ROOT)) {
     add('ERROR', 'v-for 缺 :key', rel, line, body.replace(/\s+/g, ' '))
   }
 
+  // v-for 的 :key 是方法调用 → uni-app 会把该表达式当作「找回条目」的属性路径,
+  // 运行时 find(v => v['getXxx(item)'] === value) 恒失败 → handler 收到 undefined
+  if (tplStart !== -1 && tplEnd !== -1) {
+    const tplOffset = tplStart + tplMatch[0].length
+    const roots = parseTree(src.slice(tplOffset, tplEnd), tplOffset, src)
+    const walk = (els) => {
+      for (const el of els) {
+        const vf = parseVFor(el.attrs['v-for'])
+        const keyExpr = el.attrs[':key'] || el.attrs['v-bind:key']
+        if (vf && keyExpr && isMethodCallKey(keyExpr)) {
+          const hits = []
+          for (const [name, val] of Object.entries(el.attrs)) {
+            if (name === 'v-model') {
+              if (refAlias(val, [vf.item])) hits.push({ line: el.line, via: 'v-model="' + val + '"' })
+            } else if (name.charAt(0) === '@' || name.indexOf('v-on:') === 0) {
+              const ia = callInner(val)
+              if (ia !== null && splitTop(ia).some(a => refAlias(a, [vf.item]))) hits.push({ line: el.line, via: name + '="' + val + '"' })
+            }
+          }
+          scanScoped(el, [vf.item], hits)
+          if (hits.length) {
+            add('ERROR', ':key 方法调用 → 事件参数 undefined', rel, el.line,
+              ':key="' + keyExpr + '"(v-for=' + el.attrs['v-for'] + ');作用域内 ' + hits.length +
+              ' 处事件/v-model 传条目变量 → ' + hits[0].via)
+          }
+        }
+        walk(el.children)
+      }
+    }
+    walk(roots)
+  }
+
   // CSS 选择器含中文(排除注释行)
   for (const m of src.matchAll(/^<style[^>]*>([\s\S]*?)^<\/style>/gm)) {
     const base = src.slice(0, m.index).split('\n').length