源战役客户端
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

169 linhas
5.3 KiB

  1. ChildChatNiceView = ChildChatNiceView or BaseClass(BaseView)
  2. local ChildChatNiceView = ChildChatNiceView
  3. function ChildChatNiceView:__init()
  4. self.base_file = "child"
  5. self.layout_file = "ChildChatNiceView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  11. self.hide_maincancas = true
  12. self.blur_activity_bg = true
  13. self.close_fog = true
  14. self.model = ChildModel:GetInstance()
  15. self.showNum = 0
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. self:AddEvent()
  19. if self.data.role_id then
  20. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
  21. end
  22. end
  23. self.open_callback = function ( )
  24. self:UpdateView()
  25. end
  26. self.destroy_callback = function ( )
  27. self:DestroySuccess()
  28. end
  29. end
  30. function ChildChatNiceView:Open(data,callBack)
  31. self.data = data
  32. self.callBack = callBack
  33. BaseView.Open(self)
  34. if self.data.role_id then
  35. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
  36. end
  37. end
  38. function ChildChatNiceView:LoadSuccess()
  39. local nodes = {
  40. "closeBtn:obj","btn_nice:obj","text_num:tmp","bg:raw","rt_image_show","closeBtn2:obj",
  41. "txt_name:tmp",
  42. "name_con", "name_con/vip:obj:img",
  43. "roleHead", "name_con/name:tmp",
  44. "name_con/sex:img",
  45. }
  46. self:GetChildren(nodes)
  47. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("child_chat_nice_bg_1009_622"),false)
  48. local function bg_back_func( ... )
  49. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  50. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  51. end
  52. self:MoveUIToBack(self.bg_raw)
  53. end
  54. if self.background_wnd then
  55. bg_back_func()
  56. else
  57. self.bg_back_func = bg_back_func
  58. end
  59. end
  60. function ChildChatNiceView:AddEvent()
  61. local function SUCCESS_CHILD_NICE_fun(vo)
  62. -- self.text_num_tmp.text = self.showNum + 1
  63. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16511, tonumber(self.data.role_id)) -- 获取点赞数
  64. end
  65. self.success_child_nice_id = self.model:Bind(ChildConst.SUCCESS_CHILD_NICE, SUCCESS_CHILD_NICE_fun) --成功后返回
  66. local function SUCCESS_CHECK_CHILD_NICE_fun(num)
  67. self.showNum = num
  68. self.text_num_tmp.text = num
  69. end
  70. self.success_check_child_nice_id = self.model:Bind(ChildConst.SUCCESS_CHECK_CHILD_NICE, SUCCESS_CHECK_CHILD_NICE_fun) --41404成功后返回
  71. local on_click = function ( click_obj )
  72. if self.closeBtn_obj == click_obj or self.closeBtn2_obj == click_obj then
  73. self:Close()
  74. elseif self.btn_nice_obj == click_obj then
  75. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16510,tonumber(self.data.role_id))
  76. end
  77. end
  78. AddClickEvent(self.closeBtn_obj, on_click)
  79. AddClickEvent(self.btn_nice_obj, on_click)
  80. AddClickEvent(self.closeBtn2_obj, on_click)
  81. end
  82. function ChildChatNiceView:UpdateView()
  83. self.text_num_tmp.text = self.showNum
  84. self.txt_name_tmp.text = self.data.child_name
  85. --local show_figure_id = self.model:GetFashionModelID( self.data.fashion_id, self.data.child_sex )()
  86. local show_figure_id = self.model:GetChildClothByParam( tonumber(self.data.child_level), tonumber(self.data.child_sex), tonumber(self.data.fashion_id) )
  87. local res_data = {
  88. father_node = self,
  89. transform = self.rt_image_show,
  90. fashion_type = FuncOpenModel.TypeId.Child,
  91. figure_id = show_figure_id,
  92. ui_model_type = UIModelCommon.ModelType.BackModel,
  93. can_rotate = true,
  94. }
  95. FuncOpenModel:getInstance():SetModelRes(res_data)
  96. self:UpdatePlayerInfo( )
  97. end
  98. -- 更新玩家信息
  99. function ChildChatNiceView:UpdatePlayerInfo( )
  100. if not self.headItem then
  101. self.headItem = HeadRoleItem.New(self.roleHead)
  102. self.headItem:SetItemSize(50,50)
  103. end
  104. local board_id = nil
  105. self.headItem:SetData({
  106. id=tonumber(self.data.role_id),
  107. career=self.data.career,
  108. level= self.data.level,
  109. sex=self.data.sex,
  110. turn=self.data.turn,
  111. picture_ver = nil,
  112. picture = nil,
  113. board = board_id,
  114. is_big = false,
  115. profile_photo_id = self.data.profile_photo_id,
  116. use_bg = 3})
  117. lua_resM:setImageSprite(self, self.sex_img, "common_asset", self.data.sex == 1 and "com_boy" or "com_girl", true)
  118. -- lua_resM:setImageSprite(self, self.vip_img, "common_asset", "com_vip"..self.data.vip_flag)
  119. if not self.vipItem then
  120. self.vipItem = RoleVipItem.New(self.vip_img.transform)
  121. end
  122. self.vipItem:SetData(self.data.vip_flag,self.data.sup_vip_type)
  123. if self.data.vip_flag == 0 and self.data.sup_vip_type == 0 then
  124. self.vip_obj:SetActive(false)
  125. else
  126. self.vip_obj:SetActive(true)
  127. end
  128. self.name_tmp.text = HtmlColorTxt( " " .. self.data.name, "#a9c1e1")
  129. SetSizeDelta(self.name, self.name_tmp.preferredWidth + 5, self.name_tmp.preferredHeight)
  130. end
  131. function ChildChatNiceView:SetCallBack(callBack)
  132. self.callBack = callBack
  133. end
  134. function ChildChatNiceView:DestroySuccess( )
  135. if self.success_child_nice_id then
  136. self.model:UnBind(self.success_child_nice_id)
  137. self.success_child_nice_id = nil
  138. end
  139. if self.success_check_child_nice_id then
  140. self.model:UnBind(self.success_check_child_nice_id)
  141. self.success_check_child_nice_id = nil
  142. end
  143. if self.vipItem then
  144. self.vipItem:DeleteMe()
  145. self.vipItem = nil
  146. end
  147. if self.headItem then
  148. self.headItem:DeleteMe()
  149. self.headItem = nil
  150. end
  151. end