import {Component, OnInit} from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {MerchantStoreService} from '../../../services/merchant-store.service';

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

    data: any = {};
    id: number;

    constructor(
        private merchantStore: MerchantStoreService,
        private message: NzMessageService, // 信息提示
        private activatedRoute: ActivatedRoute,
    ) {
    }

    ngOnInit(): void {
        this.activatedRoute.queryParams.subscribe(queryParams => {
            if (queryParams.storeId != null) {
                this.id = queryParams.storeId;
                this.getDetails(queryParams.storeId);
            }
        });
    }

    // 查询详情
    public getDetails(id: number) {
        this.merchantStore.getMerchantStoreById(id, data => {
            console.log(data);
            this.data = data['return_data'];

        });
    }

    // 返回
    getBack() {
        history.back();
    }


}
