import { Component, OnInit, ViewChild } from '@angular/core';
import { CommonModule, DatePipe } from '@angular/common';
import { ionicStandaloneModules } from '../../../ionic-standalone.modules';
import { NavComponent } from '../../../../app/components/nav/nav.component';
import * as Parse from 'parse';
import { ActivatedRoute } from '@angular/router';
import { SharedModule } from '../../../shared.module';
import { ImagePreviewComponent } from '../../../../app/components/image-preview/image-preview.component';
@Component({
  selector: 'app-detail',
  templateUrl: './detail.component.html',
  styleUrls: ['./detail.component.scss'],
  standalone: true,
  imports: [
    ...ionicStandaloneModules,
    NavComponent,
    ImagePreviewComponent,
    CommonModule,
    SharedModule,
  ],
  providers: [DatePipe],
})
export class RecDetailComponent implements OnInit {
  withdrawLog?: Parse.Object;
  @ViewChild('preview') preview!: ImagePreviewComponent;
  currentImg:string = ''
  getType(s: string): { title: string; color: string } {
    let obj: any = {
      '100': {
        title: '申请中',
        color: '#ffca22',
      },
      '200': {
        title: '已提现',
        color: '#42d96b',
      },
      '300': {
        title: '驳回',
        color: '#cb1a27',
      },
    };
    return obj[s];
  }
  constructor(private activateRoute: ActivatedRoute) {}

  ngOnInit() {
    this.activateRoute.paramMap.subscribe(async (params) => {
      let id: any = params.get('id');
      let query = new Parse.Query('UserAgentWithdraw');
      query.get(id).then((res) => {
        this.withdrawLog = res;
      });
    });
  }
  onShowImg(url: string) {
    this.currentImg = url;
    this.preview.show = 'inline-flex';
  }
}
