123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- var GameModule = require('../utils/GameModule');
- cc.Class({
- extends: cc.Component,
- properties: {
- cancelButton: cc.Button,
- okButton: cc.Button,
-
- titleRichText: cc.RichText,
- coinRichText: cc.RichText,
- ticketRichText: cc.RichText,
-
- errorTipsNode: cc.Node,
- },
-
-
- start () {
- },
- init() {
- },
- closeAlert() {
- this.node.active = false;
- },
- showRelationErrorAlert(spriteFrameString, title, cancelAction) {
- cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
- this.errorTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
- });
- this.titleRichText.string = title;
- if (cancelAction) {
- this.cancelAction = cancelAction;
- }
- this.node.active = true;
- },
- showRelationAlert(title,response,cancelAction,okAction) {
- this.titleRichText.string = title;
- this.coinRichText.string = "<img src='alert_coin' /> " + response.coin;
- let ticketString = (response.ticket).toString() +'/'+ (response.myTicket).toString();
- this.ticketRichText.string = "<img src='artist_ticket_icon' /> 艺人券(" + ticketString + ")";
- if (cancelAction) {
- this.cancelAction = cancelAction;
- }
- if (okAction) {
- this.okAction = okAction;
- }
- let normalColor = new cc.Color(88, 74, 71, 255);
- let redColor = new cc.Color(239, 61, 66, 255);
- var conditionIsOk = false;
- if (GameModule.userInfo.grossIncome >= response.coin) {
- this.coinRichText.node.color = normalColor;
- conditionIsOk = true;
- } else {
- this.coinRichText.node.color = redColor;
- }
- if (response.myTicket >= response.ticket) {
- this.ticketRichText.node.color = normalColor;
- } else {
- this.ticketRichText.node.color = redColor;
- conditionIsOk = false;
- }
- this.okButton.interactable = conditionIsOk;
- this.node.active = true;
- },
- alertCancelAction() {
- if (this.cancelAction) {
- this.cancelAction();
- }
- },
- alertOkAction() {
- if (this.okAction) {
- this.okAction();
- }
- },
-
- });
|