| | |
| | | case worldCup |
| | | } |
| | | |
| | | @IBOutlet weak var view_container: UIView! |
| | | @IBOutlet weak var cons_bottom: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_wechat: UIButton! |
| | | @IBOutlet weak var btn_alipay: UIButton! |
| | | @IBOutlet weak var btn_coin: UIButton! |
| | | @IBOutlet weak var btn_course: UIButton! |
| | | @IBOutlet weak var label_integral: UILabel! |
| | | |
| | | @IBOutlet weak var view_wechat: UIView! |
| | | @IBOutlet weak var view_alipay: UIView! |
| | | @IBOutlet weak var view_coin: UIView! |
| | | @IBOutlet weak var view_course: UIView! |
| | | @IBOutlet weak var view_integral: UIView! |
| | | |
| | | @IBOutlet weak var label_wechatMoney: UILabel! |
| | | @IBOutlet weak var label_aliPayMoney: UILabel! |
| | | @IBOutlet weak var label_coinMoney: UILabel! |
| | | @IBOutlet weak var label_courseMoney: UILabel! |
| | | @IBOutlet weak var btn_complete: UIButton! |
| | | @IBOutlet weak var btn_integral: UIButton! |
| | | private var hasNotStudent:Bool = false |
| | | private var clouse:((PayType)->Void)? |
| | | private var payType:PayType! |
| | | private var paymentEnumType:PaymentEnumType! |
| | | private var customType = [PayType]() //支付项目 |
| | | @IBOutlet weak var view_container: UIView! |
| | | @IBOutlet weak var cons_bottom: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_wechat: UIButton! |
| | | @IBOutlet weak var btn_alipay: UIButton! |
| | | @IBOutlet weak var btn_coin: UIButton! |
| | | @IBOutlet weak var btn_course: UIButton! |
| | | @IBOutlet weak var label_integral: UILabel! |
| | | |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | | @IBOutlet weak var view_wechat: UIView! |
| | | @IBOutlet weak var view_alipay: UIView! |
| | | @IBOutlet weak var view_coin: UIView! |
| | | @IBOutlet weak var view_course: UIView! |
| | | @IBOutlet weak var view_integral: UIView! |
| | | |
| | | cons_bottom.constant = -(225 + UIDevice.jq_safeEdges.bottom) |
| | | view_wechat.isHidden = true |
| | | view_coin.isHidden = true |
| | | view_course.isHidden = true |
| | | view_alipay.isHidden = true |
| | | alpha = 0 |
| | | @IBOutlet weak var label_wechatMoney: UILabel! |
| | | @IBOutlet weak var label_aliPayMoney: UILabel! |
| | | @IBOutlet weak var label_coinMoney: UILabel! |
| | | @IBOutlet weak var label_courseMoney: UILabel! |
| | | @IBOutlet weak var btn_complete: UIButton! |
| | | @IBOutlet weak var btn_integral: UIButton! |
| | | private var hasNotStudent:Bool = false |
| | | private var clouse:((PayType)->Void)? |
| | | private var payType:PayType! |
| | | private var paymentEnumType:PaymentEnumType! |
| | | private var customType = [PayType]() //支付项目 |
| | | |
| | | layoutIfNeeded() |
| | | } |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | | |
| | | 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) |
| | | paymentView.view_alipay.isHidden = (money.ali == nil || money.ali == 0) |
| | | paymentView.view_integral.isHidden = (money.integral == nil || money.integral == 0) |
| | | paymentView.label_aliPayMoney.text = money.ali?.currency() ?? "0" |
| | | paymentView.label_wechatMoney.text = money.wx?.currency() ?? "0" |
| | | paymentView.label_coinMoney.text = "\(money.coin ?? 0)币" |
| | | paymentView.label_courseMoney.text = "\(money.course ?? 0)课时" |
| | | paymentView.label_integral.text = "\(money.integral ?? 0)积分" |
| | | paymentView.view_course.alpha = hasNotStudent ? 0.5:1 |
| | | sceneDelegate?.window?.addSubview(paymentView) |
| | | paymentView.cons_bottom.constant = 0 |
| | | cons_bottom.constant = -(225 + UIDevice.jq_safeEdges.bottom) |
| | | view_wechat.isHidden = true |
| | | view_coin.isHidden = true |
| | | view_course.isHidden = true |
| | | view_alipay.isHidden = true |
| | | alpha = 0 |
| | | |
| | | var customType = [PayType]() |
| | | 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 |
| | | switch customType.first { |
| | | case .aliPay:paymentView.btn_alipay.isSelected = true |
| | | case .coin:paymentView.btn_coin.isSelected = true |
| | | case .wechat:paymentView.btn_wechat.isSelected = true |
| | | default:break |
| | | } |
| | | |
| | | UIView.animate(withDuration: 0.4) { |
| | | paymentView.alpha = 1 |
| | | paymentView.layoutIfNeeded() |
| | | } |
| | | } |
| | | |
| | | override func layoutSubviews() { |
| | | super.layoutSubviews() |
| | | view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20) |
| | | btn_complete.localGradientColor(cornerRadius: 20) |
| | | } |
| | | |
| | | |
| | | private func hidden(){ |
| | | cons_bottom.constant = -(225 + UIDevice.jq_safeEdges.bottom) |
| | | UIView.animate(withDuration: 0.4) { |
| | | self.alpha = 0 |
| | | self.layoutIfNeeded() |
| | | }completion: { _ in |
| | | self.removeFromSuperview() |
| | | } |
| | | } |
| | | |
| | | |
| | | @IBAction func tapAction(_ sender: UIButton) { |
| | | switch sender.tag{ |
| | | case 10: |
| | | payType = .wechat |
| | | case 11: |
| | | payType = .aliPay |
| | | case 12: |
| | | payType = .coin |
| | | case 14: |
| | | payType = .courseNum |
| | | case 15: |
| | | payType = .integral |
| | | default:break |
| | | } |
| | | |
| | | btn_alipay.isSelected = payType == .aliPay |
| | | btn_coin.isSelected = payType == .coin |
| | | btn_wechat.isSelected = payType == .wechat |
| | | btn_course.isSelected = payType == .courseNum |
| | | btn_integral.isSelected = payType == .integral |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | //场地,游戏,门票 可免费,根据上面的金额,展示了哪些条目判断,如果都没展示,金额全部会是0 |
| | | switch paymentEnumType { |
| | | case .yard,.game: |
| | | if payType == nil && customType.count == 0{ |
| | | payType = .coin |
| | | }else{ |
| | | guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | layoutIfNeeded() |
| | | } |
| | | 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} |
| | | |
| | | 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) || !WXApi.isWXAppInstalled() |
| | | paymentView.view_coin.isHidden = (money.coin == nil || money.coin == 0) |
| | | paymentView.view_course.isHidden = (money.course == nil || money.course == 0) |
| | | paymentView.view_alipay.isHidden = (money.ali == nil || money.ali == 0) |
| | | paymentView.view_integral.isHidden = (money.integral == nil || money.integral == 0) |
| | | paymentView.label_aliPayMoney.text = money.ali?.currency() ?? "0" |
| | | paymentView.label_wechatMoney.text = money.wx?.currency() ?? "0" |
| | | paymentView.label_coinMoney.text = "\(money.coin ?? 0)币" |
| | | paymentView.label_courseMoney.text = "\(money.course ?? 0)课时" |
| | | paymentView.label_integral.text = "\(money.integral ?? 0)积分" |
| | | paymentView.view_course.alpha = hasNotStudent ? 0.5:1 |
| | | sceneDelegate?.window?.addSubview(paymentView) |
| | | paymentView.cons_bottom.constant = 0 |
| | | |
| | | var customType = [PayType]() |
| | | 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 |
| | | switch customType.first { |
| | | case .aliPay:paymentView.btn_alipay.isSelected = true |
| | | case .coin:paymentView.btn_coin.isSelected = true |
| | | case .wechat:paymentView.btn_wechat.isSelected = true |
| | | default:break |
| | | } |
| | | |
| | | UIView.animate(withDuration: 0.4) { |
| | | paymentView.alpha = 1 |
| | | paymentView.layoutIfNeeded() |
| | | } |
| | | } |
| | | default:guard payType != nil else {alertError(msg: "请选择支付方式");return} |
| | | } |
| | | clouse?(payType!) |
| | | hidden() |
| | | } |
| | | |
| | | @IBAction func cancelAction(_ sender: UIButton) { |
| | | hidden() |
| | | } |
| | | |
| | | |
| | | override func layoutSubviews() { |
| | | super.layoutSubviews() |
| | | view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20) |
| | | btn_complete.localGradientColor(cornerRadius: 20) |
| | | } |
| | | |
| | | |
| | | private func hidden(){ |
| | | cons_bottom.constant = -(225 + UIDevice.jq_safeEdges.bottom) |
| | | UIView.animate(withDuration: 0.4) { |
| | | self.alpha = 0 |
| | | self.layoutIfNeeded() |
| | | }completion: { _ in |
| | | self.removeFromSuperview() |
| | | } |
| | | } |
| | | |
| | | |
| | | @IBAction func tapAction(_ sender: UIButton) { |
| | | switch sender.tag{ |
| | | case 10: |
| | | payType = .wechat |
| | | case 11: |
| | | payType = .aliPay |
| | | case 12: |
| | | payType = .coin |
| | | case 14: |
| | | payType = .courseNum |
| | | case 15: |
| | | payType = .integral |
| | | default:break |
| | | } |
| | | |
| | | btn_alipay.isSelected = payType == .aliPay |
| | | btn_coin.isSelected = payType == .coin |
| | | btn_wechat.isSelected = payType == .wechat |
| | | btn_course.isSelected = payType == .courseNum |
| | | btn_integral.isSelected = payType == .integral |
| | | } |
| | | |
| | | @IBAction func paymentAction(_ sender: UIButton) { |
| | | //场地,游戏,门票 可免费,根据上面的金额,展示了哪些条目判断,如果都没展示,金额全部会是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() |
| | | } |
| | | |
| | | @IBAction func cancelAction(_ sender: UIButton) { |
| | | hidden() |
| | | } |
| | | |
| | | } |