123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 |
- //
- // CommonRightMenuHK.swift
- // xingchuangke
- //
- // Created by Apple on 2021/3/4.
- // Copyright © 2021 Virgil. All rights reserved.
- //
- import UIKit
- class CommonRightMenuHK: UIView {
- @IBOutlet weak var scrollView: UIScrollView!
- @IBOutlet weak var busAllBtn: UIButton!
- @IBOutlet weak var busJJBtn: UIButton!
- @IBOutlet weak var busSHBtn: UIButton!
- @IBOutlet weak var dealAllBtn: UIButton!
- @IBOutlet weak var dealXFBtn: UIButton!
- @IBOutlet weak var dealYJBtn: UIButton!
- @IBOutlet weak var payAllBtn: UIButton!
- @IBOutlet weak var paySKBtn: UIButton!
- @IBOutlet weak var payWXBtn: UIButton!
- @IBOutlet weak var payALBtn: UIButton!
- @IBOutlet weak var payEWBtn: UIButton!
- @IBOutlet weak var payQQBtn: UIButton!
- @IBOutlet weak var cardAllBtn: UIButton!
- @IBOutlet weak var cardJJBtn: UIButton!
- @IBOutlet weak var cardDJBtn: UIButton!
- @IBOutlet weak var cardZDBtn: UIButton!
- @IBOutlet weak var cardYFBtn: UIButton!
- @IBOutlet weak var wayAllBtn: UIButton!
- @IBOutlet weak var wayBtn: UIButton!
- @IBOutlet weak var wayBtn1: UIButton!
- @IBOutlet weak var wayBtn2: UIButton!
- @IBOutlet weak var btnConfrim: UIButton!
- @IBOutlet weak var btnReset: UIButton!
- @IBOutlet weak var btnEnd: UIButton!
- @IBOutlet weak var btnStart: UIButton!
- var queryEntity: QueryEntityHK!
- var oBackFunc: CommonBackQueryHK!
- var btnTypes = [UIButton]()
- var arrTempType = NSMutableArray()
- func initView(arrType: NSMutableArray, backFunc:@escaping CommonBackQueryHK) {
- oBackFunc = backFunc
- self.setSizeWidth(width: ScreenWidth)
- btnEnd.setCornerRadius(size: 3)
- btnStart.setCornerRadius(size: 3)
- scrollView.contentSize.height = btnConfrim.bottom() + 40
- busAllBtn.isSelected = true
- dealAllBtn.isSelected = true
- payAllBtn.isSelected = true
- cardAllBtn.isSelected = true
- wayAllBtn.isSelected = true
- busAllBtn.setTitleColor(.red, for: .selected)
- dealAllBtn.setTitleColor(.red, for: .selected)
- payAllBtn.setTitleColor(.red, for: .selected)
- cardAllBtn.setTitleColor(.red, for: .selected)
- wayAllBtn.setTitleColor(.red, for: .selected)
- arrTempType.removeAllObjects()
- arrTempType.addObjects(from: arrType as! [Any])
- // scrollViewType.removeAll();
- var left: CGFloat = 14
- btnTypes.removeAll()
- for i in 0 ..< arrType.count {
- let btn = UIButton(frame: CGRect(x: left, y: 0, width: 100, height: 36))
- btn.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
- btn.setTitle((arrType[i] as! NSDictionary).getString(key: "name"), for: .normal)
- btn.setTitleColor(CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), for: .normal)
- btn.setTitleColor(UIColor.white, for: .selected)
- btn.sizeToFitWidth()
- btn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
- btn.tag = i
- btn.addTarget(self, action: #selector(btnTypeClick), for: .touchUpInside)
- btn.setSizeWidth(width: btn.width() + 40)
- // scrollViewType.addSubview(btn)
- left = btn.right() + 15
- btnTypes.append(btn)
- btn.setCornerRadius(size: 3)
- }
- // scrollViewType.contentSize.width = left;
- queryEntity = QueryEntityHK()
- queryEntity.startTime = "选择开始日期"
- queryEntity.endTime = "选择截止日期"
- }
- @objc func btnTypeClick(btn: UIButton) {
- for btnTemp in btnTypes {
- if btnTemp.tag == btn.tag {
- queryEntity.typeID = (arrTempType[btn.tag] as! NSDictionary).getString(key: "id")
- btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x2A92F7, alpha: 1.0)
- btnTemp.isSelected = true
- } else {
- btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
- btnTemp.isSelected = false
- }
- }
- }
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 开始时间
- let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
- var defaultDate: Date!
- if queryEntity.startTime == "选择开始日期" || queryEntity.startTime.length() != 10 {
- defaultDate = CommonDate.addMonth(date: Date(), month: 0)
- } else {
- defaultDate = CommonDate.getDateForString(dateStr: queryEntity.startTime, dateFormat: "yyyy-MM-dd")
- }
- viewDatePicer.datePicker.maximumDate = Date()
- viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
- self!.queryEntity.startTime = str
- self!.refreshView()
- }
- break
- case 1002: // 结束时间
- let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
- var defaultDate: Date!
- if queryEntity.endTime == "选择截止日期" || queryEntity.endTime.length() != 10 {
- defaultDate = Date()
- } else {
- defaultDate = CommonDate.getDateForString(dateStr: queryEntity.endTime, dateFormat: "yyyy-MM-dd")
- }
- viewDatePicer.datePicker.maximumDate = Date()
- viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
- self!.queryEntity.endTime = str
- self!.refreshView()
- }
- refreshView()
- break
- case 1011: // 全部
- queryEntity.busType = ""
- refreshView()
- break
- case 1012: // 个人版
- queryEntity.busType = "0"
- refreshView()
- case 1013: // 商户版
- queryEntity.busType = "1"
- refreshView()
- break
- case 1021: // 全部
- queryEntity.depositTrade = ""
- refreshView()
- break
- case 1022: // 消费
- queryEntity.depositTrade = "consume"
- refreshView()
- break
- case 1023: // 押金
- queryEntity.depositTrade = "1"
- refreshView()
- break
- case 1031: // 全部
- queryEntity.payType = ""
- refreshView()
- break
- case 1032: // 刷卡
- queryEntity.payType = "POSPAY"
- refreshView()
- break
- case 1033: // 微信
- queryEntity.payType = "QR_WECHAT"
- refreshView()
- break
- case 1034: // 支付宝
- queryEntity.payType = "QR_ALIPAY"
- refreshView()
- break
- case 1035: // 银联二维码
- queryEntity.payType = "QR_UNIONPAY"
- refreshView()
- break
- case 1036: // QQ钱包
- queryEntity.payType = "QR_QQPAY"
- refreshView()
- break
- case 1041: // 全部
- queryEntity.cardType = ""
- refreshView()
- break
- case 1042: // 借记卡
- queryEntity.cardType = "1"
- refreshView()
- break
- case 1043: // 贷记卡
- queryEntity.cardType = "2"
- refreshView()
- break
- case 1044: // 准贷记卡
- queryEntity.cardType = "3"
- refreshView()
- break
- case 1045: // 预付费卡
- queryEntity.cardType = "4"
- refreshView()
- break
- case 1003: // T0
- queryEntity.settleWay = "T0"
- refreshView()
- break
- case 1004: // T1
- queryEntity.settleWay = "T1"
- refreshView()
- break
- case 1005: // 全部
- queryEntity.settleWay = ""
- refreshView()
- break
- case 1006: // TS
- queryEntity.settleWay = "TS"
- refreshView()
- break
- case 1007: // 重置
- queryEntity.startTime = "选择开始日期"
- queryEntity.endTime = "选择截止日期"
- queryEntity.cardType = ""
- queryEntity.settleWay = ""
- queryEntity.typeID = ""
- queryEntity.payType = ""
- queryEntity.depositTrade = ""
- queryEntity.busType = ""
- refreshView()
- break
- case 1008: // 确定
- hidMenu()
- if oBackFunc != nil {
- oBackFunc(queryEntity)
- }
- break
- case 1009: // 隐藏
- hidMenu()
- break
- default:
- break
- }
- }
- func refreshView() {
- for btnTemp in btnTypes {
- if queryEntity.typeID != (arrTempType[btnTemp.tag] as! NSDictionary).getString(key: "id") {
- btnTemp.isSelected = false
- btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
- }
- }
- if queryEntity.busType == "" {
- busAllBtn.isSelected = true
- busJJBtn.isSelected = false
- busSHBtn.isSelected = false
- busAllBtn.setTitleColor(.red, for: .selected)
- busJJBtn.setTitleColor(.black, for: .normal)
- busSHBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.busType == "0" {
- busAllBtn.isSelected = false
- busJJBtn.isSelected = true
- busSHBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busJJBtn.setTitleColor(.red, for: .selected)
- busSHBtn.setTitleColor(.black, for: .normal)
- } else {
- busAllBtn.isSelected = false
- busJJBtn.isSelected = false
- busSHBtn.isSelected = true
- busAllBtn.setTitleColor(.black, for: .normal)
- busJJBtn.setTitleColor(.black, for: .normal)
- busSHBtn.setTitleColor(.red, for: .selected)
- }
- if queryEntity.depositTrade == "" {
- dealAllBtn.isSelected = true
- dealXFBtn.isSelected = false
- dealYJBtn.isSelected = false
- dealAllBtn.setTitleColor(.red, for: .selected)
- dealXFBtn.setTitleColor(.black, for: .normal)
- dealYJBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.depositTrade == "consume" {
- dealAllBtn.isSelected = false
- dealXFBtn.isSelected = true
- dealYJBtn.isSelected = false
- dealAllBtn.setTitleColor(.black, for: .normal)
- dealXFBtn.setTitleColor(.red, for: .selected)
- dealYJBtn.setTitleColor(.black, for: .normal)
- }else {
- dealAllBtn.isSelected = false
- dealXFBtn.isSelected = false
- dealYJBtn.isSelected = true
- dealAllBtn.setTitleColor(.black, for: .normal)
- dealXFBtn.setTitleColor(.black, for: .normal)
- dealYJBtn.setTitleColor(.red, for: .selected)
- }
- if queryEntity.payType == "" {
- payAllBtn.isSelected = true
- paySKBtn.isSelected = false
- payWXBtn.isSelected = false
- payALBtn.isSelected = false
- payEWBtn.isSelected = false
- payQQBtn.isSelected = false
- payAllBtn.setTitleColor(.red, for: .selected)
- paySKBtn.setTitleColor(.black, for: .normal)
- payWXBtn.setTitleColor(.black, for: .normal)
- payALBtn.setTitleColor(.black, for: .normal)
- payEWBtn.setTitleColor(.black, for: .normal)
- payQQBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.payType == "POSPAY" {
- payAllBtn.isSelected = false
- paySKBtn.isSelected = true
- payWXBtn.isSelected = false
- payALBtn.isSelected = false
- payEWBtn.isSelected = false
- payQQBtn.isSelected = false
- payAllBtn.setTitleColor(.black, for: .normal)
- paySKBtn.setTitleColor(.red, for: .selected)
- payWXBtn.setTitleColor(.black, for: .normal)
- payALBtn.setTitleColor(.black, for: .normal)
- payEWBtn.setTitleColor(.black, for: .normal)
- payQQBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.payType == "QR_WECHAT" {
- payAllBtn.isSelected = false
- paySKBtn.isSelected = false
- payWXBtn.isSelected = true
- payALBtn.isSelected = false
- payEWBtn.isSelected = false
- payQQBtn.isSelected = false
- payAllBtn.setTitleColor(.black, for: .normal)
- paySKBtn.setTitleColor(.black, for: .normal)
- payWXBtn.setTitleColor(.red, for: .selected)
- payALBtn.setTitleColor(.black, for: .normal)
- payEWBtn.setTitleColor(.black, for: .normal)
- payQQBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.payType == "QR_ALIPAY" {
- payAllBtn.isSelected = false
- paySKBtn.isSelected = false
- payWXBtn.isSelected = false
- payALBtn.isSelected = true
- payEWBtn.isSelected = false
- payQQBtn.isSelected = false
- payAllBtn.setTitleColor(.black, for: .normal)
- paySKBtn.setTitleColor(.black, for: .normal)
- payWXBtn.setTitleColor(.black, for: .normal)
- payALBtn.setTitleColor(.red, for: .selected)
- payEWBtn.setTitleColor(.black, for: .normal)
- payQQBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.payType == "QR_UNIONPAY" {
- payAllBtn.isSelected = false
- paySKBtn.isSelected = false
- payWXBtn.isSelected = false
- payALBtn.isSelected = false
- payEWBtn.isSelected = true
- payQQBtn.isSelected = false
- payAllBtn.setTitleColor(.black, for: .normal)
- paySKBtn.setTitleColor(.black, for: .normal)
- payWXBtn.setTitleColor(.black, for: .normal)
- payALBtn.setTitleColor(.black, for: .normal)
- payEWBtn.setTitleColor(.red, for: .selected)
- payQQBtn.setTitleColor(.black, for: .normal)
- }else {
- payAllBtn.isSelected = false
- paySKBtn.isSelected = false
- payWXBtn.isSelected = false
- payALBtn.isSelected = false
- payEWBtn.isSelected = false
- payQQBtn.isSelected = true
- payAllBtn.setTitleColor(.black, for: .normal)
- paySKBtn.setTitleColor(.black, for: .normal)
- payWXBtn.setTitleColor(.black, for: .normal)
- payALBtn.setTitleColor(.black, for: .normal)
- payEWBtn.setTitleColor(.black, for: .normal)
- payQQBtn.setTitleColor(.red, for: .selected)
- }
- if queryEntity.cardType == "" {
- cardAllBtn.isSelected = true
- cardJJBtn.isSelected = false
- cardDJBtn.isSelected = false
- cardZDBtn.isSelected = false
- cardYFBtn.isSelected = false
- cardAllBtn.setTitleColor(.red, for: .selected)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardDJBtn.setTitleColor(.black, for: .normal)
- cardZDBtn.setTitleColor(.black, for: .normal)
- cardYFBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.cardType == "1" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = true
- cardDJBtn.isSelected = false
- cardZDBtn.isSelected = false
- cardYFBtn.isSelected = false
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.red, for: .selected)
- cardDJBtn.setTitleColor(.black, for: .normal)
- cardZDBtn.setTitleColor(.black, for: .normal)
- cardYFBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.cardType == "2" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = false
- cardDJBtn.isSelected = true
- cardZDBtn.isSelected = false
- cardYFBtn.isSelected = false
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardDJBtn.setTitleColor(.red, for: .selected)
- cardZDBtn.setTitleColor(.black, for: .normal)
- cardYFBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.cardType == "3" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = false
- cardDJBtn.isSelected = false
- cardZDBtn.isSelected = true
- cardYFBtn.isSelected = false
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardDJBtn.setTitleColor(.black, for: .normal)
- cardZDBtn.setTitleColor(.red, for: .selected)
- cardYFBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.cardType == "4" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = false
- cardDJBtn.isSelected = false
- cardZDBtn.isSelected = false
- cardYFBtn.isSelected = true
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardDJBtn.setTitleColor(.black, for: .normal)
- cardZDBtn.setTitleColor(.black, for: .normal)
- cardYFBtn.setTitleColor(.red, for: .selected)
- }
- if queryEntity.settleWay == "" {
- wayAllBtn.isSelected = true
- wayBtn.isSelected = false
- wayBtn1.isSelected = false
- wayBtn2.isSelected = false
- wayAllBtn.setTitleColor(.red, for: .selected)
- wayBtn.setTitleColor(.black, for: .normal)
- wayBtn1.setTitleColor(.black, for: .normal)
- wayBtn2.setTitleColor(.black, for: .normal)
- } else if queryEntity.settleWay == "T0" {
- wayAllBtn.isSelected = false
- wayBtn.isSelected = true
- wayBtn1.isSelected = false
- wayBtn2.isSelected = false
- wayAllBtn.setTitleColor(.black, for: .normal)
- wayBtn.setTitleColor(.red, for: .selected)
- wayBtn1.setTitleColor(.black, for: .normal)
- wayBtn2.setTitleColor(.black, for: .normal)
- }else if queryEntity.settleWay == "T1" {
- wayAllBtn.isSelected = false
- wayBtn.isSelected = false
- wayBtn1.isSelected = true
- wayBtn2.isSelected = false
- wayAllBtn.setTitleColor(.black, for: .normal)
- wayBtn.setTitleColor(.black, for: .normal)
- wayBtn1.setTitleColor(.red, for: .selected)
- wayBtn2.setTitleColor(.black, for: .normal)
- }else {
- wayAllBtn.isSelected = false
- wayBtn.isSelected = false
- wayBtn1.isSelected = false
- wayBtn2.isSelected = true
- wayAllBtn.setTitleColor(.black, for: .normal)
- wayBtn.setTitleColor(.black, for: .normal)
- wayBtn1.setTitleColor(.black, for: .normal)
- wayBtn2.setTitleColor(.red, for: .selected)
- }
- btnStart.setTitle(queryEntity.startTime, for: .normal)
- btnEnd.setTitle(queryEntity.endTime, for: .normal)
- }
- func showMenu(paretnView: UIView) {
- scrollView.marginLeft(left: ScreenWidth)
- paretnView.addSubview(self)
- self.setFillForSuperView()
- UIView.animate(withDuration: 0.5, animations: {
- self.scrollView.marginLeft(left: ScreenWidth - self.scrollView.width())
- }) { (_) in
- }
- }
- func hidMenu() {
- UIView.animate(withDuration: 0.5, animations: {
- self.scrollView.marginLeft(left: ScreenWidth)
- }) { (_) in
- self.removeFromSuperview()
- }
- }
- }
- class QueryEntityHK: NSObject {
- ///品牌ID
- var typeID = ""
- var startTime = ""
- var endTime = ""
- ///结算方式:T0 T1
- var settleWay = ""
- ///交易卡类型:借记卡
- var cardType = ""
- ///商户类型
- var busType = ""
- ///交易类型
- var depositTrade = ""
- ///交易方式
- var payType = ""
- }
- typealias CommonBackQueryHK=(_ entity: QueryEntityHK) -> Void
|