123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- //
- // CommonRightMenuHSF.swift
- // xingchuangke
- //
- // Created by 刘惠萍 on 2023/1/31.
- //
- import UIKit
- class CommonRightMenuHSF: UIView {
- @IBOutlet weak var scrollView: UIScrollView!
- @IBOutlet weak var busAllBtn: UIButton!
- @IBOutlet weak var busBZBtn: UIButton!
- @IBOutlet weak var busYHBtn: UIButton!
- @IBOutlet weak var busWXBtn: UIButton!
- @IBOutlet weak var busZFBBtn: UIButton!
- @IBOutlet weak var busYLBtn: UIButton!
- @IBOutlet weak var busLLBtn: UIButton!
- @IBOutlet weak var busYJBtn: UIButton!
- @IBOutlet weak var cardAllBtn: UIButton!
- @IBOutlet weak var cardJJBtn: UIButton!
- @IBOutlet weak var cardXYBtn: UIButton!
- @IBOutlet weak var btnConfrim: UIButton!
- @IBOutlet weak var btnReset: UIButton!
- @IBOutlet weak var btnEnd: UIButton!
- @IBOutlet weak var btnStart: UIButton!
-
- var queryEntity: QueryEntityHSF!
- var oBackFunc: CommonBackQueryHSF!
- var btnTypes = [UIButton]()
- var arrTempType = NSMutableArray()
- func initView(arrType: NSMutableArray, backFunc:@escaping CommonBackQueryHSF) {
- oBackFunc = backFunc
- self.setSizeWidth(width: ScreenWidth)
- btnEnd.setCornerRadius(size: 3)
- btnStart.setCornerRadius(size: 3)
- scrollView.contentSize.height = btnConfrim.bottom() + 40
- busAllBtn.isSelected = true
- cardAllBtn.isSelected = true
- busAllBtn.setTitleColor(.red, for: .selected)
- cardAllBtn.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 = QueryEntityHSF()
- 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 1021: // 全部
- queryEntity.depositTrade = ""
- refreshView()
- break
- case 1022: // 标准消费
- queryEntity.depositTrade = "00"
- refreshView()
- break
- case 1023: // 优惠消费
- queryEntity.depositTrade = "01"
- refreshView()
- break
- case 1024: // wx
- queryEntity.depositTrade = "02"
- refreshView()
- break
- case 1025: // zfb
- queryEntity.depositTrade = "03"
- refreshView()
- break
- case 1026: // 银联二维码
- queryEntity.depositTrade = "04"
- refreshView()
- break
- case 1027: // 流量费
- queryEntity.depositTrade = "05"
- refreshView()
- break
- case 1028: // 押金消费
- queryEntity.depositTrade = "06"
- refreshView()
- break
- case 1041: // 全部
- queryEntity.cardType = ""
- refreshView()
- break
- case 1042: // 借记卡
- queryEntity.cardType = "0"
- refreshView()
- break
- case 1043: // 信用卡
- queryEntity.cardType = "1"
- refreshView()
- break
- case 1007: // 重置
- queryEntity.startTime = "选择开始日期"
- queryEntity.endTime = "选择截止日期"
- queryEntity.cardType = ""
- queryEntity.depositTrade = ""
- 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.depositTrade == "" {
- busAllBtn.isSelected = true
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.red, for: .selected)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.depositTrade == "00" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = true
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.red, for: .selected)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.depositTrade == "01" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = true
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.red, for: .selected)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.depositTrade == "02" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = true
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.red, for: .selected)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.depositTrade == "03" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = true
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.red, for: .selected)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.depositTrade == "04" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = true
- busLLBtn.isSelected = false
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.red, for: .selected)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.depositTrade == "05" {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = true
- busYJBtn.isSelected = false
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.red, for: .selected)
- busYJBtn.setTitleColor(.black, for: .normal)
- } else {
- busAllBtn.isSelected = false
- busBZBtn.isSelected = false
- busYHBtn.isSelected = false
- busWXBtn.isSelected = false
- busZFBBtn.isSelected = false
- busYLBtn.isSelected = false
- busLLBtn.isSelected = false
- busYJBtn.isSelected = true
- busAllBtn.setTitleColor(.black, for: .normal)
- busBZBtn.setTitleColor(.black, for: .normal)
- busYHBtn.setTitleColor(.black, for: .normal)
- busWXBtn.setTitleColor(.black, for: .normal)
- busZFBBtn.setTitleColor(.black, for: .normal)
- busYLBtn.setTitleColor(.black, for: .normal)
- busLLBtn.setTitleColor(.black, for: .normal)
- busYJBtn.setTitleColor(.red, for: .selected)
- }
- if queryEntity.cardType == "" {
- cardAllBtn.isSelected = true
- cardJJBtn.isSelected = false
- cardXYBtn.isSelected = false
- cardAllBtn.setTitleColor(.red, for: .selected)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardXYBtn.setTitleColor(.black, for: .normal)
- } else if queryEntity.cardType == "0" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = true
- cardXYBtn.isSelected = false
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.red, for: .selected)
- cardXYBtn.setTitleColor(.black, for: .normal)
- }else if queryEntity.cardType == "1" {
- cardAllBtn.isSelected = false
- cardJJBtn.isSelected = false
- cardXYBtn.isSelected = true
- cardAllBtn.setTitleColor(.black, for: .normal)
- cardJJBtn.setTitleColor(.black, for: .normal)
- cardXYBtn.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 QueryEntityHSF: NSObject {
- ///品牌ID
- var typeID = ""
- var startTime = ""
- var endTime = ""
- ///交易卡类型:借记卡
- var cardType = ""
- ///交易类型
- var depositTrade = ""
-
- }
- typealias CommonBackQueryHSF=(_ entity: QueryEntityHSF) -> Void
|