import { Component } from '@angular/core';
import { FavoritesService } from '../favorites/favorites.service'; // 替换为实际的路径

@Component({
  selector: 'app-favorites',
  templateUrl: 'favorites.page.html',
  styleUrls: ['favorites.page.scss'],
})
export class FavoritesPage {
  constructor(private favoritesService: FavoritesService) {}

  get favoriteItems() {
    return this.favoritesService.getFavoriteItems();
  }

  removeFromFavorites(item: { title: string; description: string; imageUrl: string; }) {
    this.favoritesService.removeFromFavorites(item);
  }

  addToFavorites() {
    const newItem = {
      title: '新商品',
      description: '这是新商品的描述',
      imageUrl: 'assets/images/new-product.jpg'
    };
    this.favoritesService.addToFavorites(newItem);
  }
}