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
d07e1e47
Commit
d07e1e47
authored
Apr 02, 2025
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// plan
parent
719707b3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
8 deletions
+154
-8
YHPlanShareViewController.swift
...lasses/Modules/Plan(方案)/C/YHPlanShareViewController.swift
+101
-8
YHPlanViewController.swift
...axy/Classes/Modules/Plan(方案)/C/YHPlanViewController.swift
+8
-0
YHPlanViewModel.swift
.../galaxy/Classes/Modules/Plan(方案)/VM/YHPlanViewModel.swift
+23
-0
BG@2x.png
...s/Assets.xcassets/Plan/plan_share_icon.imageset/BG@2x.png
+0
-0
BG@3x.png
...s/Assets.xcassets/Plan/plan_share_icon.imageset/BG@3x.png
+0
-0
Contents.json
...sets.xcassets/Plan/plan_share_icon.imageset/Contents.json
+22
-0
No files found.
galaxy/galaxy/Classes/Modules/Plan(方案)/C/YHPlanShareViewController.swift
View file @
d07e1e47
...
...
@@ -67,7 +67,10 @@ class YHPlanShareBgView: UIView, JXSegmentedListContainerViewListDelegate {
class
YHPlanShareViewController
:
YHBaseViewController
{
var
type
:
YHPlanShareBgType
=
.
link
var
shareUrl
:
String
=
""
var
pdfUrl
:
String
=
""
var
pdfDownloadUrl
:
String
=
""
let
viewModel
=
YHPlanViewModel
()
let
segmentTitles
=
[
"分享链接"
,
"分享PDF"
]
let
bgWidth
=
293.0
let
bgHeight
=
380.0
...
...
@@ -121,21 +124,35 @@ class YHPlanShareViewController: YHBaseViewController {
if
type
==
.
link
{
if
eventType
==
.
wechat
{
let
iconImg
=
UIImage
(
named
:
"
shareI
con"
)
??
UIImage
()
YHShareManager
.
shared
.
sendLinkContent
(
"
SB"
,
"XXXXXXXX"
,
iconImg
,
link
:
"www.baidu.com"
)
let
iconImg
=
UIImage
(
named
:
"
plan_share_i
con"
)
??
UIImage
()
YHShareManager
.
shared
.
sendLinkContent
(
"
香港续签至永居方案分析"
,
"具体方案您可以联系专属顾问和生活管家深入咨询"
,
iconImg
,
link
:
shareUrl
)
}
else
if
eventType
==
.
copyLink
{
let
pasteBoard
=
UIPasteboard
.
general
pasteBoard
.
string
=
""
pasteBoard
.
string
=
shareUrl
YHHUD
.
flash
(
message
:
"复制成功"
)
}
}
else
if
type
==
.
pdf
{
if
eventType
==
.
wechat
{
}
else
if
eventType
==
.
saveImg
{
if
let
sourceUrl
=
URL
(
string
:
pdfDownloadUrl
)
{
let
lastComponent
=
sourceUrl
.
lastPathComponent
let
destinationURL
=
self
.
planDocumentFileUrl
.
appendingPathComponent
(
lastComponent
)
if
eventType
==
.
wechat
{
if
FileManager
.
default
.
fileExists
(
atPath
:
destinationURL
.
path
)
{
let
fileName
=
destinationURL
.
lastPathComponent
let
fileExtension
=
destinationURL
.
pathExtension
YHShareManager
.
shared
.
shareFileToWeChat
(
fileUrl
:
destinationURL
,
filename
:
fileName
,
ext
:
fileExtension
)
}
}
else
if
eventType
==
.
saveImg
{
if
FileManager
.
default
.
fileExists
(
atPath
:
destinationURL
.
path
)
{
YHHUD
.
flash
(
message
:
"已下载PDF"
)
return
}
self
.
requestPDF
()
}
}
}
}
...
...
@@ -154,6 +171,13 @@ class YHPlanShareViewController: YHBaseViewController {
return
v
}()
lazy
var
planDocumentFileUrl
:
URL
=
{
let
fileManager
=
FileManager
.
default
let
documentsURL
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)
.
first
!
let
planDirectoryURL
=
documentsURL
.
appendingPathComponent
(
"plan"
)
return
planDirectoryURL
}()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navigationBar
.
backgroundColor
=
.
clear
...
...
@@ -180,6 +204,75 @@ class YHPlanShareViewController: YHBaseViewController {
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
height
.
equalTo
(
216
)
}
requestPDF
()
}
func
requestPDF
()
{
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
self
.
viewModel
.
requetPDFUrl
(
self
.
pdfUrl
)
{
[
weak
self
]
url
in
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
self
.
pdfDownloadUrl
=
url
self
.
downloadPDF
(
url
)
}
}
func
downloadPDF
(
_
urlString
:
String
)
{
guard
let
url
=
URL
(
string
:
urlString
)
else
{
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
return
}
YHHUD
.
show
(
.
progress
(
message
:
"下载中..."
))
let
task
=
URLSession
.
shared
.
downloadTask
(
with
:
url
)
{
[
weak
self
]
(
locationUrl
,
_
,
error
)
in
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
guard
let
locationUrl
=
locationUrl
,
error
==
nil
else
{
print
(
"下载失败:
\(
error
?
.
localizedDescription
??
"未知错误"
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
return
}
self
.
savePDF
(
sourceUrl
:
url
,
locationUrl
:
locationUrl
)
}
}
task
.
resume
()
}
func
savePDF
(
sourceUrl
:
URL
,
locationUrl
:
URL
)
{
let
fileManager
=
FileManager
.
default
// 创建子文件夹如果不存在
if
!
fileManager
.
fileExists
(
atPath
:
self
.
planDocumentFileUrl
.
path
)
{
do
{
try
fileManager
.
createDirectory
(
at
:
self
.
planDocumentFileUrl
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
print
(
"目录已创建:
\(
self
.
planDocumentFileUrl
.
path
)
"
)
}
catch
{
print
(
"创建目录失败:
\(
error
.
localizedDescription
)
"
)
return
}
}
// 保存文件到 plan 目录
let
lastComponent
=
sourceUrl
.
lastPathComponent
let
destinationURL
=
self
.
planDocumentFileUrl
.
appendingPathComponent
(
lastComponent
)
do
{
// 如果文件已存在,先移除
if
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
)
{
try
fileManager
.
removeItem
(
at
:
destinationURL
)
}
try
fileManager
.
moveItem
(
at
:
locationUrl
,
to
:
destinationURL
)
print
(
"文件已保存到:
\(
destinationURL
.
path
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF成功"
)
}
catch
{
print
(
"保存文件失败:
\(
error
.
localizedDescription
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/C/YHPlanViewController.swift
View file @
d07e1e47
...
...
@@ -13,6 +13,8 @@ class YHPlanViewController: YHBaseViewController {
let
viewModel
=
YHPlanViewModel
()
var
shareUrl
:
String
=
""
var
pdfUrl
:
String
=
""
var
infoArr
:
[
String
]
=
[
""
,
""
,
""
,
""
,
""
,
""
]
var
analyzeArr
:
[
YHPlanAnalyzeModel
]
=
[
YHPlanAnalyzeModel
(),
YHPlanAnalyzeModel
(),
...
...
@@ -85,6 +87,8 @@ class YHPlanViewController: YHBaseViewController {
@objc
func
didShareBtnClicked
()
{
let
vc
=
YHPlanShareViewController
()
vc
.
shareUrl
=
self
.
shareUrl
vc
.
pdfUrl
=
self
.
pdfUrl
self
.
navigationController
?
.
pushViewController
(
vc
)
}
...
...
@@ -380,6 +384,10 @@ class YHPlanViewController: YHBaseViewController {
policyVieiw
.
bannerArr
=
policyArr
let
url
=
"https://test-hklife.galaxy-immi.com/superAppBridge.html#/plan-analysis?code="
pdfUrl
=
url
+
self
.
viewModel
.
planListModel
.
code
shareUrl
=
self
.
viewModel
.
planListModel
.
url
self
.
tableView
.
reloadData
()
self
.
fakeTableView
.
reloadData
()
}
...
...
galaxy/galaxy/Classes/Modules/Plan(方案)/VM/YHPlanViewModel.swift
View file @
d07e1e47
...
...
@@ -38,4 +38,27 @@ class YHPlanViewModel: YHBaseViewModel {
}
}
func
requetPDFUrl
(
_
sourceUrl
:
String
,
callBackBlock
:
@escaping
((
String
)
->
Void
))
{
let
strUrl
=
YHBaseUrlManager
.
shared
.
curOssURL
()
+
"htmlToPdf/create"
let
params
:
[
String
:
Any
]
=
[
"url"
:
sourceUrl
]
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
_
in
// 1. json字符串 转 对象
if
json
.
code
==
200
{
guard
let
dic
=
json
.
data
?
.
peel
as?
[
String
:
Any
],
let
url
=
dic
[
"image_url"
]
as?
String
else
{
callBackBlock
(
""
)
return
}
callBackBlock
(
url
)
}
else
{
let
error
:
YHErrorModel
=
YHErrorModel
(
errorCode
:
Int32
(
json
.
code
),
errorMsg
:
json
.
msg
)
callBackBlock
(
""
)
}
}
failBlock
:
{
_
in
callBackBlock
(
""
)
}
}
}
galaxy/galaxy/Res/Assets.xcassets/Plan/plan_share_icon.imageset/BG@2x.png
0 → 100644
View file @
d07e1e47
13 KB
galaxy/galaxy/Res/Assets.xcassets/Plan/plan_share_icon.imageset/BG@3x.png
0 → 100644
View file @
d07e1e47
24.3 KB
galaxy/galaxy/Res/Assets.xcassets/Plan/plan_share_icon.imageset/Contents.json
0 → 100644
View file @
d07e1e47
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"BG@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"BG@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
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