源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 regels
4.6 KiB

4 weken geleden
  1. MarketBuyView = MarketBuyView or BaseClass(BaseView)
  2. local MarketBuyView = MarketBuyView
  3. function MarketBuyView:__init()
  4. self.base_file = "market"
  5. self.layout_file = "MarketBuyView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true --全屏界面默认使用这个参数
  9. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  10. self.change_scene_close = true
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.blur_activity_bg = true
  14. self.model = MarketModel:getInstance()
  15. self.load_callback = function ()
  16. self:LoadSuccess()
  17. self:AddEvent()
  18. end
  19. self.open_callback = function ( )
  20. self:OpenSuccess()
  21. end
  22. self.switch_callback = function(index)
  23. self:SwitchTab(index)
  24. end
  25. self.destroy_callback = function ( )
  26. self:DestroySuccess()
  27. end
  28. end
  29. --type: 1是一口价 2是竞拍
  30. function MarketBuyView:Open(data,type )
  31. self.data = data
  32. self.type = type
  33. BaseView.Open(self)
  34. end
  35. function MarketBuyView:LoadSuccess()
  36. local nodes = {
  37. "icon1:obj","title_text:tmp","close_btn:obj","right_text2:tmp","ok_btn:obj","name_text:tmp","right_text3:tmp","item_con",
  38. "icon3:obj","left_text2:tmp","left_text3:tmp","num_text:tmp","right_text1:tmp","icon2:obj","cancel_btn:obj","left_text1:tmp",
  39. "right_bg:obj","bg:img",
  40. }
  41. self:GetChildren(nodes)
  42. lua_resM:setOutsideImageSprite(self, self.bg_img,GameResPath.GetViewBigBg("market_buy_bg"),false)
  43. self.awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.item_con)
  44. self.awardItem:SetEnableClick(false)
  45. self.awardItem:SetItemSize(84, 84)
  46. end
  47. function MarketBuyView:AddEvent()
  48. local function on_click( target )
  49. if target == self.ok_btn_obj then
  50. self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15507, self.data.id, self.price)
  51. -- if self.type == MarketModel.ONE_PRICE_TYPE then--一口价购买
  52. -- elseif self.type == MarketModel.AUCTION_PRICE_TYPE then
  53. -- self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15507, self.data.id, self.price)
  54. -- end
  55. end
  56. self:Close()
  57. end
  58. AddClickEvent(self.close_btn_obj, on_click)
  59. AddClickEvent(self.ok_btn_obj, on_click)
  60. AddClickEvent(self.cancel_btn_obj, on_click)
  61. end
  62. function MarketBuyView:OpenSuccess()
  63. self:UpdateView()
  64. end
  65. function MarketBuyView:UpdateView()
  66. local goods_name = GoodsModel:getInstance():getGoodsName(self.data.type_id, true)
  67. self.name_text_tmp.text = goods_name
  68. local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.data.type_id)
  69. local wear_num = EquipModel:getInstance():EquipGoodsNumById(self.data.type_id)
  70. self.num_text_tmp.text = self.data.type == GoodsModel.TYPE.EQUIP and string.format("(拥有 %s 个)", HtmlColorTxt(wear_num, ColorUtil.GREEN_DARK)) or ""
  71. local equip_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(self.data)
  72. equip_data.equip_key = "EquipView"
  73. self.awardItem:SetData(self.data.type_id, self.data.goods_num,nil,equip_data)
  74. if self.type == MarketModel.ONE_PRICE_TYPE then--一口价购买
  75. self.left_text1_tmp.text = "购买数量"
  76. self.left_text2_tmp.text = "购买价格"
  77. self.left_text3_tmp.text = ""
  78. self.icon1_obj:SetActive(false)
  79. self.icon3_obj:SetActive(false)
  80. self.right_bg_obj:SetActive(false)
  81. SetAnchoredPositionY(self.num_text, -51)
  82. self.title_text_tmp.text = "一口价"
  83. self.right_text1_tmp.text = self.data.goods_num
  84. self.right_text2_tmp.text = self.data.get_price
  85. self.price = self.data.get_price
  86. elseif self.type == MarketModel.AUCTION_PRICE_TYPE then
  87. self.left_text1_tmp.text = "当前竞价"
  88. self.left_text2_tmp.text = HtmlColorTxt("出价金额", ColorUtil.PURPLE_DARK)
  89. self.left_text3_tmp.text = ""
  90. self.icon3_obj:SetActive(false)
  91. self.right_bg_obj:SetActive(false)
  92. SetAnchoredPositionY(self.num_text, -51)
  93. self.title_text_tmp.text = "竞拍"
  94. self.right_text1_tmp.text = self.data.price
  95. local price_markup = goods_vo.price_markup * self.data.goods_num or 0
  96. if self.data.aution_num > 0 then--如果已经不是第一次竞拍了 竞拍就要加价
  97. if self.model:IsGoodsCanBuyOnePrice(self.data.type_id) then
  98. self.price = (self.data.price + price_markup) > self.data.get_price and self.data.get_price or (self.data.price + price_markup)
  99. else
  100. self.price = self.data.price + price_markup
  101. end
  102. else
  103. self.price = self.data.price
  104. end
  105. self.right_text2_tmp.text = self.price
  106. -- self.right_text2_tmp.text = price_markup
  107. end
  108. end
  109. function MarketBuyView:SwitchTab( index )
  110. end
  111. function MarketBuyView:DestroySuccess( )
  112. if self.awardItem then
  113. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.awardItem)
  114. self.awardItem = nil
  115. end
  116. end