Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
2e04dca5
Commit
2e04dca5
authored
Jun 06, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 上传逻辑优化
parent
aaed0e53
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
574 deletions
+43
-574
YHFileListItemsView.swift
...tService(服务中心)/FileList(文件清单)/V/YHFileListItemsView.swift
+9
-150
YHCertificateListVC.swift
...ce(服务中心)/MyCertificates(我的证书)/C/YHCertificateListVC.swift
+11
-149
YHCertificateSearchViewController.swift
...tificates(我的证书)/C/YHCertificateSearchViewController.swift
+13
-153
YHCertificateUploadContentListVC.swift
...rtificates(我的证书)/C/YHCertificateUploadContentListVC.swift
+9
-121
YHCertificateViewModel.swift
...务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
+1
-1
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/FileList(文件清单)/V/YHFileListItemsView.swift
View file @
2e04dca5
...
@@ -176,7 +176,7 @@ private extension YHFileListItemsView {
...
@@ -176,7 +176,7 @@ private extension YHFileListItemsView {
}
}
if
model
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
if
model
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
showUploadSheetView
(
model
)
showUploadSheetView
(
supplementId
:
model
.
id
)
return
return
}
}
// 非待上传的进入详情
// 非待上传的进入详情
...
@@ -187,157 +187,16 @@ private extension YHFileListItemsView {
...
@@ -187,157 +187,16 @@ private extension YHFileListItemsView {
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
}
func
showUploadSheetView
(
supplementId
:
Int
)
{
func
showUploadSheetView
(
_
supplementInfo
:
YHSupplementInfo
)
{
self
.
viewModel
.
showUploadSheetView
(
supplementId
:
supplementId
)
{
DispatchQueue
.
main
.
async
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
let
vc
=
YHCertificateUploadContentListVC
()
sheetView
.
maxSelectCount
=
9
vc
.
orderId
=
self
.
orderId
sheetView
.
uploadFilesBlock
=
{
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
[
weak
self
]
fileUrl
in
vc
.
supplementId
=
supplementId
guard
let
self
=
self
else
{
return
}
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
print
(
fileUrl
)
uploadFile
(
fileUrl
,
supplementInfo
:
supplementInfo
)
{
// 待上传的进入详情
DispatchQueue
.
main
.
async
{
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
vc
.
supplementId
=
supplementInfo
.
id
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
targetImgArr
in
guard
let
self
=
self
else
{
return
}
let
ossGroup
=
DispatchGroup
()
var
ossArr
:[
YHContentUrl
]
=
[]
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
// 先将所有图片组上传到OSS
for
item
in
targetImgArr
{
if
let
image
=
item
.
data
{
ossGroup
.
enter
()
uploadImage
(
image
,
imageName
:
item
.
name
,
supplementInfo
:
supplementInfo
)
{
success
,
urlModel
in
if
success
,
let
model
=
urlModel
{
ossArr
.
append
(
model
)
}
ossGroup
.
leave
()
}
}
}
// 再将OSS上传信息组上传到服务器
ossGroup
.
notify
(
queue
:
.
main
)
{
if
ossArr
.
count
<=
0
{
YHHUD
.
hide
()
YHHUD
.
flash
(
message
:
"上传失败"
)
return
}
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:
ossArr
,
operation
:
"add"
,
rename
:
""
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
if
success
{
if
ossArr
.
count
==
targetImgArr
.
count
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
YHHUD
.
flash
(
message
:
"
\(
ossArr
.
count
)
张照片上传成功
\n\(
targetImgArr
.
count
-
ossArr
.
count
)
张照片上传失败"
)
}
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
vc
.
categoryId
=
self
.
dataModel
?
.
category_id
??
0
vc
.
supplementId
=
supplementInfo
.
id
UIViewController
.
current
?
.
navigationController
?
.
pushViewController
(
vc
)
}
else
{
YHHUD
.
flash
(
message
:
"上传失败"
)
}
}
}
}
}
}
sheetView
.
show
()
}
func
uploadImage
(
_
img
:
UIImage
,
imageName
:
String
,
supplementInfo
:
YHSupplementInfo
,
callBack
:((
Bool
,
YHContentUrl
?)
->
())?)
{
// 先OSS上传得到URL
self
.
viewModel
.
uploadImage
(
img
)
{
url
,
error
in
if
let
url
=
url
,
!
url
.
isEmpty
{
var
suffix
=
"jpg"
let
suffixName
=
url
.
pathExtension
.
lowercased
()
if
!
suffixName
.
isEmpty
{
suffix
=
suffixName
}
// 再调用业务接口
let
model
=
YHContentUrl
()
model
.
name
=
imageName
model
.
url
=
url
model
.
suffix
=
suffix
callBack
?(
true
,
model
)
}
else
{
callBack
?(
false
,
nil
)
}
}
}
func
uploadFile
(
_
fileUrl
:
URL
,
supplementInfo
:
YHSupplementInfo
,
successBlock
:(()
->
())?)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
// 再调用业务接口
if
let
successUrl
=
successUrl
,
!
successUrl
.
isEmpty
{
let
fileName
=
successUrl
.
lastPathComponent
let
suffixName
=
successUrl
.
pathExtension
.
lowercased
()
let
model
=
YHContentUrl
()
model
.
name
=
fileName
model
.
url
=
successUrl
model
.
suffix
=
suffixName
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:[
model
],
operation
:
"add"
,
rename
:
""
)
{
success
,
error
in
YHHUD
.
hide
()
// self.requestList(status:self.status)
if
success
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
var
msg
=
"上传失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
if
success
{
successBlock
?()
}
}
return
}
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
else
{
YHHUD
.
flash
(
message
:
"识别文件失败"
)
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHCertificateListVC.swift
View file @
2e04dca5
...
@@ -113,7 +113,7 @@ extension YHCertificateListVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -113,7 +113,7 @@ extension YHCertificateListVC: UITableViewDelegate, UITableViewDataSource {
let
item
=
items
[
indexPath
.
section
]
let
item
=
items
[
indexPath
.
section
]
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
showUploadSheetView
(
item
)
showUploadSheetView
(
supplementId
:
item
.
id
)
return
return
}
}
// 非待上传的进入详情
// 非待上传的进入详情
...
@@ -208,156 +208,18 @@ extension YHCertificateListVC {
...
@@ -208,156 +208,18 @@ extension YHCertificateListVC {
}
}
}
}
func
uploadImage
(
_
img
:
UIImage
,
imageName
:
String
,
supplementInfo
:
YHSupplementInfo
,
callBack
:((
Bool
,
YHContentUrl
?)
->
())?)
{
func
showUploadSheetView
(
supplementId
:
Int
)
{
let
orderID
=
self
.
orderId
??
0
// 先OSS上传得到URL
self
.
viewModel
.
showUploadSheetView
(
supplementId
:
supplementId
)
{
self
.
viewModel
.
uploadImage
(
img
)
{
[
weak
self
]
in
[
weak
self
]
url
,
error
in
guard
let
self
=
self
else
{
return
}
if
let
url
=
url
,
!
url
.
isEmpty
{
var
suffix
=
"jpg"
let
suffixName
=
url
.
pathExtension
.
lowercased
()
if
!
suffixName
.
isEmpty
{
suffix
=
suffixName
}
// 再调用业务接口
let
model
=
YHContentUrl
()
model
.
name
=
imageName
model
.
url
=
url
model
.
suffix
=
suffix
callBack
?(
true
,
model
)
}
else
{
callBack
?(
false
,
nil
)
}
}
}
func
uploadFile
(
_
fileUrl
:
URL
,
supplementInfo
:
YHSupplementInfo
,
successBlock
:(()
->
())?)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
// 再调用业务接口
if
let
successUrl
=
successUrl
,
!
successUrl
.
isEmpty
{
let
fileName
=
successUrl
.
lastPathComponent
let
suffixName
=
successUrl
.
pathExtension
.
lowercased
()
let
model
=
YHContentUrl
()
model
.
name
=
fileName
model
.
url
=
successUrl
model
.
suffix
=
suffixName
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:[
model
],
operation
:
"add"
,
rename
:
""
)
{
success
,
error
in
YHHUD
.
hide
()
self
.
requestList
(
status
:
self
.
status
)
if
success
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
var
msg
=
"上传失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
if
success
{
successBlock
?()
}
}
return
}
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
else
{
YHHUD
.
flash
(
message
:
"识别文件失败"
)
}
}
func
showUploadSheetView
(
_
supplementInfo
:
YHSupplementInfo
)
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
sheetView
.
maxSelectCount
=
9
sheetView
.
uploadFilesBlock
=
{
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
uploadFile
(
fileUrl
,
supplementInfo
:
supplementInfo
)
{
// 待上传的进入详情
DispatchQueue
.
main
.
async
{
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
??
0
vc
.
categoryId
=
self
.
categoryInfo
.
categoryId
vc
.
supplementId
=
supplementInfo
.
id
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
targetImgArr
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
ossGroup
=
DispatchGroup
()
DispatchQueue
.
main
.
async
{
var
ossArr
:[
YHContentUrl
]
=
[]
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
orderID
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
vc
.
categoryId
=
self
.
categoryInfo
.
categoryId
// 先将所有图片组上传到OSS
vc
.
supplementId
=
supplementId
for
item
in
targetImgArr
{
self
.
navigationController
?
.
pushViewController
(
vc
)
if
let
image
=
item
.
data
{
ossGroup
.
enter
()
uploadImage
(
image
,
imageName
:
item
.
name
,
supplementInfo
:
supplementInfo
)
{
success
,
urlModel
in
if
success
,
let
model
=
urlModel
{
ossArr
.
append
(
model
)
}
ossGroup
.
leave
()
}
}
}
// 再将OSS上传信息组上传到服务器
ossGroup
.
notify
(
queue
:
.
main
)
{
if
ossArr
.
count
<=
0
{
YHHUD
.
hide
()
YHHUD
.
flash
(
message
:
"上传失败"
)
return
}
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:
ossArr
,
operation
:
"add"
,
rename
:
""
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
if
success
{
if
ossArr
.
count
==
targetImgArr
.
count
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
YHHUD
.
flash
(
message
:
"
\(
ossArr
.
count
)
张照片上传成功
\n\(
targetImgArr
.
count
-
ossArr
.
count
)
张照片上传失败"
)
}
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
??
0
vc
.
categoryId
=
self
.
categoryInfo
.
categoryId
vc
.
supplementId
=
supplementInfo
.
id
self
.
navigationController
?
.
pushViewController
(
vc
)
}
else
{
YHHUD
.
flash
(
message
:
"上传失败"
)
}
}
}
}
}
}
sheetView
.
show
()
}
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHCertificateSearchViewController.swift
View file @
2e04dca5
...
@@ -80,14 +80,11 @@ class YHCertificateSearchViewController: YHBaseViewController {
...
@@ -80,14 +80,11 @@ class YHCertificateSearchViewController: YHBaseViewController {
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
backgroundColor
=
.
white
self
.
gk_navTitle
=
"资料搜索"
.
local
self
.
gk_navTitle
=
"资料搜索"
.
local
createUI
()
createUI
()
requestList
(
keyWord
:
""
)
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
if
let
text
=
searchBar
.
textField
.
text
,
!
text
.
isEmpty
{
self
.
requestList
(
keyWord
:
searchBar
.
textField
.
text
)
self
.
requestList
(
keyWord
:
text
)
}
}
}
func
createUI
()
{
func
createUI
()
{
...
@@ -150,7 +147,7 @@ extension YHCertificateSearchViewController: UITableViewDelegate, UITableViewDat
...
@@ -150,7 +147,7 @@ extension YHCertificateSearchViewController: UITableViewDelegate, UITableViewDat
let
item
=
items
[
indexPath
.
section
]
let
item
=
items
[
indexPath
.
section
]
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
// 待上传
showUploadSheetView
(
item
)
showUploadSheetView
(
supplementId
:
item
.
id
)
return
return
}
}
// 非待上传的进入详情
// 非待上传的进入详情
...
@@ -223,156 +220,19 @@ extension YHCertificateSearchViewController {
...
@@ -223,156 +220,19 @@ extension YHCertificateSearchViewController {
}
}
}
}
func
uploadImage
(
_
img
:
UIImage
,
imageName
:
String
,
supplementInfo
:
YHSupplementInfo
,
callBack
:((
Bool
,
YHContentUrl
?)
->
())?)
{
func
showUploadSheetView
(
supplementId
:
Int
)
{
let
orderID
=
self
.
orderId
??
0
// 先OSS上传得到URL
let
categoryId
=
self
.
categoryInfo
?
.
categoryId
??
0
self
.
viewModel
.
uploadImage
(
img
)
{
self
.
viewModel
.
showUploadSheetView
(
supplementId
:
supplementId
)
{
[
weak
self
]
url
,
error
in
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
if
let
url
=
url
,
!
url
.
isEmpty
{
DispatchQueue
.
main
.
async
{
var
suffix
=
"jpg"
let
vc
=
YHCertificateUploadContentListVC
()
let
suffixName
=
url
.
pathExtension
.
lowercased
()
vc
.
orderId
=
orderID
if
!
suffixName
.
isEmpty
{
vc
.
categoryId
=
categoryId
suffix
=
suffixName
vc
.
supplementId
=
supplementId
}
self
.
navigationController
?
.
pushViewController
(
vc
)
let
model
=
YHContentUrl
()
model
.
name
=
imageName
model
.
url
=
url
model
.
suffix
=
suffix
callBack
?(
true
,
model
)
}
else
{
callBack
?(
false
,
nil
)
}
}
}
func
uploadFile
(
_
fileUrl
:
URL
,
supplementInfo
:
YHSupplementInfo
,
successBlock
:(()
->
())?)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
// 再调用业务接口
if
let
successUrl
=
successUrl
,
!
successUrl
.
isEmpty
{
let
fileName
=
successUrl
.
lastPathComponent
let
suffixName
=
successUrl
.
pathExtension
.
lowercased
()
let
model
=
YHContentUrl
()
model
.
name
=
fileName
model
.
url
=
successUrl
model
.
suffix
=
suffixName
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:[
model
],
operation
:
"add"
,
rename
:
""
)
{
success
,
error
in
YHHUD
.
hide
()
if
success
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
var
msg
=
"上传失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
self
.
requestList
(
keyWord
:
self
.
searchBar
.
textField
.
text
)
if
success
{
successBlock
?()
}
}
return
}
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
}
else
{
YHHUD
.
flash
(
message
:
"识别文件失败"
)
}
}
func
showUploadSheetView
(
_
supplementInfo
:
YHSupplementInfo
)
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
sheetView
.
maxSelectCount
=
9
sheetView
.
uploadFilesBlock
=
{
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
uploadFile
(
fileUrl
,
supplementInfo
:
supplementInfo
)
{
// 待上传的进入详情
DispatchQueue
.
main
.
async
{
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
??
0
vc
.
categoryId
=
self
.
categoryInfo
?
.
categoryId
??
0
vc
.
supplementId
=
supplementInfo
.
id
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
targetImgArr
in
guard
let
self
=
self
else
{
return
}
let
ossGroup
=
DispatchGroup
()
var
ossArr
:[
YHContentUrl
]
=
[]
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
// 先将所有图片组上传到OSS
for
item
in
targetImgArr
{
if
let
image
=
item
.
data
{
ossGroup
.
enter
()
uploadImage
(
image
,
imageName
:
item
.
name
,
supplementInfo
:
supplementInfo
)
{
success
,
urlModel
in
if
success
,
let
model
=
urlModel
{
ossArr
.
append
(
model
)
}
ossGroup
.
leave
()
}
}
}
// 再将OSS上传信息组上传到服务器
ossGroup
.
notify
(
queue
:
.
main
)
{
if
ossArr
.
count
<=
0
{
YHHUD
.
hide
()
YHHUD
.
flash
(
message
:
"上传失败"
)
return
}
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:
ossArr
,
operation
:
"add"
,
rename
:
""
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
if
success
{
let
vc
=
YHCertificateUploadContentListVC
()
vc
.
orderId
=
self
.
orderId
??
0
vc
.
categoryId
=
self
.
categoryInfo
?
.
categoryId
??
0
vc
.
supplementId
=
supplementInfo
.
id
self
.
navigationController
?
.
pushViewController
(
vc
)
if
ossArr
.
count
==
targetImgArr
.
count
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
YHHUD
.
flash
(
message
:
"
\(
ossArr
.
count
)
张照片上传成功
\n\(
targetImgArr
.
count
-
ossArr
.
count
)
张照片上传失败"
)
}
}
else
{
YHHUD
.
flash
(
message
:
"上传失败"
)
}
}
}
}
}
sheetView
.
show
()
}
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHCertificateUploadContentListVC.swift
View file @
2e04dca5
...
@@ -151,54 +151,19 @@ class YHCertificateUploadContentListVC: YHBaseViewController {
...
@@ -151,54 +151,19 @@ class YHCertificateUploadContentListVC: YHBaseViewController {
[
weak
self
]
fileUrl
in
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
print
(
fileUrl
)
uploadFile
(
fileUrl
)
self
.
viewModel
.
uploadFile
(
fileUrl
,
supplementId
:
supplementId
)
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
self
.
requestList
()
}
}
}
sheetView
.
uploadImageBlock
=
{
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
targetImgArr
in
[
weak
self
]
targetImgArr
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
let
ossGroup
=
DispatchGroup
()
self
.
viewModel
.
uploadImageArr
(
targetImgArr
,
supplementId
:
supplementId
)
{
var
ossArr
:[
YHContentUrl
]
=
[]
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
requestList
()
// 先将所有图片组上传到OSS
for
item
in
targetImgArr
{
if
let
image
=
item
.
data
{
ossGroup
.
enter
()
uploadImage
(
image
,
imageName
:
item
.
name
)
{
success
,
urlModel
in
if
success
,
let
model
=
urlModel
{
ossArr
.
append
(
model
)
}
ossGroup
.
leave
()
}
}
}
// 再将OSS上传信息组上传到服务器
ossGroup
.
notify
(
queue
:
.
main
)
{
if
ossArr
.
count
<=
0
{
YHHUD
.
hide
()
YHHUD
.
flash
(
message
:
"上传失败"
)
return
}
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
self
.
supplementInfo
.
id
,
urlModels
:
ossArr
,
operation
:
"add"
,
rename
:
""
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
self
.
requestList
()
if
success
{
if
ossArr
.
count
==
targetImgArr
.
count
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
YHHUD
.
flash
(
message
:
"
\(
ossArr
.
count
)
张照片上传成功
\n\(
targetImgArr
.
count
-
ossArr
.
count
)
张照片上传失败"
)
}
}
else
{
YHHUD
.
flash
(
message
:
"上传失败"
)
}
}
}
}
}
}
sheetView
.
show
()
sheetView
.
show
()
...
@@ -665,82 +630,5 @@ extension YHCertificateUploadContentListVC {
...
@@ -665,82 +630,5 @@ extension YHCertificateUploadContentListVC {
}
}
}
}
}
}
func
uploadImage
(
_
img
:
UIImage
,
imageName
:
String
,
callBack
:((
Bool
,
YHContentUrl
?)
->
())?)
{
// 先OSS上传得到URL
self
.
viewModel
.
uploadImage
(
img
)
{
[
weak
self
]
url
,
error
in
guard
let
self
=
self
else
{
return
}
if
let
url
=
url
,
!
url
.
isEmpty
{
var
suffix
=
"jpg"
let
suffixName
=
url
.
pathExtension
.
lowercased
()
if
!
suffixName
.
isEmpty
{
suffix
=
suffixName
}
let
model
=
YHContentUrl
()
model
.
name
=
imageName
model
.
url
=
url
model
.
suffix
=
suffix
callBack
?(
true
,
model
)
}
else
{
callBack
?(
false
,
nil
)
}
}
}
func
uploadFile
(
_
fileUrl
:
URL
)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
// 再调用业务接口
if
let
successUrl
=
successUrl
,
!
successUrl
.
isEmpty
{
var
fileName
=
fileUrl
.
lastPathComponent
if
fileName
.
isEmpty
{
fileName
=
successUrl
.
lastPathComponent
}
let
suffixName
=
successUrl
.
pathExtension
.
lowercased
()
let
model
=
YHContentUrl
()
model
.
name
=
fileName
model
.
url
=
successUrl
model
.
suffix
=
suffixName
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
updateCertificateItem
(
supplementsId
:
supplementInfo
.
id
,
urlModels
:[
model
],
operation
:
"add"
,
rename
:
""
)
{
success
,
error
in
YHHUD
.
hide
()
if
success
{
YHHUD
.
flash
(
message
:
"上传成功"
)
}
else
{
var
msg
=
"上传失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
self
.
requestList
()
}
return
}
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
else
{
YHHUD
.
flash
(
message
:
"识别文件失败"
)
}
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
View file @
2e04dca5
...
@@ -237,7 +237,7 @@ class YHCertificateViewModel: YHBaseViewModel {
...
@@ -237,7 +237,7 @@ class YHCertificateViewModel: YHBaseViewModel {
extension
YHCertificateViewModel
{
extension
YHCertificateViewModel
{
func
showUploadSheetView
(
orderId
:
Int
,
categoryId
:
Int
,
supplementId
:
Int
,
completion
:(()
->
())?)
{
func
showUploadSheetView
(
supplementId
:
Int
,
completion
:(()
->
())?)
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
()
sheetView
.
maxSelectCount
=
9
sheetView
.
maxSelectCount
=
9
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment