WxGameClubButton.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  5. (this && this.__decorate) ||
  6. function (t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", {value: !0});
  17. var {ccclass: e} = cc._decorator,
  18. e = s(
  19. [e],
  20. (e = class extends cc.Component {
  21. constructor() {
  22. super(...arguments), (this.btn = null), (this._init = !1);
  23. }
  24. initBtn() {
  25. var t, e, i, s, o, a;
  26. this._init ||
  27. cc.sys.platform !== cc.sys.WECHAT_GAME ||
  28. ((this._init = !0),
  29. (t = this.node.getBoundingBoxToWorld()),
  30. (a = wx.getSystemInfoSync()),
  31. (e = cc.winSize),
  32. (i = (t.xMin / e.width) * a.windowWidth),
  33. (s = ((e.height - t.yMax) / e.height) * a.windowHeight),
  34. (o = (t.width / e.width) * a.windowWidth),
  35. (a = (t.height / e.height) * a.windowHeight),
  36. (this.btn = wx.createGameClubButton({
  37. type: "text",
  38. text: "",
  39. style: {
  40. left: i,
  41. top: s,
  42. width: o,
  43. height: a,
  44. lineHeight: 0,
  45. backgroundColor: "",
  46. color: "#3296fa",
  47. textAlign: "center",
  48. fontSize: 16,
  49. borderRadius: 4
  50. }
  51. })),
  52. this.btn.show());
  53. }
  54. onEnable() {
  55. this.btn && this.btn.show();
  56. }
  57. onDisable() {
  58. this.btn && this.btn.hide();
  59. }
  60. onDestroy() {
  61. this.btn && (this.btn.destroy(), (this.btn = null));
  62. }
  63. })
  64. );
  65. i.default = e;