Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPAbout.lua

194 lines
5.8 KiB
Lua
Raw Normal View History

2020-07-18 21:12:14 +08:00
---@type IDBasePanel
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPAbout:TRBasePanel 邮件列表
local TRPAbout = class("TRPAbout", TRBasePanel)
local uiobjs = {}
-- 初始化,只会调用一次
function TRPAbout:init(csObj)
TRPAbout.super.init(self, csObj)
self:initFiledsAttr()
self:setEventDelegate()
MyUtl.setContentView(getChild(self.transform, "PanelContent"), 132 + 500, 0)
---@type UIScrollView
uiobjs.scrollView = getCC(self.transform, "PanelContent", "UIScrollView")
---@type UITable
uiobjs.Table = getCC(uiobjs.scrollView.transform, "Table", "UITable")
---@type CLUIFormRoot
uiobjs.TableForm = uiobjs.Table:GetComponent("CLUIFormRoot")
---@type Coolape.CLCellLua
uiobjs.TableLua = uiobjs.Table:GetComponent("CLCellLua")
end
function TRPAbout:initFiledsAttr()
---@type _ParamFieldAttr
local attr
self.baseFiledsAttr = {}
attr = {}
attr.attrName = "更新动态"
attr.id = "upgrade"
attr.attrType = DBCust.FieldType.text
attr.ifMust = 0
attr.donotJoinKey = true
table.insert(self.baseFiledsAttr, attr)
attr = {}
attr.attrName = "服务协议"
attr.id = "serviceAgreement"
attr.attrType = DBCust.FieldType.text
attr.ifMust = 0
attr.donotJoinKey = true
table.insert(self.baseFiledsAttr, attr)
2020-07-28 21:02:59 +08:00
-- attr = {}
-- attr.attrName = "发布评价"
-- attr.id = "assess"
-- attr.attrType = DBCust.FieldType.text
-- attr.ifMust = 0
-- attr.donotJoinKey = true
-- table.insert(self.baseFiledsAttr, attr)
2020-07-18 21:12:14 +08:00
end
-- 设置数据
---@param paras _ParamTRPAbout
function TRPAbout:setData(paras)
self.mdata = {}
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPAbout:show()
---@type _ParamCellExtendFiledRoot
local fieldRootInfor = {}
fieldRootInfor.fields = {}
fieldRootInfor.data = self.mdata
fieldRootInfor.onFinish = self:wrapFunc(self.reposition)
for i, v in ipairs(self.baseFiledsAttr) do
---@type _ParamCellExtendFiled
local d = {}
d.attr = v
d.showMode = _FieldMode.button
d.onClick = self:wrapFunc(self.onClickField)
d.onSelect = self:wrapFunc(self.onSelectField)
table.insert(fieldRootInfor.fields, d)
end
uiobjs.TableLua:init(fieldRootInfor, nil)
end
---@param el CLUIElement
function TRPAbout:onClickField(el)
if el.jsonKey == "upgrade" then
-- 更新
2020-07-28 21:02:59 +08:00
self:upgrade()
2020-07-18 21:12:14 +08:00
elseif el.jsonKey == "serviceAgreement" then
-- 显示协议
2020-07-28 21:02:59 +08:00
local path =
joinStr(
CLPathCfg.self.basePath,
"/",
CLPathCfg.upgradeRes,
"/other/txt/",
CLPathCfg.self.platform,
"/serviceProto",
".unity3d"
)
CLVerManager.self:getNewestRes(
path,
CLAssetType.assetBundle,
function(path, content, orgs)
if content then
local msg = content.mainAsset and content.mainAsset.text or ""
content:Unload(false)
getPanelAsy(
"PanelSysMsgDetail",
onLoadedPanelTT,
{PanelTitle = "服务协议", TITLE = "服务协议", CONTENT = msg}
)
end
end,
true,
nil
)
2020-07-18 21:12:14 +08:00
elseif el.jsonKey == "assess" then
2020-07-28 21:02:59 +08:00
-- 评价(这个做起来麻烦)
2020-07-18 21:12:14 +08:00
end
end
2020-07-28 21:02:59 +08:00
function TRPAbout:upgrade()
showHotWheel()
local oldVer = __version__
local onGetVer = function(content, orgs)
hideHotWheel()
local map = JSON.DecodeMap(content)
local newVer = MapEx.getString(map, "ver")
if (tonumber(newVer) > tonumber(oldVer)) then
local doUpgradeApp = function()
Application.OpenURL(MapEx.getString(map, "url"))
end
if MapEx.getBool(map, "force") then
CLUIUtl.showConfirm(LGet("MsgHadNewVerApp"), true, "更新", doUpgradeApp, "", nil)
else
CLUIUtl.showConfirm(LGet("MsgHadNewVerApp"), false, "更新", doUpgradeApp, "忽略", nil)
end
else
MyUtl.toastS("当前已经是最新版本 V" .. newVer)
end
end
local onGetVerError = function(msg, orgs)
hideHotWheel()
MyUtl.toastW("更新检查失败")
end
local chlCode = getChlCode()
local url = Utl.urlAddTimes(joinStr(CLVerManager.self.baseUrl, "/appVer.", chlCode, ".json"))
WWWEx.get(url, CLAssetType.text, onGetVer, onGetVerError, nil, true, 1)
end
2020-07-18 21:12:14 +08:00
function TRPAbout:onSelectField(go)
end
function TRPAbout:reposition()
uiobjs.Table:Reposition()
uiobjs.Table.repositionNow = true
uiobjs.scrollView:ResetPosition()
end
-- 刷新
function TRPAbout:refresh()
end
-- 关闭页面
function TRPAbout:hide()
uiobjs.TableLua.luaTable.release()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPAbout:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
--[[
if cmd == xx then
end
]]
end
end
function TRPAbout:setEventDelegate()
self.EventDelegate = {}
end
-- 处理ui上的事件例如点击等
function TRPAbout:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func(go)
end
end
-- 当顶层页面发生变化时回调
function TRPAbout:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPAbout