add file open

This commit is contained in:
2020-08-07 22:40:04 +08:00
parent c1e3f992aa
commit f9bedd2c62
115 changed files with 9835 additions and 1096 deletions

View File

@@ -120,27 +120,15 @@ function DBTextures.download(name, url, callback)
if File.Exists(localPath) then
_url = Path.Combine("file://", localPath)
end
local assetType
if MyUtl.isImage(name) then
assetType = CLAssetType.texture
else
assetType = CLAssetType.bytes
end
local www =
WWWEx.get(
_url,
nil,
CLAssetType.texture,
CLAssetType.bytes,
function(content, orgs)
isDownoading[name] = nil
if content then
local bytes
if assetType == CLAssetType.texture then
bytes = content:GetRawTextureData()
else
bytes = content
end
local bytes = content
Directory.CreateDirectory(Path.GetDirectoryName(localPath))
File.WriteAllBytes(localPath, bytes)
Utl.doCallback(downloadCallback[name], content, localPath)
@@ -162,6 +150,7 @@ function DBTextures.download(name, url, callback)
2
)
isDownoading[name] = www
return www
end
return DBTextures

View File

@@ -114,14 +114,14 @@ end
-- 上传头像
NetProto.uploadUserHeadIcon = function(path, finishCallback)
NetProto._uploadFile("updateUserImg", path, "", finishCallback)
NetProto._uploadFile("updateUserImg", path, "", MyUtl.CompressImage(path, 512), finishCallback)
end
NetProto.uploadFile = function(path, uploadPath, finishCallback)
NetProto._uploadFile("uploadFile", path, uploadPath, finishCallback)
NetProto._uploadFile("uploadFile", path, uploadPath, File.ReadAllBytes(path), finishCallback)
end
NetProto._uploadFile = function(methord, path, uploadPath, finishCallback)
NetProto._uploadFile = function(methord, path, uploadPath, bytes, finishCallback)
local params = {
operator = NetProto.loginNo,
uploadPath = uploadPath
@@ -134,7 +134,7 @@ NetProto._uploadFile = function(methord, path, uploadPath, finishCallback)
NetProto.httpHeader,
"uploadFile",
Path.GetFileName(path),
File.ReadAllBytes(path),
bytes,
CLAssetType.text,
function(content, orgs)
content = json.decode(content)

View File

@@ -270,6 +270,17 @@ MyGallery = CS.MyGallery
NativeCamera = CS.NativeCamera
---@type MyCamera
MyCamera = CS.MyCamera
---@type UnityEngine.Texture
Texture = CS.UnityEngine.Texture
---@type UnityEngine.Texture2D
Texture2D = CS.UnityEngine.Texture2D
---@type MyFileOpen
MyFileOpen = CS.MyFileOpen
---@type UnityEngine.TextureFormat
TextureFormat = CS.UnityEngine.TextureFormat
---@type UnityEngine.ImageConversion
ImageConversion = CS.UnityEngine.ImageConversion
-------------------------------------------------------
-------------------------------------------------------

View File

@@ -118,7 +118,9 @@ function MyUtl.setIsHidePhone(val)
end
MyUtl.hidePhone = function(phone)
if not phone then return end
if not phone then
return
end
if not MyUtl.isHidePhone then
return phone
end
@@ -135,7 +137,8 @@ MyUtl.Images = {
[".PNG"] = true,
[".PDF"] = true,
[".BMP"] = true,
[".GIF"] = true,
[".TGA"] = true,
[".GIF"] = true
}
---public 是图片
@@ -143,4 +146,24 @@ MyUtl.isImage = function(path)
local extension = Path.GetExtension(path)
return MyUtl.Images[string.upper(extension)] or false
end
---@param oldTexture UnityEngine.Texture2D
MyUtl.CompressImage = function(imgPath, maxSize, quality)
if not File.Exists(imgPath) then
printe("文件不存在==".. imgPath)
return
end
-- int quality = 80;//图片压缩质量1-100
quality = quality or 75
local bytes = File.ReadAllBytes(imgPath)
---@type UnityEngine.Texture2D
local texture = Texture2D(2, 2)
ImageConversion.LoadImage(texture, bytes)
texture = MyFileOpen.ResizeTexture(texture, maxSize, MyFileOpen.ImageFilterMode.Average)
local newBytes = ImageConversion.EncodeToJPG(texture, quality)
return newBytes
end
return MyUtl

View File

@@ -15,7 +15,7 @@ function _cell.init(csObj)
uiobjs.Label = getCC(transform, "Label", "UILabel")
uiobjs.ButtonDel = getChild(transform, "ButtonDel").gameObject
uiobjs.SpriteIcon = getCC(transform, "SpriteIcon", "UISprite")
uiobjs.SpriteRight = getChild(transform, "SpriteRight").gameObject
uiobjs.ButtonDownload = getChild(transform, "ButtonDownload").gameObject
uiobjs.DownloadProgress = getChild(transform, "DownloadProgress")
uiobjs.DownloadProgressLb = getCC(uiobjs.DownloadProgress, "Label", "UILabel")
@@ -28,15 +28,19 @@ function _cell.show(go, data)
SetActive(uiobjs.ButtonDel, false)
uiobjs.Label.text = mData.name
if MyUtl.isImage(mData.name) then
--//TODO:
uiobjs.SpriteIcon.spriteName = "work_img-icon"
else
uiobjs.SpriteIcon.spriteName = "work_wenjian-icon"
end
SetActive(uiobjs.DownloadProgress.gameObject, false)
--//TODO:权限判断,如果有权限的可以考虑直接显示图片
if DBTextures.hadDownloaded(mData.name) then
SetActive(uiobjs.ButtonDownload, false)
SetActive(uiobjs.SpriteRight, true)
else
SetActive(uiobjs.ButtonDownload, true)
SetActive(uiobjs.SpriteRight, false)
end
end
@@ -62,6 +66,7 @@ function _cell.download()
if content and localPath then
-- 附件下载完成
MyUtl.toastS(joinStr("附件已保存本地:" .. localPath))
SetActive(uiobjs.SpriteRight, true)
else
SetActive(uiobjs.ButtonDownload, true)
end
@@ -77,17 +82,11 @@ function _cell.refreshProgress()
else
SetActive(uiobjs.DownloadProgress.gameObject, true)
local progressVal = www.downloadProgress or 0 -- downloadProgress uploadProgress
uiobjs.LabelPersent.text = joinStr(math.floor(progressVal * 100), "%")
uiobjs.DownloadProgressLb.text = joinStr(math.floor(progressVal * 100), "%")
end
csSelf:invoke4Lua(_cell.refreshProgress, 0.1)
end
function _cell.uiEventDelegate(go)
if go.name == "ButtonDownload" then
_cell.download()
end
end
--------------------------------------------
return _cell

View File

@@ -66,7 +66,10 @@ end
function _cell.uiEventDelegate(go)
local goName = go.name
if goName == "ButtonFollow" then
getPanelAsy("PanelNewFollow", onLoadedPanelTT, mData)
---@type _ParamTRPNewFollow
local param = {}
param.cust = mData
getPanelAsy("PanelNewFollow", onLoadedPanelTT, param)
elseif goName == "ButtonTask" then
getPanelAsy("PanelNewFollowTask", onLoadedPanelTT, mData)
elseif goName == "ButtonContact" then

View File

@@ -26,6 +26,10 @@ end
-- 注意c#侧不会在调用show时调用refresh
function _cell.show(go, data)
mData = data
mData._phoneNo = MyUtl.hidePhone(mData.phone)
if isNilOrEmpty(mData.custName) then
mData.custName = mData._phoneNo
end
local optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.followUpTypeList)
uiobjs.LabelStatus:refreshItems(optionInfor.options, optionInfor.values)
local optionInfor = DBUser.getPopList(DBUser.FilterGroup.user)

View File

@@ -23,12 +23,14 @@ end
-- 注意c#侧不会在调用show时调用refresh
function _cell.show(go, data)
mData = data
-- mData.money = mData.prodNum * mData.salePrice
-- 修改数据
mData._phoneNo = MyUtl.hidePhone(mData.phoneNo)
if isNilOrEmpty(mData.custName) then
mData.custName = mData._phoneNo
end
local optionInfor = DBUser.getPopList(DBUser.FilterGroup.user)
uiobjs.LabelServerNo:refreshItems(optionInfor.options, optionInfor.values)
uiobjs.formRoot:setValue(mData)
if tonumber(mData.bookingDone) == 1 then
uiobjs.SpriteStatus.color = ColorEx.getColor(0xff27ae60)
else
@@ -36,11 +38,13 @@ function _cell.show(go, data)
if DateTime.Now:ToFileTime() > bookingTime:ToFileTime() then
--- 超时
uiobjs.SpriteStatus.color = ColorEx.getColor(0xfff15a4a)
mData.bookingDone = -1 --超时是特殊出来的
else
uiobjs.SpriteStatus.color = ColorEx.getColor(0xff999999)
end
end
uiobjs.formRoot:setValue(mData)
_cell.setHeadIcon()
end

View File

@@ -86,8 +86,14 @@ do
ButtonOK.localPosition = pos
SetActive(Spriteline2.gameObject, false)
else
ButtonCancel.localPosition = buttonCancelOrgPositon
ButtonOK.localPosition = buttonOkOrgPositon
local pos = ButtonCancel.localPosition
pos.x = buttonCancelOrgPositon.x
ButtonCancel.localPosition = pos
local pos = ButtonOK.localPosition
pos.x = buttonOkOrgPositon.x
ButtonOK.localPosition = pos
NGUITools.SetActive(ButtonCancel.gameObject, true)
lbButtonCancel.text = lbbutton2
SetActive(Spriteline2.gameObject, true)

View File

@@ -1,4 +1,9 @@
---@type IDBasePanel
---@class _ParamTRPCustDetail
---@field cust
---@field bookingData
---@field needShowMore
---@type IDBasePanel
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPCustDetail:TRBasePanel 邮件列表
local TRPCustDetail = class("TRPCustDetail", TRBasePanel)
@@ -36,6 +41,8 @@ function TRPCustDetail:init(csObj)
uiobjs.SpriteToggle.cellWidth = width
---@type UIToggle
uiobjs.ToggleDetail = getCC(uiobjs.SpriteToggle.transform, "ToggleDetail", "UIToggle")
---@type UIToggle
uiobjs.ToggleMore = getCC(uiobjs.SpriteToggle.transform, "ToggleMore", "UIToggle")
---@type CLUIFormRoot
uiobjs.DetailRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLUIFormRoot")
uiobjs.InputTask = getCC(uiobjs.DetailRoot.transform, "InputTask", "UIPopupList")
@@ -154,25 +161,27 @@ function TRPCustDetail:prepareMoreData()
attr.donotJoinKey = true
table.insert(self.sysFields, attr)
---@type _ParamFieldAttr
attr = {}
attr.id = "followupTime"
attr.attrName = "下次跟进"
attr.attrType = DBCust.FieldType.text
attr.ifMust = 0
attr.height = 180
attr.donotJoinKey = true
table.insert(self.sysFields, attr)
-- attr = {}
-- attr.id = "followupTime"
-- attr.attrName = "下次跟进"
-- attr.attrType = DBCust.FieldType.text
-- attr.ifMust = 0
-- attr.height = 180
-- attr.donotJoinKey = true
-- table.insert(self.sysFields, attr)
end
-- 设置数据
---@param paras _ParamTRPCustDetail
function TRPCustDetail:setData(paras)
---@type _DBCust
self.mdata = paras
self.mdata = paras.cust
self.mdata._phoneNo = MyUtl.hidePhone(self.mdata.phoneNo)
if type(self.mdata.jsonStr) == "string" then
self.mdata.jsonStr = json.decode(self.mdata.jsonStr)
end
self.bookingData = paras.bookingData
self.needShowMore = paras.needShowMore
end
---public 当有通用背板显示时的回调
@@ -190,6 +199,7 @@ end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPCustDetail:show()
-- SetActive(uiobjs.ToggleMore.gameObject, self.needShowMore)
self.records = nil
self.orders = nil
local optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.dealFlagList)
@@ -448,10 +458,10 @@ end
function TRPCustDetail:onClickMoreProc(el)
if el.jsonKey == "follows" then
-- 跟进记录
getPanelAsy("PanelFollowList", onLoadedPanelTT, {custId = self.mdata.custId})
getPanelAsy("PanelFollowList4Cust", onLoadedPanelTT, {custId = self.mdata.custId})
elseif el.jsonKey == "followTasks" then
-- 预约记录
getPanelAsy("PanelTaskList", onLoadedPanelTT, {custId = self.mdata.custId})
getPanelAsy("PanelTaskList4Cust", onLoadedPanelTT, {custId = self.mdata.custId})
elseif el.jsonKey == "smsList" then
-- 短信记录
elseif el.jsonKey == "opList" then
@@ -561,7 +571,11 @@ function TRPCustDetail:setEventDelegate()
self:showMore()
end,
ButtonNewFollow = function()
getPanelAsy("PanelNewFollow", onLoadedPanelTT, self.mdata)
---@type _ParamTRPNewFollow
local param = {}
param.cust = self.mdata
param.bookingData = self.bookingData
getPanelAsy("PanelNewFollow", onLoadedPanelTT, param)
end,
ButtonNewTask = function()
getPanelAsy("PanelNewFollowTask", onLoadedPanelTT, self.mdata)

View File

@@ -168,7 +168,12 @@ function TRPCustList:initCell(cell, data)
end
function TRPCustList:onClickCell(cell, data)
getPanelAsy("PanelCustDetail", onLoadedPanelTT, data)
---@type _ParamTRPCustDetail
local param = {}
param.cust = data
param.bookingData = nil
param.needShowMore = true
getPanelAsy("PanelCustDetail", onLoadedPanelTT, param)
end
function TRPCustList:refreshFilterBtnStatus()

View File

@@ -166,7 +166,10 @@ function TRPFollowList:initCell(cell, data)
end
function TRPFollowList:onClickCell(cell, data)
getPanelAsy("PanelNewFollow", onLoadedPanelTT, data)
---@type _ParamTRPNewFollow
local param = {}
param.followData = data
getPanelAsy("PanelNewFollow", onLoadedPanelTT, param)
end
function TRPFollowList:refreshFilterBtnStatus()

View File

@@ -396,7 +396,12 @@ function TRPNewCust:setEventDelegate()
cust,
function(content)
if content.success then
getPanelAsy("PanelCustDetail", onLoadedPanel, content.result)
---@type _ParamTRPCustDetail
local param = {}
param.cust = content.result
param.bookingData = nil
param.needShowMore = true
getPanelAsy("PanelCustDetail", onLoadedPanel, param)
end
hideHotWheel()
end

View File

@@ -1,4 +1,9 @@
---@type IDBasePanel
---@class _ParamTRPNewFollow
---@field cust
---@field followData
---@field bookingData
---@type IDBasePanel
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPNewFollow:TRBasePanel 邮件列表
local TRPNewFollow = class("TRPNewFollow", TRBasePanel)
@@ -111,14 +116,17 @@ end
-- 设置数据
---@param paras _ParamTRPNewFollow
function TRPNewFollow:setData(paras)
if paras.recordingTime then
self.mdata = paras
self.cust = paras.cust
self.mdata = paras.followData
self.bookingData = paras.bookingData
if self.mdata and self.mdata.recordingTime then
self.isNewFollow = false
else
self.mdata = {}
self.mdata.custId = paras.custId
self.mdata.taskId = paras.taskId
self.mdata.custName = paras.custName
self.mdata.custId = self.cust.custId
self.mdata.taskId = self.cust.taskId
self.mdata.custName = self.cust.custName
self.mdata.opportunity = "0"
self.mdata.followUpType = "0"
@@ -244,12 +252,19 @@ function TRPNewFollow:setEventDelegate()
return
end
self.mdata = uiobjs.DetailFromRoot:getValue(self.mdata, true)
if self.bookingData then
self.mdata.bookingId = self.bookingData.bookingId
end
showHotWheel()
NetProto.send.create_followUp_record(
self.mdata,
function(content)
hideHotWheel()
if content.success then
if self.bookingData then
-- 刷新预约的状态
self.bookingData.bookingDone = "1"
end
MyUtl.toastS("保存成功")
hideTopPanel(self.csSelf)
end
@@ -267,12 +282,14 @@ function TRPNewFollow:setEventDelegate()
hideHotWheel()
if content.success then
local cust = content.result
---@type _ParamTRPCustDetail
local param = {}
param.cust = cust
param.bookingData = self.mdata
param.needShowMore = false
if cust then
getPanelAsy(
"PanelCustDetailSimple",
onLoadedPanelTT,
{cust = cust, isShowButtonGet = false}
)
getPanelAsy("PanelCustDetail", onLoadedPanelTF, param)
end
end
end

View File

@@ -25,6 +25,7 @@ function TRPNewFollowTask:init(csObj)
uiobjs.ButtonSave = getChild(self.transform, "Top/ButtonSave")
uiobjs.ButtonCustDetail = getChild(self.transform, "ButtonCustDetail")
uiobjs.ButtonNewFollow = getChild(self.transform, "ButtonNewFollow")
end
function TRPNewFollowTask:initFiledsAttr()
@@ -99,13 +100,16 @@ end
function TRPNewFollowTask:show()
if self.isNewFollow then
SetActive(uiobjs.ButtonCustDetail.gameObject, false)
SetActive(uiobjs.ButtonNewFollow.gameObject, false)
else
---@type Coolape.CLPanelLua
local panel = CLPanelManager.getPanel("PanelCustDetail")
if panel and panel.gameObject.activeInHierarchy then
SetActive(uiobjs.ButtonCustDetail.gameObject, false)
SetActive(uiobjs.ButtonNewFollow.gameObject, false)
else
SetActive(uiobjs.ButtonCustDetail.gameObject, true)
SetActive(uiobjs.ButtonNewFollow.gameObject, true)
end
end
@@ -232,6 +236,8 @@ function TRPNewFollowTask:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
if cmd == NetProto.cmds.update_customer then
self:refreshContent()
elseif cmd == NetProto.cmds.create_followUp_record then
self:refreshContent()
end
end
end
@@ -245,6 +251,12 @@ function TRPNewFollowTask:setEventDelegate()
return
end
self.mdata = uiobjs.DetailFromRoot:getValue(self.mdata, true)
-- 时间处理
local setDt = DateTime.Parse( self.mdata.bookingTime)
if setDt:ToFileTime() < DateTime.Now:ToFileTime() then
MyUtl.toastW("预约时间已过,请选择未来的预约时间")
return
end
showHotWheel()
NetProto.send.create_followUp_task(
self.mdata,
@@ -266,15 +278,27 @@ function TRPNewFollowTask:setEventDelegate()
if content.success then
local cust = content.result
if cust then
---@type _ParamTRPCustDetail
local param = {}
param.cust = cust
param.bookingData = self.mdata
param.needShowMore = false
getPanelAsy(
"PanelCustDetailSimple",
onLoadedPanelTT,
{cust = cust, isShowButtonGet = false}
"PanelCustDetail",
onLoadedPanelTF,
param
)
end
end
end
)
end,
ButtonNewFollow = function()
---@type _ParamTRPNewFollow
local param = {}
param.cust = self.mdata
param.bookingData = self.mdata
getPanelAsy("PanelNewFollow", onLoadedPanelTT, param)
end
}
end

View File

@@ -252,7 +252,7 @@ function TRPOrderDetail:showExtentFiles(templetId)
param.data = self.mdata and self.mdata.attrJson or {}
param.onFinish = self:wrapFunc(self.reposition)
param.fields = {}
local fields = DBCust.getFieldsByTask(templetId) or {}
local fields = DBOrder.getFields(templetId) or {}
---@type _ParamCellExtendFiled
local filedInfor
for i, v in ipairs(fields) do
@@ -301,13 +301,15 @@ function TRPOrderDetail:onClickAttachment(cell, data)
false,
"打开",
function()
Application.OpenURL(joinStr("file://", path))
-- Application.OpenURL(joinStr("file://", path))
MyFileOpen.open(path)
end,
"取消",
nil
)
else
MyUtl.toastW("附件未下载完成,暂时无法查看")
cell.luaTable.download()
-- MyUtl.toastW("附件未下载完成,暂时无法查看")
end
end

View File

@@ -103,9 +103,15 @@ function TRPResetPasswordStep2:setEventDelegate()
data,
function(content)
if content.success then
MyUtl.toastS("绑定手机号成功")
Prefs.setUserName(self.mData.phone)
hideTopPanel(self.csSelf)
hideTopPanel()
MyUtl.toastS("绑定手机号成功")
hideTopPanel()
hideTopPanel()
hideTopPanel()
hideTopPanel()
getPanelAsy("PanelLogin", onLoadedPanel)
end
end
)

View File

@@ -242,6 +242,8 @@ function TRPTaskList:procNetwork(cmd, succ, msg, paras)
uiobjs.Grid:refreshContentOnly()
elseif cmd == NetProto.cmds.save_customer then
self:refreshList()
elseif cmd == NetProto.cmds.create_followUp_record then
uiobjs.Grid:refreshContentOnly()
end
end
end