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

1085 lines
40 KiB

  1. SocialityFriendView = SocialityFriendView or BaseClass(BaseItem)
  2. function SocialityFriendView:__init()
  3. self.base_file = "sociality"
  4. self.layout_file = "SocialityFriendView"
  5. self.model = SocialityModel:getInstance()
  6. self.chatModel = ChatModel:getInstance()
  7. self.scrollView_original_y = 0 --滚动面板最初的y值
  8. self.curr_channel = ChatModel.CHANNEL_CECRET --当前频道
  9. self.chating_key_id = 0 --当前正在私聊的玩家id 0表示没有正在私聊的玩家
  10. self.all_chatItem_list = {} --总的聊天显示列表
  11. self.cache_chatItem_list = {} --缓存聊天显示列表
  12. self.cur_index = 0--TabBtn的index
  13. self.cur_sub_index = 0--TabSubBtn的index
  14. self.second_index = 0 --选中的一项,用于刷新的时候选回之前的一项
  15. self.curr_channel_height = 0 --当前频道界面的高度 用于布局
  16. self.chatItem_prefab = nil
  17. self.event_list = {}
  18. self.send_limit = 50
  19. self:SetSendFormat(Config.ConfigChat.friendChannel)
  20. self.open_index = 1--Config.ConfigSocial.RelativeType.friend --默认打开界面时展示的标签
  21. self.is_reset_open_index = false
  22. self.model.friend_tab_index = 2--打开界面时候,默认展示“联系人”界面
  23. self.recent_cur_index = 0
  24. self.recent_cur_sub_index = 0
  25. --更新社交列表 提前绑定事件
  26. local function onUpdate( need_sel_last )
  27. if self.is_loaded then
  28. self.is_need_update_sociality_view = false
  29. self.need_sel_last = need_sel_last
  30. self:UpdateView(false, need_sel_last)
  31. else
  32. self.is_need_update_sociality_view = true
  33. end
  34. end
  35. self.list_event_id = self.model:Bind(SocialityModel.UPDATE_SOCIALITY_VIEW, onUpdate) --更新社交列表
  36. --从外部调用事件私聊其他人时,不等协议全部返回才刷新界面
  37. if not self.model.only_show_recent_view then
  38. self.model:Fire(SocialityModel.REQUEST_SOCIAL_LIST)
  39. else
  40. self.model.only_rqeuest_data = true--只请求数据,不在协议返回后立即刷新界面
  41. self.model:Fire(SocialityModel.REQUEST_SOCIAL_LIST)
  42. end
  43. self:Load()
  44. end
  45. function SocialityFriendView:Load_callback()
  46. self.input_con,
  47. self.voiceBtn,
  48. self.faceBtn,
  49. self.sendBtn,
  50. self.chatCon,
  51. self.tipCon,
  52. self.chatBg,
  53. self.contactsBtn,--联系人按钮
  54. self.recentlyBtn,--最近联系列表
  55. self.sendBtnBlock,--发送按钮的挡板
  56. self.recentlyRed,
  57. self.firstLabel,
  58. self.oneKeyGetBtn,
  59. self.oneKeySendBtn,
  60. self.oneKeyGetRed,
  61. self.oneKeySendRed
  62. = GetChildGameObjects(self.transform,
  63. {
  64. "chatCon/bottom_con/TextInput",
  65. "chatCon/bottom_con/voiceBtn",
  66. "chatCon/bottom_con/faceBtn",
  67. "chatCon/bottom_con/sendBtn",
  68. "chatCon",
  69. "tipCon",
  70. "chatMsgBg",
  71. "topBarCon/contactsBtn",
  72. "topBarCon/recentlyBtn",
  73. "chatCon/bottom_con/sendBtnBlock",
  74. "topBarCon/recentlyBtn/recentlyRed",
  75. "first_label",
  76. "oneKeyGetBtn",
  77. "oneKeySendBtn",
  78. "oneKeyGetBtn/oneKeyGetRed",
  79. "oneKeySendBtn/oneKeySendRed",
  80. })
  81. self.bottom_con,
  82. self.scroll_content,
  83. self.tabCon,
  84. self.friendMsgCon,
  85. self.assistantChatCon--小助手聊天三分栏
  86. = GetChildTransforms(self.transform,
  87. {
  88. "chatCon/bottom_con",
  89. "chatCon/ScrollView/Viewport/Content",
  90. "tabCon",
  91. "friendMsgCon",
  92. "assistantChatCon",
  93. })
  94. self.sendBtn_text = self:GetChild("chatCon/bottom_con/sendBtn/Text"):GetComponent("TextMeshProUGUI")
  95. self.tipLabel = self:GetChild("tipCon/tipLabel"):GetComponent("TextMeshProUGUI")
  96. self.recentTabTxt = self:GetChild("topBarCon/recentlyBtn/Text"):GetComponent("TextMeshProUGUI")
  97. self.contactsStr = self:GetChild("topBarCon/contactsBtn/Text"):GetComponent("TextMeshProUGUI")
  98. self.sendText = self:GetChild("chatCon/bottom_con/sendBtn/Text"):GetComponent("TextMeshProUGUI")
  99. self.contactsImg,--联系人按钮背景图
  100. self.recentlyImg,--最近按钮背景图
  101. self.friendListBg,
  102. self.chatMsgBg,
  103. self.chatBottomBg
  104. = GetChildImages(self.transform,
  105. {
  106. "topBarCon/contactsBtn",
  107. "topBarCon/recentlyBtn",
  108. "friendListBg",
  109. "chatMsgBg",
  110. "chatMsgBg/chatBottomBg",
  111. })
  112. self.input_text = self:GetChild("chatCon/bottom_con/TextInput"):GetComponent("InputField")
  113. self.ScrollView = self:GetChild("chatCon/ScrollView"):GetComponent("RectTransform")
  114. self.girlIcon = self:GetChild("tipCon/girlIcon"):GetComponent("RawImage")
  115. self.empty_talk_bg = self:GetChild("tipCon/Image"):GetComponent("RawImage")
  116. self.scrollView_original_y = self.ScrollView.anchoredPosition.y
  117. self.input_text.characterLimit = self.send_limit
  118. self.chatCon:SetActive(false)
  119. self.chatBg:SetActive(false)
  120. self.tipCon:SetActive(false)
  121. self.firstLabel:SetActive(false)
  122. -- self.transform.localPosition = Vector3.zero
  123. lua_resM:setOutsideImageSprite(self, self.friendListBg, GameResPath.GetSocialityImage("sociality_friend_list_bg"))
  124. lua_resM:setOutsideImageSprite(self, self.chatMsgBg, GameResPath.GetSocialityImage("sociality_chat_bg"))
  125. lua_resM:setOutsideImageSprite(self, self.chatBottomBg, GameResPath.GetSocialityImage("sociality_chat_bottom"))
  126. lua_resM:setOutsideRawImage(self, self.girlIcon, GameResPath.GetRoleBg("team_empty_bg_267_589"), false)
  127. lua_resM:setOutsideRawImage(self, self.empty_talk_bg, GameResPath.GetViewBigBg("com_empty_bg1"))
  128. self.sendBtnBlock:SetActive(false)
  129. self:InitEvent()
  130. if self.friend_msg_view == nil then
  131. self.friend_msg_view = SocialityFriendMsg.New(self.friendMsgCon)
  132. end
  133. self.friend_msg_view:SetVisible(false)
  134. if self.assistan_chat_bar == nil then
  135. self.assistan_chat_bar = SocialityAssistanChatBar.New(self.assistantChatCon)
  136. end
  137. self.assistan_chat_bar:SetVisible(false)
  138. self:LoadChatItemPrefab()
  139. if self.is_need_update_sociality_view then
  140. self:UpdateView(false, self.need_sel_last)
  141. end
  142. end
  143. function SocialityFriendView:LoadChatItemPrefab()
  144. local function call_back(objs)
  145. if self._use_delete_method then
  146. return
  147. end
  148. self.chatItem_prefab = objs[0]
  149. -- self:UpdateView(true)
  150. -- self:UpdateView(false, self.need_sel_last)
  151. --正常打开好友界面时等协议返回再updateview,从外部私聊时,先updateview
  152. if self.model.only_show_recent_view then
  153. self:UpdateView()
  154. else
  155. self:UpdateView(false,false,true)
  156. end
  157. self.model.only_show_recent_view = false
  158. end
  159. lua_resM:loadPrefabs(self, "chat", {"chatItem"}, call_back)
  160. end
  161. function SocialityFriendView:InitEvent( )
  162. local function onClickBtnHandler(target)
  163. if target == self.faceBtn then
  164. GlobalEventSystem:Fire(EventName.OPEN_INDIVIDUATION_VIEW,self.chatModel.curr_individuation_bar_index,-192,-270, true, self.chating_key_id,true)
  165. elseif target == self.sendBtn then
  166. GlobalEventSystem:Fire(EventName.CLOSE_INDIVIDUATION_VIEW)
  167. self:SendMsg()
  168. elseif target == self.posBtn then
  169. -- 仇人不能聊天
  170. local is_enemy = self.model:IsRelaviveType(self.chating_key_id, Config.ConfigSocial.RelativeType.enemy)
  171. if is_enemy then
  172. Message.show("仇人不能聊天")
  173. self.input_text.text = ""
  174. return
  175. end
  176. local use_index = self.model.friend_tab_index == 1 and self.recent_cur_index or self.cur_index
  177. local use_sub_index = self.model.friend_tab_index == 1 and self.recent_cur_sub_index or self.cur_sub_index
  178. local vo = self.model:GetInfoByIndex(use_index, use_sub_index)
  179. -- if vo and vo.online_flag~=1 then
  180. -- Message.show("对方不在线")
  181. -- return
  182. -- end
  183. --跳跃中不能发坐标,障碍点也不能发
  184. if Scene.Instance.main_role:IsInState(PoseState.JUMP) or Scene.Instance.main_role:IsInState(PoseState.FLY) then return end
  185. --发送坐标 用超链接的方法
  186. local role = Scene.Instance:GetMainRole()
  187. if not role then return end
  188. local scene_id = SceneManager:getInstance():GetSceneId()
  189. local line = MapModel:getInstance():GetServerLine()
  190. local x = role.logic_pos.x
  191. local y = role.logic_pos.y
  192. if not SceneManager:getInstance():IsBlockXY(x , y) then
  193. local scene_name = SceneManager:getInstance():GetSceneInfo(scene_id).name
  194. local content = string.format("<a@pos@%s@%s@%s@%s><color=%s><u>%s,%d,%d</u></color></a>", scene_id, line, role.real_pos.x, role.real_pos.y, "#2cf89a", scene_name, x, y)
  195. local tmpArgs = ChatModel:getInstance():GetAllArgsText(content)
  196. content = ChatModel:getInstance():GetHyperlinkText(content)
  197. ChatModel:getInstance():Fire(ChatModel.SEND_MSG,self.curr_channel,content,self.chating_key_id,tmpArgs,ChatModel.CHAT_COMMON_TYPE.COMMON)
  198. end
  199. elseif target == self.contactsBtn then--联系人按钮
  200. --切换到联系人页签时,会加载到上次在联系人界面时候的历史位置(打开socialityview时默认加载第一个位置)
  201. if self.model.friend_tab_index ==2 then return end--已经是当前页签时候就不再刷新界面了
  202. self.model.friend_tab_index = 2
  203. self.model.special_flag_change_tab = true--特殊标记:切换页签时防止好友列表遍历setselected时选中其他好友
  204. self:UpdateView()
  205. self.model:Fire(SocialityModel.REFRESH_SUB_BTN_RED)
  206. elseif target == self.recentlyBtn then--最近联系按钮
  207. if self.model.friend_tab_index ==1 then return end--已经是当前页签时候就不再刷新界面了
  208. self.model.friend_tab_index = 1
  209. self.model.special_flag_change_tab = true--特殊标记:切换页签时防止好友列表遍历setselected时选中其他好友
  210. self.model.only_request_recent_flag = true--标识:只请求最近联系人列表
  211. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 5)--请求最近联系人
  212. elseif target == self.oneKeyGetBtn then--一键领取票券
  213. local id_list = self.model:GetCanGetTicketFriendIdList()
  214. if #id_list == 0 then
  215. Message.show("暂无交易券可领")
  216. else
  217. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14023)
  218. end
  219. elseif target == self.oneKeySendBtn then--一键赠送票券
  220. local id_list,special_flag = self.model:GetCanSendTicketFriendIdList()
  221. if special_flag then
  222. Message.show("已达到赠送次数限制")
  223. else
  224. if #id_list == 0 then
  225. Message.show("暂无好友可赠送")
  226. else
  227. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14022, id_list)
  228. end
  229. end
  230. end
  231. end
  232. AddClickEvent(self.faceBtn,onClickBtnHandler,2)
  233. AddClickEvent(self.sendBtn,onClickBtnHandler,2)
  234. AddClickEvent(self.applyBtn,onClickBtnHandler,2)
  235. AddClickEvent(self.addBtn,onClickBtnHandler,2)
  236. AddClickEvent(self.flowerBtn,onClickBtnHandler,LuaSoundManager.SOUND_UI.NONE)
  237. AddClickEvent(self.contactsBtn,onClickBtnHandler,2)
  238. AddClickEvent(self.recentlyBtn,onClickBtnHandler,2)
  239. AddClickEvent(self.oneKeyGetBtn,onClickBtnHandler,2)
  240. AddClickEvent(self.oneKeySendBtn,onClickBtnHandler,2)
  241. local function onUpdateRecentView()
  242. self:UpdateView()
  243. self.model:Fire(SocialityModel.REFRESH_SUB_BTN_RED)
  244. end
  245. self:BindEvent(self.model,SocialityModel.UPDATE_SOCIALITY_RECENT_VIEW,onUpdateRecentView)
  246. local function onSelectFaceItemHandler(item)
  247. if item then
  248. local face_str = "<#f_"..(item.index - 1)..">"
  249. if #self.input_text.text + #face_str <= self.input_text.characterLimit and self.input_text.characterLimit ~= 0 then
  250. self.input_text.text = self.input_text.text .. face_str
  251. end
  252. end
  253. end
  254. self.select_faceItem_id = self.chatModel:Bind(ChatModel.SELECT_FACE_ITEM,onSelectFaceItemHandler)
  255. local function onSelectTextFaceItemHandler(item)
  256. if item then
  257. if self.chatModel.clicked_role_item == nil then
  258. self.input_text.text = string.gsub(item.vo.one,"#N",RoleManager.Instance:GetMainRoleVo().name)
  259. else
  260. self.input_text.text = string.gsub(item.vo.two,"#n",self.chatModel.clicked_role_item.info.name)
  261. self.input_text.text = string.gsub(self.input_text.text,"#N",RoleManager.Instance:GetMainRoleVo().name)
  262. end
  263. end
  264. end
  265. self.select_textFaceItem_id = self.chatModel:Bind(ChatModel.SELECT_TEXT_FACE_ITEM,onSelectTextFaceItemHandler)
  266. local function onSelectHistoryTextItemHandler(str)
  267. self.input_text.text = str
  268. end
  269. table.insert(self.event_list, self.chatModel:Bind(ChatModel.SELECT_HISTORY_TEXT_ITEM, onSelectHistoryTextItemHandler))
  270. local function onClickPosBtnHandler(content, show_str)
  271. self.click_pos_content = content
  272. self.click_pos_show_str = show_str
  273. self.input_text.text = show_str
  274. end
  275. table.insert(self.event_list, self.chatModel:Bind(ChatModel.CLICK_POS_BTN, onClickPosBtnHandler))
  276. local function onSelectGoodItemHandler(goodVo)
  277. -- if goodVo then
  278. -- local content = nil
  279. -- if goodVo.type == GoodsModel.TYPE.EQUIP then
  280. -- content = string.format("<a@goods4@%s@%s@%s></a>", goodVo.type_id, goodVo.goods_id, RoleManager.Instance:GetMainRoleId())
  281. -- else
  282. -- content = string.format("<a@goods4@%s></a>", goodVo.type_id)
  283. -- end
  284. -- local args = string.format("{goods,%s,%s}", goodVo.type_id, goodVo.goods_id)
  285. -- local str = "<" .. Trim(goodVo.goods_name) .. ">"
  286. -- if goodVo.type == 11 and (goodVo.subtype == 10 or goodVo.subtype == 11) then
  287. -- local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(goodVo.type_id, RoleManager.Instance.mainRoleInfo.career, goodVo.color, true)
  288. -- str = "<" .. _name .. ">"
  289. -- end
  290. -- self:ReplaceInputTextMark(str)
  291. -- self.chatModel:AddArgs(str, {args, content})
  292. -- -- self.model.curr_chat_args = "{goods,"..goodVo.type_id..","..goodVo.goods_id.."}"
  293. -- end
  294. if goodVo then
  295. local content = nil
  296. local em_power_lv = 0
  297. if goodVo.type == GoodsModel.TYPE.EQUIP then
  298. content = string.format("<a@goods2@%s@%s@%s></a>", RoleManager.Instance:GetMainRoleId(),goodVo.goods_id, goodVo.type_id)
  299. if goodVo then
  300. for i,v in pairs(goodVo.other_data) do
  301. if v.type == GoodsModel.GoodsInfoType.EquipEmpower then
  302. em_power_lv = tonumber(v.info)
  303. break
  304. end
  305. end
  306. if em_power_lv == 0 and EquipModel:getInstance():IsWearEquip(goodVo.goods_id) then--如果是已穿戴
  307. local equip_cfg = EquipModel:getInstance():GetEquipmentCfg(goodVo.type_id)
  308. if equip_cfg and equip_cfg.series ~= 99 then
  309. local server_info = EquipModel:getInstance():GetRedEquipInfo(equip_cfg.series,equip_cfg.equip_type)
  310. em_power_lv = server_info and server_info.lv or 0
  311. end
  312. end
  313. if em_power_lv > 0 then
  314. content = string.format("<a@goods2@%s@%s@%s@%s></a>", RoleManager.Instance:GetMainRoleId(),goodVo.goods_id, goodVo.type_id,em_power_lv)
  315. end
  316. end
  317. else
  318. content = string.format("<a@goods4@%s></a>", goodVo.type_id)
  319. end
  320. local args = string.format("{goods,%s,%s}", goodVo.type_id, goodVo.goods_id)
  321. local str = "<" .. Trim(goodVo.goods_name) .. ">"
  322. if goodVo.type == 11 and (goodVo.subtype == 10 or goodVo.subtype == 11) then
  323. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(goodVo.type_id, RoleManager.Instance.mainRoleInfo.career, goodVo.color, true)
  324. str = "<" .. _name .. ">"
  325. end
  326. self:ReplaceInputTextMark(str)
  327. self.chatModel:AddArgs(str, {args, content})
  328. -- self.model.curr_chat_args = "{goods,"..goodVo.type_id..","..goodVo.goods_id.."}"
  329. end
  330. end
  331. self.select_goodItem_id = self.chatModel:Bind(ChatModel.SELECT_GOOD_ITEM, onSelectGoodItemHandler)
  332. local function onSendMsg( str )
  333. self.input_text.text = str
  334. self:SendMsg()
  335. end
  336. self.send_event_id = self.chatModel:Bind(ChatModel.SEND_MSG_IN_VIEW, onSendMsg)
  337. local function onAddMsgHandler(info)
  338. if info and info.channel and info.channel == self.curr_channel then
  339. self:AddMsgItem(info,true)
  340. self.firstLabel:SetActive(false)
  341. -- --保存聊天记录
  342. -- CookieWrapper.Instance:WriteChatHistroy()
  343. end
  344. end
  345. self.add_msg_id = self.chatModel:Bind(ChatModel.ADD_NEW_MSG,onAddMsgHandler)
  346. GlobalEventSystem:Fire(EventName.ADD_RECORD_BTN,self.voiceBtn,{channel = ChatModel.CHANNEL_CECRET, rect = {x = 401,y = 33, w = 397, h = 58}, dis = 60})
  347. local function onBoardCast( scmd )
  348. local offset = 0
  349. local curr_channel_list = self.all_chatItem_list[self.chatModel.curr_channel]
  350. if not curr_channel_list then return end
  351. for k,v in pairs(curr_channel_list) do
  352. if offset ~= 0 then
  353. v:ReLayout(offset)
  354. else
  355. if v.info.voice_id == scmd.auto_id then
  356. offset = -v:SetRegText(scmd)
  357. end
  358. end
  359. end
  360. self.curr_channel_height = self.curr_channel_height + offset
  361. end
  362. self.bind_update_reg_text = self.chatModel:Bind(ChatModel.BROADCAST_VOICE_TEXT, onBoardCast)
  363. -- local function onUpdate( need_sel_last )
  364. -- if self.is_loaded then
  365. -- self.is_need_update_sociality_view = false
  366. -- self.need_sel_last = need_sel_last
  367. -- self:UpdateView(false, need_sel_last)
  368. -- else
  369. -- self.is_need_update_sociality_view = true
  370. -- end
  371. -- end
  372. -- self.list_event_id = self.model:Bind(SocialityModel.UPDATE_SOCIALITY_VIEW, onUpdate) --更新社交列表
  373. local onRed = function ( )
  374. -- self:RefreshRed()--主界面的申请、送花红点
  375. self:RefreshRed()
  376. end
  377. self.social_event_id = GlobalEventSystem:Bind(EventName.REFRESH_SOCIAL_RED_DOT, onRed)
  378. -- local onSelect = function ( )
  379. -- --需要打开私聊对象
  380. -- if ChatModel:getInstance().need_chat_key then
  381. -- local index, sub_index = self.model:GetIndexByChatKey(ChatModel:getInstance().need_chat_key)
  382. -- if index and sub_index then
  383. -- self.verTabBar:SetSelectTab(index, sub_index, true)
  384. -- end
  385. -- ChatModel:getInstance().need_chat_key = nil
  386. -- end
  387. -- end
  388. -- self.sel_event_id = GlobalEventSystem:Bind(EventName.SOCIAL_CHAT_SEL, onSelect)
  389. --打开聊天界面上方的好友信息栏
  390. local function UpdateFriendMsgView( data )
  391. if not data then return end
  392. if self.friend_msg_view then
  393. local is_black = self.model:IsRelaviveType(data.role_id, Config.ConfigSocial.RelativeType.black)
  394. if is_black then
  395. self.friend_msg_view:SetVisible(false)
  396. else
  397. self.friend_msg_view:SetVisible(true)
  398. end
  399. self.friend_msg_view:SetData(data)
  400. end
  401. end
  402. self.friend_msg_event_id = self.model:Bind(SocialityModel.OPEN_FRIEND_MSG_VIEW, UpdateFriendMsgView)
  403. local function onUpdateSendTime()
  404. self:UpdateSendTime()
  405. end
  406. self:BindEvent(ChatModel:getInstance(),ChatModel.UPDATE_SEND_TIME,onUpdateSendTime)
  407. local function onUpdateScrollViewSize(is_one_way)
  408. if is_one_way then
  409. self.ScrollView.anchoredPosition = Vector3(self.ScrollView.anchoredPosition.x,305,self.ScrollView.anchoredPosition.z)
  410. self.ScrollView.sizeDelta = Vector2(650,450)
  411. else
  412. self.ScrollView.anchoredPosition = Vector3(self.ScrollView.anchoredPosition.x,self.scrollView_original_y,self.ScrollView.anchoredPosition.z)
  413. self.ScrollView.sizeDelta = Vector2(650,500)
  414. end
  415. end
  416. self:BindEvent(self.model,SocialityModel.UPDATE_ONE_WAY_SCROLL_VIEW_SIZE,onUpdateScrollViewSize)
  417. end
  418. function SocialityFriendView:SetVisible( bool )
  419. BaseItem.SetVisible(self, bool)
  420. if bool and self.is_loaded then
  421. GlobalEventSystem:Fire(EventName.ADD_RECORD_BTN,self.voiceBtn,{channel = ChatModel.CHANNEL_CECRET, rect = {x = 401,y = 33, w = 397, h = 58}, dis = 60})
  422. end
  423. end
  424. function SocialityFriendView:RefreshRed( )
  425. self:RefreshTopBarRed()
  426. self:RefreshOneKeyTicketRed()
  427. end
  428. --根据“最近”、“联系人”页签来获取tabdata
  429. function SocialityFriendView:GetFriendListDataByTabIndex()
  430. local contactsAb = self.model.friend_tab_index == 1 and "uiComponent_asset" or "sociality_asset"
  431. local contactsStr = self.model.friend_tab_index == 1 and "com_empty" or "sociality_tab_on"
  432. local recentlyAb = self.model.friend_tab_index == 1 and "sociality_asset" or "uiComponent_asset"
  433. local recentlyStr = self.model.friend_tab_index == 1 and "sociality_tab_on" or "com_empty"
  434. lua_resM:setImageSprite(self, self.contactsImg, contactsAb, contactsStr)
  435. lua_resM:setImageSprite(self, self.recentlyImg, recentlyAb, recentlyStr)
  436. self.contactsStr.text = self.model.friend_tab_index == 2 and "<color=#ffffff>联系人</color>" or "<color=#9eb3cf>联系人</color>"
  437. self.recentTabTxt.text = self.model.friend_tab_index == 2 and "<color=#9eb3cf>最近</color>" or "<color=#ffffff>最近</color>"
  438. local contactsMat = self.model.friend_tab_index == 2 and ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab or ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault
  439. local recentTabMat = self.model.friend_tab_index == 2 and ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault or ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab
  440. SetTMPSharedMaterial(self.contactsStr, contactsMat)
  441. SetTMPSharedMaterial(self.recentTabTxt, recentTabMat)
  442. if self.model.friend_tab_index == 1 then
  443. self.tab_data = self.model:GetRecentFriendTabData()
  444. else
  445. self.tab_data = self.model:GetFriendTabData()
  446. end
  447. end
  448. function SocialityFriendView:UpdateView( show, need_sel_last,do_not_reset_chat_key)
  449. self.need_cecret_chat = ChatModel:getInstance().need_chat_key
  450. --先判断一次是不是有人私聊,如果有,界面打开时需要切换到最近页签
  451. if self.need_cecret_chat then
  452. self.model.friend_tab_index = 1
  453. end
  454. --判断页签,并使用相应的下标
  455. local use_index = self.model.friend_tab_index == 1 and self.recent_cur_index or self.cur_index
  456. local use_sub_index = self.model.friend_tab_index == 1 and self.recent_cur_sub_index or self.cur_sub_index
  457. if self.model.friend_tab_index == 1 then
  458. need_sel_last = false
  459. end
  460. self:GetFriendListDataByTabIndex()--根据页签获取到相应的好友列表数据
  461. self:ReLayoutScroll()
  462. --创建好友列表TabBar
  463. if not self.verTabBar then
  464. self.verTabBar = SocialityTabBar.New(self.tabCon)
  465. end
  466. local call_back = function (index, sub_index)
  467. self:SwitchView(index, sub_index)
  468. end
  469. local call_back2 = function (index)
  470. self.second_index = index
  471. end
  472. self.verTabBar:SetTabBars(self.tab_data, call_back, false, call_back2)
  473. self.model.special_flag_change_tab = false
  474. self.model.special_flag_online_changed = false
  475. if show then return end --只是展示列表 不要往下执行, 等协议返回再执行
  476. if self.need_cecret_chat then--需要打开私聊对象
  477. local index, sub_index
  478. if self.model.friend_tab_index == 1 then
  479. index, sub_index = self.model:GetRecentListIndex(self.need_cecret_chat)
  480. else
  481. index, sub_index = self.model:GetIndexByChatKey(self.need_cecret_chat)
  482. end
  483. if index and sub_index then
  484. self.verTabBar:SetSelectTab(index, sub_index, true)
  485. end
  486. --预加载的updateview不要重置私聊id
  487. if not do_not_reset_chat_key then
  488. ChatModel:getInstance().need_chat_key = nil
  489. self.need_cecret_chat = nil
  490. end
  491. if self.model.has_private_chat then
  492. self.model.has_private_chat = false
  493. -- if MsgManager:getInstance():IsMsgTypeShow(Config.ConfigMainIcon.TipType.private_chat) then
  494. -- MsgManager:getInstance():Remove(Config.ConfigMainIcon.TipType.private_chat)
  495. -- end --WQ:暂时不需要主界面的私聊图标
  496. end
  497. return
  498. elseif need_sel_last and use_index~=0 then
  499. -- self.verTabBar:SetNewData(use_index)
  500. local index, sub_index = self.model:GetIndexByChatKey(self.chating_key_id)
  501. if index and sub_index then
  502. self.verTabBar:SetSelectTab(index, sub_index, true)
  503. end
  504. return
  505. else
  506. if use_index == 0 and use_sub_index == 0 then --历史记录为(0,0)时直接打开(1,1)位置
  507. self.verTabBar:SetSelectTab(1, 1, true)
  508. use_index = 1--强行打开指定位置后,临时下标变量use_index等也要手动变化,因为当前函数后面还将用到
  509. use_sub_index = 1
  510. elseif use_index ~= 0 and use_sub_index ~= 0 then --当历史记录存在时,直接打开历史位置
  511. self.verTabBar:SetSelectTab(use_index, use_sub_index, true)
  512. elseif self.second_index~=0 then
  513. self.verTabBar:SetSelectTab(self.second_index, 1, true)
  514. elseif self.open_index then
  515. self.verTabBar:SetSelectTab(self.open_index,1,true)
  516. self.open_index = nil
  517. self.is_reset_open_index = true
  518. else
  519. self.firstLabel:SetActive(false)
  520. self.chatCon:SetActive(false)
  521. self.chatBg:SetActive(false)
  522. self.friend_msg_view:SetVisible(false)
  523. self.tipCon:SetActive(true)
  524. end
  525. end
  526. if self.is_reset_open_index then return end
  527. -- if use_index == 0 then
  528. -- self.verTabBar:SetNewData(self.second_index)
  529. -- else
  530. -- self.verTabBar:SetNewData(use_index)
  531. -- end
  532. self.is_reset_open_index = false
  533. end
  534. function SocialityFriendView:__delete( )
  535. GlobalEventSystem:Fire(EventName.CLOSE_INDIVIDUATION_VIEW)
  536. GlobalEventSystem:Fire(EventName.REMOVE_RECORD_BTN,self.voiceBtn)
  537. if self.select_faceItem_id then
  538. self.chatModel:UnBind(self.select_faceItem_id)
  539. self.select_faceItem_id = nil
  540. end
  541. if self.select_textFaceItem_id then
  542. self.chatModel:UnBind(self.select_textFaceItem_id)
  543. self.select_textFaceItem_id = nil
  544. end
  545. if self.send_event_id then
  546. self.chatModel:UnBind(self.send_event_id)
  547. self.send_event_id = nil
  548. end
  549. if self.list_event_id then
  550. self.model:UnBind(self.list_event_id)
  551. self.list_event_id = nil
  552. end
  553. if self.add_msg_id then
  554. self.chatModel:UnBind(self.add_msg_id)
  555. self.add_msg_id = nil
  556. end
  557. if self.social_event_id then
  558. GlobalEventSystem:UnBind(self.social_event_id)
  559. self.social_event_id = nil
  560. end
  561. for channel,list in pairs(self.all_chatItem_list) do
  562. for i,item in pairs(list) do
  563. item:DeleteMe()
  564. item = nil
  565. end
  566. list = nil
  567. end
  568. if self.verTabBar then
  569. self.verTabBar:DestroyBtnList()
  570. self.verTabBar:DeleteMe()
  571. self.verTabBar = nil
  572. end
  573. for i,item in pairs(self.cache_chatItem_list) do
  574. item:DeleteMe()
  575. item = nil
  576. end
  577. for i, v in ipairs(self.event_list) do
  578. self.chatModel:UnBind(v)
  579. v = nil
  580. end
  581. self.event_list = nil
  582. if self.friend_msg_event_id then
  583. self.model:UnBind(self.friend_msg_event_id)
  584. self.friend_msg_event_id = nil
  585. end
  586. if self.friend_msg_view then
  587. self.friend_msg_view:DeleteMe()
  588. self.friend_msg_view = nil
  589. end
  590. if self.assistan_chat_bar then
  591. self.assistan_chat_bar:DeleteMe()
  592. self.assistan_chat_bar = nil
  593. end
  594. if self.send_timer_id then
  595. GlobalTimerQuest:CancelQuest(self.send_timer_id)
  596. self.send_timer_id = nil
  597. end
  598. self.cache_chatItem_list = {}
  599. self.all_chatItem_list = {}
  600. self.chating_key_id = 0
  601. self.chatModel.chating_key_id = 0
  602. self.chatItem_prefab = nil
  603. if self.delay_show_assist_msg then
  604. TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_assist_msg)
  605. self.delay_show_assist_msg = nil
  606. end
  607. --保存聊天记录
  608. CookieWrapper.Instance:WriteChatHistroy()
  609. end
  610. function SocialityFriendView:SendMsg()
  611. local use_index = self.model.friend_tab_index == 1 and self.recent_cur_index or self.cur_index
  612. local use_sub_index = self.model.friend_tab_index == 1 and self.recent_cur_sub_index or self.cur_sub_index
  613. -- 黑名单不能聊天
  614. local is_black = self.model:IsRelaviveType(self.chating_key_id, Config.ConfigSocial.RelativeType.black)
  615. if is_black then
  616. Message.show("不能向黑名单发送消息")
  617. self.input_text.text = ""
  618. return
  619. end
  620. --对方是否在线(WQ暂时先不要离线禁止私聊的逻辑)
  621. -- local vo = self.model:GetInfoByIndex(use_index, use_sub_index)
  622. -- if vo and vo.online_flag~=1 then
  623. -- Message.show("对方不在线")
  624. -- self.input_text.text = ""
  625. -- return
  626. -- end
  627. if self.chatModel:CheckCurrentTimeCanSend(channel,self.send_interval) then
  628. local content = self.input_text.text
  629. local _, title_filter = LanguageFilter.FilterMsg(content)
  630. if title_filter == false then
  631. Message.show("内容有敏感词")
  632. return
  633. end
  634. if not CheatModel:getInstance():CheckCommand(content) then
  635. return
  636. end
  637. if self.input_text.text == "@##@" then
  638. GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW) --秘籍
  639. return
  640. elseif self.input_text.text == "@testclient" then
  641. GlobalEventSystem:Fire(EventName.OPEN_CHEAT_CLIENT_VIEW) --客户端秘籍
  642. return
  643. end
  644. if content and content ~= "" then
  645. if self.click_pos_content then
  646. if Trim(self.click_pos_show_str) == Trim(content) then
  647. content = self.click_pos_content
  648. self.click_pos_content = false
  649. end
  650. end
  651. local tmpArgs = self.chatModel:GetAllArgsText(content)
  652. content = self.chatModel:GetHyperlinkText(content)
  653. self.chatModel:Fire(ChatModel.SEND_MSG,self.curr_channel,content,self.chating_key_id,tmpArgs,ChatModel.CHAT_COMMON_TYPE.COMMON)
  654. self.input_text.text = ""
  655. self.chatModel.chat_args_dic = {}
  656. --判断私聊是否可以完成羁绊日常任务
  657. local mate_daily_need_chat_role_list = MateModel:GetInstance():GetMateDailyTaskNeedChatData()
  658. if mate_daily_need_chat_role_list and mate_daily_need_chat_role_list[self.chating_key_id] then
  659. MateModel:GetInstance():Fire(MateConst.PROTO_CCMD_EVENT,14956,1,self.chating_key_id)
  660. mate_daily_need_chat_role_list[self.chating_key_id] = nil
  661. end
  662. end
  663. else
  664. if self.input_text.text ~= "" then
  665. Message.show("发送频率过快,请销后再试...")
  666. end
  667. end
  668. end
  669. --设置发送的格式
  670. function SocialityFriendView:SetSendFormat(info)
  671. self.send_interval = info.send_interval
  672. self.send_limit = info.send_limit
  673. end
  674. function SocialityFriendView:ReplaceInputTextMark(str)
  675. --替换规则是"(<.->)"
  676. local text = self.input_text.text
  677. local old_args = self.chatModel:IsHasArgs(text)
  678. if (string.find(text,"(<.->)") and old_args) then
  679. old_args = LanguageFilter.ConvPartten(old_args)
  680. self.input_text.text = string.gsub(text,old_args,str)
  681. else
  682. self.input_text.text = text .. str
  683. end
  684. return str
  685. end
  686. --重新布局滚动条大小 以及位置
  687. function SocialityFriendView:ReLayoutScroll()
  688. local is_one_way = self.model:IsRelaviveType(self.chating_key_id,Config.ConfigSocial.RelativeType.oneWay)
  689. if is_one_way then
  690. self.ScrollView.anchoredPosition = Vector3(self.ScrollView.anchoredPosition.x,305,self.ScrollView.anchoredPosition.z)
  691. self.ScrollView.sizeDelta = Vector2(650,450)
  692. else
  693. self.ScrollView.anchoredPosition = Vector3(self.ScrollView.anchoredPosition.x,self.scrollView_original_y,self.ScrollView.anchoredPosition.z)
  694. self.ScrollView.sizeDelta = Vector2(650,500)
  695. end
  696. self.scroll_content.sizeDelta = Vector2(702,self.curr_channel_height+10)
  697. local off_h = self.scroll_content.sizeDelta.y - self.ScrollView.sizeDelta.y
  698. off_h = off_h < 0 and 0 or off_h
  699. self.scroll_content.localPosition = Vector3(0,off_h,0)
  700. end
  701. --添加一个聊天信息 autoLayout是否自动布局
  702. function SocialityFriendView:AddMsgItem(info,autoLayout)
  703. -- self.firstLabel:SetActive(false)
  704. if self.curr_channel ~= info.channel or info.key_id~=self.chating_key_id then return end
  705. if self.pre_renderer_chatItem and not self.pre_renderer_chatItem:IsLineItem() then
  706. local time_off = info.time - self.pre_renderer_chatItem.info.time
  707. if time_off >= ChatModel.SHOW_LINE_TIME then --说话间隔大于该时间 就要添加横线时间
  708. self.pre_renderer_chatItem = nil
  709. local lineInfo = self.chatModel:PackChatInfo(self.curr_channel,info.time,info.key_id)
  710. self:AddMsgItem(lineInfo,true)
  711. end
  712. end
  713. local curr_channel_list = nil
  714. curr_channel_list = self.all_chatItem_list[self.curr_channel] -- 取出当前频道的消息列表
  715. if curr_channel_list == nil then --如果没有就创建一个空表出来
  716. curr_channel_list = {}
  717. self.all_chatItem_list[self.curr_channel] = curr_channel_list
  718. end
  719. --超过长度放入缓存列表
  720. if #curr_channel_list >= ChatModel.MAX_LEN_LIST[self.curr_channel] then
  721. local item = table.remove(curr_channel_list,1)
  722. item:SetVisible(false)
  723. table.insert(self.cache_chatItem_list,item)
  724. local item_height = item:GetHeight()
  725. for i = 1, #curr_channel_list do
  726. item = curr_channel_list[i]
  727. item:ReLayout(item_height)
  728. end
  729. self.curr_channel_height = self.curr_channel_height - item_height
  730. end
  731. --检查缓存
  732. local new_item
  733. if #self.cache_chatItem_list > 0 then
  734. new_item = table.remove(self.cache_chatItem_list,1)
  735. else
  736. new_item = ChatItem.New(self.scroll_content, self.chatItem_prefab, nil, nil, true)
  737. end
  738. self.curr_channel_height = self.curr_channel_height + new_item:SetData(info,self.curr_channel_height) or 0
  739. table.insert(curr_channel_list,new_item)
  740. if new_item:IsLineItem() then
  741. new_item:SetLineTimeColor(ColorType.WHITE)
  742. new_item:SetLineSize(560, 192)
  743. end
  744. if autoLayout then
  745. self:ReLayoutScroll()
  746. end
  747. self.pre_renderer_chatItem = new_item
  748. new_item.transform.sizeDelta = Vector2(575, new_item.height)
  749. end
  750. function SocialityFriendView:UpdateSendTime()
  751. local time = self:SetSendTimeText()
  752. if time > 0 then
  753. if self.send_timer_id then
  754. GlobalTimerQuest:CancelQuest(self.send_timer_id)
  755. self.send_timer_id = nil
  756. end
  757. local function onSendTimerPlaying()
  758. self:SetSendTimeText()
  759. end
  760. self.send_timer_id = GlobalTimerQuest:AddPeriodQuest(onSendTimerPlaying,1,-1)
  761. end
  762. end
  763. function SocialityFriendView:SetSendTimeText()
  764. if self._use_delete_method then return end
  765. -- local time = self.chatModel:GetPassTimeFromSend(ChatModel.CHANNEL_CECRET,Config.ConfigChat.channel_level[4].send_interval)
  766. local time = self.chatModel:GetPassTimeFromSend(ChatModel.CHANNEL_CECRET,3)
  767. if time > 0 then
  768. local str = math.ceil(time) .. "s"
  769. self.sendText.text = str
  770. self.sendBtnBlock:SetActive(true)
  771. else
  772. self:CancelSendTimer()
  773. self.sendText.text = "发送"
  774. self.sendBtnBlock:SetActive(false)
  775. end
  776. return time
  777. end
  778. function SocialityFriendView:CancelSendTimer( )
  779. if self.send_timer_id then
  780. GlobalTimerQuest:CancelQuest(self.send_timer_id)
  781. self.send_timer_id = nil
  782. end
  783. end
  784. function SocialityFriendView:SwitchView(index, sub_index)
  785. -------- 先处理和小助手聊天的情况
  786. local is_assistant = (self.model.friend_tab_index == 1 and index == 1 and sub_index == 1) or (self.model.friend_tab_index == 2 and index == 1 and sub_index == 1)
  787. if is_assistant then
  788. self.friend_msg_view:HideBtnCon(false)
  789. self.assistan_chat_bar:SetVisible(true)
  790. self.bottom_con.gameObject:SetActive(false)
  791. self.chatBottomBg.gameObject:SetActive(false)
  792. else
  793. self.friend_msg_view:HideBtnCon(true)
  794. self.assistan_chat_bar:SetVisible(false)
  795. self.bottom_con.gameObject:SetActive(true)
  796. self.chatBottomBg.gameObject:SetActive(true)
  797. end
  798. --------
  799. local vo = self.model:GetInfoByIndex(index, sub_index) -- 拿到好友信息
  800. if vo then
  801. self.chating_key_id = vo.role_id
  802. self.chatModel.chating_key_id = vo.role_id
  803. if self.model.friend_tab_index == 2 then
  804. self.cur_index = index
  805. self.cur_sub_index = sub_index
  806. else
  807. self.recent_cur_index = index
  808. self.recent_cur_sub_index = sub_index
  809. end
  810. local use_index = self.model.friend_tab_index == 1 and self.recent_cur_index or self.cur_index
  811. local use_sub_index = self.model.friend_tab_index == 1 and self.recent_cur_sub_index or self.cur_sub_index
  812. if index==3 then
  813. self.chatCon:SetActive(false)
  814. self.chatBg:SetActive(false)
  815. self.friend_msg_view:SetVisible(false)
  816. self.tipCon:SetActive(true)
  817. self.tipLabel.text = "无法向黑名单玩家发消息哦!"
  818. else
  819. self.chatCon:SetActive(true)
  820. self.chatBg:SetActive(true)
  821. self.tipCon:SetActive(false)
  822. self.tipLabel.text = "点击左侧列表好友即可聊天!"
  823. end
  824. self.curr_channel_height = 0
  825. --先显示界面再加载 非黑名单的情况下
  826. if index~=3 then
  827. self.chatCon:SetActive(true)
  828. self.chatBg:SetActive(true)
  829. self.tipCon:SetActive(false)
  830. end
  831. --好友首次聊天显示防骗信息(除去小助手)
  832. if (index == 1 or index == 2)
  833. and vo.last_chat_time==0
  834. and not is_assistant
  835. and self.model:IsRelaviveType(vo.role_id,Config.ConfigSocial.RelativeType.friend) then
  836. self.firstLabel:SetActive(true)
  837. else
  838. self.firstLabel:SetActive(false)
  839. end
  840. local pre_channel_list = self.all_chatItem_list[self.curr_channel]
  841. if pre_channel_list then
  842. for i,item in pairs(pre_channel_list) do
  843. item:SetVisible(false)
  844. if not TableContains(self.cache_chatItem_list,item) then
  845. table.insert(self.cache_chatItem_list,item)
  846. end
  847. end
  848. end
  849. --测试用,用于删除和指定玩家的聊天缓存
  850. -- CookieWrapper.Instance:DeleteChatHistroyFile(1)
  851. local list = CookieWrapper.Instance:GetChatHistroy(self.chating_key_id,true)--根据id获取聊天缓存
  852. if list and list[tostring(self.chating_key_id)] then
  853. for k,v in pairs(list[tostring(self.chating_key_id)]) do
  854. --获取新头像信息
  855. if v.key_id then
  856. if v.player_id==RoleManager.Instance.mainRoleInfo.role_id then
  857. v.turn = RoleManager.Instance.mainRoleInfo.turn
  858. v.sex = RoleManager.Instance.mainRoleInfo.sex
  859. v.career = RoleManager.Instance.mainRoleInfo.career
  860. v.picture_ver = RoleManager.Instance.mainRoleInfo.picture_ver
  861. v.picture = RoleManager.Instance.mainRoleInfo.picture
  862. v.profile_photo_id = RoleManager.Instance.mainRoleInfo.profile_photo_id
  863. else
  864. local vo = SocialityModel:getInstance():GetVoByOnlyId(v.key_id)
  865. if vo then
  866. v.picture_ver = vo.picture_ver
  867. v.picture = vo.picture
  868. v.profile_photo_id = vo.profile_photo_id
  869. v.board = vo.board
  870. v.turn = vo.turn
  871. v.sex = vo.sex
  872. v.career = vo.career
  873. end
  874. end
  875. end
  876. end
  877. end
  878. self.chatModel.all_chat_list[ChatModel.CHANNEL_CECRET] = list
  879. local curr_channel_list = list[tostring(self.chating_key_id)]
  880. --设置好友信息栏的展示
  881. self.model:Fire(SocialityModel.OPEN_FRIEND_MSG_VIEW,vo)
  882. --判断有没有小助手的私聊信息,如果有的话,打开界面后要延时展示消息
  883. local has_assist_info = false
  884. local chat_priate_info = ChatModel:getInstance():GetPriateChatInfo() or {}
  885. for k,v in pairs(chat_priate_info) do
  886. if v == 1 then
  887. has_assist_info = true
  888. end
  889. end
  890. --设置聊天记录
  891. self.pre_renderer_chatItem = nil
  892. local need_hide_first_label = false
  893. if curr_channel_list then
  894. self.all_chatItem_list[self.curr_channel] = {}
  895. if #curr_channel_list > 0 then
  896. need_hide_first_label = true
  897. end
  898. if is_assistant and has_assist_info then
  899. for i = 1,#curr_channel_list-1 do
  900. self:AddMsgItem(curr_channel_list[i],false)
  901. end
  902. else
  903. for i = 1,#curr_channel_list do
  904. self:AddMsgItem(curr_channel_list[i],false)
  905. end
  906. end
  907. end
  908. if need_hide_first_label then
  909. self.firstLabel:SetActive(false)
  910. end
  911. self:ReLayoutScroll()--滚动到聊天栏最后的位置
  912. if self.model.temp_chat_msg_content then
  913. self.input_text.text = self.model.temp_chat_msg_content
  914. self.model.temp_chat_msg_content = nil
  915. end
  916. if self.delay_show_assist_msg then
  917. TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_assist_msg)
  918. self.delay_show_assist_msg = nil
  919. end
  920. if is_assistant and has_assist_info then
  921. local function delay_method( )
  922. self:AddMsgItem(curr_channel_list[#curr_channel_list],false)
  923. self:ReLayoutScroll()--滚动到聊天栏最后的位置
  924. end
  925. self.delay_show_assist_msg = setTimeout(delay_method, 0.5)
  926. end
  927. else
  928. self.chating_key_id = 0
  929. self.chatModel.chating_key_id = 0
  930. self.cur_index = 0
  931. self.cur_sub_index = 0
  932. self.curr_channel_height = 0
  933. self.firstLabel:SetActive(false)
  934. self.chatCon:SetActive(false)
  935. self.chatBg:SetActive(false)
  936. self.friend_msg_view:SetVisible(false)
  937. self.tipCon:SetActive(true)
  938. self.tipLabel.text = "点击左侧列表好友即可聊天!"
  939. end
  940. --清除红点
  941. self.chatModel:ClearChannelMessageNum(self.curr_channel, self.chating_key_id)
  942. self.chatModel:Fire(ChatModel.SHOW_TAB_RED_POINT,self.chatModel.all_chat_list_count)
  943. end
  944. --刷新“最近”页签的红点,当有其他玩家(非当前聊天时)消息过来时,刷新红点
  945. function SocialityFriendView:RefreshTopBarRed( ... )
  946. self.info,self.vo = MainUIModel:getInstance():IsShowChatFriendRed()
  947. if self.vo then
  948. self.recentlyRed:SetActive(self.info)
  949. end
  950. local chat_priate_info = ChatModel:getInstance():GetPriateChatInfo() or {}
  951. local recent_red = {}
  952. self.recentlyRed:SetActive(TableSize(chat_priate_info) > 0)
  953. end
  954. function SocialityFriendView:RefreshOneKeyTicketRed( )
  955. local can_send_list = self.model:GetCanSendTicketFriendIdList()
  956. local can_get_list = self.model:GetCanGetTicketFriendIdList()
  957. local sendRed = #can_send_list ~= 0
  958. local getRed = #can_get_list ~= 0
  959. self.oneKeySendRed:SetActive(sendRed)
  960. self.oneKeyGetRed:SetActive(getRed)
  961. end