12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // MerchantsStateVC.swift
- // xingchuangke
- //
- // Created by Apple on 2021/3/2.
- // Copyright © 2021 Virgil. All rights reserved.
- //
- class MerchantsStateVC: BaseViewController {
- var dicModel = NSMutableDictionary()
- override func viewDidLoad() {
- super.viewDidLoad()
- self.view.backgroundColor = UIColor.init(white: 246/255.0, alpha: 1.0)
- self.title = "商户状态"
- initNavLeftBackButton()
- loadData()
- }
- // MARK: - request
- func loadData() {
- let url1 = RequestURL.machineInforNum
- let params1 = NSMutableDictionary()
- params1.setValue(CommonValue.getUserId(), forKey: "userId")
- params1.setValue("", forKey: "machineTypeId")
- submitDatMachineInforNumdic(url: url1, params: params1, tag: 1001)
- }
- var w: CGFloat = 0
- var h: CGFloat = 15
- override func returnData(tag: Int) {
- for i in 0..<self.arrDataMj.count {
- let dicNew = NSMutableDictionary(dictionary: self.arrDataMj[i] as! NSDictionary)
- let name = (dicNew as NSDictionary).object(forKey: "name") as! String
- let num = "\((dicNew as NSDictionary)["num"] as! Int)"
- let buttonView = UIView.init()
- buttonView.backgroundColor = .white
- buttonView.layer.cornerRadius = 8.0
- buttonView.layer.masksToBounds = true
- let length = (SCREEN_WIDTH-10*3)/2
- buttonView.frame = CGRect(x: 10 + w, y: h, width: length, height: 80)
- //当button的位置超出右侧边缘时换行
- if 10+w+length > SCREEN_WIDTH {
- w = 0
- h = h + buttonView.frame.size.height + 10
- buttonView.frame = CGRect(x: 10+w, y: h, width: length, height: 80)
- }
- w = buttonView.frame.size.width + buttonView.frame.origin.x
- view.addSubview(buttonView)
- let lblt = UILabel.init()
- lblt.text = name
- lblt.textColor = UIColor.black
- lblt.textAlignment = .center
- lblt.setOrigin(x: 0, y: 15)
- lblt.setSizeHeight(height: 30)
- lblt.setSizeWidth(width: length)
- buttonView.addSubview(lblt)
- let lbld = UILabel.init()
- lbld.text = num
- lbld.textColor = UIColor.red
- lbld.textAlignment = .center
- lbld.setOrigin(x: 0, y: 15+lblt.frame.size.height)
- lbld.setSizeHeight(height: 30)
- lbld.setSizeWidth(width: length)
- buttonView.addSubview(lbld)
- let button = UIButton(type: .custom)
- button.backgroundColor = .clear
- button.setOrigin(x: 0, y: 0)
- button.setSizeHeight(height: 80)
- button.setSizeWidth(width: length)
- button.tag = i
- button.addTarget(self, action: #selector(rewardClick(sender:)), for: .touchUpInside)
- buttonView.addSubview(button)
-
- }
- }
- @objc func rewardClick(sender : UIButton ) {
- let vc = MerchantsStateDetailVC()
- let dic: NSDictionary = self.arrDataMj[sender.tag] as! NSDictionary
- vc.dicModel = dic as! NSMutableDictionary
- appDelegate.navController.pushViewController(vc, animated: true)
- }
- }
|