difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"use strict";
cc._RF.push(module, '602cayAUnJOHIEpkam2LKWg', 'partnersummon_score_window');
// Scripts/mod/partnersummon/view/partnersummon_score_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-01-19 09:41:52
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var SummonConst = require("partnersummon_const");
 
var PartnersummonScoreWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("partnersummon", "partnersummon_score_window");
    this.viewTag = SCENE_TAG.ui; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Tips; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = arguments[0];
    this.model = this.ctrl.getModel();
 
    var RoleController = require("role_controller");
 
    this.role_vo = RoleController.getInstance().getRoleVo();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {},
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {},
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(params) {
    this.initWidgets();
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    this.ctrl.openScoreTipWindow(false);
  },
  initWidgets: function initWidgets() {
    this.close_btn_nd = this.seekChild("close_btn");
    this.ok_btn_nd = this.seekChild("ok_btn");
    this.ok_btn_bt = this.ok_btn_nd.getComponent(cc.Button);
    this.content_lb = this.seekChild("content_label", cc.Label);
    this.btn_title_ol = this.seekChild("btn_label", cc.LabelOutline);
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    var hero_sp = this.seekChild("Image_9", cc.Sprite);
    this.loadRes(PathTool.getIconPath("item", "29999"), function (res) {
      hero_sp.spriteFrame = res;
    }.bind(this));
    this.ok_btn_nd.on(cc.Node.EventType.TOUCH_END, this.didClickOkBtn, this);
    this.close_btn_nd.on(cc.Node.EventType.TOUCH_END, this.didCloseBnt, this);
    this.updateWidgets();
  },
  updateWidgets: function updateWidgets() {
    var need_score = this.model.getScoreSummonNeedCount();
    var des_str = Utils.TI18N(cc.js.formatStr(Lang.SCORE_RECRUIT, need_score));
    this.content_lb.string = des_str;
    var have_score = this.role_vo.recruit_hero;
 
    if (have_score >= need_score) {
      this.ok_btn_bt.interactable = true;
      this.btn_title_ol.enabled = true;
    } else {
      this.ok_btn_bt.interactable = false;
      this.btn_title_ol.enabled = false;
    }
  },
  didCloseBnt: function didCloseBnt(event) {
    this.ctrl.openScoreTipWindow(false);
  },
  didClickOkBtn: function didClickOkBtn(event) {
    if (this.ok_btn_bt.interactable) {
      var times = 1;
      var recruit_type = 2;
      this.ctrl.scoreRecruit(SummonConst.Summon_Type.Score, 1, 3);
      this.ctrl.openScoreTipWindow(false);
    }
  }
});
 
cc._RF.pop();