Commit ac561645 authored by David黄金龙's avatar David黄金龙

文件清单 截图

parent 98257603
...@@ -41,7 +41,12 @@ class YHFileListViewController: YHBaseViewController { ...@@ -41,7 +41,12 @@ class YHFileListViewController: YHBaseViewController {
}() }()
let bottomView : YHFileListBottomView = YHFileListBottomView() private lazy var bottomView : YHFileListBottomView = {
var bottomView : YHFileListBottomView = YHFileListBottomView()
bottomView.nextButton.isEnabled = false
bottomView.layer.opacity = 0.8
return bottomView
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -60,9 +65,11 @@ class YHFileListViewController: YHBaseViewController { ...@@ -60,9 +65,11 @@ class YHFileListViewController: YHBaseViewController {
let footLable = UILabel() let footLable = UILabel()
footLable.text = "*感谢您对银河移民的信赖,以上信息均用于香港优才签证申 请银河移民承诺对您所提供的信息将绝对保密" footLable.text = "*感谢您对银河移民的信赖,以上信息均用于香港优才签证申 请银河移民承诺对您所提供的信息将绝对保密"
footLable.textColor = .white footLable.textColor = .white
footLable.textAlignment = .center
footLable.font = UIFont.PFSC_R(ofSize: 12) footLable.font = UIFont.PFSC_R(ofSize: 12)
footLable.numberOfLines = 0 footLable.numberOfLines = 0
footLable.lineBreakMode = .byWordWrapping footLable.lineBreakMode = .byWordWrapping
return footLable return footLable
}() }()
} }
...@@ -70,13 +77,24 @@ class YHFileListViewController: YHBaseViewController { ...@@ -70,13 +77,24 @@ class YHFileListViewController: YHBaseViewController {
extension YHFileListViewController { extension YHFileListViewController {
func loadData() { func loadData() {
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") { if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") {
YHHUD.show(.progress(message: ""))
let param = ["order_id":orderID,"node":"1","state":"1"] let param = ["order_id":orderID,"node":"1","state":"1"]
// let param = ["order_id":"11758","node":"1","state":"1"] //for test hjl
certificateReqVM.getCertificateFileListData(params: param) { success, error in certificateReqVM.getCertificateFileListData(params: param) { success, error in
YHHUD.hide()
if success == true { if success == true {
self.myContentView.dataModel = self.certificateReqVM.arrFileListData self.myContentView.dataModel = self.certificateReqVM.arrFileListData
self.myContentView.layoutIfNeeded()
let r = self.myContentView.bounds
self.myContentView.frame = CGRect(x: kMargin, y: 217, width: KScreenWidth - 2*kMargin, height: r.height)
self.footLable.frame = CGRect(x: 28, y: 217 + r.height + 29, width: KScreenWidth - 2*28, height: 36)
self.myScrollView.contentSize = CGSize(width: KScreenWidth, height: r.height + 217 + 29 + 36 + 41)
self.bottomView.nextButton.isEnabled = true
self.bottomView.layer.opacity = 1.0
} else { } else {
YHHUD.flash(message: error?.errorMsg ?? "请求出错") YHHUD.flash(message: error?.errorMsg ?? "请求出错")
} }
...@@ -117,29 +135,27 @@ extension YHFileListViewController { ...@@ -117,29 +135,27 @@ extension YHFileListViewController {
bottomView.block = { [self] flag in bottomView.block = { [self] flag in
if flag == 1 { if flag == 1 {
printLog("生成清单") YHHUD.show(.progress(message: "正在生成图片"))
// if let image = self.captureScrollView(scrollView: self.myScrollView) { if let image = self.captureScrollView(scrollView: self.myScrollView) {
// saveImageToPhotosAlbum(image: image) YHHUD.hide()
// } else { saveImageToPhotosAlbum(image: image)
// YHHUD.flash(message: "截图失败~~~") } else {
// } YHHUD.hide()
YHHUD.flash(message: "生成图片失败")
}
} }
} }
myScrollView.backgroundColor = UIColor(hex:0x0D37C7, alpha: 1.0) myScrollView.backgroundColor = UIColor(hex:0x0D37C7, alpha: 1.0)
view.addSubview(myScrollView) view.addSubview(myScrollView)
myScrollView.snp.makeConstraints { make in myScrollView.frame = CGRect(x: 0, y: k_Height_NavigationtBarAndStatuBar, width: KScreenWidth, height: KScreenHeight - k_Height_NavigationtBarAndStatuBar - YHFileListBottomView.viewH)
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalToSuperview()
make.bottom.equalTo(bottomView.snp.top) myScrollView.contentSize = CGSize(width: KScreenWidth, height: 2000)
}
myScrollView.addSubview(headView) myScrollView.addSubview(headView)
headView.snp.makeConstraints { make in headView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: YHFileListHeaerView.viewH)
make.top.left.right.equalToSuperview()
make.height.equalTo(YHFileListHeaerView.viewH)
}
myScrollView.addSubview(myContentView) myScrollView.addSubview(myContentView)
myContentView.snp.makeConstraints { make in myContentView.snp.makeConstraints { make in
...@@ -149,39 +165,26 @@ extension YHFileListViewController { ...@@ -149,39 +165,26 @@ extension YHFileListViewController {
} }
myScrollView.addSubview(footLable) myScrollView.addSubview(footLable)
footLable.snp.makeConstraints { make in
make.top.equalTo(myContentView.snp.bottom).offset(29)
make.left.equalTo(28)
make.width.equalTo(KScreenWidth - 2*28)
make.bottom.equalToSuperview().offset(-41)
}
return
} }
func captureScrollView(scrollView : UIScrollView) -> UIImage? { func captureScrollView(scrollView : UIScrollView) -> UIImage? {
var image: UIImage? = nil
scrollView.showsVerticalScrollIndicator = false
UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, false, UIScreen.main.scale)
let savedContentOffset = scrollView.contentOffset let savedContentOffset = scrollView.contentOffset
let savedFrame = scrollView.frame let savedFrame = scrollView.frame
scrollView.contentOffset = .zero
scrollView.frame = CGRect(x: 0, y: 0,
width: scrollView.contentSize.width,
height: scrollView.contentSize.height)
UIGraphicsBeginImageContext(scrollView.frame.size)
UIGraphicsBeginImageContextWithOptions(
CGSize(width: scrollView.frame.size.width,
height: scrollView.frame.size.height),
false,
UIScreen.main.scale)
scrollView.layer.render(in: UIGraphicsGetCurrentContext()!)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
print("contentSize == \(scrollView.contentSize)") scrollView.contentOffset = CGPoint.zero
scrollView.frame = CGRect(x: 0, y: 0, width: scrollView.contentSize.width, height: scrollView.contentSize.height)
scrollView.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
scrollView.contentOffset = savedContentOffset scrollView.contentOffset = savedContentOffset
scrollView.frame = savedFrame scrollView.frame = savedFrame
return image UIGraphicsEndImageContext()
scrollView.showsVerticalScrollIndicator = true
return image
} }
...@@ -190,11 +193,21 @@ extension YHFileListViewController { ...@@ -190,11 +193,21 @@ extension YHFileListViewController {
PHPhotoLibrary.requestAuthorization { status in PHPhotoLibrary.requestAuthorization { status in
if status == .authorized { if status == .authorized {
// 保存图片到相册 // 保存图片到相册
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) DispatchQueue.main.sync {
YHHUD.flash(message: "保存成功") UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.image(image:didFinishSavingWithError:contextInfo:)), nil)
}
} else { } else {
YHHUD.flash(message: "范围图库权限不足") YHHUD.flash(message: "没有访问图库权限")
} }
} }
} }
@objc func image(image: UIImage,didFinishSavingWithError: NSError?,contextInfo: AnyObject) {
if didFinishSavingWithError != nil {
YHHUD.flash(message: "保存失败")
return
}
YHHUD.flash(message: "保存成功")
}
} }
...@@ -24,7 +24,7 @@ class YHFileListBottomView: UIView { ...@@ -24,7 +24,7 @@ class YHFileListBottomView: UIView {
typealias Block = (Int) -> () typealias Block = (Int) -> ()
var block: Block? var block: Block?
var saveButton: UIButton! // var saveButton: UIButton!
var nextButton: UIButton! var nextButton: UIButton!
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment