GamePassItem.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 ConfigM, { 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) {
  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_season_end_time",
  67. ""
  68. );
  69. let c = ConfigM.ins.getShopListByStoreId(1)[0];
  70. this.setText(
  71. "lbl_desc4",
  72. Utils.setI18nLabel(
  73. "Shop.GamePassSalesInfo",
  74. data.totalSell + "/" +c.total,
  75. data.freeAirdropSell + "/" + data.freeAirdropTotal
  76. )
  77. );
  78. this.PaysItem.init(payList, this);
  79. }
  80. }