EventAdInfo.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const { ccclass, property } = cc._decorator;
  2. /**
  3. * 广告类型
  4. */
  5. export enum YwAdType {
  6. BANNER = 1,
  7. INTERSITITIAL = 2,
  8. REWARD_VIDEO = 3,
  9. SPLASH = 4,
  10. NATIVE_BANNER = 5,
  11. NATIVE_INTERSITITIAL = 6,
  12. NATIVE_ICON = 7,
  13. INTERSITITIAL_VIDEO = 8,
  14. NATIVE = 9,
  15. NATIVE_TEMPLATE_BANNER = 10,
  16. NATIVE_TEMPLATE_INTERSITIAL = 11,
  17. };
  18. export enum YwAdStatus {
  19. REQUEST = 0,
  20. REQUEST_SUCCESS = 1,
  21. REQUEST_FAIL = 2,
  22. SHOW_SUCCESS = 3,
  23. SHOW_FAIL = 4,
  24. CLICK = 5,
  25. REWARD_SUCCESS = 6,
  26. REWARD_FAIL = 7,
  27. AD_ID_REQUEST = 10,
  28. AD_ID_REQUEST_SUCCESS = 11,
  29. AD_ID_REQUEST_FAIL = 12
  30. }
  31. export class AdEventParameter {
  32. public code: number; //状态码
  33. public msg: string; //状态信息
  34. public tag: string; //标签
  35. public adId: string; //广告id
  36. constructor(adId: string, code?: number, msg?: string, tag?: string) {
  37. this.adId = adId;
  38. this.code = code;
  39. this.msg = msg;
  40. this.tag = tag;
  41. }
  42. public toJsonData() {
  43. let data: any = {};
  44. data.adId = this.adId;
  45. if (this.code) {
  46. data.code = this.code;
  47. }
  48. if (this.msg) {
  49. data.msg = this.msg;
  50. }
  51. if (this.tag) {
  52. data.tag = this.tag;
  53. }
  54. return data;
  55. }
  56. }
  57. @ccclass
  58. export default class EventAdInfo {
  59. private adType: YwAdType;
  60. private adStatus: YwAdStatus;
  61. private adEventParameter: AdEventParameter;
  62. private time: number;
  63. constructor(adType: YwAdType, adStatus: YwAdStatus, adEventParameter?: AdEventParameter) {
  64. this.time = new Date().getTime();
  65. this.adType = adType;
  66. this.adStatus = adStatus;
  67. this.adEventParameter = adEventParameter;
  68. }
  69. public toJsonData() {
  70. try {
  71. let data: any = {};
  72. data.ad_type = this.adType;
  73. data.ad_status = this.adStatus;
  74. if (this.adEventParameter != null) {
  75. if (this.adEventParameter.adId) {
  76. data.ad_id = this.adEventParameter.adId;
  77. }
  78. data.ad_info = this.adEventParameter.toJsonData();
  79. }
  80. data.time = this.time;
  81. return data;
  82. } catch (ex) {
  83. console.error("EventAdInfo toJsonData erro msg =" + ex);
  84. }
  85. return {};
  86. }
  87. // update =dt {}
  88. }