EachWindowItem.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { _decorator, Node, Label, Sprite, Texture2D, SpriteFrame, ImageAsset } from 'cc';
  2. import { JSB } from 'cc/env';
  3. import InfiniteCell from '../../core/InfiniteList/InfiniteCell';
  4. import { Http } from '../../core/net/Http';
  5. import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
  6. import { g } from '../../Data/g';
  7. import { platform } from '../../Data/platform';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('EachWindowItem')
  10. export class EachWindowItem extends InfiniteCell {
  11. @property({ type: Label, tooltip: "名字文本" }) titleLabel: Label;
  12. @property({ type: Label, tooltip: "描述文本" }) decLabel: Label;
  13. @property({ type: Sprite, tooltip: "图标" }) icon: Sprite;
  14. @property({ type: Http, tooltip: "Http组件" }) http: Http;
  15. private url: string = "";
  16. private nebulaAppId: string = "";
  17. async UpdateContent(itemData: any) {
  18. this.titleLabel.string = itemData.title;
  19. this.decLabel.string = itemData.dec;
  20. this.nebulaAppId = itemData.nebulaAppId;
  21. this.url = itemData.url;
  22. if (JSB) {
  23. let img = await ResourcesUtils.loadRemote<ImageAsset>(itemData.icon, { ext: ".png" }, this);
  24. const spriteFrame = new SpriteFrame();
  25. const texture = new Texture2D();
  26. texture.image = img;
  27. spriteFrame.texture = texture;
  28. this.icon.spriteFrame = spriteFrame;
  29. }
  30. }
  31. public onClick(): void {
  32. platform.downloadAPK(this.url, this.titleLabel.string + ".apk", true);
  33. platform.umUp("eachPushGame");//互推游戏下载埋点
  34. this.http.send("/api/recommend/AppDownloadLog", { downloadAppId: this.nebulaAppId, unionId: null, imei: g.deviceData.imei, idfa: g.deviceData.idfa, androId: g.deviceData.androId, oaid: g.deviceData.oaid, mac: g.deviceData.mac });
  35. }
  36. }