import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { AppEnvironment } from 'src/environments/AppEnvironment';

@Component({
  selector: 'app-storestyle-list',
  templateUrl: './app-storestyle-list.component.html',
  styleUrls: ['./app-storestyle-list.component.scss'],
})
export class AppStorestyleList implements OnInit {


  @Input() title: String;
  /**
  * 基础路径
  */
  url: String = AppEnvironment.BaseUrl + AppEnvironment.ExportFile + '/';


  public _items: Array<any> = [];

  /**
   * 输入数组
   */
  @Input() set items(val: any) {
    if (val) {
      this._items = JSON.parse(JSON.stringify(val));
      if (this._items.length > 0) {
        this._items.forEach((item: any) => {
          if (item && item.image) {
            item.image = JSON.parse(item.image);
          }
        })
      }
    }
  }

  /**
* 抛出数据
*/
  @Output() itemClick: EventEmitter<any> = new EventEmitter<any>();

  constructor() { }

  ngOnInit() { }

  handleClick(item: any) {
    this.itemClick.emit(item);
  }
}
