|
|
@@ -27,7 +27,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">过敏原 *</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetAllergies" :key="getChipKey('a', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetAllergies" :key="i"
|
|
|
:class="{ 'chip-active': allergies.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('allergies', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -46,7 +46,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">绝对忌口 *</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetAvoid" :key="getChipKey('v', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetAvoid" :key="i"
|
|
|
:class="{ 'chip-active': absoluteAvoid.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('absoluteAvoid', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -65,7 +65,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">宗教饮食</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(opt, i) in religiousOptions" :key="getChipKey('r', i)"
|
|
|
+ <view class="chip" v-for="(opt, i) in religiousOptions" :key="i"
|
|
|
:class="{ 'chip-active': religiousDiet === opt.value }"
|
|
|
@tap="religiousDiet = opt.value">
|
|
|
<text>{{ opt.label }}</text>
|
|
|
@@ -100,7 +100,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">口味偏好</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetFlavor" :key="getChipKey('f', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetFlavor" :key="i"
|
|
|
:class="{ 'chip-active': flavorPref.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('flavorPref', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -120,7 +120,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">菜系偏好</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetCuisine" :key="getChipKey('c', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetCuisine" :key="i"
|
|
|
:class="{ 'chip-active': cuisinePref.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('cuisinePref', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -140,7 +140,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">烹饪方式</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetCooking" :key="getChipKey('k', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetCooking" :key="i"
|
|
|
:class="{ 'chip-active': cookingMethods.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('cookingMethods', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -171,7 +171,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">必吃食物</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetMustEat" :key="getChipKey('m', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetMustEat" :key="i"
|
|
|
:class="{ 'chip-active': mustEat.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('mustEat', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -190,7 +190,7 @@
|
|
|
<view class="card">
|
|
|
<text class="card-title">健康目标</text>
|
|
|
<view class="chip-group">
|
|
|
- <view class="chip" v-for="(item, i) in presetGoals" :key="getChipKey('g', i)"
|
|
|
+ <view class="chip" v-for="(item, i) in presetGoals" :key="i"
|
|
|
:class="{ 'chip-active': healthGoals.indexOf(item) >= 0 }"
|
|
|
@tap="toggleChip('healthGoals', item)">
|
|
|
<text>{{ item }}</text>
|
|
|
@@ -304,9 +304,6 @@ 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) {
|