Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/CSPMine.lua
2020-08-04 21:58:27 +08:00

139 lines
4.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- xx界面
local CSPMine = {}
local csSelf = nil
local transform = nil
CSPMine.sizeAdjust = 1
CSPMine.contentRect = Vector4.zero
local objs = {}
local mdata = {}
-- 初始化,只会调用一次
function CSPMine.init(csObj)
csSelf = csObj
transform = csObj.transform
CSPMine.contentRect = MyUtl.getUIContent(csSelf, nil, nil, true)
objs.Content = getCC(transform, "PanelContent", "UIPanel")
MyUtl.setContentView(objs.Content, MyUtl.defaultBottomHeight + 370)
---@type CLUIFormRoot
objs.Top = getCC(transform, "Top", "CLUIFormRoot")
---@type UITexture
objs.HeadIcon = getCC(objs.Top.transform, "SpriteHeadBg/SpriteHeadIcon", "UITexture")
---@type UIScrollView
objs.scrollView = objs.Content:GetComponent("UIScrollView")
end
-- 设置数据
function CSPMine.setData(paras)
-- 初始化顶部数据
-- local currGroup = Prefs.getCurrGroup(Prefs.getUserName())
-- local companyInfro = json.decode(currGroup)
-- local user = DBUser.getUserById(companyInfro.login_no)
-- headData.company_id = companyInfro.company_id
-- headData.company_name = companyInfro.company_name
-- if user then
-- headData.loginNo = user.loginNo
-- headData.loginName = user.loginName
-- headData.imageUrl = user.imageUrl
-- else
-- printe("账号信息未取得!")
-- end
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function CSPMine.show()
mdata = DBUser.getMyInfor()
CSPMine.setHeadInfor()
objs.scrollView:ResetPosition()
end
function CSPMine.setHeadInfor()
objs.Top:setValue(mdata)
DBUser.getIcon(
mdata.loginNo,
function(content)
objs.HeadIcon.mainTexture = content
end
)
end
-- 刷新
function CSPMine.refresh()
end
-- 关闭页面
function CSPMine.hide()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function CSPMine.procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
if cmd == NetProto.cmds.personal_data_query then
CSPMine.show()
end
end
end
-- 处理ui上的事件例如点击等
function CSPMine.uiEventDelegate(go)
local goName = go.name
if goName == "ButtonMyCheck" then
showHotWheel()
-- CSPMine.onGetLocation(json.encode({code = 0, latitude = "116.404", longitude = "39.915"}))
MyLocation.self:getMyLocation(CSPMine.onGetLocation)
elseif goName == "ButtonSetting" or goName == "ButtonMySetting" then
getPanelAsy("PanelSetting", onLoadedPanelTT)
elseif goName == "SpriteTopBg" then
getPanelAsy("PanelMyInfor", onLoadedPanelTT)
elseif goName == "ButtonAbout" then
getPanelAsy("PanelAbout", onLoadedPanelTT)
end
end
function CSPMine.onGetLocation(locInfor)
printe(locInfor)
local location = json.decode(locInfor)
local code = location.code
if code == 0 then
-- 116.404, 39.915
local latitude = location.latitude
local longitude = location.longitude
local AddrStr = location.AddrStr
local upgradeRes = "/upgradeRes"
if (CLCfgBase.self.isEditMode) then
upgradeRes = "/upgradeRes4Dev"
end
local url =
joinStr(
"trCrm",
upgradeRes,
"/priority/www/baidumap.html?latitude=",
latitude,
"&longitude=",
longitude,
"@AddrStr=",
AddrStr
)
getPanelAsy("PanelWebView", onLoadedPanelTT, {url = url})
else
MyUtl.toastW(location.msg)
if code == 8 or code == 9 or code == 5 then
-- 打开gps
MyLocation.self:guidSwitchGps()
end
end
hideHotWheel()
end
-- 当按了返回键时关闭自己返值为true时关闭
function CSPMine.hideSelfOnKeyBack()
return false
end
--------------------------------------------
return CSPMine