|
|
@@ -121,6 +121,9 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// ——— chip 选中态(模板用内联 indexOf,方法供 toggle 用) ———
|
|
|
+ getChipKey: function(prefix, index) {
|
|
|
+ return prefix + '-' + index
|
|
|
+ },
|
|
|
toggleChip: function(field, value) {
|
|
|
var idx = this[field].indexOf(value)
|
|
|
if (idx >= 0) {
|
|
|
@@ -230,7 +233,7 @@ export default {
|
|
|
<view class="card">
|
|
|
<text class="card-title">过敏原 *</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetAllergies" :key="'a' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetAllergies" :key="getChipKey('a', i)"
|
|
|
:class="{ 'chip-active': allergies.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('allergies', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -249,7 +252,7 @@ export default {
|
|
|
<view class="card">
|
|
|
<text class="card-title">绝对忌口 *</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetAvoid" :key="'v' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetAvoid" :key="getChipKey('v', i)"
|
|
|
:class="{ 'chip-active': absoluteAvoid.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('absoluteAvoid', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -268,7 +271,7 @@ export default {
|
|
|
<view class="card">
|
|
|
<text class="card-title">宗教饮食</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(opt, i) in religiousOptions" :key="'r' + i"
|
|
|
+ <view class="chip" v-for="(opt, i) in religiousOptions" :key="getChipKey('r', i)"
|
|
|
:class="{ 'chip-active': religiousDiet === opt.value }"
|
|
|
@tap="religiousDiet = opt.value">
|
|
|
<text>{{ opt.label }}</text>
|
|
|
@@ -339,7 +342,7 @@ git commit -m "feat(diet): 饮食偏好调研 重构为3步引导问卷 - 数据
|
|
|
<view class="card">
|
|
|
<text class="card-title">口味偏好</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetFlavor" :key="'f' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetFlavor" :key="getChipKey('f', i)"
|
|
|
:class="{ 'chip-active': flavorPref.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('flavorPref', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -359,7 +362,7 @@ git commit -m "feat(diet): 饮食偏好调研 重构为3步引导问卷 - 数据
|
|
|
<view class="card">
|
|
|
<text class="card-title">菜系偏好</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetCuisine" :key="'c' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetCuisine" :key="getChipKey('c', i)"
|
|
|
:class="{ 'chip-active': cuisinePref.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('cuisinePref', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -379,7 +382,7 @@ git commit -m "feat(diet): 饮食偏好调研 重构为3步引导问卷 - 数据
|
|
|
<view class="card">
|
|
|
<text class="card-title">烹饪方式</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetCooking" :key="'k' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetCooking" :key="getChipKey('k', i)"
|
|
|
:class="{ 'chip-active': cookingMethods.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('cookingMethods', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -416,7 +419,7 @@ git commit -m "feat(diet): 饮食偏好调研 重构为3步引导问卷 - 数据
|
|
|
<view class="card">
|
|
|
<text class="card-title">必吃食物</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetMustEat" :key="'m' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetMustEat" :key="getChipKey('m', i)"
|
|
|
:class="{ 'chip-active': mustEat.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('mustEat', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -435,7 +438,7 @@ git commit -m "feat(diet): 饮食偏好调研 重构为3步引导问卷 - 数据
|
|
|
<view class="card">
|
|
|
<text class="card-title">健康目标</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetGoals" :key="'g' + i"
|
|
|
+ <view class="chip" v-for="(item, i) in presetGoals" :key="getChipKey('g', i)"
|
|
|
:class="{ 'chip-active': healthGoals.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('healthGoals', item)">
|
|
|
<text>{{ item }}</text>
|