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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
"use strict";
cc._RF.push(module, '68c13+FaaNOM4OuMcTbSfAk', 'backpack_comp_tips_window');
// Scripts/mod/tips/view/backpack_comp_tips_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-04-12 10:00:15
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var BackpackController = require("backpack_controller");
 
var Backpack_comp_tipsWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("tips", "backpack_comp_tips");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属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();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {},
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.background = this.root_wnd.getChildByName("background");
    this.main_panel = this.root_wnd.getChildByName("main_panel");
    this.text_name = this.main_panel.getChildByName("text_name").getComponent(cc.Label);
    this.get_path = this.main_panel.getChildByName("get_path");
    this.get_path.active = false;
    var text_2 = this.get_path.getChildByName("Text_2").getComponent(cc.Label);
    text_2.string = Utils.TI18N("获取途径");
    this.goto_btn = this.get_path.getChildByName("goto");
    this.text_desc = this.main_panel.getChildByName("text_desc").getComponent(cc.Label);
    this.com_btn = this.main_panel.getChildByName("com_btn");
    this.com_btn.active = false;
    this.info_btn = this.main_panel.getChildByName("info_btn");
    this.info_btn.active = false;
    this.goods_item = ItemsPool.getInstance().getItem("backpack_item");
    this.goods_item.initConfig(true, 1, false);
    this.goods_item.setPosition(-this.main_panel.width / 2 + 113, 258 - this.main_panel.height / 2);
    this.goods_item.setParent(this.main_panel);
    this.goods_item.show();
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.background, function () {
      this.ctrl.showBackPackCompTips(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.goto_btn, function () {
      if (this.item_config) {
        var BackpackController = require("backpack_controller");
 
        BackpackController.getInstance().openTipsSource(true, this.item_config.id);
        this.ctrl.showBackPackCompTips(false);
      }
    }.bind(this), 1);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(item_bid) {
    if (!item_bid) return;
    var config = Utils.getItemConfig(item_bid);
    var btn_num = 1;
 
    if (Config.partner_data.data_get_compound_info[config.id]) {
      var random = Config.partner_data.data_get_compound_info[config.id].is_random;
 
      if (random == 1) {
        btn_num = 2;
        this.get_path.active = false;
      } else {
        this.get_path.active = true;
      }
    } else {
      // 符文
      var hallows_data = BackpackController.getInstance().getModel().getHallowsCompData(config.id);
      ;
 
      if (hallows_data) {
        this.get_path.active = true;
      }
    }
 
    this.item_config = config;
    this.showBtn(btn_num);
    this.setBaseInfo();
  },
  // 显示按钮个数
  showBtn: function showBtn(num) {
    var pos = 0;
 
    if (num > 1) {
      pos = 0 + 120;
    }
 
    this.com_btn.active = true;
    this.com_btn.x = pos;
    Utils.onTouchEnd(this.com_btn, function () {
      var item_data = BackpackController.getInstance().getModel().getBackPackItemNumByBid(this.item_config.id);
      var num = 1;
      var status = false;
      var product_id;
 
      if (Config.partner_data.data_get_compound_info[this.item_config.id]) {
        product_id = this.item_config.id;
        var comp_num = Config.partner_data.data_get_compound_info[this.item_config.id].num;
        num = Math.floor(item_data / comp_num);
        status = true;
      } else {
        var hallows_data = BackpackController.getInstance().getModel().getHallowsCompData(this.item_config.id);
        product_id = hallows_data.bid;
        num = Math.floor(item_data / hallows_data.num);
      }
 
      if (num >= 2) {
        if (status == true) {
          var TipsController = require("tips_controller");
 
          TipsController.getInstance().showCompChooseTips(true, this.item_config.id);
        } else {
          BackpackController.getInstance().sender10523(product_id, 1);
        }
      } else {
        if (num != 0) {
          if (status == true) {
            BackpackController.getInstance().sender11008(this.item_config.id, 1);
          } else {
            BackpackController.getInstance().sender10523(product_id, 1);
          }
        } else {
          message(Utils.TI18N("数量不足"));
        }
      }
    }.bind(this), 1);
 
    if (num == 2) {
      this.info_btn.active = true;
      this.info_btn.x = 120 - this.main_panel.getContentSize().width / 2;
      Utils.onTouchEnd(this.info_btn, function () {
        if (this.item_config.effect && this.item_config.effect[0].val && this.item_config.eqm_jie) {
          this.ctrl.showBackPackCompTips(false);
 
          var HeroController = require("hero_controller");
 
          HeroController.getInstance().openHeroInfoWindowByBidStar(this.item_config.effect[0].val, this.item_config.eqm_jie);
        }
      }.bind(this), 1);
    }
  },
  setBaseInfo: function setBaseInfo() {
    if (this.item_config == null) return;
    this.goods_item.setData(this.item_config.id);
    this.text_name.string = this.item_config.name;
    this.text_desc.string = this.item_config.use_desc;
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    if (this.goods_item) {
      this.goods_item.deleteMe();
    }
 
    this.goods_item = null;
 
    var GuideEvent = require("guide_event");
 
    gcore.GlobalEvent.fire(GuideEvent.CloseTaskEffect);
    this.ctrl.showBackPackCompTips(false);
  }
});
 
cc._RF.pop();