CommonRightMenuHK.swift 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. //
  2. // CommonRightMenuHK.swift
  3. // xingchuangke
  4. //
  5. // Created by Apple on 2021/3/4.
  6. // Copyright © 2021 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class CommonRightMenuHK: UIView {
  10. @IBOutlet weak var scrollView: UIScrollView!
  11. @IBOutlet weak var busAllBtn: UIButton!
  12. @IBOutlet weak var busJJBtn: UIButton!
  13. @IBOutlet weak var busSHBtn: UIButton!
  14. @IBOutlet weak var dealAllBtn: UIButton!
  15. @IBOutlet weak var dealXFBtn: UIButton!
  16. @IBOutlet weak var dealYJBtn: UIButton!
  17. @IBOutlet weak var payAllBtn: UIButton!
  18. @IBOutlet weak var paySKBtn: UIButton!
  19. @IBOutlet weak var payWXBtn: UIButton!
  20. @IBOutlet weak var payALBtn: UIButton!
  21. @IBOutlet weak var payEWBtn: UIButton!
  22. @IBOutlet weak var payQQBtn: UIButton!
  23. @IBOutlet weak var cardAllBtn: UIButton!
  24. @IBOutlet weak var cardJJBtn: UIButton!
  25. @IBOutlet weak var cardDJBtn: UIButton!
  26. @IBOutlet weak var cardZDBtn: UIButton!
  27. @IBOutlet weak var cardYFBtn: UIButton!
  28. @IBOutlet weak var wayAllBtn: UIButton!
  29. @IBOutlet weak var wayBtn: UIButton!
  30. @IBOutlet weak var wayBtn1: UIButton!
  31. @IBOutlet weak var wayBtn2: UIButton!
  32. @IBOutlet weak var btnConfrim: UIButton!
  33. @IBOutlet weak var btnReset: UIButton!
  34. @IBOutlet weak var btnEnd: UIButton!
  35. @IBOutlet weak var btnStart: UIButton!
  36. var queryEntity: QueryEntityHK!
  37. var oBackFunc: CommonBackQueryHK!
  38. var btnTypes = [UIButton]()
  39. var arrTempType = NSMutableArray()
  40. func initView(arrType: NSMutableArray, backFunc:@escaping CommonBackQueryHK) {
  41. oBackFunc = backFunc
  42. self.setSizeWidth(width: ScreenWidth)
  43. btnEnd.setCornerRadius(size: 3)
  44. btnStart.setCornerRadius(size: 3)
  45. scrollView.contentSize.height = btnConfrim.bottom() + 40
  46. busAllBtn.isSelected = true
  47. dealAllBtn.isSelected = true
  48. payAllBtn.isSelected = true
  49. cardAllBtn.isSelected = true
  50. wayAllBtn.isSelected = true
  51. busAllBtn.setTitleColor(.red, for: .selected)
  52. dealAllBtn.setTitleColor(.red, for: .selected)
  53. payAllBtn.setTitleColor(.red, for: .selected)
  54. cardAllBtn.setTitleColor(.red, for: .selected)
  55. wayAllBtn.setTitleColor(.red, for: .selected)
  56. arrTempType.removeAllObjects()
  57. arrTempType.addObjects(from: arrType as! [Any])
  58. // scrollViewType.removeAll();
  59. var left: CGFloat = 14
  60. btnTypes.removeAll()
  61. for i in 0 ..< arrType.count {
  62. let btn = UIButton(frame: CGRect(x: left, y: 0, width: 100, height: 36))
  63. btn.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  64. btn.setTitle((arrType[i] as! NSDictionary).getString(key: "name"), for: .normal)
  65. btn.setTitleColor(CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), for: .normal)
  66. btn.setTitleColor(UIColor.white, for: .selected)
  67. btn.sizeToFitWidth()
  68. btn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
  69. btn.tag = i
  70. btn.addTarget(self, action: #selector(btnTypeClick), for: .touchUpInside)
  71. btn.setSizeWidth(width: btn.width() + 40)
  72. // scrollViewType.addSubview(btn)
  73. left = btn.right() + 15
  74. btnTypes.append(btn)
  75. btn.setCornerRadius(size: 3)
  76. }
  77. // scrollViewType.contentSize.width = left;
  78. queryEntity = QueryEntityHK()
  79. queryEntity.startTime = "选择开始日期"
  80. queryEntity.endTime = "选择截止日期"
  81. }
  82. @objc func btnTypeClick(btn: UIButton) {
  83. for btnTemp in btnTypes {
  84. if btnTemp.tag == btn.tag {
  85. queryEntity.typeID = (arrTempType[btn.tag] as! NSDictionary).getString(key: "id")
  86. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x2A92F7, alpha: 1.0)
  87. btnTemp.isSelected = true
  88. } else {
  89. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  90. btnTemp.isSelected = false
  91. }
  92. }
  93. }
  94. @IBAction func btnMenuClick(_ sender: AnyObject) {
  95. switch (sender as! UIButton).tag {
  96. case 1001: // 开始时间
  97. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  98. var defaultDate: Date!
  99. if queryEntity.startTime == "选择开始日期" || queryEntity.startTime.length() != 10 {
  100. defaultDate = CommonDate.addMonth(date: Date(), month: 0)
  101. } else {
  102. defaultDate = CommonDate.getDateForString(dateStr: queryEntity.startTime, dateFormat: "yyyy-MM-dd")
  103. }
  104. viewDatePicer.datePicker.maximumDate = Date()
  105. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  106. self!.queryEntity.startTime = str
  107. self!.refreshView()
  108. }
  109. break
  110. case 1002: // 结束时间
  111. let viewDatePicer = (CommonViewUntils.getViewForXIB(anyClass: Virgil_SelectDateForPickerView.self) as! Virgil_SelectDateForPickerView)
  112. var defaultDate: Date!
  113. if queryEntity.endTime == "选择截止日期" || queryEntity.endTime.length() != 10 {
  114. defaultDate = Date()
  115. } else {
  116. defaultDate = CommonDate.getDateForString(dateStr: queryEntity.endTime, dateFormat: "yyyy-MM-dd")
  117. }
  118. viewDatePicer.datePicker.maximumDate = Date()
  119. viewDatePicer.showDatePickerView(defaultDate: defaultDate) {[weak self] (str) in
  120. self!.queryEntity.endTime = str
  121. self!.refreshView()
  122. }
  123. refreshView()
  124. break
  125. case 1011: // 全部
  126. queryEntity.busType = ""
  127. refreshView()
  128. break
  129. case 1012: // 个人版
  130. queryEntity.busType = "0"
  131. refreshView()
  132. case 1013: // 商户版
  133. queryEntity.busType = "1"
  134. refreshView()
  135. break
  136. case 1021: // 全部
  137. queryEntity.depositTrade = ""
  138. refreshView()
  139. break
  140. case 1022: // 消费
  141. queryEntity.depositTrade = "consume"
  142. refreshView()
  143. break
  144. case 1023: // 押金
  145. queryEntity.depositTrade = "1"
  146. refreshView()
  147. break
  148. case 1031: // 全部
  149. queryEntity.payType = ""
  150. refreshView()
  151. break
  152. case 1032: // 刷卡
  153. queryEntity.payType = "POSPAY"
  154. refreshView()
  155. break
  156. case 1033: // 微信
  157. queryEntity.payType = "QR_WECHAT"
  158. refreshView()
  159. break
  160. case 1034: // 支付宝
  161. queryEntity.payType = "QR_ALIPAY"
  162. refreshView()
  163. break
  164. case 1035: // 银联二维码
  165. queryEntity.payType = "QR_UNIONPAY"
  166. refreshView()
  167. break
  168. case 1036: // QQ钱包
  169. queryEntity.payType = "QR_QQPAY"
  170. refreshView()
  171. break
  172. case 1041: // 全部
  173. queryEntity.cardType = ""
  174. refreshView()
  175. break
  176. case 1042: // 借记卡
  177. queryEntity.cardType = "1"
  178. refreshView()
  179. break
  180. case 1043: // 贷记卡
  181. queryEntity.cardType = "2"
  182. refreshView()
  183. break
  184. case 1044: // 准贷记卡
  185. queryEntity.cardType = "3"
  186. refreshView()
  187. break
  188. case 1045: // 预付费卡
  189. queryEntity.cardType = "4"
  190. refreshView()
  191. break
  192. case 1003: // T0
  193. queryEntity.settleWay = "T0"
  194. refreshView()
  195. break
  196. case 1004: // T1
  197. queryEntity.settleWay = "T1"
  198. refreshView()
  199. break
  200. case 1005: // 全部
  201. queryEntity.settleWay = ""
  202. refreshView()
  203. break
  204. case 1006: // TS
  205. queryEntity.settleWay = "TS"
  206. refreshView()
  207. break
  208. case 1007: // 重置
  209. queryEntity.startTime = "选择开始日期"
  210. queryEntity.endTime = "选择截止日期"
  211. queryEntity.cardType = ""
  212. queryEntity.settleWay = ""
  213. queryEntity.typeID = ""
  214. queryEntity.payType = ""
  215. queryEntity.depositTrade = ""
  216. queryEntity.busType = ""
  217. refreshView()
  218. break
  219. case 1008: // 确定
  220. hidMenu()
  221. if oBackFunc != nil {
  222. oBackFunc(queryEntity)
  223. }
  224. break
  225. case 1009: // 隐藏
  226. hidMenu()
  227. break
  228. default:
  229. break
  230. }
  231. }
  232. func refreshView() {
  233. for btnTemp in btnTypes {
  234. if queryEntity.typeID != (arrTempType[btnTemp.tag] as! NSDictionary).getString(key: "id") {
  235. btnTemp.isSelected = false
  236. btnTemp.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf5f5f5, alpha: 1.0)
  237. }
  238. }
  239. if queryEntity.busType == "" {
  240. busAllBtn.isSelected = true
  241. busJJBtn.isSelected = false
  242. busSHBtn.isSelected = false
  243. busAllBtn.setTitleColor(.red, for: .selected)
  244. busJJBtn.setTitleColor(.black, for: .normal)
  245. busSHBtn.setTitleColor(.black, for: .normal)
  246. } else if queryEntity.busType == "0" {
  247. busAllBtn.isSelected = false
  248. busJJBtn.isSelected = true
  249. busSHBtn.isSelected = false
  250. busAllBtn.setTitleColor(.black, for: .normal)
  251. busJJBtn.setTitleColor(.red, for: .selected)
  252. busSHBtn.setTitleColor(.black, for: .normal)
  253. } else {
  254. busAllBtn.isSelected = false
  255. busJJBtn.isSelected = false
  256. busSHBtn.isSelected = true
  257. busAllBtn.setTitleColor(.black, for: .normal)
  258. busJJBtn.setTitleColor(.black, for: .normal)
  259. busSHBtn.setTitleColor(.red, for: .selected)
  260. }
  261. if queryEntity.depositTrade == "" {
  262. dealAllBtn.isSelected = true
  263. dealXFBtn.isSelected = false
  264. dealYJBtn.isSelected = false
  265. dealAllBtn.setTitleColor(.red, for: .selected)
  266. dealXFBtn.setTitleColor(.black, for: .normal)
  267. dealYJBtn.setTitleColor(.black, for: .normal)
  268. } else if queryEntity.depositTrade == "consume" {
  269. dealAllBtn.isSelected = false
  270. dealXFBtn.isSelected = true
  271. dealYJBtn.isSelected = false
  272. dealAllBtn.setTitleColor(.black, for: .normal)
  273. dealXFBtn.setTitleColor(.red, for: .selected)
  274. dealYJBtn.setTitleColor(.black, for: .normal)
  275. }else {
  276. dealAllBtn.isSelected = false
  277. dealXFBtn.isSelected = false
  278. dealYJBtn.isSelected = true
  279. dealAllBtn.setTitleColor(.black, for: .normal)
  280. dealXFBtn.setTitleColor(.black, for: .normal)
  281. dealYJBtn.setTitleColor(.red, for: .selected)
  282. }
  283. if queryEntity.payType == "" {
  284. payAllBtn.isSelected = true
  285. paySKBtn.isSelected = false
  286. payWXBtn.isSelected = false
  287. payALBtn.isSelected = false
  288. payEWBtn.isSelected = false
  289. payQQBtn.isSelected = false
  290. payAllBtn.setTitleColor(.red, for: .selected)
  291. paySKBtn.setTitleColor(.black, for: .normal)
  292. payWXBtn.setTitleColor(.black, for: .normal)
  293. payALBtn.setTitleColor(.black, for: .normal)
  294. payEWBtn.setTitleColor(.black, for: .normal)
  295. payQQBtn.setTitleColor(.black, for: .normal)
  296. } else if queryEntity.payType == "POSPAY" {
  297. payAllBtn.isSelected = false
  298. paySKBtn.isSelected = true
  299. payWXBtn.isSelected = false
  300. payALBtn.isSelected = false
  301. payEWBtn.isSelected = false
  302. payQQBtn.isSelected = false
  303. payAllBtn.setTitleColor(.black, for: .normal)
  304. paySKBtn.setTitleColor(.red, for: .selected)
  305. payWXBtn.setTitleColor(.black, for: .normal)
  306. payALBtn.setTitleColor(.black, for: .normal)
  307. payEWBtn.setTitleColor(.black, for: .normal)
  308. payQQBtn.setTitleColor(.black, for: .normal)
  309. }else if queryEntity.payType == "QR_WECHAT" {
  310. payAllBtn.isSelected = false
  311. paySKBtn.isSelected = false
  312. payWXBtn.isSelected = true
  313. payALBtn.isSelected = false
  314. payEWBtn.isSelected = false
  315. payQQBtn.isSelected = false
  316. payAllBtn.setTitleColor(.black, for: .normal)
  317. paySKBtn.setTitleColor(.black, for: .normal)
  318. payWXBtn.setTitleColor(.red, for: .selected)
  319. payALBtn.setTitleColor(.black, for: .normal)
  320. payEWBtn.setTitleColor(.black, for: .normal)
  321. payQQBtn.setTitleColor(.black, for: .normal)
  322. }else if queryEntity.payType == "QR_ALIPAY" {
  323. payAllBtn.isSelected = false
  324. paySKBtn.isSelected = false
  325. payWXBtn.isSelected = false
  326. payALBtn.isSelected = true
  327. payEWBtn.isSelected = false
  328. payQQBtn.isSelected = false
  329. payAllBtn.setTitleColor(.black, for: .normal)
  330. paySKBtn.setTitleColor(.black, for: .normal)
  331. payWXBtn.setTitleColor(.black, for: .normal)
  332. payALBtn.setTitleColor(.red, for: .selected)
  333. payEWBtn.setTitleColor(.black, for: .normal)
  334. payQQBtn.setTitleColor(.black, for: .normal)
  335. }else if queryEntity.payType == "QR_UNIONPAY" {
  336. payAllBtn.isSelected = false
  337. paySKBtn.isSelected = false
  338. payWXBtn.isSelected = false
  339. payALBtn.isSelected = false
  340. payEWBtn.isSelected = true
  341. payQQBtn.isSelected = false
  342. payAllBtn.setTitleColor(.black, for: .normal)
  343. paySKBtn.setTitleColor(.black, for: .normal)
  344. payWXBtn.setTitleColor(.black, for: .normal)
  345. payALBtn.setTitleColor(.black, for: .normal)
  346. payEWBtn.setTitleColor(.red, for: .selected)
  347. payQQBtn.setTitleColor(.black, for: .normal)
  348. }else {
  349. payAllBtn.isSelected = false
  350. paySKBtn.isSelected = false
  351. payWXBtn.isSelected = false
  352. payALBtn.isSelected = false
  353. payEWBtn.isSelected = false
  354. payQQBtn.isSelected = true
  355. payAllBtn.setTitleColor(.black, for: .normal)
  356. paySKBtn.setTitleColor(.black, for: .normal)
  357. payWXBtn.setTitleColor(.black, for: .normal)
  358. payALBtn.setTitleColor(.black, for: .normal)
  359. payEWBtn.setTitleColor(.black, for: .normal)
  360. payQQBtn.setTitleColor(.red, for: .selected)
  361. }
  362. if queryEntity.cardType == "" {
  363. cardAllBtn.isSelected = true
  364. cardJJBtn.isSelected = false
  365. cardDJBtn.isSelected = false
  366. cardZDBtn.isSelected = false
  367. cardYFBtn.isSelected = false
  368. cardAllBtn.setTitleColor(.red, for: .selected)
  369. cardJJBtn.setTitleColor(.black, for: .normal)
  370. cardDJBtn.setTitleColor(.black, for: .normal)
  371. cardZDBtn.setTitleColor(.black, for: .normal)
  372. cardYFBtn.setTitleColor(.black, for: .normal)
  373. } else if queryEntity.cardType == "1" {
  374. cardAllBtn.isSelected = false
  375. cardJJBtn.isSelected = true
  376. cardDJBtn.isSelected = false
  377. cardZDBtn.isSelected = false
  378. cardYFBtn.isSelected = false
  379. cardAllBtn.setTitleColor(.black, for: .normal)
  380. cardJJBtn.setTitleColor(.red, for: .selected)
  381. cardDJBtn.setTitleColor(.black, for: .normal)
  382. cardZDBtn.setTitleColor(.black, for: .normal)
  383. cardYFBtn.setTitleColor(.black, for: .normal)
  384. }else if queryEntity.cardType == "2" {
  385. cardAllBtn.isSelected = false
  386. cardJJBtn.isSelected = false
  387. cardDJBtn.isSelected = true
  388. cardZDBtn.isSelected = false
  389. cardYFBtn.isSelected = false
  390. cardAllBtn.setTitleColor(.black, for: .normal)
  391. cardJJBtn.setTitleColor(.black, for: .normal)
  392. cardDJBtn.setTitleColor(.red, for: .selected)
  393. cardZDBtn.setTitleColor(.black, for: .normal)
  394. cardYFBtn.setTitleColor(.black, for: .normal)
  395. }else if queryEntity.cardType == "3" {
  396. cardAllBtn.isSelected = false
  397. cardJJBtn.isSelected = false
  398. cardDJBtn.isSelected = false
  399. cardZDBtn.isSelected = true
  400. cardYFBtn.isSelected = false
  401. cardAllBtn.setTitleColor(.black, for: .normal)
  402. cardJJBtn.setTitleColor(.black, for: .normal)
  403. cardDJBtn.setTitleColor(.black, for: .normal)
  404. cardZDBtn.setTitleColor(.red, for: .selected)
  405. cardYFBtn.setTitleColor(.black, for: .normal)
  406. }else if queryEntity.cardType == "4" {
  407. cardAllBtn.isSelected = false
  408. cardJJBtn.isSelected = false
  409. cardDJBtn.isSelected = false
  410. cardZDBtn.isSelected = false
  411. cardYFBtn.isSelected = true
  412. cardAllBtn.setTitleColor(.black, for: .normal)
  413. cardJJBtn.setTitleColor(.black, for: .normal)
  414. cardDJBtn.setTitleColor(.black, for: .normal)
  415. cardZDBtn.setTitleColor(.black, for: .normal)
  416. cardYFBtn.setTitleColor(.red, for: .selected)
  417. }
  418. if queryEntity.settleWay == "" {
  419. wayAllBtn.isSelected = true
  420. wayBtn.isSelected = false
  421. wayBtn1.isSelected = false
  422. wayBtn2.isSelected = false
  423. wayAllBtn.setTitleColor(.red, for: .selected)
  424. wayBtn.setTitleColor(.black, for: .normal)
  425. wayBtn1.setTitleColor(.black, for: .normal)
  426. wayBtn2.setTitleColor(.black, for: .normal)
  427. } else if queryEntity.settleWay == "T0" {
  428. wayAllBtn.isSelected = false
  429. wayBtn.isSelected = true
  430. wayBtn1.isSelected = false
  431. wayBtn2.isSelected = false
  432. wayAllBtn.setTitleColor(.black, for: .normal)
  433. wayBtn.setTitleColor(.red, for: .selected)
  434. wayBtn1.setTitleColor(.black, for: .normal)
  435. wayBtn2.setTitleColor(.black, for: .normal)
  436. }else if queryEntity.settleWay == "T1" {
  437. wayAllBtn.isSelected = false
  438. wayBtn.isSelected = false
  439. wayBtn1.isSelected = true
  440. wayBtn2.isSelected = false
  441. wayAllBtn.setTitleColor(.black, for: .normal)
  442. wayBtn.setTitleColor(.black, for: .normal)
  443. wayBtn1.setTitleColor(.red, for: .selected)
  444. wayBtn2.setTitleColor(.black, for: .normal)
  445. }else {
  446. wayAllBtn.isSelected = false
  447. wayBtn.isSelected = false
  448. wayBtn1.isSelected = false
  449. wayBtn2.isSelected = true
  450. wayAllBtn.setTitleColor(.black, for: .normal)
  451. wayBtn.setTitleColor(.black, for: .normal)
  452. wayBtn1.setTitleColor(.black, for: .normal)
  453. wayBtn2.setTitleColor(.red, for: .selected)
  454. }
  455. btnStart.setTitle(queryEntity.startTime, for: .normal)
  456. btnEnd.setTitle(queryEntity.endTime, for: .normal)
  457. }
  458. func showMenu(paretnView: UIView) {
  459. scrollView.marginLeft(left: ScreenWidth)
  460. paretnView.addSubview(self)
  461. self.setFillForSuperView()
  462. UIView.animate(withDuration: 0.5, animations: {
  463. self.scrollView.marginLeft(left: ScreenWidth - self.scrollView.width())
  464. }) { (_) in
  465. }
  466. }
  467. func hidMenu() {
  468. UIView.animate(withDuration: 0.5, animations: {
  469. self.scrollView.marginLeft(left: ScreenWidth)
  470. }) { (_) in
  471. self.removeFromSuperview()
  472. }
  473. }
  474. }
  475. class QueryEntityHK: NSObject {
  476. ///品牌ID
  477. var typeID = ""
  478. var startTime = ""
  479. var endTime = ""
  480. ///结算方式:T0 T1
  481. var settleWay = ""
  482. ///交易卡类型:借记卡
  483. var cardType = ""
  484. ///商户类型
  485. var busType = ""
  486. ///交易类型
  487. var depositTrade = ""
  488. ///交易方式
  489. var payType = ""
  490. }
  491. typealias CommonBackQueryHK=(_ entity: QueryEntityHK) -> Void