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

171 line
5.6 KiB

  1. SocialityFriendSelectItem = SocialityFriendSelectItem or BaseClass(BaseItem)
  2. function SocialityFriendSelectItem:__init()
  3. self.base_file = "sociality"
  4. self.layout_file = "SocialityFriendSelectItem"
  5. self.model = SocialityModel:getInstance()
  6. self:Load()
  7. end
  8. function SocialityFriendSelectItem:Load_callback()
  9. self.nodes = {
  10. "nameCon","headCon",
  11. "nameCon/name:tmp","heartText:tmp","heart:img",
  12. "nameCon/sex:img","vip",
  13. "chooseBtn:obj:img", "chooseBg:obj", "getFriendBtn:obj", "sendGiftBtn:obj", "emptyBlock:obj",
  14. }
  15. self:GetChildren(self.nodes)
  16. self.emptyBlock_obj:SetActive(false)
  17. self.roleItem = HeadRoleItem.New(self.headCon)
  18. self.roleItem:SetItemSize(70,70)
  19. self.vipItem = RoleVipItem.New(self.vip)
  20. self:InitEvent()
  21. if self.need_refreshData then
  22. self:SetData(self.info,self.index)
  23. self:SetSelected(self.is_selected)
  24. end
  25. end
  26. function SocialityFriendSelectItem:InitEvent()
  27. local on_click = function ( click_obj )
  28. if self.chooseBtn_obj == click_obj or self.chooseBg_obj == click_obj then
  29. self.model.need_show_operation = "none"--收回14010协议后既不打开互动面板,也不对送礼界面进行开闭
  30. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14010, self.info.role_id)
  31. self.model:Fire(SocialityModel.SELECT_FIREND, self.info, self.op_type)
  32. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FRIEND_SEL_VIEW, false)
  33. self.model.select_info = nil
  34. lua_resM:setImageSprite(self, self.chooseBtn_img, "sociality_asset","sociality_btn_accept")
  35. elseif self.getFriendBtn_obj == click_obj then
  36. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
  37. self.getFriendBtn_obj:SetActive(false)
  38. elseif self.sendGiftBtn_obj == click_obj then
  39. local role_vo = SocialityModel:getInstance():GetFriendData(self.info.role_id)
  40. role_vo.vip_flag = role_vo.vip --好友那边的vip_flag字段自动转化成vip了,会拿不到vip数据,要重新转换回来
  41. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, role_vo)
  42. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FRIEND_SEL_VIEW, false)
  43. end
  44. end
  45. AddClickEvent(self.chooseBtn_obj, on_click)
  46. AddClickEvent(self.chooseBg_obj, on_click)
  47. AddClickEvent(self.getFriendBtn_obj, on_click)
  48. AddClickEvent(self.sendGiftBtn_obj, on_click)
  49. end
  50. function SocialityFriendSelectItem:SetData(info,index,op_type)
  51. if not info or not info.sex then return end
  52. self.info = info
  53. self.index = index
  54. self.op_type = op_type or 1--点击类型,1为显示右侧按钮,2为不显示按钮,整个区域做点击热区
  55. if not self.is_loaded then
  56. self.need_refreshData = true
  57. return
  58. end
  59. self.need_refreshData = false
  60. if self.roleItem then
  61. local head_data = {
  62. vo = {
  63. id = info.role_id,
  64. server_id = info.ser_id,
  65. career = info.career,
  66. sex = info.sex,
  67. turn = info.turn,
  68. picture_ver = info.picture_ver,
  69. picture = info.picture,
  70. profile_photo_id = info.profile_photo_id,
  71. dress_board_id = info.dress_board,
  72. level = info.lv,
  73. empty_head = false, -- 是否是空数据头像
  74. }
  75. }
  76. self.roleItem:SetData(head_data)
  77. end
  78. local role_lv = WordManager:GetRoleLevel(info.lv,info.turn)
  79. -- self.level_tmp.text = role_lv
  80. self.vipItem:SetData(info.vip,info.sup_vip_type)
  81. if self.info.vip and self.info.vip > 0 then
  82. SetAnchoredPositionX(self.nameCon,36)
  83. else
  84. SetAnchoredPositionX(self.nameCon,-3)
  85. end
  86. self.name_tmp.text = info.role_name
  87. local sex_res = info.sex == 1 and "com_boy" or "com_girl"
  88. lua_resM:setImageSprite(self, self.sex_img, "common_asset", sex_res, true)
  89. SetAnchoredPositionX(self.sex,self.name_tmp.preferredWidth+4)
  90. local lv = self.model:GetLvByIntimacy(info.intimacy)
  91. local cfg = Config.Intimacylv[lv]
  92. if not self.model:IsRelaviveType(self.info.role_id, Config.ConfigSocial.RelativeType.friend)
  93. or self.model:IsOneWayToFriend(self.info.role_id) then
  94. if self.op_type == 1 then
  95. self.heartText_tmp.text = string.format("%s(临时好友)",info.intimacy)
  96. self.chooseBtn_obj:SetActive(true)
  97. self.getFriendBtn_obj:SetActive(false)
  98. elseif self.op_type == 2 then
  99. self.heartText_tmp.text = string.format("<color=#ff203a>%s(临时好友)</color>",info.intimacy)
  100. self.chooseBtn_obj:SetActive(false)
  101. self.getFriendBtn_obj:SetActive(true)
  102. end
  103. self.sendGiftBtn_obj:SetActive(false)
  104. else
  105. if self.op_type == 1 then
  106. self.heartText_tmp.text = string.format("%s(%s)",info.intimacy,Trim(cfg.name))
  107. elseif self.op_type == 2 then
  108. if info.intimacy >= MateModel:GetInstance():GetKeyValueConf("mate_intimacy") then
  109. self.heartText_tmp.text = string.format("%s(%s)",info.intimacy,Trim(cfg.name))
  110. self.chooseBtn_obj:SetActive(true)
  111. self.sendGiftBtn_obj:SetActive(false)
  112. else
  113. self.heartText_tmp.text = string.format("<color=#ff203a>%s(%s)</color>",info.intimacy,Trim(cfg.name))
  114. self.chooseBtn_obj:SetActive(false)
  115. self.sendGiftBtn_obj:SetActive(true)
  116. end
  117. end
  118. self.getFriendBtn_obj:SetActive(false)
  119. end
  120. lua_resM:setImageSprite(self, self.heart_img, "sociality_asset","sociality_intimacy_"..lv,true)
  121. -- self.chooseBtn_obj:SetActive(self.op_type == 1)
  122. -- self.chooseBg_obj:SetActive(self.op_type == 2)
  123. end
  124. function SocialityFriendSelectItem:SetSelected(bool)
  125. self.is_selected = bool
  126. if not self.is_loaded then return end
  127. -- if self.selectBg_obj then
  128. -- self.selectBg_obj:SetActive(bool)
  129. -- end
  130. if bool then
  131. self.model.select_info = self.info
  132. end
  133. end
  134. function SocialityFriendSelectItem:__delete( )
  135. if self.roleItem then
  136. self.roleItem:DeleteMe()
  137. self.roleItem = nil
  138. end
  139. if self.vipItem then
  140. self.vipItem:DeleteMe()
  141. self.vipItem = nil
  142. end
  143. end