| | |
| | | |
| | | class PaymentView: UIView,JQNibView{ |
| | | |
| | | enum PaymentEnumType { |
| | | case course //课程 |
| | | case yard //场地 |
| | | case joinMember //会员加入 |
| | | case game //游戏 |
| | | case recharge //充值 |
| | | case goods(ExchangeType) |
| | | case activity |
| | | } |
| | | |
| | | @IBOutlet weak var view_container: UIView! |
| | | @IBOutlet weak var cons_bottom: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_wechat: UIButton! |
| | |
| | | @IBOutlet weak var btn_integral: UIButton! |
| | | private var hasNotStudent:Bool = false |
| | | private var clouse:((PayType)->Void)? |
| | | private var payType:PayType? |
| | | private var payType:PayType! |
| | | private var paymentEnumType:PaymentEnumType! |
| | | private var customType = [PayType]() //支付项目 |
| | | |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | |
| | | layoutIfNeeded() |
| | | } |
| | | |
| | | static func show(money:(ali:Double?,wx:Double?,coin:Int?,course:Int?,integral:Int?),hasNotStudent:Bool = false,_ clouse:@escaping (PayType)->Void){ |
| | | static func show(enumType:PaymentEnumType,money:(ali:Double?,wx:Double?,coin:Int?,course:Int?,integral:Int?),hasNotStudent:Bool = false,_ clouse:@escaping (PayType)->Void){ |
| | | let paymentView = PaymentView.jq_loadNibView() |
| | | paymentView.frame = sceneDelegate?.window?.frame ?? .zero |
| | | paymentView.clouse = clouse |
| | | paymentView.paymentEnumType = enumType |
| | | // paymentView.view_wechat.isHidden = (money.wx == nil || money.wx == 0) |
| | | paymentView.view_coin.isHidden = (money.coin == nil || money.coin == 0) |
| | | paymentView.view_course.isHidden = (money.course == nil || money.course == 0) |
| | |
| | | if !paymentView.view_alipay.isHidden{customType.append(.aliPay)} |
| | | if !paymentView.view_wechat.isHidden{customType.append(.wechat)} |
| | | if !paymentView.view_coin.isHidden{customType.append(.coin)} |
| | | |
| | | paymentView.customType = customType |
| | | paymentView.btn_course.isUserInteractionEnabled = !hasNotStudent |
| | | |
| | | paymentView.payType = customType.first |
| | |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | //场地,游戏,门票 可免费,根据上面的金额,展示了哪些条目判断,如果都没展示,金额全部会是0 |
| | | switch paymentEnumType { |
| | | case .yard,.game: |
| | | if payType == nil && customType.count == 0{ |
| | | payType = .coin |
| | | }else{ |
| | | guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | } |
| | | case .goods(let type): |
| | | if type == .ticket{ |
| | | if payType == nil && customType.count == 0{ |
| | | payType = .coin |
| | | }else{ |
| | | guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | } |
| | | }else{ |
| | | guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | } |
| | | default:guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | } |
| | | clouse?(payType!) |
| | | hidden() |
| | | } |