import { Component, OnInit } from '@angular/core';
import {AjaxService} from '../../../../core/ajax/ajax.service';
import {FramePageComponent} from '../../../frame/core/FramePageComponent';
import {BsModalService} from 'ngx-bootstrap';
import {CookieService} from 'ngx-cookie-service';
import {Router} from '@angular/router';
import {WeixinTagDetailComponent} from '../weixin-tag-detail/weixin-tag-detail.component';

@Component({
  selector: 'app-weixin-tag-page',
  templateUrl: './weixin-tag-page.component.html',
  styleUrls: ['./weixin-tag-page.component.scss']
})
export class WeixinTagPageComponent extends FramePageComponent implements OnInit {

  wxDefine: any;
  constructor(private router: Router, private cookies: CookieService,  modalService: BsModalService) {
    super(modalService);
    // 获取缓存中的微信编号
    const wx_id = this.cookies.get('CurrentWxId');
    if (wx_id !== undefined && wx_id.length > 0 ) {
      // 去获取
      AjaxService.requestEntity('weixin/define/find.htm', {wx_id: wx_id}, (entity) => {
        this.wxDefine = entity;
        setTimeout( () => {
          if (this.pager) {
            this.pager.reload({wx_id: this.wxDefine.wx_id});
          }
        }, 1);
      });
    } else {
      this.router.navigate(['/weixin/define/page']) ;
    }
    this.modalComponent = WeixinTagDetailComponent;
  }
  ngOnInit() {
  }

}
