Commit 9709ff9d authored by pete谢兆麟's avatar pete谢兆麟

案例分享逻辑修改

parent 4d0cad51
...@@ -229,11 +229,6 @@ extension YHServiceCenterViewController { ...@@ -229,11 +229,6 @@ extension YHServiceCenterViewController {
} }
@objc func pushOrderView() { @objc func pushOrderView() {
// let vc = YHResignGuidelinesExampleViewController()
// self.navigationController?.pushViewController(vc)
// return
var flag = true var flag = true
if self.state == 1 || self.state == 3 { if self.state == 1 || self.state == 3 {
......
...@@ -94,7 +94,6 @@ extension YHResignGuidelinesExampleShareViewController { ...@@ -94,7 +94,6 @@ extension YHResignGuidelinesExampleShareViewController {
centerImageView = { centerImageView = {
let view = UIImageView() let view = UIImageView()
view.image = UIImage(named: centerImageName)
return view return view
}() }()
view.addSubview(centerImageView) view.addSubview(centerImageView)
...@@ -126,6 +125,7 @@ extension YHResignGuidelinesExampleShareViewController { ...@@ -126,6 +125,7 @@ extension YHResignGuidelinesExampleShareViewController {
make.center.equalToSuperview() make.center.equalToSuperview()
make.width.height.equalTo(21) make.width.height.equalTo(21)
} }
centerImageView.kf.setImage(with: URL(string: centerImageName))
let qrString = url let qrString = url
if let qrCode = qrString.generateQRCode() { if let qrCode = qrString.generateQRCode() {
// 可以将qrCode设置为UIImageView的image属性来显示二维码 // 可以将qrCode设置为UIImageView的image属性来显示二维码
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// //
import UIKit import UIKit
import Kingfisher
enum YHResignGuidelinesExampleType: Int { enum YHResignGuidelinesExampleType: Int {
case house case house
...@@ -23,6 +24,9 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController { ...@@ -23,6 +24,9 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController {
var type: YHResignGuidelinesExampleType = .house var type: YHResignGuidelinesExampleType = .house
// var viewModel = YHResignCertificateListViewModel() // var viewModel = YHResignCertificateListViewModel()
var viewModel = YHResignGuidelinesViewModel() var viewModel = YHResignGuidelinesViewModel()
var height: CGFloat = 0
var id = 3473
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
gk_navTitle = "银河续签案例分享" gk_navTitle = "银河续签案例分享"
...@@ -37,21 +41,21 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController { ...@@ -37,21 +41,21 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController {
} }
func getData() { func getData() {
if type == .house { // if type == .house {
imageName = "resign_guidelines_example_house" // imageName = "resign_guidelines_example_house"
} else if type == .work { // } else if type == .work {
imageName = "resign_guidelines_example_work" // imageName = "resign_guidelines_example_work"
} else if type == .taxation { // } else if type == .taxation {
imageName = "resign_guidelines_example_taxation" // imageName = "resign_guidelines_example_taxation"
} else { // } else {
imageName = "resign_guidelines_example_nowork" // imageName = "resign_guidelines_example_nowork"
} // }
viewModel.getResignDetail(Id: 3473) {[weak self] success, error in viewModel.getResignDetail(Id: id) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.imageName = self.viewModel.mainModel.content_url
self.getImageSizeFromURL(urlString: self.imageName)
} }
tableView.reloadData()
} }
func setView() { func setView() {
...@@ -104,21 +108,41 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController { ...@@ -104,21 +108,41 @@ class YHResignGuidelinesExampleViewController: YHBaseViewController {
} }
@objc func nextStep() { @objc func nextStep() {
var imageName = "" // var imageName = ""
if type == .house { // if type == .house {
imageName = "resign_guidelines_example_house_share" // imageName = "resign_guidelines_example_house_share"
} else if type == .work { // } else if type == .work {
imageName = "resign_guidelines_example_work_share" // imageName = "resign_guidelines_example_work_share"
} else if type == .taxation { // } else if type == .taxation {
imageName = "resign_guidelines_example_taxation_share" // imageName = "resign_guidelines_example_taxation_share"
} else { // } else {
imageName = "resign_guidelines_example_nowork_share" // imageName = "resign_guidelines_example_nowork_share"
} // }
let vc = YHResignGuidelinesExampleShareViewController() let vc = YHResignGuidelinesExampleShareViewController()
vc.centerImageName = imageName vc.centerImageName = self.viewModel.mainModel.share_url
vc.url = "https://baidu.com" vc.url = "https://baidu.com"
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
func getImageSizeFromURL(urlString: String) {
let imageURL = URL(string: urlString)!
// 使用Kingfisher的ImageDownloader下载图片数据
ImageDownloader.default.downloadImage(with: imageURL, options: [], progressBlock: nil) { (result) in
switch result {
case .success(let response):
// 使用UIImage初始化图片数据
let image = response.image
let size = image.size
let scale = size.width > 0 ? Double(size.height / size.width) : 0.0
// 获取图片的宽度和高度
self.height = KScreenWidth * scale
self.tableView.reloadData()
case .failure(let error):
print(error)
}
}
}
} }
extension YHResignGuidelinesExampleViewController: UITableViewDelegate, UITableViewDataSource { extension YHResignGuidelinesExampleViewController: UITableViewDelegate, UITableViewDataSource {
...@@ -133,15 +157,17 @@ extension YHResignGuidelinesExampleViewController: UITableViewDelegate, UITableV ...@@ -133,15 +157,17 @@ extension YHResignGuidelinesExampleViewController: UITableViewDelegate, UITableV
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if type == .house { // if type == .house {
return 986.fix // return 986.fix
} else if type == .work { // } else if type == .work {
return 925.fix // return 925.fix
} else if type == .taxation { // } else if type == .taxation {
return 946.fix // return 946.fix
} else { // } else {
return 1069.fix // return 1069.fix
} // }
return height
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...@@ -154,7 +180,7 @@ class YHResignGuidelinesExampleTableViewCell: UITableViewCell { ...@@ -154,7 +180,7 @@ class YHResignGuidelinesExampleTableViewCell: UITableViewCell {
var bgImageView: UIImageView! var bgImageView: UIImageView!
var imageName: String? { var imageName: String? {
didSet { didSet {
bgImageView.image = UIImage(named: imageName ?? "") bgImageView.kf.setImage(with: URL(string: imageName))
} }
} }
override func awakeFromNib() { override func awakeFromNib() {
......
...@@ -21,6 +21,8 @@ class YHResignGuidelinesModel: SmartCodable { ...@@ -21,6 +21,8 @@ class YHResignGuidelinesModel: SmartCodable {
var is_finished_transcode: Int = 0 var is_finished_transcode: Int = 0
var img_url_compress: String = "" var img_url_compress: String = ""
var clue_classify_img_url: String = "" var clue_classify_img_url: String = ""
var share_url: String = ""
var content_url: String = ""
required init() { required init() {
} }
......
...@@ -18,10 +18,11 @@ class YHResignGuidelinesViewModel: YHBaseViewModel { ...@@ -18,10 +18,11 @@ class YHResignGuidelinesViewModel: YHBaseViewModel {
//1. json字符串 转 对象 //1. json字符串 转 对象
guard self != nil else { return } guard self != nil else { return }
if json.code == 200 { if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let data = dic["data"] as? [String: Any], let result = YHResignGuidelinesModel.deserialize(from: data) else { guard let dic = json.data?.peel as? [String : Any], let result = YHResignGuidelinesModel.deserialize(from: dic) else {
callBackBlock(false,nil) callBackBlock(false,nil)
return return
} }
self?.mainModel = result self?.mainModel = result
callBackBlock(true, nil) callBackBlock(true, nil)
} else { } else {
......
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