|
@@ -31,7 +31,7 @@
|
|
|
<view class="preference-children">
|
|
<view class="preference-children">
|
|
|
<view v-for="(child, cIndex) in parent.childrenList" :key="cIndex" class="preference-tag"
|
|
<view v-for="(child, cIndex) in parent.childrenList" :key="cIndex" class="preference-tag"
|
|
|
:class="{ active: selectedPreferences.includes(child.postSkillName) }"
|
|
:class="{ active: selectedPreferences.includes(child.postSkillName) }"
|
|
|
- @click="togglePreference(child.postSkillName)">
|
|
|
|
|
|
|
+ @click="togglePreference(pIndex,child.postSkillName)">
|
|
|
<text>{{ child.postSkillName }}</text>
|
|
<text>{{ child.postSkillName }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -91,15 +91,36 @@ export default {
|
|
|
goBack() {
|
|
goBack() {
|
|
|
uni.navigateBack()
|
|
uni.navigateBack()
|
|
|
},
|
|
},
|
|
|
- togglePreference(name) {
|
|
|
|
|
|
|
+ // togglePreference(name) {
|
|
|
|
|
+ // const index = this.selectedPreferences.indexOf(name);
|
|
|
|
|
+ // const realLength = this.selectedPreferences.filter(item => item !== '不限').length;
|
|
|
|
|
+ // if (index === -1) {
|
|
|
|
|
+ // if (realLength >= 5) {
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // title: '最多选择5个偏好!',
|
|
|
|
|
+ // icon: 'none'
|
|
|
|
|
+ // })
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.selectedPreferences.push(name);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.selectedPreferences.splice(index, 1);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+ togglePreference(pIndex, name) {
|
|
|
|
|
+ const parent = this.preferenceOptions[pIndex];
|
|
|
|
|
+ // 当前分类下已选中的标签(排除不限)
|
|
|
|
|
+ const selectedInGroup = parent.childrenList
|
|
|
|
|
+ .filter(item => item.postSkillName !== '不限' && this.selectedPreferences.includes(item.postSkillName));
|
|
|
|
|
+
|
|
|
const index = this.selectedPreferences.indexOf(name);
|
|
const index = this.selectedPreferences.indexOf(name);
|
|
|
- const realLength = this.selectedPreferences.filter(item => item !== '不限').length;
|
|
|
|
|
|
|
+
|
|
|
if (index === -1) {
|
|
if (index === -1) {
|
|
|
- if (realLength >= 5) {
|
|
|
|
|
|
|
+ if (selectedInGroup.length >= 5) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '最多选择5个偏好!',
|
|
|
|
|
|
|
+ title: '每个分类最多选择5个偏好!',
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.selectedPreferences.push(name);
|
|
this.selectedPreferences.push(name);
|