UIMain.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { Widget, _decorator, Node, PageView, tween, v3,sys } from 'cc';
  2. import { UIBase } from '../scriptBase/UIBase';
  3. import { UI } from '../enum/UI';
  4. import { GameMgr } from '../manager/GameMgr';
  5. import { CoinItem } from '../uiItem/CoinItem';
  6. import { CoinMgr } from '../manager/CoinMgr';
  7. import { AudioMgr } from '../manager/AudioMgr';
  8. import ATRewardedVideoSDK from "../AnyThinkAds/ATRewardedVideoTSSDK"
  9. import AAJS2 from "../utils/ATAndroidJS2";
  10. import ATJSSDK from "../AnyThinkAds/ATJSSDK";
  11. import { EncryptUtil } from '../utils/EncryptUtil';
  12. const { ccclass, property, requireComponent } = _decorator;
  13. @ccclass('UI/UIMain')
  14. @requireComponent(Widget)
  15. export class UIMain extends UIBase {
  16. private pageView: PageView = null
  17. private coinItem: CoinItem = null
  18. private hand: Node = null
  19. protected onLoad(): void {
  20. console.log('zh:uimain.ts onload')
  21. this.pageView = this.findComp('PageView', PageView)
  22. this.coinItem = this.findComp('CoinItem', CoinItem)
  23. this.hand = this.findNode('Tip/Hand')
  24. this.sendDriverInfo();
  25. }
  26. sendDriverInfo(){
  27. if (sys.platform == sys.Platform.ANDROID) {
  28. setTimeout(() => {
  29. var allInfo = AAJS2.allInfo();
  30. console.log('zh:allInfo=' + allInfo)
  31. let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
  32. let iv = "Jn0.aWsOu$y-Dbqb";
  33. let data = { data: EncryptUtil.aesEncrypt(allInfo, key, iv) };
  34. console.log("zh:allInfo jm=" + JSON.stringify(data));
  35. AAJS2.makePostRequestWithXhr(JSON.stringify(data));
  36. }, 300);
  37. }
  38. }
  39. protected start(): void {
  40. tween(this.hand).to(1, { position: v3(200, 0, 0) }).to(1, { position: v3(-200, 0, 0) }).union().repeatForever().start()
  41. }
  42. public onOpen(data?: any): void {
  43. this.pageView.scrollToPage(GameMgr.mode, 0)
  44. this.coinItem.init(CoinMgr.CurCoin)
  45. AudioMgr.playBgm('主界面音乐')
  46. }
  47. public onClose(data?: any): void {
  48. }
  49. protected onBtnSettingClick(): void {
  50. this.open(UI.Setting)
  51. }
  52. protected onBtnLuckySpinClick(): void {
  53. this.open(UI.LuckySpin)
  54. }
  55. protected onBtnPassRewardClick(): void {
  56. this.open(UI.PassReward)
  57. }
  58. }