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

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

    data: any = {};
    id: number;
    FILE_URL = environment.imageUrl;

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

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

    // 查询详情
    public getDetails(id: number) {
        this.merchant.getMerchantById(id, data => {
            this.data = data['return_data'];
        });
    }

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

}
