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

856 linhas
29 KiB

  1. require("game.sociality.SocialityView")
  2. require("game.sociality.SocialityModel")
  3. require("game.sociality.SocialityFriendView")
  4. require("game.sociality.SocialityMailView")
  5. require("game.sociality.SocialityTabBar")
  6. require("game.sociality.SocialityTabBtn")
  7. require("game.sociality.SocialityTabSubBtn")
  8. require("game.sociality.OperationView")
  9. require("game.sociality.OperationItem")
  10. require("game.sociality.SocialityAddFriendView")
  11. require("game.sociality.SocialityAddFriendItem")
  12. require("game.sociality.SocialityApplyItem")
  13. require("game.sociality.SocialityFlowerView")
  14. require("game.sociality.SocialityFlowerItem")
  15. require("game.sociality.SocialityFriendSelectItem")
  16. require("game.sociality.SocialityFriendSelectView")
  17. require("game.sociality.SocialityFriendMsg")
  18. require("game.sociality.SocialityReceiveItem")
  19. require("game.sociality.SocialityAssistantChatItem")
  20. require("game.sociality.SocialityAssistanChatBar")
  21. require("game.sociality.SocialityGiftRecordView")
  22. require("game.sociality.SocialityGiftRecordReceiveView")
  23. require("game.sociality.SocialityGiftRecordGiveView")
  24. require("game.sociality.SocialityGiveItem")
  25. require("game.sociality.SocialityGiftAdditionItem")
  26. require("game.sociality.SocialityGiftRecordIntimacyView")
  27. require("game.sociality.SocialityGiftRecordFameView")
  28. require("game.proto.140.Require140")
  29. require("game.proto.223.Require223")
  30. SocialityController = SocialityController or BaseClass(BaseController)
  31. function SocialityController:__init()
  32. SocialityController.Instance = self
  33. self.model = SocialityModel:getInstance()
  34. self:InitEvent()
  35. self:RegisterAllProtocals()
  36. end
  37. function SocialityController:InitEvent()
  38. local function onRequestHandler(...)
  39. local args_list = {...}
  40. if args_list[1] == 14000 then
  41. self:SendFmtToGame(args_list[1], "c", args_list[2])
  42. elseif args_list[1] == 14001 then
  43. self:SendFmtToGame(args_list[1], "c", args_list[2])
  44. elseif args_list[1] == 14002 then
  45. self:SendFmtToGame(args_list[1], "s", args_list[2])
  46. elseif args_list[1] == 14003 then
  47. self:SendFmtToGame(args_list[1], "l", args_list[2])
  48. elseif args_list[1] == 14004 then
  49. self:SendFmtToGame(args_list[1], "c", args_list[2])
  50. elseif args_list[1] == 14005 then
  51. self:SendFmtToGame(args_list[1], "lc", args_list[2], args_list[3])
  52. elseif args_list[1] == 14006 then
  53. self:SendFmtToGame(args_list[1])
  54. elseif args_list[1] == 14007 then
  55. self:SendFmtToGame(args_list[1], "cl", args_list[2], args_list[3])
  56. elseif args_list[1] == 14008 then
  57. self:SendFmtToGame(args_list[1], "lshi", args_list[2],args_list[3], args_list[4], args_list[5])
  58. elseif args_list[1] == 14009 then
  59. self:SendFmtToGame(args_list[1], "lscc", args_list[2],args_list[3], args_list[4], args_list[5])
  60. elseif args_list[1] == 14010 then
  61. local role_id = tonumber(args_list[2])
  62. if role_id and RoleManager.Instance.mainRoleInfo.role_id ~= role_id then
  63. self:SendFmtToGame(args_list[1], "l",role_id)
  64. end
  65. elseif args_list[1] == 14011 then
  66. local role_id = tonumber(args_list[2])
  67. self:SendFmtToGame(args_list[1],"l",role_id)
  68. elseif args_list[1] == 22301 then
  69. self:SendFmtToGame(args_list[1], "licc", args_list[2],args_list[3], args_list[4], args_list[5])
  70. elseif args_list[1] == 14015 then
  71. self:SendFmtToGame(args_list[1])
  72. elseif args_list[1] == 14017 then
  73. self:SendFmtToGame(args_list[1], "lc", args_list[2],args_list[3])
  74. elseif args_list[1] == 14018 then
  75. self:SendFmtToGame(args_list[1], "lc", args_list[2],args_list[3])
  76. elseif args_list[1] == 14020 then
  77. self:SendFmtToGame(args_list[1], "l", args_list[2])
  78. elseif args_list[1] == 14021 then
  79. local data = args_list[2]
  80. UserMsgAdapter.WriteBegin(14021)
  81. UserMsgAdapter.WriteFMT("h", #data)
  82. for k,v in ipairs(data) do
  83. UserMsgAdapter.WriteFMT("l", v)
  84. end
  85. UserMsgAdapter.SendToGame()
  86. elseif args_list[1] == 14022 then
  87. local data = args_list[2]
  88. UserMsgAdapter.WriteBegin(14022)
  89. UserMsgAdapter.WriteFMT("h", #data)
  90. for k,v in ipairs(data) do
  91. UserMsgAdapter.WriteFMT("l", v)
  92. end
  93. UserMsgAdapter.SendToGame()
  94. elseif args_list[1] == 14024 then
  95. self:SendFmtToGame(args_list[1], "l", args_list[2])
  96. elseif args_list[1] == 22309 then
  97. self:SendFmtToGame(args_list[1], "l", args_list[2])
  98. else
  99. self:SendFmtToGame(args_list[1])
  100. end
  101. end
  102. self.model:Bind(SocialityModel.REQUEST_CCMD_EVENT,onRequestHandler)
  103. local function gameStartHandler( )
  104. self.model:InitRelaList()
  105. self.model:Fire(SocialityModel.REQUEST_SOCIAL_LIST)
  106. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,22307)
  107. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,22303)
  108. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,14016)
  109. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,22308)
  110. self.game_start_req_handler = true
  111. end
  112. GlobalEventSystem:Bind(EventName.GAME_START, gameStartHandler)
  113. -- 满足等级后请求信息
  114. local function onLevelUp(level)
  115. -- local lv = RoleManager.Instance.mainRoleInfo.level
  116. if level == GetModuleOpenLevel(140) then
  117. gameStartHandler()
  118. end
  119. --小助手消息推送
  120. for k,v in pairs(Config.AssistantChat.LevelPushMsg) do
  121. if v.lv == level then
  122. self.model:AssistantSendMsg(v.msg)
  123. end
  124. end
  125. end
  126. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  127. local function OnTaskSuccess(task_id)
  128. --小助手消息推送
  129. for k,v in pairs(Config.AssistantChat.TaskPushMsg) do
  130. if task_id == v.task_id then
  131. self.model:AssistantSendMsg(v.msg)
  132. end
  133. end
  134. end
  135. GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, OnTaskSuccess)
  136. --绑定打开界面方法
  137. local function onOpenSocialityView(tab_index)
  138. local is_open = GetModuleIsOpen(140) or GetModuleIsOpen(190)
  139. local open_min_lv = GetModuleOpenLevel(140) <= GetModuleOpenLevel(190) and GetModuleOpenLevel(140) or GetModuleOpenLevel(190)
  140. if not is_open then
  141. Message.show(string.format("%d级开放", open_min_lv))
  142. return
  143. end
  144. if self.SocialityView == nil then
  145. self.SocialityView = SocialityView.New()
  146. end
  147. self.SocialityView:Open(tab_index)
  148. -- GlobalEventSystem:Fire(EventName.SOCIAL_CHAT_SEL) --在打开界面的情况下要选中私聊好友
  149. MailModel:getInstance():Fire(MailEvent.UPDATE_TOP_BAR_RED)--打开界面时刷新一下主界面的邮件图标红点
  150. end
  151. GlobalEventSystem:Bind(EventName.OPEN_SOCIALITY_VIEW, onOpenSocialityView)
  152. local function onCloseSocialityView()
  153. if self.SocialityView and self.SocialityView:HasOpen() then
  154. self.SocialityView:Close()
  155. end
  156. end
  157. GlobalEventSystem:Bind(EventName.CLOSE_SOCIALITY_VIEW, onCloseSocialityView)
  158. local function onOpenOperationView(info)
  159. if self.OperationView == nil then
  160. self.OperationView = OperationView.New()
  161. end
  162. -- if self.OperationView:HasOpen() then
  163. -- self.OperationView:Close()
  164. -- else
  165. self.OperationView:Open(info)
  166. -- end
  167. end
  168. GlobalEventSystem:Bind(EventName.OPEN_OPERATION_VIEW,onOpenOperationView)
  169. local function onOpenSocialityFlowerView(roleVo, select_goods_id)
  170. if roleVo and RoleManager.Instance.mainRoleInfo.role_id == roleVo.role_id then
  171. Message.show("不能给自己送花")
  172. return
  173. end
  174. if self.SocialityFlowerView == nil then
  175. self.SocialityFlowerView = SocialityFlowerView.New()
  176. end
  177. self.SocialityFlowerView:Open(roleVo, select_goods_id)
  178. end
  179. GlobalEventSystem:Bind(EventName.OPEN_SOCIAL_FLOWER_VIEW, onOpenSocialityFlowerView)
  180. local function onCloseSocialityFlowerView()
  181. if self.SocialityFlowerView and self.SocialityFlowerView:HasOpen() then
  182. self.SocialityFlowerView:Close()
  183. end
  184. end
  185. GlobalEventSystem:Bind(EventName.CLOSE_SOCIAL_FLOWER_VIEW, onCloseSocialityFlowerView)
  186. local function onOpenSocialityFriendSelView(flag, friend_list, op_type)
  187. op_type = op_type or 1--点击类型,1为显示右侧按钮,2为不显示按钮,整个区域做点击热区
  188. if flag then
  189. if self.SocialityFriendSelectView == nil then
  190. self.SocialityFriendSelectView = SocialityFriendSelectView.New()
  191. end
  192. self.SocialityFriendSelectView:Open(friend_list,op_type)
  193. else
  194. if self.SocialityFriendSelectView and self.SocialityFriendSelectView:HasOpen() then
  195. self.SocialityFriendSelectView:Close()
  196. end
  197. end
  198. end
  199. GlobalEventSystem:Bind(EventName.OPEN_SOCIAL_FRIEND_SEL_VIEW, onOpenSocialityFriendSelView)
  200. local function RequestSocialList()
  201. self.wait_update = 3
  202. -- self.wait_update = 1
  203. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 1)--请求好友
  204. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 2)--请求羁绊
  205. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 5)--请求最近联系人
  206. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 6)--请求单向好友列表
  207. end
  208. self.model:Bind(SocialityModel.REQUEST_SOCIAL_LIST, RequestSocialList)
  209. --初始化界面时请求一部分需要红点判断的数据
  210. local onInitMainUIHandler = function ()
  211. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14006) --好友列表
  212. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22302) --送花收花记录
  213. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22304) --上线之后下线期间的送花提醒
  214. end
  215. self:Bind(EventName.INIT_MAINUI_EVENT, onInitMainUIHandler)
  216. local function onRequestOther( role_id, x, y, chat_info, force_x, force_y )
  217. --记录点击坐标
  218. SocialityModel:getInstance().mousePos = Vector2(x, y)
  219. if force_x and force_y then
  220. SocialityModel:getInstance().operationPos = Vector2(force_x, force_y)
  221. else
  222. SocialityModel:getInstance().operationPos = false
  223. end
  224. self.model.need_show_operation = true--重置为14010协议回调后打开好友互动面板
  225. if chat_info and chat_info.ser_id ~= RoleManager.Instance:GetMainRoleServerId() then -- 外服玩家时仅显示“查看信息按钮”
  226. chat_info.rela = 1 -- OPERATION_VIEW查看时展示出来的需要这个参
  227. GlobalEventSystem:Fire(EventName.OPEN_OPERATION_VIEW, chat_info)
  228. self.model.need_show_operation = false
  229. else
  230. SocialityModel:getInstance():Fire(SocialityModel.REQUEST_CCMD_EVENT, 14010, role_id)
  231. end
  232. end
  233. self.model:Bind(SocialityModel.REQUEST_OTHER_INFO, onRequestOther)
  234. --和指定id的人私聊(如陌生人聊天)
  235. local function onChatWithRoleId(role_id, msg_content)
  236. --不在最近联系人列表中人发来消息时加入最近联系人列表
  237. if role_id ~= RoleManager.Instance.mainRoleInfo.role_id and
  238. not self.model:IsRelaviveType(role_id,Config.ConfigSocial.RelativeType.recent) then
  239. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,14020,role_id)
  240. end
  241. ChatModel:getInstance().need_chat_key = role_id
  242. self.model.only_request_recent_flag = true--标识:只请求最近联系人列表
  243. if msg_content then
  244. self.model.temp_chat_msg_content = msg_content
  245. else
  246. self.model.temp_chat_msg_content = nil
  247. end
  248. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14000, 5)--请求最近联系人
  249. -- GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW, 1)
  250. end
  251. self.model:Bind(SocialityModel.CHAT_WITH_ROLEID,onChatWithRoleId)
  252. --intimacy 只在查看好友的亲密度时才传
  253. local function onOpenSocialityGiftRecordView(index,intimacy,info,figure)
  254. if self.sociality_gift_record_view == nil then
  255. self.sociality_gift_record_view = SocialityGiftRecordView.New()
  256. end
  257. -- if self.sociality_gift_record_view:HasOpen() then
  258. -- self.sociality_gift_record_view:Close()
  259. -- else
  260. self.sociality_gift_record_view:Open(index,intimacy,info,figure)
  261. -- end
  262. end
  263. GlobalEventSystem:Bind(EventName.OPEN_SOCIAL_GIFT_RECORD_VIEW, onOpenSocialityGiftRecordView)
  264. end
  265. function SocialityController:RegisterAllProtocals()
  266. self:RegisterProtocal(14000,"handle14000")
  267. self:RegisterProtocal(14001,"handle14001")
  268. self:RegisterProtocal(14002,"handle14002")
  269. self:RegisterProtocal(14003,"handle14003")
  270. self:RegisterProtocal(14004,"handle14004")
  271. self:RegisterProtocal(14005,"handle14005")
  272. self:RegisterProtocal(14006,"handle14006")
  273. self:RegisterProtocal(14007,"handle14007")
  274. self:RegisterProtocal(14008,"handle14008")
  275. self:RegisterProtocal(14009,"handle14009")
  276. self:RegisterProtocal(14010,"handle14010")
  277. self:RegisterProtocal(14011,"handle14011")
  278. self:RegisterProtocal(14013,"handle14013")
  279. self:RegisterProtocal(14014,"handle14014")
  280. self:RegisterProtocal(14015,"handle14015")
  281. self:RegisterProtocal(14016,"handle14016")
  282. self:RegisterProtocal(14017,"handle14017")
  283. self:RegisterProtocal(14018,"handle14018")
  284. self:RegisterProtocal(14019,"handle14019")
  285. self:RegisterProtocal(14021,"handle14021")
  286. self:RegisterProtocal(14022,"handle14022")
  287. self:RegisterProtocal(14023,"handle14023")
  288. self:RegisterProtocal(14024,"handle14024")
  289. self:RegisterProtocal(22300,"handle22300")
  290. self:RegisterProtocal(22301,"handle22301")
  291. self:RegisterProtocal(22302,"handle22302")
  292. self:RegisterProtocal(22303,"handle22303")
  293. self:RegisterProtocal(22304,"handle22304")
  294. self:RegisterProtocal(22308,"handle22308")
  295. self:RegisterProtocal(22309,"handle22309")
  296. end
  297. function SocialityController:handle14000()
  298. local vo = SCMD14000.New(true)
  299. --14007删除好友时不重新刷新最近联系人列表,防止最近联系人列表顺序立刻刷新
  300. if self.model.not_update_recent and vo.type == 5 then
  301. self.model.not_update_recent = false -- 重置刷新的flag
  302. else
  303. self.model:SetRelativeInfo(vo.type, vo.rela_list)
  304. end
  305. if self.model.only_request_recent_flag then--如果是单独只请求了最近联系人的情况,不需要等待其他列表返回再刷新界面
  306. self.model.only_request_recent_flag = false
  307. if self.SocialityView == nil then
  308. self.SocialityView = SocialityView.New()
  309. self.SocialityView:Open(1)
  310. end
  311. self.model.only_show_recent_view = true--单独给从外部私聊他人的情况处理界面刷新
  312. self.model:Fire(SocialityModel.UPDATE_SOCIALITY_RECENT_VIEW)
  313. return
  314. end
  315. if self.model.only_request_mate_flag then--如果是单独只请求了羁绊好友的情况,直接记录好数据就行
  316. self.model.only_request_mate_flag = false
  317. return
  318. end
  319. if self.wait_update and self.wait_update > 0 then
  320. self.wait_update = self.wait_update - 1
  321. else
  322. --发送14021协议请求自己对好友的状态列表
  323. if self.game_start_req_handler then
  324. local friend_data = {}
  325. for k,v in pairs(self.model:GetRelativeInfoByType(1)) do
  326. if v.role_id ~= 1 then--ai管家排除
  327. table.insert(friend_data,v.role_id)
  328. end
  329. end
  330. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14021, friend_data)
  331. end
  332. self.game_start_req_handler = false
  333. if not self.model.only_rqeuest_data then
  334. self.model:Fire(SocialityModel.UPDATE_SOCIALITY_VIEW)
  335. end
  336. self.model.only_rqeuest_data = false
  337. end
  338. end
  339. --请求添加好友界面的随机可添加的数据
  340. function SocialityController:handle14001()
  341. local vo = SCMD14001.New(true)
  342. if vo.code == 1 then
  343. --先过滤一遍,防止好友进入推荐列表中
  344. local true_recommended_list = {}
  345. for k,v in pairs(vo.recommended_list) do
  346. local is_friend = self.model:IsRelaviveType(v.role_id,Config.ConfigSocial.RelativeType.friend)
  347. if not is_friend then
  348. true_recommended_list[#true_recommended_list+1] = v
  349. end
  350. end
  351. self.model:Fire(SocialityModel.UPDATE_ADD_FRIEND_VIEW, true_recommended_list)
  352. else
  353. ErrorCodeShow(vo.code)
  354. end
  355. end
  356. --在发送添加成功后刷新添加好友的界面
  357. function SocialityController:handle14002()
  358. local vo = SCMD14002.New(true)
  359. self.model:SetSearchInfo(vo)
  360. if vo.code == 1 then
  361. local is_friend = self.model:IsRelaviveType(vo.role_id,Config.ConfigSocial.RelativeType.friend)
  362. if is_friend then
  363. Message.show("对方已经是好友了")
  364. else
  365. self.model:Fire(SocialityModel.UPDATE_ADD_FRIEND_VIEW, {[1] = vo})
  366. self.model:Fire(SocialityModel.UPDATE_RECOMMEND_TEXT)
  367. end
  368. else
  369. ErrorCodeShow(vo.code)
  370. end
  371. end
  372. --点击一键添加所有好友之后的添加好友界面的刷新
  373. function SocialityController:handle14015()
  374. -- body
  375. end
  376. function SocialityController:handle14003()
  377. local vo = SCMD14003.New(true)
  378. if vo.code == 1 then
  379. Message.show("您已成功添加对方为好友")
  380. self.model:Fire(SocialityModel.UPDATE_ADD_FRIEND_BTN_STATE)
  381. else
  382. ErrorCodeShow(vo.code)
  383. end
  384. end
  385. function SocialityController:handle14004()
  386. local vo = SCMD14004.New(true)
  387. ErrorCodeShow(vo.code)
  388. --请求好友申请列表
  389. if vo.code == 1 then
  390. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14006)
  391. end
  392. end
  393. function SocialityController:handle14005()
  394. local vo = SCMD14005.New(true)
  395. ErrorCodeShow(vo.code)
  396. --请求好友申请列表
  397. if vo.code == 1 then
  398. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14006)
  399. end
  400. end
  401. function SocialityController:handle14006()
  402. local vo = SCMD14006.New(true)
  403. -------------------------
  404. -- local tb = {type = Config.ConfigMainIcon.TipType.friend}
  405. -- if TableSize(vo.ask_list) > 0 then
  406. -- if self.model:CheckIsFullFriend() then
  407. -- if MsgManager:getInstance():IsMsgTypeShow(tb.type) then
  408. -- MsgManager:getInstance():Remove(tb.type)
  409. -- end
  410. -- else
  411. -- MsgManager:getInstance():Add(tb)
  412. -- end
  413. -- else
  414. -- MsgManager:getInstance():Remove(tb.type)
  415. -- end
  416. -------------------------
  417. --先过滤一遍,防止好友进入推荐列表中
  418. local true_recommended_list = {}
  419. true_recommended_list.ask_list = {}
  420. for k,v in pairs(vo.ask_list) do
  421. local is_friend = self.model:IsRelaviveType(v.role_id,Config.ConfigSocial.RelativeType.friend)
  422. if not is_friend then
  423. true_recommended_list.ask_list[#true_recommended_list.ask_list+1] = v
  424. end
  425. end
  426. self.model:SetApplyInfo(true_recommended_list)
  427. self.model:Fire(SocialityModel.UPDATE_APPLY_FRIEND_VIEW)
  428. self.model:Fire(SocialityModel.UPDATE_ADD_FRIEND_BTN_STATE)
  429. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT) --刷新红点
  430. if #true_recommended_list.ask_list > 0 then
  431. MsgManager:getInstance():Add({type=Config.ConfigMainIcon.TipType.friend})
  432. else
  433. MsgManager:getInstance():Remove(Config.ConfigMainIcon.TipType.friend)
  434. end
  435. end
  436. function SocialityController:handle14007()
  437. local vo = SCMD14007.New(true)
  438. ErrorCodeShow(vo.code)
  439. if vo.code == 1 then
  440. self.model.not_update_recent = true -- 删除好友时不要立刻刷新最近联系人的顺序
  441. self.model:Fire(SocialityModel.REQUEST_SOCIAL_LIST)
  442. end
  443. end
  444. function SocialityController:handle14008()
  445. local vo = SCMD14008.New(true)
  446. if GetModuleIsOpen(140,0) then
  447. local is_friend = self.model:IsRelaviveType(vo.role_id,Config.ConfigSocial.RelativeType.friend)
  448. if not is_friend then
  449. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14006)
  450. end
  451. end
  452. end
  453. function SocialityController:handle14009()
  454. local vo = SCMD14009.New(true)
  455. local strName = ""
  456. local strType = ""
  457. local rela_id = 1
  458. --不管后端发过来rela是1还是6,他都是好友
  459. if vo.rela_type == 1 or vo.rela_type == 6 then
  460. vo.rela_type = 1
  461. end
  462. if vo.rela_type == 1 then
  463. strName = "好友"
  464. end
  465. -- 最近联系人列表也要刷新其在线状态
  466. local recent_list = self.model:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.recent)
  467. for i,v in ipairs(recent_list) do
  468. if v.role_id == vo.role_id then
  469. recent_list[i].online_flag = vo.online_flag
  470. end
  471. end
  472. rela_id = Config.ConfigSocial.OnAndOffLine[vo.rela_type].relative_list_id
  473. if vo.online_flag == 0 then
  474. strType = "下线了"
  475. elseif vo.online_flag == 1 then
  476. strType = "上线了"
  477. end
  478. if self.model:IsRelaviveType(vo.role_id, Config.ConfigSocial.RelativeType.friend) then
  479. Message.show(string.format("您的%s%s%s", strName, vo.role_name, strType))
  480. end
  481. --更新数据
  482. local role = self.model:GetVoById(rela_id, vo.role_id) --公用的更新
  483. if role then
  484. role.online_flag = vo.online_flag
  485. if vo.online_flag == 0 then --玩家下线时 更新上次登录的时间为当前的时间
  486. role.last_logout_time = TimeUtil:getServerTime()
  487. end
  488. end
  489. local info = self.model:GetRelativeInfoByType(rela_id)
  490. if info then
  491. self.model:SetRelativeInfo(rela_id, info,true)--不排序了,重新打开界面才排序
  492. end
  493. --特殊标记:有好友上下线通知时,会重排序好友列表,此标记避免选中其他好友
  494. self.model.special_flag_online_changed = true
  495. -- self.model:Fire(SocialityModel.UPDATE_SOCIALITY_VIEW, true)--重新刷列表太浪费了,改成单独刷item吧
  496. self.model:Fire(SocialityModel.UPDATE_TAB_SUB_ITEM,vo.role_id)
  497. end
  498. function SocialityController:handle14010( )
  499. local vo = SCMD14010.New(true)
  500. if vo.code == 1 then
  501. if self.model.need_show_operation == "none" then
  502. --什麽都不用做的版本
  503. elseif self.model.need_show_operation == "showLookView" then
  504. --直接打开查看界面
  505. GlobalEventSystem:Fire(EventName.OPEN_LOOK_ROLE_INFO_VIEW,vo.role_id,vo.rela)
  506. elseif not self.model.need_show_operation then
  507. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, vo)
  508. else
  509. GlobalEventSystem:Fire(EventName.OPEN_OPERATION_VIEW, vo)
  510. self.model.need_show_operation = false
  511. end
  512. self.model:Fire(SocialityModel.ANS_FRIEND_SHOW_DATA,vo)
  513. self.model.need_show_operation = nil
  514. else
  515. ErrorCodeShow(vo.code)
  516. GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, false)
  517. end
  518. end
  519. function SocialityController:handle14013( )
  520. local vo = SCMD14013.New(true)
  521. for m,n in pairs(vo.update_list) do
  522. local list = self.model:GetRelativeInfoByType(n.type)
  523. for k,t in pairs(n.role_list) do
  524. local find = false
  525. for i,v in ipairs(list) do
  526. if v.role_id == t.role_id then
  527. list[i] = t
  528. find = true
  529. break
  530. end
  531. end
  532. if not find then
  533. table.insert(list, t)
  534. end
  535. -------------------------
  536. --如果是好友,需要去羁绊数据同步修改
  537. if n.type == 1 then
  538. local mate_list = self.model:GetRelativeInfoByType(2)
  539. for i,v in ipairs(mate_list) do
  540. if v.role_id == t.role_id then
  541. mate_list[i] = t
  542. break
  543. end
  544. end
  545. end
  546. -------------------------
  547. -------------------------
  548. --如果是从单向好友变成好友,需要去单向好友列表修改
  549. if n.type == 1 then
  550. local one_way_list = self.model:GetRelativeInfoByType(6)
  551. for i,v in ipairs(one_way_list) do
  552. if v.role_id == t.role_id then
  553. TableRemove(one_way_list,v)
  554. break
  555. end
  556. end
  557. end
  558. --如果是从好友变成单向好友,需要去删除好友列表中的数据
  559. if n.type == 6 then
  560. local friend_list = self.model:GetRelativeInfoByType(1)
  561. for i,v in ipairs(friend_list) do
  562. if v.role_id == t.role_id then
  563. TableRemove(friend_list,v)
  564. break
  565. end
  566. end
  567. end
  568. -------------------------
  569. -- 最近联系人列表也要刷新,但是聊天时间不要变
  570. local recent_list = self.model:GetRelativeInfoByType(Config.ConfigSocial.RelativeType.recent)
  571. for i,v in ipairs(recent_list) do
  572. if v.role_id == t.role_id then
  573. local old_chat_time = v.last_chat_time
  574. recent_list[i] = t
  575. recent_list[i].last_chat_time = old_chat_time
  576. end
  577. end
  578. end
  579. end
  580. for i=1,3 do --列表排序
  581. local info = self.model:GetRelativeInfoByType(i)
  582. if info then
  583. -- self.model:SetRelativeInfo(i, info)
  584. self.model:SetRelativeInfo(i, info,true)
  585. end
  586. end
  587. self.model.tab_sub_btn_do_not_scroll_to = true
  588. self.model:Fire(SocialityModel.UPDATE_SOCIALITY_VIEW, false)
  589. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14006)
  590. end
  591. function SocialityController:handle14014( )
  592. local vo = SCMD14014.New(true)
  593. for m,n in pairs(vo.update_list) do
  594. local delete_list = nil
  595. local list = self.model:GetRelativeInfoByType(n.type)
  596. for k,t in pairs(n.role_ids) do
  597. for i,v in ipairs(list) do
  598. if v.role_id == t.role_id then
  599. delete_list = delete_list or {}
  600. table.insert(delete_list, i)
  601. break
  602. end
  603. end
  604. end
  605. if delete_list then
  606. for i, id in ipairs(delete_list) do
  607. list[id] = nil
  608. end
  609. end
  610. --重新排列
  611. local temp = DeepCopy(list)
  612. self.model.relative_info[n.type] = {}
  613. for k,v in pairs(temp) do
  614. table.insert(self.model.relative_info[n.type], v)
  615. end
  616. end
  617. -- self.model:SaveRelativeInfo(vo)
  618. self.model:Fire(SocialityModel.UPDATE_SOCIALITY_VIEW)
  619. end
  620. function SocialityController:handle14011( )
  621. local vo = SCMD14011.New(true)
  622. self.model:Fire(SocialityModel.UPDATE_OTHER_ROLE_RELA, vo)
  623. end
  624. function SocialityController:handle14016( )
  625. local vo = SCMD14016.New(true)
  626. self.model:SetTicketsData(vo)
  627. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)
  628. end
  629. function SocialityController:handle14017( )
  630. local vo = SCMD14017.New(true)
  631. if vo.errcode == 1 then
  632. if vo.type == SocialityModel.TicketType.Friend then--赠送名望券
  633. Message.show("赠送成功!","success")
  634. elseif vo.type == SocialityModel.TicketType.Mate then--赠送羁绊点
  635. Message.show("赠送羁绊点成功","success")
  636. end
  637. self.model:UpdateTicketsState(1,vo.torole,vo.type)
  638. self.model:Fire(SocialityModel.UPDATE_TICKETS_STATE,vo.torole)
  639. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)
  640. else
  641. ErrorCodeShow(vo.errcode)
  642. end
  643. end
  644. function SocialityController:handle14018( )
  645. local vo = SCMD14018.New(true)
  646. if vo.errcode == 1 then
  647. if vo.type == SocialityModel.TicketType.Friend then
  648. -- local goods_type_id = 100003
  649. -- local goods_name = GoodsModel:getInstance():getGoodsName(goods_type_id,true,true)
  650. -- local message_str = string.format("领取 %s x%s",goods_name,5)
  651. -- Message.show(message_str,"award")
  652. elseif vo.type == SocialityModel.TicketType.Mate then
  653. Message.show("领取羁绊点成功","award")
  654. end
  655. self.model:UpdateTicketsState(2,vo.fromid,vo.type)
  656. self.model:Fire(SocialityModel.UPDATE_TICKETS_STATE,vo.fromid)
  657. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)
  658. else
  659. ErrorCodeShow(vo.errcode)
  660. end
  661. end
  662. function SocialityController:handle14019( )
  663. local vo = SCMD14019.New(true)
  664. self.model:UpdateGiftRoleList(vo.from_id,vo.type)
  665. self.model:Fire(SocialityModel.UPDATE_TICKETS_STATE,vo.from_id)
  666. GlobalEventSystem:Fire(EventName.REFRESH_SOCIAL_RED_DOT)
  667. end
  668. function SocialityController:handle22300( )
  669. local vo = SCMD22300.New(true)
  670. ErrorCodeShow(vo.code)
  671. end
  672. function SocialityController:handle22301( )
  673. local vo = SCMD22301.New(true)
  674. if vo.code~=1 then
  675. ErrorCodeShow(vo.code)
  676. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  677. else
  678. Message.show("赠送成功","success")
  679. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22302)
  680. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22303)
  681. self.model:Fire(SocialityModel.UPDATE_FLOWER_NUM,vo.receive_id,vo.week_charm,vo.intimacy)
  682. end
  683. end
  684. function SocialityController:handle22302( )
  685. local vo = SCMD22302.New(true)
  686. -- print("==WQ==:SocialityController [start:743] vo:", vo)
  687. -- PrintTable(vo)
  688. -- print("==WQ==:SocialityController [end]")
  689. if vo then
  690. self.model:SetReceiveInfo(vo)
  691. self.model:Fire(SocialityModel.UPDATE_RECEIVE_VIEW)
  692. end
  693. end
  694. function SocialityController:handle22303( )
  695. local vo = SCMD22303.New(true)
  696. self.model:SetCharmInfo(vo)
  697. self.model:Fire(SocialityModel.UPDATE_CHARM_VIEW)
  698. end
  699. function SocialityController:handle22304()
  700. local vo = SCMD22304.New(true)
  701. if vo.code == 1 then --在下线时有新的送花礼物 就显示提示
  702. local tb = {}
  703. tb.type = Config.ConfigMainIcon.TipType.flower
  704. MsgManager:getInstance():Add(tb)
  705. self.model.has_new_flower_record = true
  706. end
  707. end
  708. -- ############ 陌生人私聊将其加入到最近联系人列表中 ##############
  709. -- protocol=14020
  710. -- {
  711. -- c2s{
  712. -- role_id:int64 // 将要私聊的陌生人id
  713. -- }
  714. -- }
  715. function SocialityController:handle14020()
  716. local vo = SCMD14020.New(true)
  717. end
  718. -- ############ 双向好友一方删除好友更新对方前端亲密度 ##############
  719. -- protocol=14021
  720. -- {
  721. -- c2s{
  722. -- friend_list:array{
  723. -- role_id:int64 // 存在好友关系的角色Id
  724. -- }
  725. -- }
  726. -- s2c{
  727. -- type:int8 // 操作类型 1-客户端主动请求 2-服务端推送
  728. -- opp_rela_list:array{
  729. -- role_id:int64 // 存在好友关系的角色Id
  730. -- opp_rela_type:int8 // 我在对方所处的关系
  731. -- ask_response_status:int8 // 我在对方申请列表里面的处理状态 0-未响应 1-已拒绝 2-同意加好友
  732. -- }
  733. -- }
  734. -- }
  735. function SocialityController:handle14021()
  736. local vo = SCMD14021.New(true)
  737. self.model:SetFriendStateList(vo)
  738. if vo.type == 1 then
  739. -- if not self.model.only_rqeuest_data then
  740. -- self.model:Fire(SocialityModel.UPDATE_SOCIALITY_VIEW)
  741. -- end
  742. -- self.model.only_rqeuest_data = false
  743. elseif vo.type == 2 then
  744. for k,v in pairs(vo.opp_rela_list) do
  745. self.model:Fire(SocialityModel.UPDATE_TICKETS_STATE,v.role_id)
  746. end
  747. end
  748. end
  749. function SocialityController:handle14022( )
  750. local vo = SCMD14022.New(true)
  751. if vo.errcode~=1 then
  752. ErrorCodeShow(vo.errcode)
  753. else
  754. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14016)
  755. end
  756. end
  757. function SocialityController:handle14023( )
  758. local vo = SCMD14023.New(true)
  759. if vo.errcode~=1 then
  760. ErrorCodeShow(vo.errcode)
  761. else
  762. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14016)
  763. end
  764. end
  765. function SocialityController:handle14024( )
  766. local vo = SCMD14024.New(true)
  767. if vo.errcode~=1 then
  768. ErrorCodeShow(vo.errcode)
  769. else
  770. self.model:Fire(SocialityModel.OPEN_SOCIALITY_INTIMACY_ADDITION_AFTER_FIGURE,vo)
  771. end
  772. end
  773. function SocialityController:handle22308( )
  774. local vo = SCMD22308.New(true)
  775. self.model:SetSpGiftLimitData(vo)
  776. self.model:Fire(SocialityModel.REFRESH_SOCIALITY_SP_GIFT_LIMIT)
  777. end
  778. function SocialityController:handle22309( )
  779. local vo = SCMD22309.New(true)
  780. -- print("==WQ==:SocialityController [start:847] vo:", vo)
  781. -- PrintTable(vo)
  782. -- print("==WQ==:SocialityController [end]")
  783. if vo.errcode == 1 then
  784. Message.show("感谢成功!")
  785. self.model:UpdateGiftReciveThankState(vo)
  786. self.model:Fire(SocialityModel.UPDATE_RECEIVE_RECORD_THANK_STATE)
  787. else
  788. ErrorCodeShow(vo.errcode)
  789. end
  790. end