Commit 5676a2ef authored by David黄金龙's avatar David黄金龙

删除 不使用的代码

parent 34130e10
//
// YHOfficialApprovalResultVC.swift
// galaxy
//
// Created by davidhuangA on 2024/8/6.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
import AttributedString
/*
正式批 结果页
*/
class YHOfficialApprovalResultVC: YHBaseViewController {
//背景
lazy var bkgImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_bkg")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//白纸
lazy var paperImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_paper")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//文档
lazy var docImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_doc")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//文档内容
lazy var contentView: YHOffivialApprovalSuccessView = {
let view = YHOffivialApprovalSuccessView()
view.isHidden = true
return view
}()
//pen
lazy var penImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_pen")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//bottom
lazy var bottomImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_bottom_shadow")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//光线
lazy var lightImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_result_top_shadow")
imageV.contentMode = .scaleAspectFill
imageV.clipsToBounds = true
return imageV
}()
//bottom
lazy var bottomContentView: UIView = {
let view = UIView()
return view
}()
lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hex: 0xffffff, alpha: 0.6)
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "左滑查看其他获批信,当前"
return label
}()
private lazy var bannerView: FSPagerView = {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.bounces = false
view.isInfinite = false
view.removesInfiniteLoopForSingleItem = true
view.alwaysBounceHorizontal = true
view.register(YHOfficailLetterColledtionCell.self, forCellWithReuseIdentifier: YHOfficailLetterColledtionCell.cellReuseIdentifier)
view.itemSize = CGSizeMake(268.0, 148)
view.interitemSpacing = 20
return view
}()
lazy var indicatorView : YHHomeBannerIndicatorView = {
let view = YHHomeBannerIndicatorView()
return view
}()
var dataArr: [YHOfficalLetterModel] = [] {
didSet {
self.indicatorView.indicatorItems = self.dataArr.count
bannerView.reloadData()
self.indicatorView.curIndicatorIndex = 0
bannerView.selectItem(at: 0, animated: false)
let aa: ASAttributedString = .init("左滑查看其他获批信,当前 ", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 0.6)))
let bb: ASAttributedString = .init("1/\(self.dataArr.count)", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 1.0)))
tipsLabel.attributed.text = aa + bb
}
}
lazy var princleVM : YHPrincleViewModel = {
let vm = YHPrincleViewModel()
return vm
}()
//
var showGuildViewFlag : Bool = false
lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: UIViewController.current)
return tool
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
getApprovalLetter()
getAlertStatus()
getOfficalGuildCheckStatus()
}
}
private extension YHOfficialApprovalResultVC {
func updateMainApplicationInfo() {
guard let model = princleVM.lettersModel else { return }
contentView.dataModel = model
}
func updateLetterListInfo() {
self.dataArr = self.princleVM.lettersModel?.list ?? []
}
//获取正式批信件列表
func getApprovalLetter() {
if let orderID = UserDefaults.standard.value(forKey: "orderIdForPreview") {
let param = ["orderId":orderID,"searchType":1]
princleVM.getApprovalLetter(param: param) { success, error in
if success {
//1、更新主申请人信息
self.contentView.isHidden = false
self.updateMainApplicationInfo()
//2、更新letter信息
self.updateLetterListInfo()
} else {
YHHUD.flash(message: "数据获取失败")
}
}
} else {
YHHUD.flash(message: "订单号为空")
}
}
//上报弹窗状态
func postAlertStatus(_ type : Int) {
princleVM.postAlertStatus(type) { success, error in
if success {
} else {
}
}
}
//获取正式批 操作指引 确认状态
func getOfficalGuildCheckStatus() {
princleVM.getOfficialCheckStatus { success, error in
if success {
if self.showGuildViewFlag {
self.clickRightItemBtn()
}
}
}
}
//获取原则批、正式批的弹窗状态
func getAlertStatus() {
princleVM.getPrincleStatus { success, error in
if success {
guard let model = self.princleVM.alertStatusModel else {
return
}
model.type = 1 //for test hjl
if model.type == 1 {
let now = Date()
let timestamp = now.timeIntervalSince1970
print("当前时间戳:\(timestamp)")
let offsetSecond = CGFloat(Int64(timestamp) - Int64(model.date))
var roundedUp = 0
if offsetSecond > 0 {
roundedUp = Int(ceil(offsetSecond / (24 * 60 * 60)))
printLog(roundedUp)
}
let view = YHOffivialApprovalSuccessCheckView.sheetView()
view.days = roundedUp
view.show()
view.block = { tag in
DispatchQueue.main.async {
self.postAlertStatus(6)
}
if tag == 0 {
self.clickRightItemBtn()
}
}
}
}
}
}
func setupUI() {
gk_navBarAlpha = 0.0
gk_backImage = UIImage(named: "back_icon_white")
addRightItem()
view.addSubview(bkgImageV)
bkgImageV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
view.addSubview(paperImageV)
paperImageV.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalToSuperview().offset(200)
make.width.equalTo(294)
make.height.equalTo(530)
}
paperImageV.layer.zPosition = 0
view.addSubview(docImageV)
docImageV.snp.makeConstraints { make in
make.right.equalToSuperview()
make.top.equalToSuperview().offset(64)
make.width.equalTo(294)
make.height.equalTo(530)
}
docImageV.layer.zPosition = 1
docImageV.addSubview(contentView)
contentView.snp.makeConstraints { make in
make.left.equalTo(50)
make.top.equalTo(140)
make.width.equalTo(294)
make.height.equalTo(530)
}
contentView.transform = rotatedTransform()
docImageV.addSubview(penImageV)
penImageV.snp.makeConstraints { make in
make.top.equalToSuperview().offset(204)
make.right.equalToSuperview()
make.width.equalTo(67)
make.height.equalTo(141)
}
penImageV.layer.zPosition = 1
view.addSubview(bottomImageV)
bottomImageV.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(200)
}
bottomImageV.layer.zPosition = 2
view.addSubview(lightImageV)
lightImageV.snp.makeConstraints { make in
make.top.right.left.equalToSuperview()
make.height.equalTo(543)
}
lightImageV.layer.zPosition = 3
//底部内容区域
view.addSubview(bottomContentView)
bottomContentView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
}
bottomContentView.layer.zPosition = 4
bottomContentView.addSubview(tipsLabel)
tipsLabel.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-50)
make.centerX.equalToSuperview()
}
bottomContentView.addSubview(indicatorView)
indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(2)
make.bottom.equalTo(tipsLabel.snp.top).offset(-20)
}
bottomContentView.addSubview(bannerView)
bannerView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(148)
make.bottom.equalTo(indicatorView.snp.top).offset(-16)
make.top.equalToSuperview().offset(20)
}
bannerView.layer.zPosition = 10
// let transform = CGAffineTransform(scaleX: 0.6, y: 0.75)
bannerView.transformer = FSPagerViewTransformer(type:.linear)
// bannerView.itemSize = CGSize(width: 268, height: 148).applying(transform)
bannerView.reloadData()
}
private func rotatedTransform() -> CGAffineTransform {
// 创建一个 CGAffineTransform 对象并设置旋转角度
return CGAffineTransform(rotationAngle: -CGFloat.pi / 64) // 旋转 45 度
}
func addRightItem() {
let searchButton = {
let button = UIButton(type: .custom)
button.frame = CGRect(x: 0, y: 0, width: 54, height: 24)
button.setTitleColor(UIColor.white, for: .normal)
button.setTitle("操作指引", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
button.contentHorizontalAlignment = .right
button.addTarget(self, action: #selector(self.clickRightItemBtn), for: .touchUpInside)
return button
}()
let rightButtonItem = UIBarButtonItem(customView: searchButton)
gk_navRightBarButtonItem = rightButtonItem
gk_navItemRightSpace = kMargin
}
@objc func clickRightItemBtn() {
let view = YHOffivialApprovalGuildLineCheckView.sheetView()
view.ischeckBeforeFlag = princleVM.isOfficialGuildCheckFlag
view.block = {
//点击了 正式批 操作指引
if !self.princleVM.isOfficialGuildCheckFlag {
self.princleVM.postAlertStatus(2) { success, error in
if success {
} else {
}
self.getOfficalGuildCheckStatus()
}
}
}
view.show()
}
}
// MARK: - FSPagerView Delegate
extension YHOfficialApprovalResultVC: FSPagerViewDataSource, FSPagerViewDelegate {
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.dataArr.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: YHOfficailLetterColledtionCell.cellReuseIdentifier, at: index) as! YHOfficailLetterColledtionCell
if index < dataArr.count {
cell.dataModel = dataArr[index]
}
return cell
}
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true)
if index < dataArr.count {
let model = self.dataArr[index]
self.previewFileTool.openXLSXRemoteFile(urlString: model.file_url_transformed, fileName: "")
if !model.localShowFlag {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
model.localShowFlag = true
UserDefaults.standard.setValue("localShowFlag", forKey: String(model.id))
UserDefaults.standard.synchronize()
self.bannerView.reloadData()
}
}
return
}
}
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.indicatorView.curIndicatorIndex = targetIndex
let aa: ASAttributedString = .init("左滑查看其他获批信,当前 ", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 0.6)))
let bb: ASAttributedString = .init("\(targetIndex + 1)/\(self.dataArr.count)", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 1.0)))
tipsLabel.attributed.text = aa + bb
}
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.indicatorView.curIndicatorIndex = pagerView.currentIndex
let aa: ASAttributedString = .init("左滑查看其他获批信,当前 ", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 0.6)))
let bb: ASAttributedString = .init("\(pagerView.currentIndex + 1)/\(self.dataArr.count)", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xffffff, alpha: 1.0)))
tipsLabel.attributed.text = aa + bb
}
}
//
// YHOfficalLetterListModel.swift
// galaxy
//
// Created by davidhuangA on 2024/8/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import SmartCodable
class YHOfficalLetterModel: SmartCodable {
var id : Int = -1//申请记录的唯一标识符
var applicant : String = ""//申请人的姓名
var approval_date : String = ""//申请人姓名
var applicant_approval_date : String = ""//申请的日期和时间
var archivist_id : Int = -1//来自相关记录的数据ID
var data_from_type : Int = -1 //数据来源的类型
var deleted_at : String = ""//申请记录被删除的时间(可选)
var e_visa_cn : String = ""//申请人姓名
var email_received_at : String = "" //邮件接收时间
var file_no : String = ""//文件编号
var file_num : String = ""//文件号(可能与file_no重复,用于不同场景)
var file_type : Int = -1 //文件类型
var file_url_transformed : String = ""//转换后的文件URL
var from_order_id : Int = -1 //来源订单ID
var from_relation : Int = -1//与申请人关系的代码
var from_relation_cn : String = ""//与申请人关系的中文描述
var handler : String = ""//处理申请的人员
var is_check : Int = -1//是否进行了检查
var name : String = ""//申请人的姓名
var pay_deadline : String = ""//支付截止日期
var read_status : Int = -1 //阅读状态(例如:未读,已读)
var remark : String = ""//备注信息
var remark_archivist : [String] = []//备注信息,可包含多个档案管理员的备注
var result : Int = -1//申请结果代码
var result_at : String = ""//申请结果的时间
var result_cn : String = ""//申请结果的中文描述
var type : String = ""//申请的类型(例如:旅游,商务)
var updated_at : String = "" //申请记录最后更新的时间
var url : String = ""//文件的URL
var localShowFlag : Bool = false //信件是否点击打开 本地变量
required init() {
}
}
class YHOfficalLetterListModel: SmartCodable {
var order_id : Int = -1//订单id
var applicant_id :Int = -1//申请人id
var applicant_name : String = ""//申请人姓名
var applicant_approval_date : String = ""//申请人通过时间
var applicant_sex : Int = -1//申请人性别
var days : Int = -1 //天数
var list : [YHOfficalLetterModel] = []
required init() {
}
}
//
// YHOfficailLetterColledtionCell.swift
// galaxy
//
// Created by davidhuangA on 2024/8/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
class YHOfficailLetterColledtionCell: FSPagerViewCell {
static let cellReuseIdentifier = "YHOfficailLetterColledtionCell"
var dataModel: YHOfficalLetterModel? {
didSet {
updateUI()
}
}
lazy var bkgImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "official_approval_result_envelope_not_read"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var nameLable:UILabel = {
let label = UILabel()
label.text = ""
label.textColor = UIColor(hex: 0xA96B42, alpha: 1.0)
label.font = UIFont.PFSC_M(ofSize: 15)
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
contentView.removeSubviews()
setupUI()
}
}
private extension YHOfficailLetterColledtionCell {
func setupUI() {
backgroundColor = .clear
contentView.backgroundColor = .clear
clipsToBounds = true
contentView.layer.shadowColor = UIColor.clear.cgColor
contentView.layer.shadowRadius = 0
contentView.layer.shadowOpacity = 0
contentView.layer.shadowOffset = .zero
contentView.addSubview(bkgImageView)
bkgImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentView.addSubview(nameLable)
nameLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(kMargin + 12)
make.left.equalToSuperview().offset(60)
make.height.equalTo(21)
}
}
func updateUI() {
guard let model = dataModel else { return }
nameLable.text = model.applicant
if !model.localShowFlag {
//未读
bkgImageView.image = UIImage(named: "official_approval_result_envelope_not_read")
} else {
//已读
bkgImageView.image = UIImage(named: "official_approval_result_envelope_readed")
}
}
}
//
// YHOffivialApprovalGuildLineCheckView.swift
// galaxy
//
// Created by davidhuangA on 2024/8/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOffivialApprovalGuildLineCheckView: UIView {
typealias Block = () -> ()
var block: Block?
lazy var blackMaskView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
let tap = UITapGestureRecognizer(target: self, action: #selector(dismiss))
view.addGestureRecognizer(tap)
return view
}()
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
lazy var bottomView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.addSubview(self.rewardBtn)
self.rewardBtn.snp.makeConstraints { make in
make.top.equalToSuperview().offset(10)
make.left.equalTo(kMargin)
make.right.equalTo(-kMargin)
make.height.equalTo(44)
}
view.layer.zPosition = 10
return view
}()
//我已悉知,确认
lazy var rewardBtn: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("我已悉知,确认", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.addTarget(self, action: #selector(clickSureBtn), for: .touchUpInside)
button.backgroundColor = UIColor.brandMainColor
return button
}()
lazy var myScrollView: UIScrollView = {
let view = UIScrollView()
view.backgroundColor = .clear
view.showsVerticalScrollIndicator = false
view.delegate = self
return view
}()
lazy var bkgImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_guideline")
imageV.contentMode = .scaleToFill
imageV.clipsToBounds = true
return imageV
}()
lazy var bkgImageV2: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_guideline_bkg")
imageV.contentMode = .scaleToFill
imageV.clipsToBounds = true
return imageV
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private var timer : Timer?
private var maxCount : Int = 5
//之前是否展示过
var ischeckBeforeFlag : Bool = false {
didSet {
if ischeckBeforeFlag {
setButtonEnable(true)
} else {
setButtonEnable(false)
startTimer()
}
}
}
}
extension YHOffivialApprovalGuildLineCheckView {
static func sheetView() -> YHOffivialApprovalGuildLineCheckView {
let view = YHOffivialApprovalGuildLineCheckView(frame:UIScreen.main.bounds)
return view
}
func show() {
UIApplication.shared.yhKeyWindow()?.addSubview(self)
UIView.animate(withDuration: 0.5) {
let whiteHeight = KScreenHeight - k_Height_NavigationtBarAndStatuBar
self.whiteContentView.frame = CGRect(x: 0, y: KScreenHeight - whiteHeight, width: KScreenWidth, height: whiteHeight)
}
}
@objc func dismiss() {
self.removeFromSuperview()
}
@objc func clickSureBtn() {
self.block?()
dismiss()
}
}
private extension YHOffivialApprovalGuildLineCheckView {
@objc func timerFired() {
// 定时器触发时执行的代码
print("Timer fired")
self.maxCount = self.maxCount - 1
if self.maxCount < 0 {
self.stopTimer()
self.setButtonEnable(true)
} else {
rewardBtn.setTitle("请上滑看完指引后操作(\(maxCount)s)", for: .normal)
}
}
func startTimer() {
stopTimer()
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerFired), userInfo: nil, repeats: true)
RunLoop.current.add(timer!, forMode: .common)
}
func stopTimer() {
maxCount = 5
timer?.invalidate()
timer = nil
}
func setButtonEnable(_ enable : Bool) {
rewardBtn.isEnabled = enable
if enable {
rewardBtn.setTitle("我已悉知,确认", for: .normal)
rewardBtn.backgroundColor = UIColor.brandMainColor
} else {
rewardBtn.setTitle("请上滑看完指引后操作(5s)", for: .normal)
rewardBtn.backgroundColor = UIColor(hex: 0xB7C0CC, alpha: 1.0)
}
}
func setupUI() {
self.addSubview(blackMaskView)
self.addSubview(whiteContentView)
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
let path = UIBezierPath(roundedRect:bounds,byRoundingCorners: corner,cornerRadii:CGSizeMake(16.0, 16.0));
let layer = CAShapeLayer();
layer.frame = whiteContentView.bounds;
layer.path = path.cgPath;
whiteContentView.layer.mask = layer;
whiteContentView.clipsToBounds = true
blackMaskView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let whiteHeight = KScreenHeight - k_Height_NavigationtBarAndStatuBar
// whiteContentView.snp.makeConstraints { make in
// make.left.right.bottom.equalToSuperview()
// make.height.equalTo(whiteHeight)
// }
whiteContentView.frame = CGRect(x: 0, y: KScreenHeight, width: KScreenWidth, height: whiteHeight)
whiteContentView.addSubview(bkgImageV2)
bkgImageV2.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(375)
}
whiteContentView.addSubview(bottomView)
bottomView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(98)
}
whiteContentView.addSubview(myScrollView)
myScrollView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.right.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(whiteHeight-98 - 20)
}
if let tmpImage = UIImage(named:"official_approval_guideline") {
let scale = Double(tmpImage.size.height / tmpImage.size.width)
let imageH = scale * KScreenWidth
myScrollView.addSubview(bkgImageV)
bkgImageV.snp.makeConstraints { make in
make.top.left.equalToSuperview()
make.width.equalTo(KScreenWidth)
make.height.equalTo(imageH)
}
myScrollView.contentSize = CGSize(width: KScreenWidth, height: imageH)
}
}
}
extension YHOffivialApprovalGuildLineCheckView : UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if !ischeckBeforeFlag {
let scrollViewContentHeight = scrollView.contentSize.height
let scrollOffsetThreshold = scrollViewContentHeight - scrollView.bounds.size.height
// 当前滚动位置
let currentOffset = scrollView.contentOffset.y
if currentOffset > scrollOffsetThreshold { // 接近底部
// 滚动到了底部
ischeckBeforeFlag = true
stopTimer()
setButtonEnable(true)
} else {
// 没有滚动到底部
}
}
}
}
//
// YHOffivialApprovalSuccessCheckView.swift
// galaxy
//
// Created by davidhuangA on 2024/8/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
import Lottie
import YYImage
class YHOffivialApprovalSuccessCheckView: UIView {
typealias Block = (Int) -> ()
var block: Block?
lazy var blackMaskView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.6)
return view
}()
lazy var animationView: LottieAnimationView = {
let view = LottieAnimationView(name: "flower2")
view.loopMode = .playOnce
return view
}()
lazy var scrollBgImgV:YYAnimatedImageView = {
let img = YYImage(named:"officalsuccess.gif")
let imgV = YYAnimatedImageView(image: img)
imgV.autoPlayAnimatedImage = false
imgV.currentAnimatedImageIndex = 0
return imgV
}()
//香港身份获批指引操作
lazy var rewardBtn: UIButton = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(clickSureBtn), for: .touchUpInside)
button.setImage(UIImage(named: "official_approval_btn"), for: .normal)
button.setImage(UIImage(named: "official_approval_btn"), for: .disabled)
button.isEnabled = false
return button
}()
lazy var closeBtn: UIButton = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(clickCloseBtn), for: .touchUpInside)
button.setImage(UIImage(named: "official_approval_close_btn"), for: .normal)
button.isHidden = true
return button
}()
lazy var bkgImageV: UIImageView = {
let imageV = UIImageView()
imageV.image = UIImage(named: "official_approval_bkg")
imageV.contentMode = .scaleToFill
imageV.clipsToBounds = true
return imageV
}()
lazy var holdView: UIView = {
let view = UIView()
return view
}()
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 15)
label.textColor = UIColor(hex: 0x671908, alpha: 1.0)
label.text = ""
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
return label
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
let testContent = "恭喜您申请的【优秀人才入境计划】已获得港府的正式批准!从递交资料伊始,经历了235天,感谢您这一路以来对银河的信赖与包容!"
var timer: Timer?
var counter = 0
private var displayLink: CADisplayLink?
private var currentIndex: Int = 0
private var fullText: String = "恭喜您申请的【优秀人才入境计划】"
private var centerText: String = "已获得港府的正式批准!"
private var lastText: String = "从递交资料伊始,经历了235天,感谢您这一路以来对银河的信赖与包容!"
var days : Int = 0 {
didSet {
lastText = "从递交资料伊始,经历了" + String(days) + "天,感谢您这一路以来对银河的信赖与包容!"
}
}
}
extension YHOffivialApprovalSuccessCheckView {
static func sheetView() -> YHOffivialApprovalSuccessCheckView {
let view = YHOffivialApprovalSuccessCheckView(frame:UIScreen.main.bounds)
return view
}
func show() {
UIApplication.shared.yhKeyWindow()?.addSubview(self)
}
@objc func dismiss() {
self.removeFromSuperview()
}
@objc func clickSureBtn() {
self.block?(0)
dismiss()
}
@objc func clickCloseBtn() {
self.block?(1)
dismiss()
}
}
private extension YHOffivialApprovalSuccessCheckView {
func setupUI() {
addSubview(blackMaskView)
blackMaskView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
if let tmpImage = UIImage(named:"official_approval_bkg") {
let scale = Double(tmpImage.size.height / tmpImage.size.width)
let imageH = scale * KScreenWidth
holdView.frame = CGRect(x: 0, y: KScreenHeight, width: KScreenWidth, height: imageH)
addSubview(holdView)
bkgImageV.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: imageH)
holdView.addSubview(bkgImageV)
holdView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(112)
make.left.equalTo(64)
make.right.equalTo(-64)
}
titleLabel.isHidden = true
holdView.addSubview(rewardBtn)
rewardBtn.snp.makeConstraints { make in
make.top.equalTo(233)
make.width.equalTo(196)
make.height.equalTo(44)
make.centerX.equalToSuperview()
}
holdView.addSubview(closeBtn)
closeBtn.snp.makeConstraints { make in
make.top.equalTo(rewardBtn.snp.bottom).offset(156)
make.width.equalTo(24)
make.height.equalTo(24)
make.centerX.equalToSuperview()
}
closeBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
UIView.animate(withDuration: 1) {
self.holdView.frame = CGRect(x: 0, y: (KScreenHeight-imageH)/2 + 20, width: KScreenWidth, height: imageH)
} completion: { flag in
self.titleLabel.isHidden = false
self.startTypingEffect()
}
}
// addSubview(animationView)
// animationView.snp.makeConstraints { make in
// make.edges.equalToSuperview()
// }
// animationView.play { completed in
// self.animationView.isHidden = true
// }
addSubview(scrollBgImgV)
scrollBgImgV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
self.scrollBgImgV.isHidden = false
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 1) {
self.scrollBgImgV.animationRepeatCount = 2
self.scrollBgImgV.startAnimating()
Timer.scheduledTimer(withTimeInterval: 4, repeats: false) { timer in
self.scrollBgImgV.stopAnimating()
timer.invalidate()
self.scrollBgImgV.isHidden = true
}
}
}
func startTyping() {
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(typeText), userInfo: nil, repeats: true)
RunLoop.current.add(timer!, forMode: .common)
}
@objc func typeText() {
if counter < testContent.count {
self.titleLabel.text = String(testContent.prefix(counter + 1))
counter += 1
} else {
timer?.invalidate()
counter = 0
let aa: ASAttributedString = .init("恭喜您申请的【优秀人才入境计划】", .font(UIFont.PFSC_R(ofSize: 15)),.foreground(UIColor(hex: 0x671908, alpha: 1.0)))
let bb: ASAttributedString = .init("已获得港府的正式批准!", .font(UIFont.PFSC_R(ofSize: 15)),.foreground(UIColor(hex: 0xAE1616, alpha: 1.0)))
let cc: ASAttributedString = .init("从递交资料伊始,经历了235天,感谢您这一路以来对银河的信赖与包容!", .font(UIFont.PFSC_R(ofSize: 15)),.foreground(UIColor(hex: 0x671908, alpha: 1.0)))
self.titleLabel.attributed.text = aa + bb + cc
}
}
private func startTypingEffect() {
displayLink = CADisplayLink(target: self, selector: #selector(handleDisplayLink(_:)))
displayLink?.preferredFramesPerSecond = Int(1 / 0.1) // 设置帧率
displayLink?.add(to: .current, forMode: .common)
}
@objc private func handleDisplayLink(_ displayLink: CADisplayLink) {
if currentIndex < fullText.count + centerText.count + lastText.count {
var index = currentIndex
if currentIndex >= fullText.count {
index = fullText.count
}
let attributedString = NSMutableAttributedString(string: String(fullText[..<index]),
attributes: [
NSAttributedString.Key.foregroundColor: UIColor(hex: 0x671908, alpha: 1.0),
NSAttributedString.Key.paragraphStyle: {
let style = NSMutableParagraphStyle()
style.lineSpacing = 6 //控制行间距
style.alignment = .left
return style
}()
])
var centerIndex = 0
if currentIndex >= fullText.count + centerText.count {
centerIndex = centerText.count
} else if currentIndex >= fullText.count {
centerIndex = currentIndex - fullText.count
}
let centerattributedString = NSMutableAttributedString(string: String(centerText[..<centerIndex]),
attributes: [
NSAttributedString.Key.foregroundColor: UIColor(hex: 0xAE1616, alpha: 1.0),
NSAttributedString.Key.paragraphStyle: {
let style = NSMutableParagraphStyle()
style.lineSpacing = 6 //控制行间距
style.alignment = .left
return style
}()
])
var lastIndex = 0
if currentIndex >= fullText.count + centerText.count {
lastIndex = currentIndex - fullText.count - centerText.count
}
let lastattributedString = NSMutableAttributedString(string: String(lastText[..<lastIndex]),
attributes: [
NSAttributedString.Key.foregroundColor: UIColor(hex: 0x671908, alpha: 1.0),
NSAttributedString.Key.paragraphStyle: {
let style = NSMutableParagraphStyle()
style.lineSpacing = 6 //控制行间距
style.alignment = .left
return style
}()
])
let result = NSMutableAttributedString(attributedString: attributedString)
result.append(centerattributedString)
result.append(lastattributedString)
self.titleLabel.attributedText = result
currentIndex += 1
} else {
displayLink.invalidate()
self.closeBtn.isHidden = false
self.rewardBtn.isEnabled = true
}
}
}
//
// YHOffivialApprovalSuccessView.swift
// galaxy
//
// Created by EDY on 2024/8/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOffivialApprovalSuccessView: UIView {
var dataModel : YHOfficalLetterListModel? {
didSet {
updateUI()
}
}
private var titleLabel: UILabel!
private var arrViews : [UIView] = []
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
func setupUI() {
titleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 30)
label.textColor = UIColor(hex: 0x881000)
label.text = "恭喜"
return label
}()
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(5)
make.top.equalTo(0)
make.right.equalTo(-5)
make.height.equalTo(42)
}
}
func updataView(data: [String]) {
for (_,item) in arrViews.enumerated() {
item.removeFromSuperview()
}
var h = 60
var index = 0
for item in data {
let label = UILabel()
label.text = item
label.font = UIFont.PFSC_M(ofSize: 15)
label.textColor = UIColor(hex: 0x881000)
if index == 2 {
label.textColor = UIColor(hex: 0xd12501)
}
addSubview(label)
label.snp.makeConstraints { make in
make.left.equalTo(5)
make.top.equalTo(h)
make.right.equalTo(-5)
make.height.equalTo(26)
}
let line = UIView()
line.backgroundColor = UIColor(hex: 0x881000).withAlphaComponent(0.15)
addSubview(line)
line.snp.makeConstraints { make in
make.left.equalTo(5)
make.top.equalTo(h + 26 + 2)
make.width.equalTo(234)
make.height.equalTo(1)
}
h = h + 26 + 10
index = index + 1
arrViews.append(label)
arrViews.append(line)
}
}
}
private extension YHOffivialApprovalSuccessView {
func updateUI() {
// backgroundColor = .purple // for test hjl
guard let model = dataModel else { return }
titleLabel.text = "恭喜 " + model.applicant_name + model.applicant_sex.gentlemanDescribe() + "!"
if model.applicant_approval_date.count >= "2023年10月1日".count {
var tmp = model.applicant_approval_date.slice(from: 0, length: "2023年10月1日".count)
let arr = tmp.split(separator: "-")
if arr.count == 3 {
tmp = arr[0] + "年" + arr[1] + "月" + arr[2] + "日" + "正式获批"
let fourItems = ["祝贺您和您的家人申请的","【优秀人才入境计划】",tmp,"这意味着,您领取香港居民身份证","仅有一步之遥!!"]
updataView(data: fourItems)
}
}
}
}
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