import { FileUtil } from "@pura/harmony-utils"
import { StringUtils } from "../../util/StringUtils"


export class ApplicationTypeModel{
    "推荐应用":Array<ApplicationModel>
    "最新应用":Array<ApplicationModel>
}

export class ApplicationModel{
  baseType:number = 1

  name:string = ""
  id:string = ""
  //应用等级  3 = 原生应用       其他  H5应用
  level:number=1
  link:string = ""
  //应用所在区类  1 = II类区    2 == III类区
  type:number = 1

  clientId:string = ""
  clientSecret:string = ""
  //图片地址
  icon:string = ""

  locationIcon:Resource=$r('app.media.icon_gd2')

  //应用分类  情指应用    经侦、刑侦等
  classification:string = ""
  //应用厂商
  serviceProvider:string = ""

  packageName?:string
  //运维人员
  operationPerson:string = ""
  phoneNumber?:string
  //应用上架时间
  applicationTime:string = ""
}


@Observed
export class AppDataModel{
  baseType:number = 1

  id:string = ""
  isSelect:boolean = false

  name:string = ""
  //图片地址
  icon:string = ""
  link:string = ""
  packageName?:string
  effectiveness:number = 0

  //应用等级  3 = 原生应用       其他  H5应用
  level:number=1
  //应用所在区类  1 = II类区    2 == III类区
  type:number = 1

  cityNumber:string = ""
  //应用厂商
  serviceProvider:string = ""
  //运维人员
  operationPerson:string = ""
  //运维人员联系电话
  phoneNumber:string = ""

  clientId:string = ""
  clientSecret:string = ""
  state:string = ""
  //备注
  remark:string = ""
  //操作指南
  operationGuide:string = ""
  isRecommend:number = 0
  label:string = ""
  attribution:number  = 0
  locationIcon:Resource=$r('app.media.icon_gd2')
}

export class AppGuideDetailsBean{
  baseType:number = 1

  id:string = ""
  applicationId:string = ""
  applicationName:string = ""
  filePath:string = ""
  type:number = 0
  remark:string = ""

  getName():string{
    if(StringUtils.isNullOrEmpty(this.filePath))return ""
    let index = this.filePath.lastIndexOf('/');
    return this.filePath.substring(index+1)
  }

  getFileIcon(filePath: string): Resource {
    let i = filePath.lastIndexOf("/");
    let substring = filePath.substring(i + 1);
    let flExt = FileUtil.getFileExtention(substring)
    if (StringUtils.containsChar("doc,docx", flExt)) {
      return $r('app.media.fileselect_img_doc')
    }
    if (StringUtils.containsChar("xls,xlsx", flExt)) {
      return $r('app.media.fileselect_img_xls')
    }
    if (StringUtils.containsChar("rar,zip,7Z", flExt)) {
      return $r('app.media.fileselect_img_zip')
    }
    if (flExt.endsWith("ppt")) {
      return $r('app.media.fileselect_img_ppt')
    }
    if (flExt.endsWith("pfd")) {
      return $r('app.media.fileselect_img_pfd')
    }
    if (flExt.endsWith("txt")) {
      return $r('app.media.fileselect_img_txt')
    }
    return $r('app.media.fileselect_img_unknown')
  }
}
