pushAdBtBtn.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. properties: {
  14. nameLabel: {
  15. default: null,
  16. type: cc.Label
  17. }
  18. },
  19. onDestroy(){
  20. if (wb.PushAdBtEnableIndex) wb.PushAdBtEnableIndex.push(this.dataIndex);
  21. },
  22. getDataIndex() {
  23. var index = wb.getPushAdBtBtnIndex(this);
  24. cc.log("index " + index);
  25. this.dataIndex = index;
  26. return index;
  27. },
  28. flushNameLabel() {
  29. this.nameLabel.string = wb.SysValue.subStr(this.data.gameName, 8);
  30. },
  31. loopNext() {
  32. if(!wb.wxData.pushData) return;
  33. if (!this.isLoop) return;
  34. var newIndex = this.getDataIndex();
  35. if (newIndex == undefined || this.dataIndex == newIndex) return;
  36. this.dataIndex = newIndex;
  37. this.data = this.pushData[this.dataIndex];
  38. this.setData(this.data);
  39. },
  40. });