源战役客户端
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.

124 lines
3.8 KiB

  1. CommonAuctionTips = CommonAuctionTips or BaseClass(BaseView)
  2. local CommonAuctionTips = CommonAuctionTips
  3. --[[
  4. CommonAuctionTips.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. function CommonAuctionTips:__init()
  9. self.base_file = "mainui"
  10. self.layout_file = "CommonAuctionTips"
  11. self.layer_name = "Top"
  12. self.destroy_imm = true
  13. self.use_background = false --全屏界面默认使用这个参数
  14. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  15. self.change_scene_close = false
  16. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  17. self.need_show_money = false --是否要显示顶部的金钱栏
  18. -- self.base_x = -108
  19. self.base_x = ScreenWidth/2-377--377是对右边的值
  20. -- self.base_y = 60
  21. self.base_y = -ScreenHeight/2+195--177是对下边的值
  22. self.model = MarketModel:GetInstance()
  23. self.load_callback = function ()
  24. self:LoadSuccess()
  25. self:AddEvent()
  26. end
  27. self.open_callback = function ( )
  28. self:OpenSuccess()
  29. end
  30. self.switch_callback = function(index)
  31. self:SwitchTab(index)
  32. end
  33. self.destroy_callback = function ( )
  34. self:DestroySuccess()
  35. end
  36. end
  37. function CommonAuctionTips:Open(data)
  38. self.data = data
  39. BaseView.Open(self)
  40. end
  41. function CommonAuctionTips:ReOpen( data )
  42. self.data = data
  43. self:UpdateView()
  44. end
  45. function CommonAuctionTips:LoadSuccess()
  46. local nodes = {
  47. "layout/auction_btn:obj", "layout/bg:raw", "layout/tip_text:tmp", "layout/close_btn:obj", "layout/item_con", "layout",
  48. }
  49. self:GetChildren(nodes)
  50. self.awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_con)
  51. self.awardItem:SetItemSize(78,78)
  52. self.awardItem:SetEnableClick(false)
  53. end
  54. function CommonAuctionTips:AddEvent()
  55. local function on_click( target )
  56. if target == self.close_btn_obj then
  57. self:Close()
  58. elseif target == self.auction_btn_obj then
  59. OpenFun.Open(155,3)
  60. self:Close()
  61. end
  62. end
  63. AddClickEvent(self.close_btn_obj, on_click)
  64. AddClickEvent(self.auction_btn_obj, on_click)
  65. local function onOrientationChange()
  66. self:ChangeUiPosition()
  67. end
  68. self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  69. end
  70. function CommonAuctionTips:OpenSuccess()
  71. self:UpdateView()
  72. end
  73. function CommonAuctionTips:ChangeUiPosition( )
  74. if GuildModel:getInstance().is_open_auctiontip then
  75. -- SetAnchoredPosition(self.layout, self.base_x + ClientConfig.iphone_x_offset_left, self.base_y)
  76. SetAnchoredPosition(self.layout, self.base_x - ClientConfig.iphone_x_offset_right - 200, self.base_y)
  77. else
  78. -- SetAnchoredPosition(self.layout, -304 + ClientConfig.iphone_x_offset_left, self.base_y)
  79. SetAnchoredPosition(self.layout, self.base_x - ClientConfig.iphone_x_offset_right, self.base_y)
  80. end
  81. end
  82. function CommonAuctionTips:UpdateView()
  83. self:ChangeUiPosition()
  84. self.awardItem:SetData(self.data.goods_id)
  85. local goodsVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.data.goods_id)
  86. if goodsVo and goodsVo.type == GoodsModel.TYPE.EQUIP then
  87. goodsVo.goods_num = 1
  88. local can_tip, flag = EquipModel:getInstance():EquipCanShowGoodsTip(goodsVo)
  89. self.awardItem:ChangeEquipState(flag)
  90. else
  91. self.awardItem:ChangeEquipState(nil)
  92. end
  93. local goods_name = GoodsModel:getInstance():getGoodsName(self.data.goods_id, true)
  94. if self.data.is_show_time then
  95. self.tip_text_tmp.text = string.format("您关注的 %s 已经可以竞价了!", goods_name)
  96. else
  97. self.tip_text_tmp.text = string.format("您对 %s 的竞价已被超过", goods_name)
  98. end
  99. end
  100. function CommonAuctionTips:SwitchTab( index )
  101. end
  102. function CommonAuctionTips:DestroySuccess( )
  103. if self.awardItem then
  104. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.awardItem)
  105. self.awardItem = nil
  106. end
  107. if self.orientation_change_id then
  108. GlobalEventSystem:UnBind(self.orientation_change_id)
  109. self.orientation_change_id = nil
  110. end
  111. end