| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { _decorator, Node, Label, Sprite, Texture2D, SpriteFrame, ImageAsset } from 'cc';
- import { JSB } from 'cc/env';
- import InfiniteCell from '../../core/InfiniteList/InfiniteCell';
- import { Http } from '../../core/net/Http';
- import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
- import { g } from '../../Data/g';
- import { platform } from '../../Data/platform';
- const { ccclass, property } = _decorator;
- @ccclass('EachWindowItem')
- export class EachWindowItem extends InfiniteCell {
- @property({ type: Label, tooltip: "名字文本" }) titleLabel: Label;
- @property({ type: Label, tooltip: "描述文本" }) decLabel: Label;
- @property({ type: Sprite, tooltip: "图标" }) icon: Sprite;
- @property({ type: Http, tooltip: "Http组件" }) http: Http;
- private url: string = "";
- private nebulaAppId: string = "";
- async UpdateContent(itemData: any) {
- this.titleLabel.string = itemData.title;
- this.decLabel.string = itemData.dec;
- this.nebulaAppId = itemData.nebulaAppId;
- this.url = itemData.url;
- if (JSB) {
- let img = await ResourcesUtils.loadRemote<ImageAsset>(itemData.icon, { ext: ".png" }, this);
- const spriteFrame = new SpriteFrame();
- const texture = new Texture2D();
- texture.image = img;
- spriteFrame.texture = texture;
- this.icon.spriteFrame = spriteFrame;
- }
- }
- public onClick(): void {
- platform.downloadAPK(this.url, this.titleLabel.string + ".apk", true);
- platform.umUp("eachPushGame");//互推游戏下载埋点
- 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 });
- }
- }
|