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
ef0351c4
Commit
ef0351c4
authored
Mar 21, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 我的证件
parent
acd3623e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
267 additions
and
121 deletions
+267
-121
YHCertificateResourceUploadVC.swift
...yCertificates(我的证书)/C/YHCertificateResourceUploadVC.swift
+86
-23
YHUploadContentVC.swift
...vice(服务中心)/MyCertificates(我的证书)/C/YHUploadContentVC.swift
+75
-98
YHCertificateTemplateSheetView.swift
...Certificates(我的证书)/V/YHCertificateTemplateSheetView.swift
+6
-0
YHCertificateUploadSheetView.swift
...MyCertificates(我的证书)/V/YHCertificateUploadSheetView.swift
+28
-0
YHCertificateViewModel.swift
...务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
+72
-0
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHCertificateResourceUploadVC.swift
View file @
ef0351c4
...
@@ -128,14 +128,14 @@ extension YHCertificateResourceUploadVC: UITableViewDelegate, UITableViewDataSou
...
@@ -128,14 +128,14 @@ extension YHCertificateResourceUploadVC: UITableViewDelegate, UITableViewDataSou
let
item
=
items
[
indexPath
.
section
]
let
item
=
items
[
indexPath
.
section
]
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
{
// 待上传
if
item
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
{
// 待上传
showUploadSheetView
(
item
.
templateInfo
)
showUploadSheetView
(
item
)
return
return
}
}
// 非待上传的进入详情
// 非待上传的进入详情
let
vc
=
YHUploadContentVC
()
let
vc
=
YHUploadContentVC
()
vc
.
orderId
=
orderId
vc
.
orderId
=
orderId
vc
.
categoryInfo
=
categoryInfo
vc
.
categoryInfo
=
categoryInfo
vc
.
upload
Info
=
item
vc
.
supplement
Info
=
item
self
.
navigationController
?
.
pushViewController
(
vc
)
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
}
}
...
@@ -223,29 +223,92 @@ extension YHCertificateResourceUploadVC {
...
@@ -223,29 +223,92 @@ extension YHCertificateResourceUploadVC {
}
}
}
}
func
showUploadSheetView
(
_
template
:
YHTemplateInfo
)
{
func
uploadImage
(
_
img
:
UIImage
,
supplementInfo
:
YHSupplementInfo
)
{
// 先OSS上传得到URL
YHHUD
.
show
(
.
progress
(
message
:
"上传中..."
))
self
.
viewModel
.
uploadImage
(
img
)
{
[
weak
self
]
url
,
error
in
guard
let
self
=
self
else
{
return
}
YHHUD
.
hide
()
if
let
url
=
url
,
!
url
.
isEmpty
{
let
imgName
=
url
.
lastPathComponent
var
suffix
=
"jpg"
let
suffixName
=
url
.
pathExtension
.
lowercased
()
if
!
suffixName
.
isEmpty
{
suffix
=
suffixName
}
// 再调用业务接口
let
model
=
YHContentUrl
()
model
.
name
=
imgName
model
.
url
=
url
model
.
suffix
=
suffix
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
supplementInfo
.
id
,
urlModel
:
model
,
operation
:
"add"
,
rename
:
""
)
{
self
.
requestList
(
status
:
self
.
status
)
}
return
}
//
var
msg
=
"上传图片失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
}
func
uploadFile
(
_
fileUrl
:
URL
,
supplementInfo
:
YHSupplementInfo
)
{
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
// 先OSS上传得到URL
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
// 再调用业务接口
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
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
supplementInfo
.
id
,
urlModel
:
model
,
operation
:
"add"
,
rename
:
""
)
{
self
.
requestList
(
status
:
self
.
status
)
}
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
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
sheetView
.
templateInfo
=
template
sheetView
.
templateInfo
=
supplementInfo
.
templateInfo
sheetView
.
uploadFilesBlock
=
{
sheetView
.
uploadFilesBlock
=
{
[
weak
self
]
fileUrl
in
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
print
(
fileUrl
)
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
uploadFile
(
fileUrl
,
supplementInfo
:
supplementInfo
)
// 将文件数据上传到服务器
}
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
sheetView
.
uploadImageBlock
=
{
print
(
"
\(
size
)
"
)
[
weak
self
]
image
in
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
uploadImage
(
image
,
supplementInfo
:
supplementInfo
)
}
}
sheetView
.
show
()
}
}
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
image
in
guard
let
self
=
self
else
{
return
}
// uploadImage(image)
}
sheetView
.
show
()
}
}
}
}
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/C/YHUploadContentVC.swift
View file @
ef0351c4
...
@@ -13,10 +13,10 @@ class YHUploadContentVC: YHBaseViewController {
...
@@ -13,10 +13,10 @@ class YHUploadContentVC: YHBaseViewController {
var
orderId
:
Int
!
var
orderId
:
Int
!
var
categoryInfo
:
YHCategoryData
!
var
categoryInfo
:
YHCategoryData
!
var
upload
Info
:
YHSupplementInfo
!
{
var
supplement
Info
:
YHSupplementInfo
!
{
didSet
{
didSet
{
templateArr
.
removeAll
()
templateArr
.
removeAll
()
if
let
uploadInfo
=
upload
Info
{
if
let
uploadInfo
=
supplement
Info
{
if
uploadInfo
.
templateInfo
.
materialPath
.
count
>
0
{
if
uploadInfo
.
templateInfo
.
materialPath
.
count
>
0
{
templateArr
.
append
(
uploadInfo
.
templateInfo
.
materialPath
[
0
])
templateArr
.
append
(
uploadInfo
.
templateInfo
.
materialPath
[
0
])
}
}
...
@@ -88,7 +88,7 @@ class YHUploadContentVC: YHBaseViewController {
...
@@ -88,7 +88,7 @@ class YHUploadContentVC: YHBaseViewController {
createUI
()
createUI
()
items
.
removeAll
()
items
.
removeAll
()
items
.
append
(
contentsOf
:
upload
Info
.
contentUrl
)
items
.
append
(
contentsOf
:
supplement
Info
.
contentUrl
)
tableView
.
reloadData
()
tableView
.
reloadData
()
requestList
()
requestList
()
...
@@ -97,7 +97,9 @@ class YHUploadContentVC: YHBaseViewController {
...
@@ -97,7 +97,9 @@ class YHUploadContentVC: YHBaseViewController {
[
weak
self
]
text
in
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
if
let
selectEditItem
=
selectEditItem
,
let
text
=
text
{
if
let
selectEditItem
=
selectEditItem
,
let
text
=
text
{
self
.
updateCertificateItem
(
selectEditItem
,
operation
:
"rename"
,
rename
:
text
)
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
supplementInfo
.
id
,
urlModel
:
selectEditItem
,
operation
:
"rename"
,
rename
:
text
)
{
self
.
requestList
()
}
}
}
}
}
}
}
...
@@ -108,20 +110,12 @@ class YHUploadContentVC: YHBaseViewController {
...
@@ -108,20 +110,12 @@ class YHUploadContentVC: YHBaseViewController {
@objc
func
didClickUploadBtn
()
{
@objc
func
didClickUploadBtn
()
{
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
let
sheetView
=
YHCertificateUploadSheetView
.
sheetView
sheetView
.
templateInfo
=
upload
Info
.
templateInfo
sheetView
.
templateInfo
=
supplement
Info
.
templateInfo
sheetView
.
uploadFilesBlock
=
{
sheetView
.
uploadFilesBlock
=
{
[
weak
self
]
fileUrl
in
[
weak
self
]
fileUrl
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
print
(
fileUrl
)
print
(
fileUrl
)
if
let
fileData
=
try
?
Data
(
contentsOf
:
fileUrl
)
{
uploadFile
(
fileUrl
)
// 将文件数据上传到服务器
let
size
=
String
(
format
:
"%.2fM"
,
Double
(
fileData
.
count
)
/
(
1024.0
*
1024.0
))
print
(
"
\(
size
)
"
)
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
}
}
}
}
sheetView
.
uploadImageBlock
=
{
sheetView
.
uploadImageBlock
=
{
[
weak
self
]
image
in
[
weak
self
]
image
in
...
@@ -140,7 +134,7 @@ class YHUploadContentVC: YHBaseViewController {
...
@@ -140,7 +134,7 @@ class YHUploadContentVC: YHBaseViewController {
tableView
.
snp
.
makeConstraints
{
make
in
tableView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
k_Height_NavigationtBarAndStatuBar
)
make
.
top
.
equalTo
(
k_Height_NavigationtBarAndStatuBar
)
make
.
left
.
right
.
equalTo
(
view
)
make
.
left
.
right
.
equalTo
(
view
)
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
}
else
{
}
else
{
make
.
bottom
.
equalTo
(
uploadBtn
.
snp
.
top
)
.
offset
(
-
34
)
make
.
bottom
.
equalTo
(
uploadBtn
.
snp
.
top
)
.
offset
(
-
34
)
...
@@ -205,7 +199,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -205,7 +199,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
YHCertificateEditItem
(
type
:
.
delete
,
title
:
"删除"
),
YHCertificateEditItem
(
type
:
.
delete
,
title
:
"删除"
),
YHCertificateEditItem
(
type
:
.
cancel
,
title
:
"取消"
)]
YHCertificateEditItem
(
type
:
.
cancel
,
title
:
"取消"
)]
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
items
=
[
YHCertificateEditItem
(
type
:
.
preview
,
title
:
"预览"
),
items
=
[
YHCertificateEditItem
(
type
:
.
preview
,
title
:
"预览"
),
YHCertificateEditItem
(
type
:
.
cancel
,
title
:
"取消"
)]
YHCertificateEditItem
(
type
:
.
cancel
,
title
:
"取消"
)]
}
}
...
@@ -225,7 +219,9 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -225,7 +219,9 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
let
msg
=
"您确定要删除文档
\(
contentItem
.
name
)
吗"
let
msg
=
"您确定要删除文档
\(
contentItem
.
name
)
吗"
YHTwoOptionAlertView
.
showAlertView
(
message
:
msg
)
{
sure
in
YHTwoOptionAlertView
.
showAlertView
(
message
:
msg
)
{
sure
in
if
!
sure
{
return
}
if
!
sure
{
return
}
self
.
updateCertificateItem
(
contentItem
,
operation
:
"del"
,
rename
:
""
)
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
self
.
supplementInfo
.
id
,
urlModel
:
contentItem
,
operation
:
"del"
,
rename
:
""
)
{
self
.
requestList
()
}
}
}
}
else
if
editType
==
.
preview
{
// 预览
}
else
if
editType
==
.
preview
{
// 预览
...
@@ -247,7 +243,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -247,7 +243,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
if
section
==
0
{
if
section
==
0
{
if
upload
Info
.
templateInfo
.
isNeedShowTemplate
()
{
if
supplement
Info
.
templateInfo
.
isNeedShowTemplate
()
{
return
UITableView
.
automaticDimension
return
UITableView
.
automaticDimension
}
}
return
0.0
return
0.0
...
@@ -260,7 +256,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -260,7 +256,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
let
view
=
UIView
()
let
view
=
UIView
()
if
section
==
0
{
// 证件示例模版
if
section
==
0
{
// 证件示例模版
if
!
upload
Info
.
templateInfo
.
isNeedShowTemplate
()
{
if
!
supplement
Info
.
templateInfo
.
isNeedShowTemplate
()
{
return
view
return
view
}
}
...
@@ -268,7 +264,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -268,7 +264,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
titlelabel
.
textColor
=
UIColor
.
mainTextColor
titlelabel
.
textColor
=
UIColor
.
mainTextColor
titlelabel
.
textAlignment
=
.
left
titlelabel
.
textAlignment
=
.
left
titlelabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
17
)
titlelabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
17
)
titlelabel
.
text
=
"
\(
upload
Info
.
name
)
示例模版"
titlelabel
.
text
=
"
\(
supplement
Info
.
name
)
示例模版"
titlelabel
.
numberOfLines
=
0
titlelabel
.
numberOfLines
=
0
view
.
addSubview
(
titlelabel
)
view
.
addSubview
(
titlelabel
)
...
@@ -283,8 +279,8 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -283,8 +279,8 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
tipsLabel
.
textAlignment
=
.
left
tipsLabel
.
textAlignment
=
.
left
tipsLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
tipsLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
tipsLabel
.
numberOfLines
=
0
tipsLabel
.
numberOfLines
=
0
if
!
upload
Info
.
templateInfo
.
description
.
isEmpty
{
if
!
supplement
Info
.
templateInfo
.
description
.
isEmpty
{
tipsLabel
.
text
=
"注意事项:
\(
upload
Info
.
templateInfo
.
description
)
"
tipsLabel
.
text
=
"注意事项:
\(
supplement
Info
.
templateInfo
.
description
)
"
}
}
view
.
addSubview
(
tipsLabel
)
view
.
addSubview
(
tipsLabel
)
...
@@ -302,7 +298,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -302,7 +298,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
titlelabel
.
textColor
=
UIColor
.
mainTextColor
titlelabel
.
textColor
=
UIColor
.
mainTextColor
titlelabel
.
textAlignment
=
.
left
titlelabel
.
textAlignment
=
.
left
titlelabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
17
)
titlelabel
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
17
)
titlelabel
.
text
=
upload
Info
.
name
titlelabel
.
text
=
supplement
Info
.
name
titlelabel
.
numberOfLines
=
0
titlelabel
.
numberOfLines
=
0
view
.
addSubview
(
titlelabel
)
view
.
addSubview
(
titlelabel
)
...
@@ -316,21 +312,21 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -316,21 +312,21 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
var
text
=
""
var
text
=
""
var
textColor
:
UIColor
=
.
clear
var
textColor
:
UIColor
=
.
clear
var
bgColor
:
UIColor
=
.
clear
var
bgColor
:
UIColor
=
.
clear
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
review
.
rawValue
{
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
review
.
rawValue
{
text
=
"审核中"
.
local
text
=
"审核中"
.
local
textColor
=
UIColor
(
hexString
:
"#FF9900"
)
textColor
=
UIColor
(
hexString
:
"#FF9900"
)
bgColor
=
UIColor
(
hexString
:
"#FF9900"
,
0.08
)
bgColor
=
UIColor
(
hexString
:
"#FF9900"
,
0.08
)
}
else
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
}
else
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
preUpload
.
rawValue
{
text
=
"待上传"
.
local
text
=
"待上传"
.
local
textColor
=
UIColor
(
hexString
:
"#2F7EF6"
)
textColor
=
UIColor
(
hexString
:
"#2F7EF6"
)
bgColor
=
UIColor
(
hexString
:
"#2F7EF6"
,
0.08
)
bgColor
=
UIColor
(
hexString
:
"#2F7EF6"
,
0.08
)
}
else
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
}
else
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
finish
.
rawValue
{
text
=
"已通过"
.
local
text
=
"已通过"
.
local
textColor
=
UIColor
(
hexString
:
"#49D2B1"
)
textColor
=
UIColor
(
hexString
:
"#49D2B1"
)
bgColor
=
UIColor
(
hexString
:
"#49D2B1"
,
0.08
)
bgColor
=
UIColor
(
hexString
:
"#49D2B1"
,
0.08
)
}
else
if
upload
Info
.
checkStatus
==
YHCertificateUploadStatus
.
rejected
.
rawValue
{
}
else
if
supplement
Info
.
checkStatus
==
YHCertificateUploadStatus
.
rejected
.
rawValue
{
text
=
"已驳回"
.
local
text
=
"已驳回"
.
local
textColor
=
UIColor
(
hexString
:
"#F81D22"
)
textColor
=
UIColor
(
hexString
:
"#F81D22"
)
bgColor
=
UIColor
(
hexString
:
"#F81D22"
,
0.08
)
bgColor
=
UIColor
(
hexString
:
"#F81D22"
,
0.08
)
...
@@ -344,7 +340,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -344,7 +340,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
tipsLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
12
)
tipsLabel
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
12
)
tipsLabel
.
textAlignment
=
.
left
tipsLabel
.
textAlignment
=
.
left
tipsLabel
.
numberOfLines
=
0
tipsLabel
.
numberOfLines
=
0
tipsLabel
.
text
=
upload
Info
.
auditContent
tipsLabel
.
text
=
supplement
Info
.
auditContent
view
.
addSubview
(
tipsLabel
)
view
.
addSubview
(
tipsLabel
)
titlelabel
.
snp
.
makeConstraints
{
make
in
titlelabel
.
snp
.
makeConstraints
{
make
in
...
@@ -394,7 +390,14 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -394,7 +390,14 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
indexPath
.
section
==
0
{
// 模版列表
if
0
<=
indexPath
.
row
&&
indexPath
.
row
<
templateArr
.
count
{
let
path
=
templateArr
[
indexPath
.
row
]
}
}
else
if
indexPath
.
section
==
1
{
// 证件列表
}
}
}
@objc
func
dismissed
()
{
@objc
func
dismissed
()
{
...
@@ -446,7 +449,7 @@ extension YHUploadContentVC {
...
@@ -446,7 +449,7 @@ extension YHUploadContentVC {
"node"
:
"1"
,
"node"
:
"1"
,
"state"
:
"1"
,
"state"
:
"1"
,
"category_id"
:
categoryInfo
.
categoryId
,
"category_id"
:
categoryInfo
.
categoryId
,
"supplement_ids"
:
upload
Info
.
id
]
"supplement_ids"
:
supplement
Info
.
id
]
print
(
params
)
print
(
params
)
viewModel
.
getCertificateList
(
params
:
params
)
{
viewModel
.
getCertificateList
(
params
:
params
)
{
...
@@ -458,6 +461,9 @@ extension YHUploadContentVC {
...
@@ -458,6 +461,9 @@ extension YHUploadContentVC {
if
let
listInfo
=
listInfo
{
if
let
listInfo
=
listInfo
{
categoryInfo
=
listInfo
.
categoryData
categoryInfo
=
listInfo
.
categoryData
let
arr
=
listInfo
.
supplementList
let
arr
=
listInfo
.
supplementList
if
arr
.
count
>
0
{
supplementInfo
=
arr
[
0
]
}
for
item
in
arr
{
for
item
in
arr
{
items
.
append
(
contentsOf
:
item
.
contentUrl
)
items
.
append
(
contentsOf
:
item
.
contentUrl
)
}
}
...
@@ -470,73 +476,7 @@ extension YHUploadContentVC {
...
@@ -470,73 +476,7 @@ extension YHUploadContentVC {
}
}
}
}
// 更改证件
// operation参数必填,必须是:add(上传)、del(删除)、rename(重命名)
func
updateCertificateItem
(
_
model
:
YHContentUrl
,
operation
:
String
,
rename
:
String
)
{
var
name
=
model
.
name
if
operation
==
"rename"
{
name
=
rename
}
let
dic
:[
String
:
Any
]
=
[
"id"
:
uploadInfo
.
id
,
"content_url"
:
[
"name"
:
name
,
"url"
:
model
.
url
,
"suffix"
:
model
.
suffix
]]
let
params
:
[
String
:
Any
]
=
[
"file_info"
:
[
dic
],
"operation"
:
operation
,
]
self
.
viewModel
.
updateCertificates
(
params
:
params
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
if
operation
==
"del"
{
if
success
{
YHHUD
.
flash
(
message
:
"删除成功"
)
}
else
{
var
msg
=
"删除失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
requestList
()
return
}
if
operation
==
"rename"
{
if
success
{
YHHUD
.
flash
(
message
:
"重命名成功"
)
}
else
{
var
msg
=
"重命名失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
requestList
()
return
}
if
operation
==
"add"
{
if
success
{
YHHUD
.
flash
(
message
:
"添加成功"
)
}
else
{
var
msg
=
"添加失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
requestList
()
return
}
}
}
func
uploadImage
(
_
img
:
UIImage
)
{
func
uploadImage
(
_
img
:
UIImage
)
{
...
@@ -559,7 +499,9 @@ extension YHUploadContentVC {
...
@@ -559,7 +499,9 @@ extension YHUploadContentVC {
model
.
name
=
imgName
model
.
name
=
imgName
model
.
url
=
url
model
.
url
=
url
model
.
suffix
=
suffix
model
.
suffix
=
suffix
updateCertificateItem
(
model
,
operation
:
"add"
,
rename
:
""
)
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
supplementInfo
.
id
,
urlModel
:
model
,
operation
:
"add"
,
rename
:
""
)
{
self
.
requestList
()
}
return
return
}
}
//
//
...
@@ -570,5 +512,40 @@ extension YHUploadContentVC {
...
@@ -570,5 +512,40 @@ extension YHUploadContentVC {
YHHUD
.
flash
(
message
:
msg
)
YHHUD
.
flash
(
message
:
msg
)
}
}
}
}
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
self
.
viewModel
.
uploadFile
(
fileUrl
.
absoluteString
)
{
[
weak
self
]
successUrl
,
error
in
guard
let
self
=
self
else
{
return
}
// 再调用业务接口
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
self
.
viewModel
.
updateCertificateItem
(
supplementId
:
supplementInfo
.
id
,
urlModel
:
model
,
operation
:
"add"
,
rename
:
""
)
{
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(我的证书)/V/YHCertificateTemplateSheetView.swift
View file @
ef0351c4
...
@@ -239,6 +239,12 @@ extension YHCertificateTemplateSheetView: UITableViewDelegate, UITableViewDataSo
...
@@ -239,6 +239,12 @@ extension YHCertificateTemplateSheetView: UITableViewDelegate, UITableViewDataSo
return
cell
return
cell
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
0
<=
indexPath
.
row
&&
indexPath
.
row
<
templateArr
.
count
{
let
path
=
templateArr
[
indexPath
.
row
]
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
82.0
return
82.0
}
}
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/V/YHCertificateUploadSheetView.swift
View file @
ef0351c4
...
@@ -253,6 +253,33 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
...
@@ -253,6 +253,33 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
return
cell
return
cell
}
}
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
indexPath
.
section
==
0
{
// 模版列表
if
0
<=
indexPath
.
row
&&
indexPath
.
row
<
templateArr
.
count
{
let
path
=
templateArr
[
indexPath
.
row
]
}
}
else
if
indexPath
.
section
==
1
{
// 操作列表
if
0
<=
indexPath
.
row
&&
indexPath
.
row
<
uploadTypeArr
.
count
{
let
operationItem
=
uploadTypeArr
[
indexPath
.
row
]
if
operationItem
.
type
==
.
cancel
{
dismiss
()
}
else
if
operationItem
.
type
==
.
photo
{
selectPhoto
()
}
else
if
operationItem
.
type
==
.
camera
{
takePhoto
()
}
else
if
operationItem
.
type
==
.
phoneFile
{
selectFile
()
}
}
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
indexPath
.
section
==
0
{
if
indexPath
.
section
==
0
{
return
82.0
return
82.0
...
@@ -364,6 +391,7 @@ extension YHCertificateUploadSheetView: (UIImagePickerControllerDelegate & UINav
...
@@ -364,6 +391,7 @@ extension YHCertificateUploadSheetView: (UIImagePickerControllerDelegate & UINav
}
else
{
}
else
{
printLog
(
"pick image wrong"
)
printLog
(
"pick image wrong"
)
self
.
dismiss
()
}
}
// 收回图库选择界面
// 收回图库选择界面
picker
.
dismiss
(
animated
:
true
,
completion
:
nil
)
picker
.
dismiss
(
animated
:
true
,
completion
:
nil
)
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/MyCertificates(我的证书)/VM/YHCertificateViewModel.swift
View file @
ef0351c4
...
@@ -198,4 +198,76 @@ class YHCertificateViewModel: YHBaseViewModel {
...
@@ -198,4 +198,76 @@ class YHCertificateViewModel: YHBaseViewModel {
callBack
(
false
,
err
)
callBack
(
false
,
err
)
}
}
}
}
// 更改证件
// operation参数必填,必须是:add(上传)、del(删除)、rename(重命名)
func
updateCertificateItem
(
supplementId
:
Int
,
urlModel
:
YHContentUrl
,
operation
:
String
,
rename
:
String
,
callBack
:(()
->
())?)
{
var
name
=
urlModel
.
name
if
operation
==
"rename"
{
name
=
rename
}
let
dic
:[
String
:
Any
]
=
[
"id"
:
supplementId
,
"content_url"
:
[
"name"
:
name
,
"url"
:
urlModel
.
url
,
"suffix"
:
urlModel
.
suffix
]]
let
params
:
[
String
:
Any
]
=
[
"file_info"
:
[
dic
],
"operation"
:
operation
,
]
YHHUD
.
show
(
.
progress
(
message
:
"数据加载中..."
))
self
.
updateCertificates
(
params
:
params
)
{
[
weak
self
]
success
,
error
in
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
if
operation
==
"del"
{
if
success
{
YHHUD
.
flash
(
message
:
"删除成功"
)
}
else
{
var
msg
=
"删除失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
callBack
?()
return
}
if
operation
==
"rename"
{
if
success
{
YHHUD
.
flash
(
message
:
"重命名成功"
)
}
else
{
var
msg
=
"重命名失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
callBack
?()
return
}
if
operation
==
"add"
{
if
success
{
YHHUD
.
flash
(
message
:
"添加成功"
)
}
else
{
var
msg
=
"添加失败"
if
let
errorMsg
=
error
?
.
errorMsg
,
!
errorMsg
.
isEmpty
{
msg
=
errorMsg
}
YHHUD
.
flash
(
message
:
msg
)
}
callBack
?()
return
}
}
}
}
}
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