源战役客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

121 satır
3.9 KiB

  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:huangcong
  4. ----------------------------------------------------------------------]]
  5. PowerTurnTableExchangeReqView = PowerTurnTableExchangeReqView or BaseClass(BaseView)
  6. local PowerTurnTableExchangeReqView = PowerTurnTableExchangeReqView
  7. function PowerTurnTableExchangeReqView:__init()
  8. self.base_file = "powerTurnTable"
  9. self.layout_file = "PowerTurnTableExchangeReqView"
  10. self.layer_name = "Top"
  11. self.destroy_imm = true
  12. self.use_background = true
  13. self.change_scene_close = true
  14. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  15. self.need_show_money = false --是否要显示顶部的金钱栏
  16. self.model = PowerTurnTableModel:getInstance()
  17. self.is_set_zdepth = true
  18. self.blur_activity_bg = true
  19. self.cur_num = 1
  20. self.load_callback = function ()
  21. self:LoadSuccess()
  22. self:AddEvent()
  23. end
  24. self.open_callback = function ( )
  25. self:OpenSuccess()
  26. end
  27. self.destroy_callback = function ( )
  28. self:DestroySuccess()
  29. end
  30. end
  31. function PowerTurnTableExchangeReqView:DestroySuccess()
  32. if self.awardItem then
  33. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.awardItem)
  34. self.awardItem = nil
  35. end
  36. if self.addNumComponent then
  37. if self.change_count_id then
  38. self.addNumComponent:UnBind(self.change_count_id)
  39. self.change_count_id = nil
  40. end
  41. self.addNumComponent:DeleteMe()
  42. self.addNumComponent = nil
  43. end
  44. end
  45. function PowerTurnTableExchangeReqView:LoadSuccess()
  46. local nodes = {
  47. "Window:raw", "Window/windowCloseBtn:obj", "Window/windowTitleText:tmp", "cancelBtn:obj", "confirmBtn:obj",
  48. "icon", "nameText:tmp", "num_con",
  49. }
  50. self:GetChildren(nodes)
  51. self.windowTitleText_tmp.text = "提示"
  52. lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"),false)
  53. self.awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.icon)
  54. self.awardItem:SetItemSize(78,78)
  55. self.awardItem:SetIsAct(true)
  56. self.awardItem:SetDataWithMapId(self.data.reward[2],self.data.reward[3])
  57. local goods_name = GoodsModel:getInstance():getGoodsName(self.data.reward[2], true)
  58. self.nameText_tmp.text = goods_name
  59. self:SetNumConInfo()
  60. if self.need_load_again then
  61. self:UpdateView()
  62. end
  63. end
  64. function PowerTurnTableExchangeReqView:AddEvent()
  65. local function onBtnClickHandler(target,x,y)
  66. if target == self.windowCloseBtn_obj or self.cancelBtn_obj == target then
  67. self:Close()
  68. elseif target == self.confirmBtn_obj then--兑换
  69. if self.data then
  70. self:Close()
  71. self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33503,self.data.sub_type,self.data.id,self.cur_num)
  72. end
  73. end
  74. end
  75. AddClickEvent(self.windowCloseBtn_obj,onBtnClickHandler,1)
  76. AddClickEvent(self.cancelBtn_obj,onBtnClickHandler,1)
  77. AddClickEvent(self.confirmBtn_obj,onBtnClickHandler,1)
  78. end
  79. function PowerTurnTableExchangeReqView:Open( data )
  80. self.data = data
  81. BaseView.Open(self)
  82. end
  83. function PowerTurnTableExchangeReqView:OpenSuccess( )
  84. self:UpdateView()
  85. end
  86. function PowerTurnTableExchangeReqView:UpdateView( )
  87. if not self.is_loaded then
  88. self.need_load_again = true
  89. return
  90. end
  91. end
  92. --设置购买数据
  93. function PowerTurnTableExchangeReqView:SetNumConInfo( )
  94. if not self.addNumComponent then
  95. self.addNumComponent = AddNumberComponent.New(self.num_con)
  96. self.addNumComponent:SetComponentWidth(240)
  97. end
  98. local function onChangeCountHandler(count)
  99. self:SetCountNum(count)
  100. end
  101. self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT, onChangeCountHandler)
  102. self.addNumComponent:SetVisibleCalcBtn(false)
  103. local max_num = 1
  104. if self.data and self.data.max_num then
  105. max_num = self.data.max_num
  106. end
  107. self.addNumComponent:InitData(1, max_num, 1, 1, 2)
  108. end
  109. function PowerTurnTableExchangeReqView:SetCountNum( count )
  110. self.cur_num = count
  111. end