/*
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2022-03-14 14:17:38
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-03-25 13:52:54
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\passport\\components\\order-agreement\\order-agreement.component.ts
 * Copyright (C) 2022 huzhenhong. All rights reserved.
 */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { PassportService } from '../../services/passport.service';

@Component({
  selector: 'app-buyer-components-serve-order-agreement',
  templateUrl: './order-agreement.component.html',
  styleUrls: ['./order-agreement.component.less']
})
export class OrderAgreementComponent implements OnInit {
  agreementContent: any;
  type = 2;
  data : any;
  constructor(private ar: ActivatedRoute, private service: PassportService) {
    ar.queryParams.subscribe((params: Params) => {
      console.log(params);
      
      this.type = params?.type || 2;
      this.data = JSON.parse(params?.data) || {};
    });
  }
  ngOnInit() {
    console.log(this.type);
    if(this.type == 3) {
      console.log(this.data);
      
      this.service.request(this.service.$api_get_getSupplementaryAgreement, { billId: this.data?.billId, billCode: this.data?.billCode }).subscribe(res => {
        if (res) {
          this.agreementContent = res;
        }
      });
    } else {
      this.service.request(this.service.$api_get_agreement, { type: this.type }).subscribe(res => {
        if (res) {
          this.agreementContent = res;
        }
      });
    }
  }
}
