diff --git a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj index 67ebe04..9901524 100644 --- a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj +++ b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj @@ -157,6 +157,7 @@ BF7B75A71E305A6D0011D5C7 /* UIScrollView+MJExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B75911E305A6D0011D5C7 /* UIScrollView+MJExtension.m */; }; BF7B75A81E305A6D0011D5C7 /* UIScrollView+MJRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B75931E305A6D0011D5C7 /* UIScrollView+MJRefresh.m */; }; BF7B75A91E305A6D0011D5C7 /* UIView+MJExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B75951E305A6D0011D5C7 /* UIView+MJExtension.m */; }; + BF8E52EE1ECFD16000E472E8 /* RankingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8E52ED1ECFD16000E472E8 /* RankingTableViewController.swift */; }; BFBB83A91ECAE35E008B404B /* LeadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBB83A81ECAE35E008B404B /* LeadViewController.swift */; }; BFBB83D11ECBEB4E008B404B /* JYScrollItem.m in Sources */ = {isa = PBXBuildFile; fileRef = BFBB83CC1ECBEB4E008B404B /* JYScrollItem.m */; }; BFBB83D21ECBEB4E008B404B /* JYScrollItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BFBB83CE1ECBEB4E008B404B /* JYScrollItemModel.m */; }; @@ -493,6 +494,7 @@ BF7B75931E305A6D0011D5C7 /* UIScrollView+MJRefresh.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+MJRefresh.m"; sourceTree = ""; }; BF7B75941E305A6D0011D5C7 /* UIView+MJExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+MJExtension.h"; sourceTree = ""; }; BF7B75951E305A6D0011D5C7 /* UIView+MJExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+MJExtension.m"; sourceTree = ""; }; + BF8E52ED1ECFD16000E472E8 /* RankingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RankingTableViewController.swift; sourceTree = ""; }; BFBB83A81ECAE35E008B404B /* LeadViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeadViewController.swift; sourceTree = ""; }; BFBB83CB1ECBEB4E008B404B /* JYScrollItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYScrollItem.h; sourceTree = ""; }; BFBB83CC1ECBEB4E008B404B /* JYScrollItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYScrollItem.m; sourceTree = ""; }; @@ -595,6 +597,7 @@ isa = PBXGroup; children = ( BF682F1D1ECE8772007632CA /* MainHomeTableViewController.swift */, + BF8E52ED1ECFD16000E472E8 /* RankingTableViewController.swift */, 5904FC541ECA8BCB00E631FF /* HomePage.storyboard */, ); path = HomePage; @@ -1545,6 +1548,7 @@ BF7B75A11E305A6D0011D5C7 /* MJRefreshGifHeader.m in Sources */, 599B2CE31DE52F7E00B4F7FD /* UMSocialUIManager.m in Sources */, BF25DFF91DDAA36A003EC0C1 /* NSImage+WebCache.m in Sources */, + BF8E52EE1ECFD16000E472E8 /* RankingTableViewController.swift in Sources */, 59F8014F1DD2C7AD000A78B0 /* AppDelegate.swift in Sources */, BF25DFED1DDAA36A003EC0C1 /* ResponseSerialization.swift in Sources */, BF25E0031DDAA36A003EC0C1 /* UIImage+GIF.m in Sources */, diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePage.storyboard b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePage.storyboard index 1dc8667..5a2f7a4 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePage.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePage.storyboard @@ -1,80 +1,131 @@ - - + + + - - + + - - - - - - + + - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift index 2149d69..0aa5043 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift @@ -111,6 +111,11 @@ class MainHomeTableViewController: UITableViewController { */ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { NSLog("点击了第\(indexPath.row)个cell") + if indexPath.row==0{ + //排行 + let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController + self.navigationController?.pushViewController(vc, animated: true) + } } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift new file mode 100644 index 0000000..dee3165 --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift @@ -0,0 +1,279 @@ +// +// RankingTableViewController.swift +// YouerLiveVideo +// +// Created by 葛建军 on 17/5/20. +// Copyright © 2017年 左丞. All rights reserved. +// + +import UIKit + +class RankingTableViewController: UITableViewController { + var openIndexAry:[Int]=[0,4] //记录那些是展开状态 + var allDic:[Int:[String]]=Dictionary() + var ary:[String]=["综合排名","资源贡献","下载排名","阅读排名","综合排名","资源贡献","下载排名","阅读排名"] + override func viewDidLoad() { + super.viewDidLoad() + getAllSubRankings() + } + func getAllSubRankings(){ + for i in 0..<8{ + allDic.updateValue([], forKey: i) + } + AppDelegate.instance().httpServer.getSchoolGeneral { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 0) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getSchoolUpload { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 1) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getSchoolDownloads { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 2) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getSchoolPv { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 3) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getTeacherGenerals { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 4) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getTeacherUpload { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 5) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getTeacherDownload { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 6) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + AppDelegate.instance().httpServer.getTeacherPvs { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineAry.append(item["f_SchoolName"].stringValue) + } + self.allDic.updateValue(lineAry, forKey: 7) + self.tableView.reloadData() + }, failHandler: { (error) in + self.view.makeToast("排名失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取排名失败:\(error!.description)") + } + } + } + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + // MARK: - Table view data source + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 8 + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + var height:CGFloat=44 + if indexPath.row==0 || indexPath.row==4{ + height=height+44 + } + if indexPath.row != 3{ + height=height+20 + } + if openIndexAry.contains(indexPath.row){ + height=height+CGFloat(30*allDic[indexPath.row]!.count) + } + return height + } + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell=tableView.dequeueReusableCell(withIdentifier: "ItemTableViewCell", for: indexPath) as! ItemTableViewCell + cell.superVC=self + cell.indexPath=indexPath + if indexPath.row==0{ + cell.sectionTitleLabel.text="学校排行" + cell.sectionTitleLabel.isHidden=false + } + if indexPath.row==4{ + cell.sectionTitleLabel.text="教师排行" + cell.sectionTitleLabel.isHidden=false + } + if indexPath.row==0 || indexPath.row==4{ + cell.titleViewTop.constant=44 + }else{ + cell.titleViewTop.constant=0 + } + if indexPath.row==3{ + cell.tableViewButtom.constant=0 + }else{ + cell.tableViewButtom.constant=20 + } + cell.titleLabel.text=ary[indexPath.row] + if openIndexAry.contains(indexPath.row){ + cell.titleImageView.image=UIImage(named: "botoom_image") + }else{ + cell.titleImageView.image=UIImage(named: "top_image") + } + cell.subTableView.reloadData() + return cell + } + +} +class ItemTableViewCell: UITableViewCell,UITableViewDelegate,UITableViewDataSource { + var superVC:RankingTableViewController? + var indexPath:IndexPath! + @IBOutlet var sectionTitleLabel: UILabel! + @IBOutlet var titleViewTop: NSLayoutConstraint! + @IBOutlet var subTableView: UITableView! + @IBOutlet var tableViewButtom: NSLayoutConstraint! + @IBOutlet var titleLabel: UILabel! + @IBOutlet var titleImageView: UIImageView! + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if superVC != nil { + if superVC!.openIndexAry.contains(indexPath.row){ + return superVC!.allDic[indexPath.row]!.count + }else{ + return 0 + } + }else{ + return 0 + } + } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 30 + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell=tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) + if superVC != nil { + cell.textLabel?.text="\(superVC!.allDic[self.indexPath.row]![indexPath.row])" + } + return cell + } + @IBAction func openOrCloseAction(_ sender: UIButton) { + if superVC!.openIndexAry.contains(indexPath.row){ + superVC!.openIndexAry.remove(at: getCurrentIndex(item: indexPath.row, arry: superVC!.openIndexAry)) + }else{ + superVC!.openIndexAry.append(indexPath.row) + } + superVC!.tableView.reloadData() + } +} diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift index c538a7e..a84126e 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift @@ -20,6 +20,7 @@ class MViewController: UITabBarController { super.viewDidLoad() self.tabBar.tintColor=Theme.topBarColor() tabBar.barTintColor=UIColor.white + tabBarController?.tabBar.isHidden=true } override func didReceiveMemoryWarning() { diff --git a/YouerLiveVideo/YouerLiveVideo/util/network.swift b/YouerLiveVideo/YouerLiveVideo/util/network.swift index c0a3520..1790745 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/network.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/network.swift @@ -308,43 +308,43 @@ final class HTTPServer{ //MARK:-DataStatistics //获取前十学校的综合排行 - func getSchoolGeneral(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLGENERAL, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getSchoolGeneral(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLGENERAL,headers:["Authorization":token!], completionHandler: completionHandler) } //获取前十学校的阅读量排行 - func getSchoolPv(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLPV, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getSchoolPv(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLPV, headers:["Authorization":token!], completionHandler: completionHandler) } //获取排行前十学校的下载量 - func getSchoolDownloads(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLDOWNLOADS, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getSchoolDownloads(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLDOWNLOADS,headers:["Authorization":token!], completionHandler: completionHandler) } //获取排行前十学校的上传数 - func getSchoolUpload(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLUPLOAD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getSchoolUpload(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETSCHOOLUPLOAD,headers:["Authorization":token!], completionHandler: completionHandler) } //获取排行前十的教师的综合数 - func getTeacherGenerals(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERGENERALS, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getTeacherGenerals(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERGENERALS,headers:["Authorization":token!], completionHandler: completionHandler) } //获取排名前十的教师发的资源的阅读量 - func getTeacherPvs(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERPVS, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getTeacherPvs(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERPVS, headers:["Authorization":token!], completionHandler: completionHandler) } //获取排名前十的资源的下载量 - func getTeacherDownload(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERDOWNLOAD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getTeacherDownload(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERDOWNLOAD, headers:["Authorization":token!], completionHandler: completionHandler) } //获取排名前十的教师的上传量 - func getTeacherUpload(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ - KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERUPLOAD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) + func getTeacherUpload(completionHandler:@escaping (String?, NSError?) -> ()){ + KHttp.GET(url: HTTPServer.URL_DATASTATISTICGETTEACHERUPLOAD,headers:["Authorization":token!], completionHandler: completionHandler) } //分页获取排行榜 diff --git a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift index a680e7c..2e49f24 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift @@ -187,7 +187,15 @@ class indexLongPressGesture: UILongPressGestureRecognizer { class indexUIMenuItem: UIMenuItem { var indexPath:IndexPath? } - +//获取元素在数组中的位置 +func getCurrentIndex(item:Int,arry:[Int])->Int{ + for i in 0..UIImage{ -- libgit2 0.21.0