import { Injectable, Injector } from '@angular/core';
import { BaseService, EACacheService, ShipperBaseService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
import { ImageViewComponent } from 'src/app/shared/components/imagelist';
import { ChannelLogModalComponent } from '../components/channel-log-modal/channel-log-modal.component';

@Injectable()
export class PartnerListService extends ShipperBaseService {
  $mock_url = '/rule?_allow_anonymous=true';

  // 查询合伙人信息-分页
  $api_get_partner_page = '/api/mdc/partner/list/page';
  // 新增/更新保存企业合伙人信息
  $api_save_entp_partner = '/api/mdc/partner/saveEnterprise';
  // 新增/更新个人合伙人信息
  $api_save_personal_partner = '/api/mdc/partner/savePersonally';
  // 获取企业合伙人信息
  $api_get_ent_partner_detail = '/api/mdc/partner/getEnterprise';
  // 获取合伙人信息
  $api_get_personal_partner_detail = '/api/mdc/partner/getPersonally';
  // 审核合伙人
  $api_audit_partner = '/api/mdc/partner/audit';
  // 修改返佣模板
  $api_update_partner_template = '/api/mdc/partner/updateTemplate';
  // 更新渠道销售
  $api_update_partner_channel = '/api/mdc/partner/updateChannelSale';
  // 更新渠道销售
  $api_update_partner_channel_by_id = '/api/mdc/partner/updateChannelSaleByID';
  // 重新发起CRM
  $api_resend_crm = '/api/mdc/partner/reSendCrm';
  // 查询合伙人修改渠道渠道销售记录
  $api_get_personal_channel_list = '/api/mdc/partnerChannelRelLog/list/page';
  // 查询客户关系列表-不分页
  $api_get_enterprice_rel_list = '/api/mdc/enterpriseRelLog/list';
  // 校验合伙人是否可修改渠道销售 true:可以修改 false：不可以修改
  $api_check_partenr_change_channel = '/api/mdc/partner/updateChannelCheck';
  // 根据手机号查询实名信息
  $api_get_identityInfo_by_mobile = '/api/mdc/cuc/identityInfo/getByMobile';
  // 渠道销售修改详情
  $api_get_partner_change_list = '/api/mdc/partnerChannelRelLog/partnerChannelUpdateDetaiList';
  // 冻结/启用企业业
  $api_lock_freight = '/api/mdc/cuc/userApp/freezeOrResume';

  // 根据地区code查询列表
  $api_get_region_by_code = '/api/mdc/pbc/region/getRegionByCode';
  // 根据地区code查询地区详情
  $api_get_region_detail_by_code = '/api/mdc/pbc/region/getRegionDetailByCode';
  // 营业执照识别
  $api_ocr_recognize_business_license = '/api/mdc/pbc/hwc/ocr/recognizeBusinessLicense';
  // 身份证识别
  $api_ocr_recognize_id_card = '/api/mdc/pbc/hwc/ocr/recognizeIdCard';

  constructor(public injector: Injector, private nzModalService: NzModalService) {
    super(injector);
  }

  showImg(url: any) {
    const params = {
      imgList: [url],
      index: 0
    };
    this.nzModalService.create({ nzContent: ImageViewComponent, nzComponentParams: { params } });
  }

  showChangeDetail(id: string) {
    const modal = this.nzModalService.create({
      nzTitle: '详情',
      nzContent: ChannelLogModalComponent,
      nzComponentParams: { id },
      nzNoAnimation: true,
      nzWidth: 800,
      nzFooter: null
    });
  }
}
