|
@@ -13,33 +13,19 @@ addIcons({ 'arrow-back-outline': arrowBackOutline });
|
|
standalone: true,
|
|
standalone: true,
|
|
imports: [IonicModule, CommonModule, FormsModule],
|
|
imports: [IonicModule, CommonModule, FormsModule],
|
|
})
|
|
})
|
|
-
|
|
|
|
export class GenerateOptionComponent implements OnInit {
|
|
export class GenerateOptionComponent implements OnInit {
|
|
- gentelIsActive = false;
|
|
|
|
- ladyIsActive = false;
|
|
|
|
- userProfile: {
|
|
|
|
- gender: string;
|
|
|
|
- age: string;
|
|
|
|
- height: string;
|
|
|
|
- weight: string;
|
|
|
|
- season: string;
|
|
|
|
- regStyle: string;
|
|
|
|
- sceFunction: string;
|
|
|
|
- dsgPhilosophy: string;
|
|
|
|
- artStyle: string;
|
|
|
|
- color: string;
|
|
|
|
- } = {
|
|
|
|
- gender: '不限制',
|
|
|
|
- age: '不限制',
|
|
|
|
- height: '不限制',
|
|
|
|
- weight: '不限制',
|
|
|
|
- season: '不限制',
|
|
|
|
- regStyle: '不限制',
|
|
|
|
- sceFunction: '不限制',
|
|
|
|
- dsgPhilosophy: '不限制',
|
|
|
|
- artStyle: '不限制',
|
|
|
|
- color: '不限制',
|
|
|
|
- }
|
|
|
|
|
|
+ userProfile: UserProfile = {
|
|
|
|
+ gender: '不限制',
|
|
|
|
+ age: '不限制',
|
|
|
|
+ height: '不限制',
|
|
|
|
+ weight: '不限制',
|
|
|
|
+ season: '不限制',
|
|
|
|
+ regStyle: '不限制',
|
|
|
|
+ sceFunction: '不限制',
|
|
|
|
+ dsgPhilosophy: '不限制',
|
|
|
|
+ artStyle: '不限制',
|
|
|
|
+ color: '不限制',
|
|
|
|
+ }
|
|
//构造器
|
|
//构造器
|
|
constructor(private router: Router, private navCtrl: NavController) { }
|
|
constructor(private router: Router, private navCtrl: NavController) { }
|
|
//初始化
|
|
//初始化
|
|
@@ -49,39 +35,56 @@ export class GenerateOptionComponent implements OnInit {
|
|
goBack() {
|
|
goBack() {
|
|
this.navCtrl.back();
|
|
this.navCtrl.back();
|
|
}
|
|
}
|
|
-
|
|
|
|
- toggleGentelActive() {
|
|
|
|
- this.gentelIsActive = !this.gentelIsActive;
|
|
|
|
- this.ladyIsActive = false;
|
|
|
|
- }
|
|
|
|
- toggleLadyActive() {
|
|
|
|
- this.ladyIsActive = !this.ladyIsActive;
|
|
|
|
- this.gentelIsActive = false;
|
|
|
|
|
|
+ //性别选项卡定义变量,第一位为男,第二位为女
|
|
|
|
+ gender: { [key: string]: boolean } = {
|
|
|
|
+ '男': false,
|
|
|
|
+ '女': false
|
|
|
|
+ };
|
|
|
|
+ //年龄选项卡定义变量
|
|
|
|
+ age: { [key: string]: boolean } = {
|
|
|
|
+ '20岁以下': false,
|
|
|
|
+ '20-30岁': false,
|
|
|
|
+ '30-40岁': false,
|
|
|
|
+ '40岁以上': false
|
|
|
|
+ };
|
|
|
|
+ //身高选项卡定义变量
|
|
|
|
+ height: { [key: string]: boolean } = {
|
|
|
|
+ '160cm以下': false,
|
|
|
|
+ '160-170cm': false,
|
|
|
|
+ '170-180cm': false,
|
|
|
|
+ '180-190cm': false,
|
|
|
|
+ '190cm以上': false
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * @切换选项卡
|
|
|
|
+ * 1.将其他选项卡设置为false
|
|
|
|
+ * 2.将当前选项卡设置为true
|
|
|
|
+ * 3.将true对应的键赋值给userProfile中对应的属性
|
|
|
|
+ */
|
|
|
|
+ toggleActive(option: { [key: string]: boolean }, index: number,name: string) {
|
|
|
|
+ for (const optkey in option) {
|
|
|
|
+ option[optkey] = false;
|
|
|
|
+ }
|
|
|
|
+ const keys = Object.keys(option); // 获取 option 对象中的所有键
|
|
|
|
+ const selectedKey = keys[index]; // 根据索引找到选中的键
|
|
|
|
+ // 将选中的键对应的值设置为 true
|
|
|
|
+ option[selectedKey] = true;
|
|
|
|
+ // 更新 userProfile 中的对应字段
|
|
|
|
+ this.userProfile[name as keyof UserProfile] = selectedKey;
|
|
|
|
+ console.log(this.userProfile);
|
|
}
|
|
}
|
|
- getImageSrc(isActive: boolean, gender: string): string {
|
|
|
|
- return isActive ? '/assets/generate-option-style/' + gender + '-isActive-true.png' : '/assets/generate-option-style/' + gender + '-isActive-false.png';
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取图片路径
|
|
|
|
+ */
|
|
|
|
+ getImageSrc(option: { [key: string]: boolean }, index: number, String: string): string {
|
|
|
|
+ const keys = Object.keys(option); // 获取 option 对象中的所有键
|
|
|
|
+ const selectedKey = keys[index]; // 根据索引找到选中的键
|
|
|
|
+ const isActive = option[selectedKey];
|
|
|
|
+ return isActive ? '/assets/generate-option-style/' + String + '-isActive-true.png' : '/assets/generate-option-style/' + String + '-isActive-false.png';
|
|
}
|
|
}
|
|
|
|
+
|
|
//选项卡结构配置数据
|
|
//选项卡结构配置数据
|
|
cards = [
|
|
cards = [
|
|
- {
|
|
|
|
- id: '年龄',
|
|
|
|
- chips: [
|
|
|
|
- { id: 1, isElected: false, label: '20岁以下' },
|
|
|
|
- { id: 2, isElected: false, label: '20-30岁' },
|
|
|
|
- { id: 3, isElected: false, label: '30-40岁' },
|
|
|
|
- { id: 4, isElected: false, label: '40岁以上' },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: '身高',
|
|
|
|
- chips: [
|
|
|
|
- { id: 1, isElected: false, label: '160以下' },
|
|
|
|
- { id: 2, isElected: false, label: '160-170cm' },
|
|
|
|
- { id: 3, isElected: false, label: '170-180cm' },
|
|
|
|
- { id: 4, isElected: false, label: '180-190cm' },
|
|
|
|
- { id: 5, isElected: false, label: '190以上' },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
{
|
|
{
|
|
id: '体重',
|
|
id: '体重',
|
|
chips: [
|
|
chips: [
|
|
@@ -173,7 +176,7 @@ export class GenerateOptionComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//补充说明
|
|
//补充说明
|
|
- suppleInput: string = '';
|
|
|
|
|
|
+ styleDesc: string = '';
|
|
//用户提示词
|
|
//用户提示词
|
|
userPrompt: string = '';
|
|
userPrompt: string = '';
|
|
|
|
|
|
@@ -186,12 +189,6 @@ export class GenerateOptionComponent implements OnInit {
|
|
});
|
|
});
|
|
|
|
|
|
switch (card.id) {
|
|
switch (card.id) {
|
|
- case '年龄':
|
|
|
|
- this.userProfile.age = card.chips[chipId - 1].label;
|
|
|
|
- break;
|
|
|
|
- case '身高':
|
|
|
|
- this.userProfile.height = card.chips[chipId - 1].label;
|
|
|
|
- break;
|
|
|
|
case '体重':
|
|
case '体重':
|
|
this.userProfile.weight = card.chips[chipId - 1].label;
|
|
this.userProfile.weight = card.chips[chipId - 1].label;
|
|
break;
|
|
break;
|
|
@@ -250,7 +247,7 @@ export class GenerateOptionComponent implements OnInit {
|
|
"设计理念:" + this.userProfile.dsgPhilosophy + "\n" +
|
|
"设计理念:" + this.userProfile.dsgPhilosophy + "\n" +
|
|
"艺术风格:" + this.userProfile.artStyle + "\n" +
|
|
"艺术风格:" + this.userProfile.artStyle + "\n" +
|
|
"色彩搭配:" + this.userProfile.color + "\n" +
|
|
"色彩搭配:" + this.userProfile.color + "\n" +
|
|
- "补充说明:" + this.suppleInput + "\n";
|
|
|
|
|
|
+ "补充说明:" + this.styleDesc + "\n";
|
|
console.log(this.userPrompt)
|
|
console.log(this.userPrompt)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -265,7 +262,19 @@ export class GenerateOptionComponent implements OnInit {
|
|
}
|
|
}
|
|
sendMsgAndGoGenerateResult() {
|
|
sendMsgAndGoGenerateResult() {
|
|
this.sendMsg();
|
|
this.sendMsg();
|
|
- this.goChatPanel();
|
|
|
|
|
|
+ //this.goChatPanel();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type UserProfile = {
|
|
|
|
+ gender: string;
|
|
|
|
+ age: string;
|
|
|
|
+ height: string;
|
|
|
|
+ weight: string;
|
|
|
|
+ season: string;
|
|
|
|
+ regStyle: string;
|
|
|
|
+ sceFunction: string;
|
|
|
|
+ dsgPhilosophy: string;
|
|
|
|
+ artStyle: string;
|
|
|
|
+ color: string;
|
|
|
|
+};
|