ApplyCardHomeViewController.swift 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // ApplyCardHomeViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/4/24.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class ApplyCardHomeViewController: BaseViewController {
  10. @IBOutlet weak var view1Height: NSLayoutConstraint!
  11. @IBOutlet weak var view1Width: NSLayoutConstraint!
  12. @IBOutlet weak var scrollView: UIScrollView!
  13. @IBOutlet weak var lblCount3: UILabel!
  14. @IBOutlet weak var lblCount2: UILabel!
  15. @IBOutlet weak var lblCount1: UILabel!
  16. @IBOutlet weak var viewNews: UIView!
  17. @IBOutlet weak var btnMenu1: UIButton!
  18. @IBOutlet weak var btnMenu2: UIButton!
  19. @IBOutlet weak var btnMenu3: UIButton!
  20. @IBOutlet weak var btnMenu4: UIButton!
  21. @IBOutlet weak var btnMenu5: UIButton!
  22. @IBOutlet weak var btnMenu6: UIButton!
  23. @IBOutlet weak var btnMenu7: UIButton!
  24. @IBOutlet weak var btnMenu8: UIButton!
  25. @IBOutlet weak var view4: UIView!
  26. @IBOutlet weak var view3: UIView!
  27. @IBOutlet weak var view2: UIView!
  28. @IBOutlet weak var view1: UIView!
  29. override func viewDidLoad() {
  30. super.viewDidLoad()
  31. self.title = "推荐办卡"
  32. initNavLeftBackButton()
  33. initNavRightButtonForImage(imgName: "")
  34. btnMenu8.isHidden = true
  35. view1Width.constant = ScreenWidth
  36. view1Height.constant = ScreenWidth / 1242 * 710
  37. 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)
  38. viewNews.addSubview(viewMarquee)
  39. loadHeaderData()
  40. }
  41. @objc func newsClick(btn: UIButton) {
  42. }
  43. override func viewSafeAreaInsetsDidChange() {
  44. CommonViewUntils.setViewCenter(arrView: [btnMenu1, btnMenu2, btnMenu3, btnMenu4], marginLeft: 15, marginRight: 15)
  45. CommonViewUntils.setViewCenter(arrView: [btnMenu5, btnMenu6, btnMenu7, btnMenu8], marginLeft: 15, marginRight: 15)
  46. }
  47. let arrHeader = NSMutableArray()
  48. func loadHeaderData() {
  49. let url = RequestURL.findAdvertisingWheel
  50. let params = NSMutableDictionary()
  51. params.setValue(0, forKey: "position")
  52. loadDataList(url: url, params: params, tag: 1003, array: arrHeader)
  53. }
  54. override func returnData(tag: Int) {
  55. if tag == 1001 {
  56. } else if tag == 1002 {
  57. } else if tag == 1003 {
  58. if arrHeader.count > 0 {
  59. var imgUrl = [String]()
  60. for i in 0 ..< arrHeader.count {
  61. imgUrl.append(getStringForArray(key: "img_path", arr: arrHeader, current: i))
  62. }
  63. 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]
  64. (item) -> Void in
  65. if CommonValue.getUserId() == "" {
  66. appDelegate.navController.pushViewController(LoginViewController(), animated: true)
  67. return
  68. }
  69. let type = (self!.arrHeader[item] as! NSDictionary).getInt(key: "type")
  70. ///0:内部web 1:外部web 111:邀请好友 222开通商户
  71. if type == 0 || type == 1 {
  72. let web = CommonWebViewViewController()
  73. web.strTitle = "详情"
  74. web.url = (self!.arrHeader[item] as! NSDictionary).getString(key: "web_url")
  75. appDelegate.navController.pushViewController(web, animated: true)
  76. } else if type == 111 {
  77. let vc = InviteViewController()
  78. appDelegate.navController.pushViewController(vc, animated: true)
  79. } else if type == 222 {
  80. let vc = SelectPayBrandViewController()
  81. appDelegate.navController.pushViewController(vc, animated: true)
  82. }
  83. }
  84. viewHeader.backgroundColor = UIColor.clear
  85. viewHeader.titles = ["1111", "2222", "3333", "4444"]
  86. view1.removeAll()
  87. view1.addSubview(viewHeader)
  88. }
  89. }
  90. }
  91. override func returnError(tag: Int, type: String) {
  92. }
  93. @IBAction func btnMenuClick(_ sender: AnyObject) {
  94. switch (sender as! UIButton).tag {
  95. case 1001: // 推荐办卡
  96. toViewController(viewController: ApplyCardViewController())
  97. break
  98. case 1002: // 奖励规则
  99. let viewWeb = CommonWebViewViewController()
  100. viewWeb.strTitle = "奖励规则"
  101. viewWeb.url = "\(RequestURL.sysConfigWeb)?type=wallet_rules"
  102. viewWeb.sourceType = 0
  103. appDelegate.navController.pushViewController(viewWeb, animated: true)
  104. break
  105. case 1003: // 办卡攻略
  106. toViewController(viewController: ApplyCardStrategyViewController())
  107. break
  108. case 1004: // 进度查询
  109. toViewController(viewController: ApplyCardPercentViewController())
  110. break
  111. case 1005: // 明星排行
  112. toViewController(viewController: RankingListViewController())
  113. break
  114. case 1006: // 常见问题
  115. toViewController(viewController: ApplyCardHelpListViewController())
  116. break
  117. case 1007: // 我的账号
  118. toViewController(viewController: ApplyCardAccountViewController())
  119. break
  120. default:
  121. break
  122. }
  123. }
  124. override func viewWillAppear(_ animated: Bool) {
  125. super.viewWillAppear(animated)
  126. }
  127. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  128. super.init(nibName: "ApplyCardHomeViewController", bundle: nil)
  129. }
  130. required init?(coder aDecoder: NSCoder) {
  131. fatalError("init(coder:) has not been implemented")
  132. }
  133. }