123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // PayMentSelectView.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/11/4.
- //
- import UIKit
- class PayMentSelectView: UIView {
- @IBOutlet weak var blackView: UIView!
- @IBOutlet weak var tableView: UITableView!
-
- @IBOutlet weak var contentHeight: NSLayoutConstraint!
-
- /// hud 提示
- lazy var hud : MCHud! = {
- return MCHud()
- }()
-
- var dataSource : [PaySettleTypeModel]?
-
- /// 支付方式Model
- var paySetModel : PaySettleTypeModel?
-
- var meansOfPaymentsBlock : ((_ model : PaySettleTypeModel)->Void)?
-
- override func awakeFromNib() {
- super.awakeFromNib()
- self.tableView.register(withType: payMentItemCell.self)
- }
-
- func configDataSource(dataSource : [PaySettleTypeModel]?){
- self.dataSource = dataSource
- self.tableView.reloadData()
- self.contentHeight.constant = 317.33 - 100 + 50 * CGFloat(self.dataSource?.count ?? 0)
- }
-
- @IBAction func saveAction(_ sender: UIButton) {
- if self.paySetModel != nil{
- if self.meansOfPaymentsBlock != nil{
- self.meansOfPaymentsBlock!(self.paySetModel!)
- }
- self.hidden()
-
- }else{
- self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请选择结算方式", Etext: "Please select a billing method"))
- }
-
-
- }
-
- @IBAction func hiddenAction(_ sender: UIButton) {
- self.hidden()
- }
-
- public func show(){
-
- kAppDelegateWindow.addSubview(self)
- self.blackView.alpha = 0
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.blackView.alpha = 0.3
- }
- }
-
- /// 隐藏
- public func hidden(){
- self.blackView.alpha = 0
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.removeFromSuperview()
- }
- }
- }
- extension PayMentSelectView : UITableViewDelegate,UITableViewDataSource{
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.dataSource?.count ?? 0
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "payMentItemCell") as! payMentItemCell
- let model : PaySettleTypeModel = self.dataSource![indexPath.row]
- cell.configModel(model: model)
- return cell
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 0.01
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- for item in self.dataSource! {
- let model : PaySettleTypeModel = item
- model.isSelect = false
- }
- let senderModel : PaySettleTypeModel = self.dataSource![indexPath.row]
- senderModel.isSelect = true
- self.paySetModel = senderModel
- self.tableView.reloadData()
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0.01
- }
- }
|