pushAdRaBtn .js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. var PushAdBtn = require("pushAdBtn");
  11. cc.Class({
  12. extends: PushAdBtn,
  13. getDataIndex() {
  14. var index = wb.getPushAdRaBtnIndex();
  15. cc.log("index " + index);
  16. this.dataIndex = index;
  17. return index;
  18. },
  19. onDestroy(){
  20. cc.log("onDestroy ~~~~~~~" + this.dataIndex);
  21. if (wb.pushAdBtnDataList) wb.pushAdBtnDataList.push(this.dataIndex);
  22. },
  23. loopNext() {
  24. if (!this.isLoop) return;
  25. if (wb.wxData.vigameAdFlag) return;
  26. var newIndex = wb.pushAdBtnDataRand(this.dataIndex);
  27. if (newIndex == undefined || this.dataIndex == newIndex) return;
  28. this.dataIndex = newIndex;
  29. this.data = this.pushData[this.dataIndex];
  30. this.setData(this.data);
  31. },
  32. });