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
"use strict";
cc._RF.push(module, 'ba1f3Rd+mxBKbCDqZ7N7cCb', 'charge_item');
// Scripts/mod/vip/view/charge_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-04-19 16:38:43
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Charge_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("vip", "charge_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.main_container = this.seekChild("main_container");
    this.price_container = this.seekChild("price_container");
    this.coin_sp = this.seekChild(this.price_container, "coin", cc.Sprite);
    this.price_lb = this.seekChild(this.price_container, "price", cc.Label);
    this.icon_sp = this.seekChild(this.main_container, "icon", cc.Sprite);
    this.loadRes(PathTool.getItemRes(3), function (sp) {
      this.coin_sp.spriteFrame = sp;
    }.bind(this));
    this.charge_price_lb = this.seekChild("charge_price", cc.Label);
    this.extra_bg_nd = this.seekChild("extra_bg");
    this.extra_bg_nd.active = false;
    this.extra_desc_lb = this.seekChild(this.extra_bg_nd, "give", cc.Label);
    this.extra_rt = this.seekChild("extra_label", cc.RichText);
    this.confirm_bg_nd = this.seekChild("confirm_bg");
    this.confirm_bg_nd.active = false;
    this.confirm_tips_nd = this.seekChild("confirm_tips");
    this.confirm_tips_nd.active = false;
    this.first_bg_nd = this.seekChild("first_bg");
    this.first_bg_nd.active = false;
    this.first_lb = this.seekChild(this.first_bg_nd, "first_label", cc.Label);
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
      if (this.callback) {
        this.callback(this);
      }
 
      if (this.confirm_tips_nd.active) {
        SDK.pay(this.data.need_rmb / 100, null, this.data.id, this.data.name, null, null, null);
        this.confirm_tips_nd.active = false;
        this.confirm_bg_nd.active = false;
      } else {
        this.confirm_tips_nd.active = true;
        this.confirm_bg_nd.active = true;
      }
    }, this);
  },
  setData: function setData(data) {
    this.data = data;
    if (this.root_wnd) this.onShow();
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow() {
    if (this.data == null) return;
    var data = this.data;
    this.charge_price_lb.string = data.need_rmb / 100;
    this.price_lb.string = data.get_gold;
 
    if (data.is_first == 1) {
      this.first_bg_nd.active = true;
    } else {
      this.first_bg_nd.active = false;
    }
 
    if (data.add_gold > 0) {
      this.extra_bg_nd.active = true;
      this.extra_desc_lb.string = Utils.TI18N("赠");
      var res = PathTool.getItemRes(Utils.getItemConfig(4).icon);
      this.extra_rt.string = cc.js.formatStr(Utils.TI18N("<img src='%s' scale=0.3 /><outline width=2 color=#5b2c06>%s</outline>"), Utils.getItemConfig(4).icon, data.add_gold);
      this.loadRes(res, function (resObject) {
        this.extra_rt.addSpriteFrame(resObject);
      }.bind(this));
    } else if (data.id == 1 || data.id == 2) {
      this.coin_sp.node.active = false;
      this.price_lb.string = data.name;
      this.extra_bg_nd.active = true;
      this.extra_desc_lb.string = Utils.TI18N("即得");
      var res = PathTool.getItemRes(Utils.getItemConfig(Config.item_data.data_assets_label2id.gold).icon);
      this.extra_rt.string = cc.js.formatStr(TI18N("<img src='%s' scale=0.3 /><outline width=2 color=#5b2c06>%s</outline>"), Utils.getItemConfig(Config.item_data.data_assets_label2id.gold).icon, data.get_gold);
      this.loadRes(res, function (resObject) {
        this.extra_rt.addSpriteFrame(resObject);
      }.bind(this));
      this.icon_sp.node.scale = 0.8;
      this.updateYuekaInfoData(data);
    }
 
    this.loadRes(PathTool.getUIIconPath("vip", "vip_icon" + data.pic), function (sp) {
      this.icon_sp.spriteFrame = sp;
    }.bind(this));
  },
  updateYuekaInfoData: function updateYuekaInfoData(data) {},
  getData: function getData() {
    return this.data;
  },
  setSelect: function setSelect(status) {
    this.confirm_tips_nd.active = status;
    this.confirm_bg_nd.active = status;
  },
  addCallBack: function addCallBack(value) {
    this.callback = value;
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {}
});
 
cc._RF.pop();