OfflineGrossIncome.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const DWTool = require('../utils/DWTool')
  2. const GameModule = require('../utils/GameModule')
  3. const WeChat = require('../net/WeChat');
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. content: cc.Node,
  8. coinRichText: cc.RichText,
  9. watchVideoRichText: cc.RichText,
  10. shareRichText: cc.RichText,
  11. secretarySprite: cc.Node,
  12. grossIncome: {
  13. get: function() {
  14. if (this._grossIncome) {
  15. this._grossIncome = 0;
  16. }
  17. return this._grossIncome;
  18. },
  19. set: function (value) {
  20. this._grossIncome = value;
  21. this.setCoinRichText(value);
  22. this.setWatchVideoRichText(value);
  23. this.setShareVideoRichText(value);
  24. }
  25. }
  26. },
  27. // LIFE-CYCLE CALLBACKS:
  28. init(grossIncome) {
  29. this.grossIncome = grossIncome;
  30. },
  31. onLoad () {
  32. },
  33. start () {
  34. this.content.scaleX = 0;
  35. this.content.scaleY = 0;
  36. this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  37. this.secretarySprite.runAction(cc.moveBy(0.3, cc.v2(400, 0)));
  38. },
  39. dismiss() {
  40. let finish = cc.callFunc(() => {
  41. this.node.destroy();
  42. }, this);
  43. let sequence = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  44. this.content.runAction(sequence);
  45. },
  46. watchVideo() {
  47. this.dismiss();
  48. },
  49. share() {
  50. WeChat.inviteFriend(ShareAction.ADD_FRIEND, () => {
  51. GameModule.userInfo.grossIncome += this.grossIncome * 3;
  52. this.dismiss();
  53. }, () => {
  54. this.dismiss();
  55. });
  56. },
  57. setCoinRichText(coin) {
  58. this.coinRichText.string = `<img src='alert_coin'/><outline color=#ffffff width=4><b><color=#009227> ${DWTool.coinParse(coin)}</c></b></outline>`;
  59. },
  60. setWatchVideoRichText(coin) {
  61. this.watchVideoRichText.string = `<img src='alert_coin'/><color=#ffffff> ${DWTool.coinParse(coin * 2)}</c>`;
  62. },
  63. setShareVideoRichText(coin) {
  64. this.shareRichText.string = `<img src='alert_coin'/><color=#ffffff> ${DWTool.coinParse(coin * 3)}</c>`;
  65. },
  66. // update (dt) {},
  67. });