YZ_BaiduRecommendWidget.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import PlatUtils from "./PlatUtils";
  2. import { utils } from "./Utils";
  3. import CompatibleTool from "./CompatibleTool";
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export default class YZ_BaiduRecommendWidget extends cc.Component {
  7. _widget: cc.Widget = null;
  8. onLoad() {
  9. this._widget = this.getComponent(cc.Widget);
  10. }
  11. onEnable() {
  12. this.getComponent(cc.Sprite).enabled = false;
  13. if (!PlatUtils.IsBaidu || !(PlatUtils.IsBaidu && utils.Tool_Baidu && utils.Tool_Baidu.canShowRecommendButton())) {
  14. utils.showLog("不支持交叉推广组件!");
  15. this.node.destroy();
  16. } else {
  17. if (PlatUtils.IsBaidu && utils.Tool_Baidu && utils.Tool_Baidu.canShowRecommendButton()) {
  18. if (this._widget) {
  19. utils.Tool_Baidu.showRecommendationButton(CompatibleTool.position(this._widget.left, this._widget.top));
  20. } else {
  21. utils.showLog("baidu recommend button widget component is null");
  22. }
  23. }
  24. }
  25. }
  26. onDisable() {
  27. if (PlatUtils.IsBaidu && utils.Tool_Baidu && utils.Tool_Baidu.canShowRecommendButton()) {
  28. }
  29. }
  30. }