123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //
- // IntegralWebViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/5/5.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class ApplyCardWebViewController: BaseViewController, UIScrollViewDelegate {
- lazy var wkWebView: WKWebView = {
- () -> WKWebView in
- let config = WKWebViewConfiguration.init()
- let wkWebView = WKWebView.init(frame: CGRect.zero, configuration: config)
- return wkWebView
- }()
- var urlStr = ""
- override func viewDidLoad() {
- super.viewDidLoad()
- initNavLeftBackButton()
- wkWebView.frame = self.view.bounds
- // self.view.addSubview(wkWebView)
- urlStr = "\(RequestURL.cardMain)#/?org_code=\(RequestURL.orgId)&user_code=\(CommonValue.getUserId())&cid=\(CommonUntils.getUUID())"
- wkWebView.load(URLRequest(url: URL(string: urlStr)!))
- // initNavRightButtonForImage(imgName: "share_common")
- // initNavRightButtonForTitle(title: "进度查询")
- self.loadData()
- }
- var dataArray = NSArray.init()
- func loadData() {
- let http = AFHTTPSessionManager()
- http.get(RequestURL.getCreditBankList, parameters: nil, progress: { (_) in
- }, success: { (operation, json) in
- print(json as Any)
- let success = (json as! NSDictionary).object(forKey: "succeed") as! String
- if success == "000"{
- self.dataArray = (json as! NSDictionary).object(forKey: "dataInfo") as! NSArray
- self.creatUI()
- }
- }) { (_, _) in
- }
- }
- let scrollView = UIScrollView()
- func creatUI() {
- let allNum = self.dataArray.count
- var l = allNum/3
- let c = allNum%3
- if c == 0 {
- l = l+1
- }
- let width = Int((kScreenWidth-40)/3)
- scrollView.delegate = self //设置代理
- scrollView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight-45)//设置scrollview的大小
- scrollView.backgroundColor = self.view.backgroundColor
- scrollView.isPagingEnabled = false //是否支持分页
- scrollView.bounces = false //是否支持回弹效果
- scrollView.showsVerticalScrollIndicator = false //垂直滑动线隐藏
- scrollView.showsHorizontalScrollIndicator = false //水平滑动线隐藏
- //scrollView.contentInset = UIEdgeInsetsMake(10, 10, 10, 10) //设置内边距
- scrollView.contentSize = CGSize(width: kScreenWidth, height: CGFloat(width*l+20))
- self.view.addSubview(scrollView)
- var num = 0
- for i in 0..<l {
- for j in 0..<3 {
- if num == allNum {
- return
- }
- let cell = BankCardCel.init()
- cell.isUserInteractionEnabled = true
- cell.mj_x = CGFloat(j*width+10*j+10)
- cell.mj_y = CGFloat(i*width+10*i+10)
- cell.setSizeWidth(width: CGFloat(width))
- cell.setSizeHeight(height: CGFloat(width))
- // cell.frame = CGRect(x: j*40+10, y: i*40+10, width: (kScreenWidth-40)/3, height: (kScreenWidth-40)/3)
- scrollView.addSubview(cell)
- let dic = self.dataArray[num]as!NSDictionary
- cell.titleLabel.text = (dic["name"]as!String)
- cell.imageView.sd_setImage(with: NSURL.init(string: "https://img.weimilo.com\(dic["logo"]as!String)") as URL?)
- cell.tipLabel.text = (dic["logo_tip"]as!String)
- cell.btn.addTarget(self, action: #selector(bankBtnTouch(_:)), for: .touchUpInside)
- num+=1
- }
- }
- }
- @objc func bankBtnTouch(_ sender: UIButton) {
- let dic = self.dataArray[sender.tag]as!NSDictionary
- let vc = UpMessageCardViewController()
- vc.dic = dic
- toViewController(viewController: vc)
- }
- override func btnRightMenuClick() {
- let urlStr = "http://app.xingchuangke.net/jsp/creditBank/bank_list.jsp?userId=\(CommonValue.getUserId())"
- CommonUMengShare.showSharedMenu(viewController: self, title: "免费办理信用卡,分享即可拿奖励", desc: "办卡有奖励、手续简、下卡快、额度高", icon: UIImage(named: "icon")!, url: urlStr)
- }
- override func handleBack() {
- if wkWebView.canGoBack {
- wkWebView.goBack()
- } else {
- super.handleBack()
- }
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- self.tabBarController?.title = self.title
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "ApplyCardWebViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|