upgrade
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
---@class _ParamCellImage
|
||||
---@field path string
|
||||
---@field onDelete function
|
||||
---@field uploadInfor table
|
||||
|
||||
-- xx单元
|
||||
local _cell = {}
|
||||
@@ -10,6 +11,7 @@ local transform = nil
|
||||
---@type _ParamCellImage
|
||||
local mData = nil
|
||||
local uiobjs = {}
|
||||
local www
|
||||
|
||||
-- 初始化,只调用一次
|
||||
function _cell.init(csObj)
|
||||
@@ -17,6 +19,10 @@ function _cell.init(csObj)
|
||||
transform = csSelf.transform
|
||||
---@type UITexture
|
||||
uiobjs.texture = csSelf:GetComponent("UITexture")
|
||||
uiobjs.SpriteProgress = getCC(transform, "SpriteProgress", "UISprite")
|
||||
uiobjs.LabelPersent = getCC(uiobjs.SpriteProgress.transform, "LabelPersent", "UILabel")
|
||||
uiobjs.Failed = getChild(transform, "Failed")
|
||||
uiobjs.success = getChild(transform, "success")
|
||||
end
|
||||
|
||||
-- 显示,
|
||||
@@ -29,12 +35,51 @@ function _cell.show(go, data)
|
||||
else
|
||||
url = mData.path
|
||||
end
|
||||
print(url)
|
||||
if uiobjs.texture.mainTexture and uiobjs.texture.mainTexture.name == mData.path then
|
||||
else
|
||||
_cell.release()
|
||||
DBTextures.getByUrl(url, _cell.onGetTextue, mData.path)
|
||||
end
|
||||
|
||||
SetActive(uiobjs.success.gameObject, false)
|
||||
_cell.upload()
|
||||
end
|
||||
|
||||
function _cell.upload()
|
||||
SetActive(uiobjs.Failed.gameObject, false)
|
||||
www =
|
||||
DBTextures.upload(
|
||||
mData.path,
|
||||
DBOrder.getUploadPath(),
|
||||
function(content)
|
||||
www = nil
|
||||
SetActive(uiobjs.SpriteProgress.gameObject, false)
|
||||
if content and content.success then
|
||||
mData.uploadInfor = content.result
|
||||
SetActive(uiobjs.success.gameObject, true)
|
||||
else
|
||||
-- 显示重传按钮
|
||||
SetActive(uiobjs.Failed.gameObject, true)
|
||||
local msg = content and content.message or "上传失败"
|
||||
MyUtl.toastW(msg)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
_cell.refreshProgress()
|
||||
end
|
||||
|
||||
function _cell.refreshProgress()
|
||||
if www == nil then
|
||||
SetActive(uiobjs.SpriteProgress.gameObject, false)
|
||||
return
|
||||
end
|
||||
SetActive(uiobjs.SpriteProgress.gameObject, true)
|
||||
local progressVal = www.uploadProgress or 0 -- downloadProgress uploadProgress
|
||||
uiobjs.LabelPersent.text = PStr.b():a(math.floor(progressVal * 100)):a("%"):e()
|
||||
uiobjs.SpriteProgress.fillAmount = progressVal
|
||||
|
||||
csSelf:invoke4Lua(_cell.refreshProgress, 0.1)
|
||||
end
|
||||
|
||||
function _cell.onGetTextue(content, orgs)
|
||||
@@ -61,7 +106,12 @@ end
|
||||
|
||||
function _cell.uiEventDelegate(go)
|
||||
if go.name == "ButtonDel" then
|
||||
csSelf:cancelInvoke4Lua(_cell.refreshProgress)
|
||||
DBTextures.cancelUpload(mData.path, DBOrder.getUploadPath())
|
||||
www = nil
|
||||
Utl.doCallback(mData.onDelete, mData)
|
||||
elseif go.name == "ButtonReload" then
|
||||
_cell.upload()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user