From 8ab2496c2800bca166d5e9df954df69e65402e72 Mon Sep 17 00:00:00 2001 From: zhangqiang <657634622@qq.com> Date: Sat, 10 Apr 2021 15:37:10 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=82=AE=E4=BB=B6=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8D=8F=E8=AE=AE=20=E7=82=B9=E5=87=BB=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E5=86=8D=E8=8E=B7=E5=8F=96=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Message/PlayerInfoProto_pb.lua | 21 +++++++++++++ .../~Lua/Modules/Mail/MailMainPanel.lua | 7 ++++- .../~Lua/Modules/Mail/MailManager.lua | 31 +++++++++++++++---- .../~Lua/Modules/Net/NetManager.lua | 4 +++ 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Message/PlayerInfoProto_pb.lua b/Assets/ManagedResources/~Lua/Message/PlayerInfoProto_pb.lua index d6fe4a4219..75a9c2f7dc 100644 --- a/Assets/ManagedResources/~Lua/Message/PlayerInfoProto_pb.lua +++ b/Assets/ManagedResources/~Lua/Message/PlayerInfoProto_pb.lua @@ -83,6 +83,8 @@ USEANDPRICEITEMRESPONSE = protobuf.Descriptor(); USEANDPRICEITEMRESPONSE_DROP_FIELD = protobuf.FieldDescriptor(); MAILREADREQUEST = protobuf.Descriptor(); MAILREADREQUEST_MAILID_FIELD = protobuf.FieldDescriptor(); +MAILREADRESPONSE = protobuf.Descriptor(); +MAILREADRESPONSE_MAILINFO_FIELD = protobuf.FieldDescriptor(); TAKEMAILREQUEST = protobuf.Descriptor(); TAKEMAILREQUEST_MAILIDS_FIELD = protobuf.FieldDescriptor(); TAKEMAILRESPONSE = protobuf.Descriptor(); @@ -1269,6 +1271,24 @@ MAILREADREQUEST.enum_types = {} MAILREADREQUEST.fields = {MAILREADREQUEST_MAILID_FIELD} MAILREADREQUEST.is_extendable = false MAILREADREQUEST.extensions = {} +MAILREADRESPONSE_MAILINFO_FIELD.name = "mailInfo" +MAILREADRESPONSE_MAILINFO_FIELD.full_name = ".rpc.protocols.MailReadResponse.mailInfo" +MAILREADRESPONSE_MAILINFO_FIELD.number = 1 +MAILREADRESPONSE_MAILINFO_FIELD.index = 0 +MAILREADRESPONSE_MAILINFO_FIELD.label = 1 +MAILREADRESPONSE_MAILINFO_FIELD.has_default_value = false +MAILREADRESPONSE_MAILINFO_FIELD.default_value = nil +MAILREADRESPONSE_MAILINFO_FIELD.message_type = CommonProto_pb.MAIL +MAILREADRESPONSE_MAILINFO_FIELD.type = 11 +MAILREADRESPONSE_MAILINFO_FIELD.cpp_type = 10 + +MAILREADRESPONSE.name = "MailReadResponse" +MAILREADRESPONSE.full_name = ".rpc.protocols.MailReadResponse" +MAILREADRESPONSE.nested_types = {} +MAILREADRESPONSE.enum_types = {} +MAILREADRESPONSE.fields = {MAILREADRESPONSE_MAILINFO_FIELD} +MAILREADRESPONSE.is_extendable = false +MAILREADRESPONSE.extensions = {} TAKEMAILREQUEST_MAILIDS_FIELD.name = "mailIds" TAKEMAILREQUEST_MAILIDS_FIELD.full_name = ".rpc.protocols.TakeMailRequest.mailIds" TAKEMAILREQUEST_MAILIDS_FIELD.number = 1 @@ -5053,6 +5073,7 @@ LoginResponse = protobuf.Message(LOGINRESPONSE) LuckWheelIndication = protobuf.Message(LUCKWHEELINDICATION) MailDelRequest = protobuf.Message(MAILDELREQUEST) MailReadRequest = protobuf.Message(MAILREADREQUEST) +MailReadResponse = protobuf.Message(MAILREADRESPONSE) MissingRoomAccelerateRequest = protobuf.Message(MISSINGROOMACCELERATEREQUEST) MissingRoomLockRequest = protobuf.Message(MISSINGROOMLOCKREQUEST) MissingRoomRefreshResponse = protobuf.Message(MISSINGROOMREFRESHRESPONSE) diff --git a/Assets/ManagedResources/~Lua/Modules/Mail/MailMainPanel.lua b/Assets/ManagedResources/~Lua/Modules/Mail/MailMainPanel.lua index 0c69a7775e..5d8c53b063 100644 --- a/Assets/ManagedResources/~Lua/Modules/Mail/MailMainPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Mail/MailMainPanel.lua @@ -190,10 +190,15 @@ function this.SingleMialDataShow(_go,_mailData) NetManager.ReadSingleMailData(_mailData.mailId,function () MailManager.UpdataMialIsReadState(_mailData.mailId,1) Log("读取邮件成功 ".._mailData.mailId) + UIManager.OpenPanel(UIName.MainSingleInfoPanel,MailManager.GetSingleMail(_mailData.mailId),this) this.UpdateMailData() end) + else + NetManager.ReadSingleMailData(_mailData.mailId,function () + MailManager.UpdataMialIsReadState(_mailData.mailId,1) + UIManager.OpenPanel(UIName.MainSingleInfoPanel,MailManager.GetSingleMail(_mailData.mailId),this) + end) end - UIManager.OpenPanel(UIName.MainSingleInfoPanel,_mailData,this) end) Util.GetGameObject(_go.transform, "mialRedPoint"):SetActive( _mailData.state==0) diff --git a/Assets/ManagedResources/~Lua/Modules/Mail/MailManager.lua b/Assets/ManagedResources/~Lua/Modules/Mail/MailManager.lua index f6b2e48e38..47ec0b54b0 100644 --- a/Assets/ManagedResources/~Lua/Modules/Mail/MailManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Mail/MailManager.lua @@ -9,7 +9,7 @@ end function this.InitMailDataList(_mialList) this.mialDataList = {} for i = 1, #_mialList do - this.UpdateMialData(_mialList[i]) + this.UpdateMialData(_mialList[i],true) end table.sort(this.mialDataList, function(a, b) @@ -20,8 +20,10 @@ function this.InitMailDataList(_mialList) end end) end - -function this.UpdateMialData(_mial) +function this.UpdateSingleMialData(_mial) + this.UpdateMialData(_mial,false) +end +function this.UpdateMialData(_mial,isAdd) local singleMail = {} --Log("添加邮件 " .. _mial.mailId) singleMail.mailId = _mial.mailId-- @@ -38,10 +40,27 @@ function this.UpdateMialData(_mial) singleMail.effectiveTime = _mial.effectiveTime--秒 0:永久有效 singleMail.sendName = _mial.sendName--发送者名字 singleMail.mailType = _mial.mailType--邮件类型 1:系统邮件 2:idip 业务邮件 - - table.insert(this.mialDataList, singleMail) + if isAdd then + table.insert(this.mialDataList, singleMail) + else + if this.mialDataList and #this.mialDataList > 0 then + for i = 1, #this.mialDataList do + if this.mialDataList[i].mailId == singleMail.mailId then + this.mialDataList[i] = singleMail + end + end + end + end +end +function this.GetSingleMail(mailId) + if this.mialDataList and #this.mialDataList > 0 then + for i = 1, #this.mialDataList do + if this.mialDataList[i].mailId == mailId then + return this.mialDataList[i] + end + end + end end - function this.GetStringByStringformat(inputStr) local msgStr = string.split(inputStr,"#") LogGreen("inputStr:"..inputStr) diff --git a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua index f58748dd1e..4dbde51371 100644 --- a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua @@ -1111,6 +1111,10 @@ function this.ReadSingleMailData(_mailId, func) data.mailId = _mailId local msg = data:SerializeToString() Network:SendMessageWithCallBack(MessageTypeProto_pb.MAIL_READ_REQUEST, MessageTypeProto_pb.MAIL_READ_RESPONSE, msg, function(buffer) + local data = buffer:DataByte() + local msg = PlayerInfoProto_pb.MailReadResponse() + msg:ParseFromString(data) + MailManager.UpdateSingleMialData(msg.mailInfo) if func then func() end