66 lines
1.4 KiB
Lua
66 lines
1.4 KiB
Lua
---@class _DBUser
|
|
---@field loginNo
|
|
---@field loginName
|
|
---@field groupId
|
|
---@field imageUrl string 头像
|
|
|
|
DBUser = {}
|
|
local db = {}
|
|
local icons = {}
|
|
local poplist = {}
|
|
|
|
|
|
function DBUser.onGetUsers(list)
|
|
poplist.options = ArrayList()
|
|
poplist.values = ArrayList()
|
|
for i, v in ipairs(list) do
|
|
db[v.loginNo] = v
|
|
poplist.options:Add(v.loginName)
|
|
poplist.values:Add(v.loginNo)
|
|
end
|
|
end
|
|
|
|
function DBUser.getPopList()
|
|
return poplist
|
|
end
|
|
|
|
---@return _DBUser
|
|
function DBUser.getUserById(loginNo)
|
|
local user = db[loginNo]
|
|
if user == nil then
|
|
printe("get user is nil=", loginNo)
|
|
end
|
|
return user
|
|
end
|
|
|
|
function DBUser.getIcon(loginNo, callback)
|
|
---@type _DBUser
|
|
local user = DBUser.getUserById(loginNo)
|
|
if user == nil or isNilOrEmpty(user.imageUrl) then
|
|
Utl.doCallback(callback, nil)
|
|
return
|
|
end
|
|
if icons[user.imageUrl] then
|
|
Utl.doCallback(callback, icons[user.imageUrl])
|
|
return
|
|
end
|
|
WWWEx.get(
|
|
user.imageUrl,
|
|
nil,
|
|
CLAssetType.texture,
|
|
function(content, orgs)
|
|
content.name = user.imageUrl
|
|
icons[user.imageUrl] = content
|
|
Utl.doCallback(callback, content)
|
|
end,
|
|
function()
|
|
printe("取得头像失败")
|
|
end,
|
|
nil,
|
|
true,
|
|
2
|
|
)
|
|
end
|
|
|
|
return DBUser
|