// // ApplyCardHomeViewController.swift // xingchuangke // // Created by Virgil on 2019/4/24. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class ApplyCardHomeViewController: BaseViewController { @IBOutlet weak var view1Height: NSLayoutConstraint! @IBOutlet weak var view1Width: NSLayoutConstraint! @IBOutlet weak var scrollView: UIScrollView! @IBOutlet weak var lblCount3: UILabel! @IBOutlet weak var lblCount2: UILabel! @IBOutlet weak var lblCount1: UILabel! @IBOutlet weak var viewNews: UIView! @IBOutlet weak var btnMenu1: UIButton! @IBOutlet weak var btnMenu2: UIButton! @IBOutlet weak var btnMenu3: UIButton! @IBOutlet weak var btnMenu4: UIButton! @IBOutlet weak var btnMenu5: UIButton! @IBOutlet weak var btnMenu6: UIButton! @IBOutlet weak var btnMenu7: UIButton! @IBOutlet weak var btnMenu8: UIButton! @IBOutlet weak var view4: UIView! @IBOutlet weak var view3: UIView! @IBOutlet weak var view2: UIView! @IBOutlet weak var view1: UIView! override func viewDidLoad() { super.viewDidLoad() self.title = "推荐办卡" initNavLeftBackButton() initNavRightButtonForImage(imgName: "") btnMenu8.isHidden = true view1Width.constant = ScreenWidth view1Height.constant = ScreenWidth / 1242 * 710 let viewMarquee = VirgilMarqueeView(frame: CGRect(x: 0, y: 10, width: ScreenWidth - 100, height: 14), titles: ["恭喜小伙伴:XXXX推荐XX信用卡成功", "22恭喜小伙伴:XXXX推荐XX信用卡成功", "33恭喜小伙伴:XXXX推荐XX信用卡成功"], fontSize: 12, timeInterval: 3, action: #selector(newsClick), target: self) viewNews.addSubview(viewMarquee) loadHeaderData() } @objc func newsClick(btn: UIButton) { } override func viewSafeAreaInsetsDidChange() { CommonViewUntils.setViewCenter(arrView: [btnMenu1, btnMenu2, btnMenu3, btnMenu4], marginLeft: 15, marginRight: 15) CommonViewUntils.setViewCenter(arrView: [btnMenu5, btnMenu6, btnMenu7, btnMenu8], marginLeft: 15, marginRight: 15) } let arrHeader = NSMutableArray() func loadHeaderData() { let url = RequestURL.findAdvertisingWheel let params = NSMutableDictionary() params.setValue(0, forKey: "position") loadDataList(url: url, params: params, tag: 1003, array: arrHeader) } override func returnData(tag: Int) { if tag == 1001 { } else if tag == 1002 { } else if tag == 1003 { if arrHeader.count > 0 { var imgUrl = [String]() for i in 0 ..< arrHeader.count { imgUrl.append(getStringForArray(key: "img_path", arr: arrHeader, current: i)) } let viewHeader = Virgil_PagedView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: view1Height.constant), imageURLStrings: imgUrl, placeholderImage: UIImage(named: "img_banner_01")!, timeInterval: 6) {[weak self] (item) -> Void in if CommonValue.getUserId() == "" { appDelegate.navController.pushViewController(LoginViewController(), animated: true) return } let type = (self!.arrHeader[item] as! NSDictionary).getInt(key: "type") ///0:内部web 1:外部web 111:邀请好友 222开通商户 if type == 0 || type == 1 { let web = CommonWebViewViewController() web.strTitle = "详情" web.url = (self!.arrHeader[item] as! NSDictionary).getString(key: "web_url") appDelegate.navController.pushViewController(web, animated: true) } else if type == 111 { let vc = InviteViewController() appDelegate.navController.pushViewController(vc, animated: true) } else if type == 222 { let vc = SelectPayBrandViewController() appDelegate.navController.pushViewController(vc, animated: true) } } viewHeader.backgroundColor = UIColor.clear viewHeader.titles = ["1111", "2222", "3333", "4444"] view1.removeAll() view1.addSubview(viewHeader) } } } override func returnError(tag: Int, type: String) { } @IBAction func btnMenuClick(_ sender: AnyObject) { switch (sender as! UIButton).tag { case 1001: // 推荐办卡 toViewController(viewController: ApplyCardViewController()) break case 1002: // 奖励规则 let viewWeb = CommonWebViewViewController() viewWeb.strTitle = "奖励规则" viewWeb.url = "\(RequestURL.sysConfigWeb)?type=wallet_rules" viewWeb.sourceType = 0 appDelegate.navController.pushViewController(viewWeb, animated: true) break case 1003: // 办卡攻略 toViewController(viewController: ApplyCardStrategyViewController()) break case 1004: // 进度查询 toViewController(viewController: ApplyCardPercentViewController()) break case 1005: // 明星排行 toViewController(viewController: RankingListViewController()) break case 1006: // 常见问题 toViewController(viewController: ApplyCardHelpListViewController()) break case 1007: // 我的账号 toViewController(viewController: ApplyCardAccountViewController()) break default: break } } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "ApplyCardHomeViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }