123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- var UIHelper = require("UIHelper");
- var propConfig = require("propConfig");
- //var byDefine = require("BYDefine");
- var Global = require("Global");
- var BaseDefine = require("BaseDefine");
- var LanguageKey = require("LanguageKey");
- var topTipMsg = require("topTipMsg")
- cc.Class({
- extends: cc.Component,
- properties: {
- _moreFun:null,
- _backCallFun:null,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- UIHelper.addButtonListener(this.node.getChildByName("Mask"), this.node, "GetAward", "hideAward");
- UIHelper.addButtonListener(this.node.getChildByName("btnMore"), this.node, "GetAward", "onClickMore");
- UIHelper.addButtonListener(this.node.getChildByName("MaskEX").getChildByName("btn_IKnow"), this.node, "GetAward", "onClickIKnow");
- UIHelper.addButtonListener(this.node.getChildByName("MaskEX").getChildByName("btn_guidance"), this.node, "GetAward", "onClickGuidance");
- this.node.getChildByName("MaskEX").active = false;
- },
- showAward: function(kPropList, backCallFun, moreFun, noGoldAdd, bOnlyShow) {
- this.node.getChildByName("MaskEX").active = false;
- if(!kPropList || kPropList.length<=0)
- {
- this.node.active = false;
- return;
- }
- var rootNode = this.node.getChildByName("rootNode");
- rootNode.removeAllChildren();
- var isRedEnvelopes = false;//奖励是红包
- var hasMatchProp = false;
- let awardListStr = LanguageKey.t(LanguageKey.Public.getAward);
- for (let index = 0; index < kPropList.length; index++) {
- const element = kPropList[index];
- if (element.dwPropID >= 100000 && element.dwPropID < 102010) {//比赛道具
- // var node = cc.instantiate(this.node.getChildByName("Spr"));
- // node.active = true;
- // rootNode.addChild(node);
- // node.getChildByName("icon").getComponent("urlSpriteFrame").setUrl(BaseDefine.MATCH_PROP_IMG_URL + element.dwPropID + ".png");
- if (element.dwPropID >= 100000 && element.dwPropID < 101000 ) {
- // node.getChildByName("AwardLabel").getComponent(cc.Label).string = "现金券×1";
- awardListStr += " 现金券×1";
- }else if (element.dwPropID >= 101000 && element.dwPropID < 102000 ) {
- // node.getChildByName("AwardLabel").getComponent(cc.Label).string = "代金券×1";
- awardListStr += " 代金券×1";
- }else if (element.dwPropID >= 102000 && element.dwPropID < 102010 ) {
- // node.getChildByName("AwardLabel").getComponent(cc.Label).string = "入场券×1";
- awardListStr += " 入场券×1";
- }
-
- hasMatchProp = true;
- } else {
- //awardType : 10000: 鲜花饼, 30000:金豆, 200000:实物, 40000:红包券 50000:现金红包
- var prop = propConfig.getPropConfig(element.dwPropID);
- if (prop.type == propConfig.propType.Prop_Type_Object) {
- continue;
- }
- if (!bOnlyShow) {
- if (prop.type != propConfig.propType.Prop_Type_Gold) {
- cc.vv.globalUserInfo.addUserProp(element.dwPropID, element.dwPropNum);
- }else {
- if (element.dwPropID == propConfig.propID.Prop_Id_Gold) {
- if (!noGoldAdd) {
- var score = cc.vv.globalUserInfo.getUserScore();
- Global.print("cc.vv.globalUserInfo.setUserScore showAward::" + score)
- cc.vv.globalUserInfo.setUserScore((parseFloat(score) + element.dwPropNum));
- }
- }else if (element.dwPropID == propConfig.propID.Prop_Id_Card) {
- var revenue = cc.vv.globalUserInfo.getUserInsure();
- cc.vv.globalUserInfo.setUserInsure(revenue + element.dwPropNum);
- }else if (element.dwPropID == propConfig.propID.Prop_Id_Red) {
- var insure = cc.vv.globalUserInfo.getRevenue();
- cc.vv.globalUserInfo.setRevenue(insure + element.dwPropNum);
- }
- }
- }
- // var node = cc.instantiate(this.node.getChildByName("Spr"));
- // node.active = true;
- // UIHelper.setSpriteFrameByUrl(node.getChildByName("icon").getComponent(cc.Sprite), "Hall/prop/prop_bag_" + element.dwPropID);
- // node.getChildByName("AwardLabel").getComponent(cc.Label).string = prop.name + "×" + element.dwPropNum;
- // rootNode.addChild(node);
- awardListStr += " " + prop.name + "×" + Global.formatString2Score(element.dwPropNum);
- if(prop.id == propConfig.propID.Prop_Id_RedEnvelopes)//红包
- {
- // this.node.getChildByName("MaskEX").active = true;
- // node.getChildByName("AwardLabel").getComponent(cc.Label).string = prop.name + "×" + element.dwPropNum + "元";
- awardListStr += " " + prop.name + "×" + element.dwPropNum + "元";
- isRedEnvelopes = true;
- }
- }
-
- }
- // if (rootNode.childrenCount <= 0) {
- // return ;
- // }
- if (hasMatchProp) {
- cc.vv.globalUserInfo.reqMatchProp();
- }
- var self = this;
- // this.node.active = true;
- UIHelper.playButtonEffect("award");
- // var spb = this.node.getChildByName("SpBg").getChildByName("sp").getComponent(sp.Skeleton);
- this.node.getChildByName("Mask").getComponent(cc.Button).interactable = false;
- this.node.getChildByName("TouchTip").active = false;
- // this.node.getChildByName("Spr").getComponent(cc.Animation).play();
- //this.node.getChildByName("AwardLabel").active = false;
- // spb.animation = "a1";
- // spb.loop = false;
- // spb.setCompleteListener(function() {
- // self.node.getChildByName("Mask").getComponent(cc.Button).interactable = true;
- // if(!isRedEnvelopes){
- // self.node.getChildByName("TouchTip").active = true;
- // }
- // //self.node.getChildByName("AwardLabel").active = true;
- // spb.animation = "a2";
- // spb.loop = true;
- // });
- topTipMsg.showTopTipMsg(awardListStr);
- this._moreFun = null;
- this.node.getChildByName("btnMore").active = false;
- if (moreFun) {
- this._moreFun = moreFun;
- this.node.getChildByName("btnMore").active = true;
- }
- this._backCallFun = null;
- if (backCallFun) {
- this._backCallFun = backCallFun;
- }
- },
- showAwardLucky: function(kProp) {
- var rootNode = this.node.getChildByName("rootNode");
- rootNode.removeAllChildren();
-
- //awardType : 10000: 鲜花饼, 30000:金豆, 200000:实物, 40000:红包券 50000:现金红包
- var node = cc.instantiate(this.node.getChildByName("Spr"));
- node.active = true;
- var imgGoods = node.getChildByName("icon");
- cc.assetManager.loadRemote(kProp.dwPropURL, function (err, tex) {
- if (err) {
- Global.print(err);
- } else {
- imgGoods.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(tex);
- }
- });
-
- node.getChildByName("AwardLabel").getComponent(cc.Label).string = Global.gbk2Utf8(kProp.dwPropName);
- rootNode.addChild(node);
-
- if (rootNode.childrenCount <= 0) {
- return ;
- }
- var self = this;
- this.node.active = true;
- UIHelper.playButtonEffect("award");
- var spb = this.node.getChildByName("SpBg").getChildByName("sp").getComponent(sp.Skeleton);
- this.node.getChildByName("Mask").getComponent(cc.Button).interactable = false;
- this.node.getChildByName("TouchTip").active = false;
- this.node.getChildByName("Spr").getComponent(cc.Animation).play();
- //this.node.getChildByName("AwardLabel").active = false;
- spb.setTrackCompleteListener(spb.setAnimation(0, "a1", false), function() {
- self.node.getChildByName("Mask").getComponent(cc.Button).interactable = true;
- self.node.getChildByName("TouchTip").active = true;
- //self.node.getChildByName("AwardLabel").active = true;
- spb.setAnimation(0, "a2", true);
- });
- },
- hideAward: function() {
- if (cc.director.getScene().name == "byScene") {
- } else {
- UIHelper.playButtonEffect("close");
- }
- this.node.active = false;
- cc.vv.shareType = "";
- if (this._backCallFun) {
- this._backCallFun(false);
- this._backCallFun = null;
- }
- },
-
- onClickMore: function() {
- if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
- this.onShareSucc();
- }
- },
- onShareSucc: function() {
- // if (cc.vv.shareType == "taskwxpyq") {
- // if (this._moreFun) {
- // this._moreFun(true);
- // this._moreFun = null;
- // }
- // this.node.active = false;
- // }
- },
- onClickIKnow:function(){
- this.hideAward();
- },
- onClickGuidance:function(){
- UIHelper.playButtonEffect("open");
- },
- });
|