import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-page-mine',
  templateUrl: 'page-mine.component.html',
  styleUrls: ['page-mine.component.scss']
})
export class PageMineComponent {
  activeTab: string = 'history';
  userName: string = '姓名未填写';
  userGender: string = '性别未填写';
  userAddress: string = '所在省份未填写';

  history: string[] = ['暂无', '暂无', '暂无'];
  favorites: string[] = ['暂无', '暂无', '暂无'];
  following: string[] = ['暂无', '暂无', '暂无'];
 
  newUserName: string = '';
  newUserGender: string = '';
  newUserAddress: string = '';

  showEditProfileModal: boolean = false;
  profileFormSubmitted: boolean = false;


  cities: string[] = [
    '北京','安徽',
    '上海','澳门',
    '广西','重庆',
    '深圳','福建',
    '甘肃','广东',
    '贵州','海南',
    '河北','河南',
    '黑龙江','湖北',
    '湖南','吉林',
    '江苏','江西',
    '辽宁','内蒙古',
    '宁夏','青海',
    '山东','山西',
    '陕西','四川',
    '台湾','天津',
    '西藏','香港',
    '新疆','云南',
    '浙江',
    
  ];


  constructor(private router: Router) {}

  login() {
    // 跳转到登录页面
    this.router.navigate(['/login']);
  }


  changeTab(tab: string) {
    this.activeTab = tab;
  }

  logout() {
    // 注销逻辑
  }

 


  saveProfile() {
    this.profileFormSubmitted = true;

    if (this.newUserName && this.newUserGender && this.newUserAddress) {
      this.userName = this.newUserName;
      this.userGender = this.newUserGender;
      this.userAddress = this.newUserAddress;
      this.cancelEditProfile();
    }
  }

  editProfile() {
    this.showEditProfileModal = true;
    this.profileFormSubmitted = false;
  }

  cancelEditProfile() {
    this.showEditProfileModal = false;
    this.newUserName = '';
    this.newUserGender = '';
    this.newUserAddress = '';
    this.profileFormSubmitted = false;
  }


}
