PaySuccessView.swift 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // PaySuccessView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2024/1/16.
  6. //
  7. import UIKit
  8. class PaySuccessView: UIView {
  9. @IBOutlet weak var blackView: UIView!
  10. @IBOutlet weak var moneyLab: UILabel!
  11. @IBOutlet weak var payTypeLab: UILabel!
  12. @IBOutlet weak var orderNumLab: UILabel!
  13. @IBOutlet weak var timeLab: UILabel!
  14. @IBAction func copyAction(_ sender: UIButton) {
  15. }
  16. @IBAction func finishAction(_ sender: UIButton) {
  17. if self.callBackBlock != nil{
  18. self.callBackBlock!()
  19. }
  20. self.hidden()
  21. }
  22. var callBackBlock : (()->Void)?
  23. var successModel : PaySuccessModel?
  24. public func showWithModel(model : PaySuccessModel){
  25. self.successModel = model
  26. let currentDate = Date()
  27. let dateFormatter = DateFormatter()
  28. dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
  29. let currentDateString = dateFormatter.string(from: currentDate)
  30. self.successModel?.time = currentDateString
  31. self.moneyLab.text = "\(self.successModel?.money ?? "")"
  32. self.payTypeLab.text = "\(self.successModel?.payTypeName ?? "")"
  33. self.orderNumLab.text = "\(self.successModel?.orderNum ?? "")"
  34. self.timeLab.text = "\(self.successModel?.time ?? "")"
  35. self.timeLab.text = currentDateString
  36. kAppDelegateWindow.addSubview(self)
  37. self.blackView.alpha = 0
  38. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  39. UIView.animate(withDuration: 0.5) {
  40. self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  41. self.layoutIfNeeded()
  42. }
  43. DELAY(0.5) {
  44. self.blackView.alpha = 0.3
  45. }
  46. }
  47. /// 隐藏
  48. public func hidden(){
  49. self.blackView.alpha = 0
  50. UIView.animate(withDuration: 0.5) {
  51. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  52. self.layoutIfNeeded()
  53. }
  54. DELAY(0.5) {
  55. self.removeFromSuperview()
  56. }
  57. }
  58. }