|
@@ -1,15 +1,79 @@
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
+import { IonicModule } from '@ionic/angular';
|
|
|
+import { addIcons } from 'ionicons';
|
|
|
+import { pause } from 'ionicons/icons';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-generate-option',
|
|
|
templateUrl: './generate-option.component.html',
|
|
|
styleUrls: ['./generate-option.component.scss'],
|
|
|
standalone: true,
|
|
|
+ imports: [ IonicModule,CommonModule ],
|
|
|
})
|
|
|
export class GenerateOptionComponent implements OnInit {
|
|
|
|
|
|
+ cards = [
|
|
|
+ {
|
|
|
+ id: 'gender',
|
|
|
+ chips: [
|
|
|
+ { id: 1, isElected: false ,label:'男'},
|
|
|
+ { id: 2, isElected: false ,label:'女'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'season',
|
|
|
+ chips: [
|
|
|
+ { id: 1, isElected: false ,label:'春季'},
|
|
|
+ { id: 2, isElected: false ,label:'夏季'},
|
|
|
+ { id: 3, isElected: false ,label:'秋季'},
|
|
|
+ { id: 4, isElected: false ,label:'冬季'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
constructor() { }
|
|
|
|
|
|
- ngOnInit() {}
|
|
|
+ ngOnInit() {
|
|
|
+ addIcons({pause})
|
|
|
+ }
|
|
|
+
|
|
|
+ toggleChip(cardId: string, chipId: number):void {
|
|
|
+ this.cards.forEach((card) => {
|
|
|
+ if (card.id === cardId) {
|
|
|
+ card.chips.forEach((chip) => {
|
|
|
+ chip.isElected = chip.id === chipId; // 当前点击的 chip 设为 active,其他设为 false
|
|
|
+
|
|
|
+ });
|
|
|
+ switch (cardId) {
|
|
|
+ case 'gender':
|
|
|
+ this.setGender(card.chips[chipId-1].label)
|
|
|
+ break;
|
|
|
+ case 'season':
|
|
|
+ this.setSeason(card.chips[chipId-1].label)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //性别
|
|
|
+ gender: string='';
|
|
|
+ setGender(gender: string){
|
|
|
+ this.gender = gender;
|
|
|
+ }
|
|
|
+ //季节
|
|
|
+ season: string='';
|
|
|
+ setSeason(season: string){
|
|
|
+ this.season = season;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ //生成结果
|
|
|
+ generateResult(){
|
|
|
+ console.log(this.gender)
|
|
|
+ console.log(this.season)
|
|
|
+ console.log("开始生成!")
|
|
|
+ }
|
|
|
}
|