UserInformationAlert.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. var GameModule = require('../utils/GameModule');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. cancelButton: cc.Button,
  6. okButton: cc.Button,
  7. //修改人物状态弹窗
  8. titleRichText: cc.RichText,
  9. coinRichText: cc.RichText,
  10. ticketRichText: cc.RichText,
  11. //失败弹窗
  12. errorTipsNode: cc.Node,
  13. },
  14. // LIFE-CYCLE CALLBACKS:
  15. // onLoad () {},
  16. start () {
  17. },
  18. init() {
  19. },
  20. closeAlert() {
  21. this.node.active = false;
  22. },
  23. showRelationErrorAlert(spriteFrameString, title, cancelAction) {
  24. cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
  25. this.errorTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  26. });
  27. this.titleRichText.string = title;
  28. if (cancelAction) {
  29. this.cancelAction = cancelAction;
  30. }
  31. this.node.active = true;
  32. },
  33. showRelationAlert(title,response,cancelAction,okAction) {
  34. this.titleRichText.string = title;
  35. this.coinRichText.string = "<img src='alert_coin' /> " + response.coin;
  36. let ticketString = (response.ticket).toString() +'/'+ (response.myTicket).toString();
  37. this.ticketRichText.string = "<img src='artist_ticket_icon' /> 艺人券(" + ticketString + ")";
  38. if (cancelAction) {
  39. this.cancelAction = cancelAction;
  40. }
  41. if (okAction) {
  42. this.okAction = okAction;
  43. }
  44. let normalColor = new cc.Color(88, 74, 71, 255);
  45. let redColor = new cc.Color(239, 61, 66, 255);
  46. var conditionIsOk = false;
  47. if (GameModule.userInfo.grossIncome >= response.coin) {
  48. this.coinRichText.node.color = normalColor;
  49. conditionIsOk = true;
  50. } else {
  51. this.coinRichText.node.color = redColor;
  52. }
  53. if (response.myTicket >= response.ticket) {
  54. this.ticketRichText.node.color = normalColor;
  55. } else {
  56. this.ticketRichText.node.color = redColor;
  57. conditionIsOk = false;
  58. }
  59. this.okButton.interactable = conditionIsOk;
  60. this.node.active = true;
  61. },
  62. alertCancelAction() {
  63. if (this.cancelAction) {
  64. this.cancelAction();
  65. }
  66. },
  67. alertOkAction() {
  68. if (this.okAction) {
  69. this.okAction();
  70. }
  71. },
  72. // update (dt) {},
  73. });