index.ets 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { LoginCollect } from './LoginCollect'
  2. import { display } from '@kit.ArkUI'
  3. export interface BasicType<T = undefined> {
  4. src?: ResourceStr,
  5. acSrc?: ResourceStr,
  6. text?: string,
  7. message?: string,
  8. color?: ResourceColor,
  9. click?: () => void,
  10. number?: number,
  11. generics?: T,
  12. date?: string,
  13. index?: number,
  14. loginType?: LoginCollect
  15. finally?: () => void
  16. }
  17. export type ReqString = Record<string, string>
  18. export interface AvoidType {
  19. top?: number,
  20. bottom?: number
  21. }
  22. export interface MessageType {
  23. text: string,
  24. header: ResourceStr,
  25. role: Role,
  26. id?: number
  27. }
  28. export enum Role {
  29. USER,
  30. OTHER,
  31. CARD
  32. }
  33. export interface DelPhotoParam {
  34. src: string,
  35. type: 'bill' | 'header' | 'image'
  36. }
  37. /**
  38. * @description 结果回调函数的类型别名
  39. * @param res 结果输出
  40. * @param err 错误输出
  41. */
  42. export type ResultCallBack<T> = (res?: T, err?: Error) => void
  43. /**
  44. * @description 断点字符串类型
  45. */
  46. export type BreakPointString = 'xs' | 'sm' | 'md' | 'lg'
  47. @ObservedV2
  48. export class Card {
  49. param: Resource;
  50. id: number
  51. @Trace isSubmit: boolean = false
  52. @Trace offsetX: number = 0
  53. @Trace offsetY: number = 0
  54. @Trace zIndex: number = 0
  55. @Trace size: number = 0
  56. @Trace opacity: number = 0
  57. constructor(img: Resource, id: number, uiContext: UIContext) {
  58. this.param = img
  59. this.id = id
  60. let displayClass: display.Display = display.getDefaultDisplaySync();
  61. let windowWidth = uiContext.px2vp(displayClass.width)
  62. let midCardOffsetX = 25
  63. let rightCardOffsetX = windowWidth - 32 - (windowWidth * 0.7833 * 0.83)
  64. if (id === 0) {
  65. this.offsetX = 0
  66. this.size = 0.83
  67. this.zIndex = 1
  68. this.opacity = 1
  69. } else if (id === 1) {
  70. this.offsetX = midCardOffsetX
  71. this.size = 1
  72. this.zIndex = 2
  73. this.opacity = 1
  74. } else if (id === 2) {
  75. this.offsetX = rightCardOffsetX
  76. this.size = 0.83
  77. this.zIndex = 1
  78. this.opacity = 1
  79. } else {
  80. this.offsetX = midCardOffsetX
  81. this.size = 0.83
  82. this.zIndex = 1
  83. this.opacity = 0
  84. }
  85. }
  86. }
  87. // 日期信息接口定义
  88. export interface DateInfo {
  89. year: number; // 年份
  90. month: number; // 月份(1-12)
  91. day: number; // 日期(1-31)
  92. week: string; // 星期(中文)
  93. id: Date ; // 唯一标识
  94. }