GamePassItem.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { _decorator, Component, Node } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import { Tips } from "../../scripts/mgr/Tips";
  4. import { IPayListener, PayItems, PayType } from "../common/PayItems";
  5. import { Event } from "cc";
  6. import ShopM, { ShopDto } from "../../scripts/api/ShopM";
  7. import Utils from "../../scripts/utils/Utils";
  8. import { instantiate } from "cc";
  9. import UIUtils from "../../scripts/base/UIUtils";
  10. import { Vec3 } from "cc";
  11. import { ConfigShopItem } from "../../scripts/api/ConfigM";
  12. const { ccclass, property } = _decorator;
  13. @ccclass("GamePassItem")
  14. export class GamePassItem extends BaseUI implements IPayListener {
  15. showAnim(to: Node) {
  16. let from = this.FindNode("icon_game_pass");
  17. if (to == null || from == null) {
  18. return;
  19. }
  20. let node = instantiate(from);
  21. node.setParent(from);
  22. node.setPosition(0, 0, 0);
  23. UIUtils.moveToNewParent(to, node);
  24. UIUtils.AnimBezierMoveAndScale(node, new Vec3(0, 0, 0), 1, 1, () => {
  25. node.destroy();
  26. });
  27. }
  28. onPay(type: PayType, price: number) {
  29. // this.FindNode("activate").active = true;
  30. switch (type) {
  31. case PayType.USDT:
  32. this.buyUseUSD();
  33. break;
  34. case PayType.Gem:
  35. break;
  36. }
  37. }
  38. buyUseUSD() {
  39. let result = ShopM.ins.createOrder(this._data.id, PayType.USDT);
  40. }
  41. private PaysItem: PayItems;
  42. private _data: ShopDto;
  43. protected onLoad(): void {
  44. super.onLoad();
  45. this.setTitles();
  46. }
  47. setTitles() {}
  48. init(data: ShopDto,c:ConfigShopItem) {
  49. this._data = data;
  50. this.setText(
  51. "lbl_title",
  52. Utils.setI18nLabel("Shop.GamePassItemTitle", "" + data.seasonId)
  53. );
  54. this.PaysItem = this.getComponentInChildren(PayItems);
  55. let payList = [
  56. {
  57. price: 30.0,
  58. type: PayType.USDT,
  59. },
  60. ];
  61. this.setText(
  62. "lbl_season_end_time",
  63. "End Time:" + Utils.formattedOnlyDate(data.endTimeAt)
  64. );
  65. this.setText(
  66. "lbl_desc4",
  67. Utils.setI18nLabel(
  68. "Shop.GamePassSalesInfo",
  69. data.totalSell + "/" +c.total,
  70. data.freeAirdropSell + "/" + data.freeAirdropTotal
  71. )
  72. );
  73. this.PaysItem.init(payList, this);
  74. }
  75. }