Commit fa0078e1fd833bf3cfd11d7863c344fa6f02ed53

Authored by 葛建军
1 parent 349ae761
Exists in newLive

资源排序筛选界面教材,目录搭建及数据处理,资源搜索方法实现。

YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj
... ... @@ -150,6 +150,9 @@
150 150 BF7722F91ED3C3E900226D44 /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF7722F81ED3C3E900226D44 /* FilterView.swift */; };
151 151 BF7722FC1ED3C54B00226D44 /* FilterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF7722FA1ED3C54B00226D44 /* FilterCollectionViewCell.swift */; };
152 152 BF7722FD1ED3C54B00226D44 /* FilterCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF7722FB1ED3C54B00226D44 /* FilterCollectionViewCell.xib */; };
  153 + BF7723011ED5660000226D44 /* FilterFootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF7723001ED5660000226D44 /* FilterFootView.swift */; };
  154 + BF7723031ED5661F00226D44 /* FilterFootView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF7723021ED5661F00226D44 /* FilterFootView.xib */; };
  155 + BF7723051ED5667500226D44 /* FilterListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF7723041ED5667500226D44 /* FilterListViewController.swift */; };
153 156 BF7B75961E305A6D0011D5C7 /* MJRefreshAutoFooter.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B756A1E305A6D0011D5C7 /* MJRefreshAutoFooter.m */; };
154 157 BF7B75971E305A6D0011D5C7 /* MJRefreshBackFooter.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B756C1E305A6D0011D5C7 /* MJRefreshBackFooter.m */; };
155 158 BF7B75981E305A6D0011D5C7 /* MJRefreshComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7B756E1E305A6D0011D5C7 /* MJRefreshComponent.m */; };
... ... @@ -480,6 +483,9 @@
480 483 BF7722F81ED3C3E900226D44 /* FilterView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterView.swift; sourceTree = "<group>"; };
481 484 BF7722FA1ED3C54B00226D44 /* FilterCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterCollectionViewCell.swift; sourceTree = "<group>"; };
482 485 BF7722FB1ED3C54B00226D44 /* FilterCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FilterCollectionViewCell.xib; sourceTree = "<group>"; };
  486 + BF7723001ED5660000226D44 /* FilterFootView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterFootView.swift; sourceTree = "<group>"; };
  487 + BF7723021ED5661F00226D44 /* FilterFootView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FilterFootView.xib; sourceTree = "<group>"; };
  488 + BF7723041ED5667500226D44 /* FilterListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterListViewController.swift; sourceTree = "<group>"; };
483 489 BF7B75691E305A6D0011D5C7 /* MJRefreshAutoFooter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshAutoFooter.h; sourceTree = "<group>"; };
484 490 BF7B756A1E305A6D0011D5C7 /* MJRefreshAutoFooter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJRefreshAutoFooter.m; sourceTree = "<group>"; };
485 491 BF7B756B1E305A6D0011D5C7 /* MJRefreshBackFooter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJRefreshBackFooter.h; sourceTree = "<group>"; };
... ... @@ -643,6 +649,7 @@
643 649 children = (
644 650 5904FC471ECA8B8C00E631FF /* ResourceViewController.swift */,
645 651 BF7722F21ED283D400226D44 /* FilterViewController.swift */,
  652 + BF7723041ED5667500226D44 /* FilterListViewController.swift */,
646 653 59AE3DFA1ECECD7D003E2C62 /* LiveInforViewController.swift */,
647 654 59AE3DFC1ECED5B1003E2C62 /* MoivePlayerViewController.swift */,
648 655 597185B41ECA990C00D7F478 /* Resource.storyboard */,
... ... @@ -1086,6 +1093,8 @@
1086 1093 BF7722F61ED3C3CD00226D44 /* FilterView.xib */,
1087 1094 BF7722FA1ED3C54B00226D44 /* FilterCollectionViewCell.swift */,
1088 1095 BF7722FB1ED3C54B00226D44 /* FilterCollectionViewCell.xib */,
  1096 + BF7723001ED5660000226D44 /* FilterFootView.swift */,
  1097 + BF7723021ED5661F00226D44 /* FilterFootView.xib */,
1089 1098 );
1090 1099 path = View;
1091 1100 sourceTree = "<group>";
... ... @@ -1462,6 +1471,7 @@
1462 1471 599B2CD51DE52F7E00B4F7FD /* TencentOpenApi_IOS_Bundle.bundle in Resources */,
1463 1472 BFBB83EA1ECC445D008B404B /* User.storyboard in Resources */,
1464 1473 597185B51ECA990C00D7F478 /* Resource.storyboard in Resources */,
  1474 + BF7723031ED5661F00226D44 /* FilterFootView.xib in Resources */,
1465 1475 BF25DFE61DDAA36A003EC0C1 /* Info.plist in Resources */,
1466 1476 BFF5F4771DD5AA5C00D33B89 /* 上传头像.png in Resources */,
1467 1477 5904FC501ECA8B8C00E631FF /* TVStation.storyboard in Resources */,
... ... @@ -1566,6 +1576,7 @@
1566 1576 59AE3DFB1ECECD7D003E2C62 /* LiveInforViewController.swift in Sources */,
1567 1577 BF7B759B1E305A6D0011D5C7 /* MJRefreshAutoGifFooter.m in Sources */,
1568 1578 BF7B75A81E305A6D0011D5C7 /* UIScrollView+MJRefresh.m in Sources */,
  1579 + BF7723011ED5660000226D44 /* FilterFootView.swift in Sources */,
1569 1580 BF25E0021DDAA36A003EC0C1 /* UIButton+WebCache.m in Sources */,
1570 1581 BF7B759E1E305A6D0011D5C7 /* MJRefreshBackGifFooter.m in Sources */,
1571 1582 59AE3DF91ECE8A90003E2C62 /* pinyin.c in Sources */,
... ... @@ -1582,6 +1593,7 @@
1582 1593 BF25DFFF1DDAA36A003EC0C1 /* SDWebImageDownloaderOperation.m in Sources */,
1583 1594 59AE3DFD1ECED5B1003E2C62 /* MoivePlayerViewController.swift in Sources */,
1584 1595 BF25DFF01DDAA36A003EC0C1 /* SessionDelegate.swift in Sources */,
  1596 + BF7723051ED5667500226D44 /* FilterListViewController.swift in Sources */,
1585 1597 BF25DFE31DDAA36A003EC0C1 /* Alamofire.swift in Sources */,
1586 1598 BF25DFEC1DDAA36A003EC0C1 /* Response.swift in Sources */,
1587 1599 BF7B75961E305A6D0011D5C7 /* MJRefreshAutoFooter.m in Sources */,
... ...
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/Resource/Contents.json 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +{
  2 + "info" : {
  3 + "version" : 1,
  4 + "author" : "xcode"
  5 + }
  6 +}
0 7 \ No newline at end of file
... ...
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/Resource/resource_diselect.imageset/Contents.json 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "cb48.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/Resource/resource_diselect.imageset/cb48.png 0 → 100644

1.94 KB

YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/Resource/resource_select.imageset/Contents.json 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "gou.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/Resource/resource_select.imageset/gou.png 0 → 100644

2.73 KB

YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq">
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq">
3 3 <device id="retina4_7" orientation="portrait">
4 4 <adaptation id="fullscreen"/>
5 5 </device>
... ... @@ -179,7 +179,7 @@
179 179 <constraint firstAttribute="height" constant="44" id="PWr-Wf-TcS"/>
180 180 </constraints>
181 181 <prototypes>
182   - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="vmV-r2-2pv">
  182 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="cell" id="vmV-r2-2pv">
183 183 <rect key="frame" x="0.0" y="28" width="375" height="44"/>
184 184 <autoresizingMask key="autoresizingMask"/>
185 185 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vmV-r2-2pv" id="tft-RM-f2B">
... ... @@ -1430,6 +1430,9 @@
1430 1430 <state key="normal" title="筛选" image="starLive">
1431 1431 <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
1432 1432 </state>
  1433 + <connections>
  1434 + <action selector="jumpFilterVCAction:" destination="VUr-8w-9Ht" eventType="touchUpInside" id="Po2-Wd-wOq"/>
  1435 + </connections>
1433 1436 </button>
1434 1437 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="T2j-JJ-ft5">
1435 1438 <rect key="frame" x="245" y="14" width="57" height="22"/>
... ... @@ -1568,7 +1571,7 @@
1568 1571 <constraint firstAttribute="height" constant="44" id="s3i-TZ-HsX"/>
1569 1572 </constraints>
1570 1573 <prototypes>
1571   - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="OoX-sY-EJ0">
  1574 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="cell" id="OoX-sY-EJ0">
1572 1575 <rect key="frame" x="0.0" y="28" width="375" height="44"/>
1573 1576 <autoresizingMask key="autoresizingMask"/>
1574 1577 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OoX-sY-EJ0" id="cE2-H1-hR9">
... ...
YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift
... ... @@ -7,7 +7,7 @@
7 7 //
8 8  
9 9 import UIKit
10   -
  10 +import AVKit
11 11 class MainHomeTableViewController: UITableViewController {
12 12 @IBOutlet var tableHeaderView: UIView!
13 13 let current=AppDelegate.instance().accountManager
... ... @@ -113,6 +113,15 @@ class MainHomeTableViewController: UITableViewController {
113 113 let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController
114 114 vc.openIndexAry=[0,4]
115 115 self.navigationController?.pushViewController(vc, animated: true)
  116 + }else if indexPath.row==1{
  117 + //热门微课
  118 + self.tabBarController?.selectedIndex=2
  119 + }else if indexPath.row==2{
  120 + //资源
  121 + self.tabBarController?.selectedIndex=1
  122 + }else{
  123 + //校园电视台
  124 + self.tabBarController?.selectedIndex=3
116 125 }
117 126 }
118 127  
... ... @@ -209,8 +218,11 @@ class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollec
209 218 }
210 219 }
211 220 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
212   - //点击进入学校 appRootViewController()
213   - NSLog("点击了****\(dataSet[indexPath.row])")
  221 + let url = URL(string:dataSet[indexPath.row].f_ResourceUrl)
  222 + let player = AVPlayerViewController()
  223 + player.player = AVPlayer(url: url!)
  224 + player.videoGravity = AVLayerVideoGravityResizeAspect
  225 + appRootViewController().present(player, animated: true, completion: nil)
214 226 }
215 227 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
216 228 return CGSize(width: (getScreenWidth()-45)/2, height: ((getScreenWidth()-45)/2/33*16+67))
... ...
YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift
... ... @@ -9,7 +9,7 @@
9 9 import UIKit
10 10 import AVKit
11 11  
12   -class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating {
  12 +class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating,UISearchBarDelegate{
13 13 @IBOutlet var tableView: UITableView!
14 14  
15 15 @IBOutlet var grayView: UIView!
... ... @@ -18,9 +18,10 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
18 18  
19 19 var searchController:UISearchController!
20 20 var dataSetAry:[String]=["葛建军","张道峰","徐晓杰","左承","段合江"]
21   - var searchAry:[String]=[]
  21 + var searchAry:[MicroCourseModel]=[]
22 22 var currentPage:Int=1 //当前页数,每次取十个数据
23 23 var resourceData:[MicroCourseModel]=[]
  24 + var parameter:Dictionary<String,AnyObject>?
24 25 override func viewDidLoad() {
25 26 super.viewDidLoad()
26 27 self.configTheme()
... ... @@ -31,11 +32,27 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
31 32 self.tableView.reloadData()
32 33 }
33 34 })
  35 + NotificationCenter.default.addObserver(self, selector: #selector(ResourceViewController.reloadTableView), name: NSNotification.Name(rawValue: "FilterReloadTableView"), object: nil)
  36 + }
  37 + //筛选结束后刷新界面
  38 + func reloadTableView(noti:Notification){
  39 + let parameters=(noti.object as! Dictionary<String,AnyObject>)
  40 + if parameters["type"]?.int8Value==0{
  41 + parameter=parameters
  42 + currentPage=1
  43 + resourceData.removeAll()
  44 + refreshLivesAction(parameters: parameters, completionHandler: { (success) in
  45 + if success{
  46 + self.tableView.reloadData()
  47 + }
  48 + })
  49 + }
34 50 }
35 51 func addSearchController(){
36 52 self.definesPresentationContext=true
37 53 searchController=UISearchController(searchResultsController: nil)
38 54 searchController.delegate=self
  55 + searchController.searchBar.delegate=self
39 56 searchController.searchResultsUpdater=self
40 57 searchController.searchBar.barTintColor=UIColor.groupTableViewBackground
41 58 searchController.searchBar.placeholder="搜索"
... ... @@ -56,7 +73,11 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
56 73 //下拉刷新
57 74 self.currentPage=1
58 75 self.resourceData.removeAll()
59   - self.refreshLivesAction(parameters: ["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  76 + var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  77 + if self.parameter != nil {
  78 + p=self.parameter!
  79 + }
  80 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
60 81 if success{
61 82 self.tableView.reloadData()
62 83 }
... ... @@ -67,7 +88,11 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
67 88 tableView.mj_header=header
68 89 tableView.mj_footer=MJRefreshBackNormalFooter(refreshingBlock: {
69 90 //上拉加载更多
70   - self.refreshLivesAction(parameters: ["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  91 + var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  92 + if self.parameter != nil {
  93 + p=self.parameter!
  94 + }
  95 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
71 96 if success{
72 97 self.tableView.reloadData()
73 98 }
... ... @@ -76,17 +101,23 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
76 101 })
77 102 }
78 103 // MARK: - 刷新数据接口
79   - func refreshLivesAction(parameters:Dictionary<String,AnyObject>,completionHandler:@escaping (Bool) -> ()){
  104 + func refreshLivesAction(isSearch:Bool=false,parameters:Dictionary<String,AnyObject>,completionHandler:@escaping (Bool) -> ()){
80 105 AppDelegate.instance().httpServer.postResourceList(parameters: parameters) { (str, error) in
81 106 var success:Bool=true
82 107 if error==nil {
83 108 if JSON.fromString(jsonString: str)!["status"].intValue == 1{
84 109 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
85   - if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{
86   - self.currentPage+=1
87   - }
88   - for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
89   - self.resourceData.append(MicroCourseModel(j: item))
  110 + if isSearch {
  111 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  112 + self.searchAry.append(MicroCourseModel(j: item))
  113 + }
  114 + }else{
  115 + if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{
  116 + self.currentPage+=1
  117 + }
  118 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  119 + self.resourceData.append(MicroCourseModel(j: item))
  120 + }
90 121 }
91 122 success=true
92 123 }, failHandler: { (error) in
... ... @@ -104,6 +135,12 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
104 135 completionHandler(success)
105 136 }
106 137 }
  138 + // MARK: - 跳转到筛选
  139 + @IBAction func jumpFilterVCAction(_ sender: UIButton) {
  140 + let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "FilterViewController") as! FilterViewController
  141 + vc.type=FilterParameter(type: 0)
  142 + self.present(vc.wrapWithNavigationController(), animated: true, completion: nil)
  143 + }
107 144 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
108 145 if tableView==searchTableView{
109 146 return searchAry.count
... ... @@ -114,7 +151,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
114 151 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
115 152 if tableView==searchTableView {
116 153 let cell=tableView.dequeueReusableCell(withIdentifier: "cell")
117   - cell?.textLabel?.text=searchAry[indexPath.row]
  154 + cell?.textLabel?.text=searchAry[indexPath.row].f_Title
118 155 return cell!
119 156 }else{
120 157 let cell=tableView.dequeueReusableCell(withIdentifier: "identifier") as! MicroCourseViewControllerTableViewCell
... ... @@ -125,12 +162,12 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
125 162 }
126 163 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
127 164 if tableView==searchTableView {
128   - let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController
129   - self.navigationController?.pushViewController(vc, animated: true)
  165 + let url = URL(string:searchAry[indexPath.row].f_ResourceUrl)
  166 + let player = AVPlayerViewController()
  167 + player.player = AVPlayer(url: url!)
  168 + player.videoGravity = AVLayerVideoGravityResizeAspect
  169 + self.present(player, animated: true, completion: nil)
130 170 }else{
131   -// let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController
132   -
133   -// self.navigationController?.pushViewController(vc, animated: true)
134 171 let url = URL(string:resourceData[indexPath.row].f_ResourceUrl)
135 172 let player = AVPlayerViewController()
136 173 player.player = AVPlayer(url: url!)
... ... @@ -140,6 +177,9 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
140 177 }
141 178 //取消键盘输入状态
142 179 @IBAction func cancleSearchActivit(_ sender: UITapGestureRecognizer) {
  180 + self.searchAry.removeAll()
  181 + searchTableHeight.constant=44
  182 + self.searchTableView.reloadData()
143 183 searchController.isActive=false
144 184 }
145 185 func willPresentSearchController(_ searchController: UISearchController) {
... ... @@ -149,17 +189,37 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
149 189 searchTableHeight.constant=44
150 190 grayView.isHidden=true
151 191 }
  192 + //searchaBarDelegate
  193 + func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
  194 + refreshLivesAction(isSearch: true,parameters: ["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":1 as AnyObject,"keyword":searchBar.text as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  195 + if success{
  196 + if CGFloat((self.searchAry.count+1)*44)>(getScreenHeight()-64){
  197 + self.searchTableHeight.constant=getScreenHeight()-64
  198 + }else{
  199 + self.searchTableHeight.constant=CGFloat((self.searchAry.count+1)*44)
  200 + }
  201 + self.searchTableView.reloadData()
  202 + }
  203 + })
  204 + }
  205 + func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
  206 + self.searchAry.removeAll()
  207 + searchTableHeight.constant=44
  208 + self.searchTableView.reloadData()
  209 + searchController.isActive=false
  210 + }
  211 +
152 212 //谓词搜索过滤
153 213 func updateSearchResults(for searchController: UISearchController) {
154   - let searchString=searchController.searchBar.text
155   - let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!)
156   - searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String]
157   - if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){
158   - searchTableHeight.constant=getScreenHeight()-64
159   - }else{
160   - searchTableHeight.constant=CGFloat((searchAry.count+1)*44)
161   - }
162   - searchTableView.reloadData()
  214 +// let searchString=searchController.searchBar.text
  215 +// let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!)
  216 +// searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String]
  217 +// if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){
  218 +// searchTableHeight.constant=getScreenHeight()-64
  219 +// }else{
  220 +// searchTableHeight.constant=CGFloat((searchAry.count+1)*44)
  221 +// }
  222 +// searchTableView.reloadData()
163 223 }
164 224  
165 225 }
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterListViewController.swift 0 → 100644
... ... @@ -0,0 +1,205 @@
  1 +//
  2 +// FilterListViewController.swift
  3 +// YouerLiveVideo
  4 +//
  5 +// Created by 葛建军 on 17/5/24.
  6 +// Copyright © 2017年 左丞. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class FilterListViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
  12 + var index:Int=0
  13 + var superVC:FilterViewController!
  14 + var dataSet:[filterListModel]=[]
  15 + var currentItem:filterListModel? //记录当前页面是否可以返回
  16 + var selectItem:filterListModel? //记录选中的目录
  17 + @IBOutlet var tableView: UITableView!
  18 + override func viewDidLoad() {
  19 + super.viewDidLoad()
  20 + getContentWithIndex()
  21 + }
  22 + func getContentWithIndex(){
  23 + switch index {
  24 + case 0:
  25 + AppDelegate.instance().httpServer.getWaveCatagory(parameters: ["waveId":superVC.type.materials as AnyObject]) { (str, error) in
  26 + if error==nil {
  27 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  28 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  29 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  30 + self.dataSet.append(filterListModel(j: item))
  31 + }
  32 + self.currentItem=filterListModel(array: self.dataSet)
  33 + self.tableView.reloadData()
  34 + }, failHandler: { (error) in
  35 + self.view.makeToast("获取教材目录失败:\(error.localizedDescription)")
  36 + })
  37 + }else{
  38 + self.view.makeToast("获取教材目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)")
  39 + }
  40 + }else{
  41 + self.view.makeToast("获取教材目录失败:\(error!.description)")
  42 + }
  43 + }
  44 + case 1:
  45 + AppDelegate.instance().httpServer.getTopicCatagory(parameters: ["waveId":superVC.type.materials as AnyObject]) { (str, error) in
  46 + if error==nil {
  47 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  48 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  49 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  50 + self.dataSet.append(filterListModel(j: item))
  51 + }
  52 + }, failHandler: { (error) in
  53 + self.view.makeToast("获取知识点目录失败:\(error.localizedDescription)")
  54 + })
  55 + }else{
  56 + self.view.makeToast("获取知识点目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)")
  57 + }
  58 + }else{
  59 + self.view.makeToast("获取知识点目录失败:\(error!.description)")
  60 + }
  61 + }
  62 + case 2:
  63 + AppDelegate.instance().httpServer.getTestCatagory(parameters: ["waveId":superVC.type.materials as AnyObject]) { (str, error) in
  64 + if error==nil {
  65 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  66 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  67 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  68 + self.dataSet.append(filterListModel(j: item))
  69 + }
  70 + }, failHandler: { (error) in
  71 + self.view.makeToast("获取考点目录失败:\(error.localizedDescription)")
  72 + })
  73 + }else{
  74 + self.view.makeToast("获取考点目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)")
  75 + }
  76 + }else{
  77 + self.view.makeToast("获取考点目录失败:\(error!.description)")
  78 + }
  79 + }
  80 + default:
  81 + break
  82 + }
  83 +
  84 + }
  85 + //MARK: - 返回和确定按钮
  86 + @IBAction func backAction(_ sender: UIBarButtonItem) {
  87 + if currentItem != nil {
  88 + if currentItem?.parentModel != nil {
  89 + //返回到上级界面
  90 + self.dataSet=currentItem!.parentModel!.children
  91 + self.tableView.reloadData()
  92 + currentItem=currentItem!.parentModel
  93 + if selectItem != nil {
  94 + selectItem=nil
  95 + }
  96 + }else{
  97 + self.navigationController!.popViewController(animated: true)
  98 + }
  99 + }
  100 + }
  101 + @IBAction func onDoneAction(_ sender: UIBarButtonItem) {
  102 + if selectItem==nil {
  103 + self.view.makeToast("请选择目录")
  104 + }else{
  105 + //发送通知
  106 + var nameID:String=""
  107 + switch index {
  108 + case 0:
  109 + nameID="chapterId"
  110 + case 1:
  111 + nameID="topicId"
  112 + case 2:
  113 + nameID="testId"
  114 + default:
  115 + nameID="chapterId"
  116 + }
  117 + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "FilterReloadTableView"), object: ["type":superVC.type.type as AnyObject,
  118 + "subjectId":superVC.type.subject as AnyObject,
  119 + "schooltypeId":superVC.type.schoolSection as AnyObject,
  120 + "gradeId":superVC.type.grade as AnyObject,
  121 + "courseWaveId":superVC.type.materials as AnyObject,
  122 + nameID:selectItem!.id as AnyObject,
  123 + "orderby":1 as AnyObject,
  124 + "pageIndex":1 as AnyObject,
  125 + "pageSize":10 as AnyObject])
  126 + self.navigationController?.dismiss(animated: true, completion: nil)
  127 + }
  128 + }
  129 +
  130 + //MARK: - UITableViewDelegate,UITableViewDataSource
  131 + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  132 + return dataSet.count
  133 + }
  134 + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  135 + let cell=tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FilterListViewCell
  136 + let item=dataSet[indexPath.row]
  137 + cell.item=item
  138 + cell.superVC=self
  139 + cell.nameLabel.text=item.name
  140 + if selectItem != nil {
  141 + if item==selectItem {
  142 + cell.selectBtn.setImage(UIImage(named: "resource_select"), for: UIControlState.normal)
  143 + }else{
  144 + cell.selectBtn.setImage(UIImage(named: "resource_diselect"), for: UIControlState.normal)
  145 + }
  146 + }else{
  147 + cell.selectBtn.setImage(UIImage(named: "resource_diselect"), for: UIControlState.normal)
  148 + }
  149 + return cell
  150 + }
  151 + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  152 + let item=dataSet[indexPath.row]
  153 + if item.children.count>0{
  154 + self.currentItem=item
  155 + self.dataSet=item.children
  156 + self.tableView.reloadData()
  157 + }
  158 + }
  159 + override func didReceiveMemoryWarning() {
  160 + super.didReceiveMemoryWarning()
  161 + }
  162 +}
  163 +class filterListModel:NSObject{
  164 + var parentModel:filterListModel?
  165 + var id:String=""
  166 + var name:String=""
  167 + var text:String=""
  168 + var open:Bool=true
  169 + var children:[filterListModel]=[]
  170 + init(j:JSON) {
  171 + super.init()
  172 + id=j["id"].stringValue
  173 + name=j["name"].stringValue
  174 + text=j["text"].stringValue
  175 + open=j["open"].boolValue
  176 + for item in j["children"].arrayValue {
  177 + let model=filterListModel(j: item)
  178 + model.parentModel=self
  179 + children.append(model)
  180 + }
  181 + }
  182 + init(array:[filterListModel]) {
  183 + super.init()
  184 + for item in array {
  185 + item.parentModel=self
  186 + children.append(item)
  187 + }
  188 + }
  189 +}
  190 +class FilterListViewCell: UITableViewCell {
  191 + @IBOutlet var nameLabel: UILabel!
  192 + @IBOutlet var selectBtn: UIButton!
  193 + var superVC:FilterListViewController!
  194 + var item:filterListModel!
  195 + @IBAction func changeSelectAction(_ sender: UIButton) {
  196 + if superVC.selectItem==item {
  197 + superVC.selectItem=nil
  198 + }else{
  199 + superVC.selectItem=item
  200 + }
  201 + superVC.tableView.reloadData()
  202 + }
  203 +
  204 +
  205 +}
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterViewController.swift
... ... @@ -14,14 +14,12 @@ class FilterViewController: UIViewController,FilterViewDelegate {
14 14 var dataGrade:[Grade]=[]
15 15 var dataSubject:[Subject]=[]
16 16 var dataMaterials:[Material]=[]
17   - var type=FilterParameter()
  17 + var type:FilterParameter!
18 18 override func viewDidLoad() {
19 19 super.viewDidLoad()
20 20 self.configTheme()
21 21 self.navigationItem.title="筛选"
22 22 getSchoolSection()
23   -// NotificationCenter.default.addObserver(self, selector: #selector(RegisterVC.keyboardWIllChange), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
24   -// NotificationCenter.default.post(name: NSNotification.Name(rawValue: "loginOutSuccess"), object: nil)
25 23 }
26 24  
27 25 @IBAction func dismissAction(_ sender: UIBarButtonItem) {
... ... @@ -117,6 +115,11 @@ class FilterViewController: UIViewController,FilterViewDelegate {
117 115 self.getGradeWithSchoolSectionID(id: self.dataSchoolSection[0].f_Id, index: 2)
118 116 }
119 117 self.getSubjects(index: 3)
  118 + let filterFootView=Bundle.main.loadNibNamed("FilterFootView", owner: nil, options: nil)![0] as! FilterFootView
  119 + self.scrollContentView.addArrangedSubview(filterFootView)
  120 + filterFootView.superVC=self
  121 + filterFootView.translatesAutoresizingMaskIntoConstraints=false
  122 + filterFootView.addConstraint(NSLayoutConstraint(item: filterFootView, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1.0, constant: 50))
120 123 }
121 124 }
122 125 func selectCurrentCount(index: Int,tag:Int) {
... ... @@ -234,18 +237,15 @@ class FilterViewController: UIViewController,FilterViewDelegate {
234 237 override func didReceiveMemoryWarning() {
235 238 super.didReceiveMemoryWarning()
236 239 }
237   - // MARK: - 销毁通知
238   - deinit {
239   - NotificationCenter.default.removeObserver(self)
240   - }
241 240 }
242 241 class FilterParameter:NSObject {
243 242 var schoolSection:String? //学段
244 243 var grade:String? //年级
245 244 var subject:String? //学科
246 245 var materials:String? //教材
247   - override init() {
248   -
  246 + var type:Int=0 //0-微课,1-课件(资源),2-电视台 ,
  247 + init(type:Int) {
  248 + self.type=type
249 249 }
250 250 }
251 251 class filterModel:NSObject{
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/Resource.storyboard
... ... @@ -6,6 +6,7 @@
6 6 <dependencies>
7 7 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
8 8 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
  9 + <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
9 10 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10 11 </dependencies>
11 12 <scenes>
... ... @@ -77,7 +78,105 @@
77 78 </viewController>
78 79 <placeholder placeholderIdentifier="IBFirstResponder" id="ocM-s7-Wga" userLabel="First Responder" sceneMemberID="firstResponder"/>
79 80 </objects>
80   - <point key="canvasLocation" x="-738.39999999999998" y="265.81709145427288"/>
  81 + <point key="canvasLocation" x="-1231" y="266"/>
  82 + </scene>
  83 + <!--Title-->
  84 + <scene sceneID="KE0-Ec-6BR">
  85 + <objects>
  86 + <viewController storyboardIdentifier="FilterListViewController" automaticallyAdjustsScrollViewInsets="NO" id="zHt-CL-DCL" customClass="FilterListViewController" customModule="YouerLiveVideo" customModuleProvider="target" sceneMemberID="viewController">
  87 + <layoutGuides>
  88 + <viewControllerLayoutGuide type="top" id="LdG-FX-62I"/>
  89 + <viewControllerLayoutGuide type="bottom" id="VWt-bS-YTo"/>
  90 + </layoutGuides>
  91 + <view key="view" contentMode="scaleToFill" id="zL1-KT-WjN">
  92 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  93 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  94 + <subviews>
  95 + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="0mu-k5-awJ">
  96 + <rect key="frame" x="0.0" y="64" width="375" height="603"/>
  97 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  98 + <view key="tableFooterView" contentMode="scaleToFill" id="Abq-Z2-9eV">
  99 + <rect key="frame" x="0.0" y="72" width="375" height="1"/>
  100 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  101 + <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
  102 + </view>
  103 + <prototypes>
  104 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="UVN-8r-w7w" customClass="FilterListViewCell" customModule="YouerLiveVideo" customModuleProvider="target">
  105 + <rect key="frame" x="0.0" y="28" width="375" height="44"/>
  106 + <autoresizingMask key="autoresizingMask"/>
  107 + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="UVN-8r-w7w" id="9FT-AK-CvV">
  108 + <rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
  109 + <autoresizingMask key="autoresizingMask"/>
  110 + <subviews>
  111 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="liq-eO-Kb6">
  112 + <rect key="frame" x="8" y="12.5" width="331" height="18"/>
  113 + <constraints>
  114 + <constraint firstAttribute="width" constant="331" id="pSj-w8-k8O"/>
  115 + </constraints>
  116 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
  117 + <nil key="textColor"/>
  118 + <nil key="highlightedColor"/>
  119 + </label>
  120 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Dl9-Wp-RkY">
  121 + <rect key="frame" x="347" y="12" width="20" height="20"/>
  122 + <constraints>
  123 + <constraint firstAttribute="width" constant="20" id="o5u-gy-UtC"/>
  124 + <constraint firstAttribute="height" constant="20" id="wd6-fW-NOJ"/>
  125 + </constraints>
  126 + <state key="normal" image="resource_diselect"/>
  127 + <connections>
  128 + <action selector="changeSelectAction:" destination="UVN-8r-w7w" eventType="touchUpInside" id="A7s-9g-mY3"/>
  129 + </connections>
  130 + </button>
  131 + </subviews>
  132 + <constraints>
  133 + <constraint firstAttribute="leadingMargin" secondItem="liq-eO-Kb6" secondAttribute="leading" id="L2j-lu-pe4"/>
  134 + <constraint firstItem="liq-eO-Kb6" firstAttribute="centerY" secondItem="9FT-AK-CvV" secondAttribute="centerY" id="Uo5-5W-S6e"/>
  135 + <constraint firstItem="Dl9-Wp-RkY" firstAttribute="centerY" secondItem="9FT-AK-CvV" secondAttribute="centerY" id="lwC-V7-fgU"/>
  136 + <constraint firstItem="Dl9-Wp-RkY" firstAttribute="leading" secondItem="liq-eO-Kb6" secondAttribute="trailing" constant="8" id="pMu-Vd-32m"/>
  137 + <constraint firstAttribute="trailingMargin" secondItem="Dl9-Wp-RkY" secondAttribute="trailing" id="vaR-5v-dX9"/>
  138 + </constraints>
  139 + </tableViewCellContentView>
  140 + <connections>
  141 + <outlet property="nameLabel" destination="liq-eO-Kb6" id="tdf-ix-PPl"/>
  142 + <outlet property="selectBtn" destination="Dl9-Wp-RkY" id="nmx-nz-3yj"/>
  143 + </connections>
  144 + </tableViewCell>
  145 + </prototypes>
  146 + <connections>
  147 + <outlet property="dataSource" destination="zHt-CL-DCL" id="kiJ-ze-WHW"/>
  148 + <outlet property="delegate" destination="zHt-CL-DCL" id="QJr-Fr-9WG"/>
  149 + </connections>
  150 + </tableView>
  151 + </subviews>
  152 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  153 + <constraints>
  154 + <constraint firstAttribute="trailing" secondItem="0mu-k5-awJ" secondAttribute="trailing" id="3Sp-No-f5O"/>
  155 + <constraint firstItem="0mu-k5-awJ" firstAttribute="top" secondItem="LdG-FX-62I" secondAttribute="bottom" id="CY4-QV-B2L"/>
  156 + <constraint firstItem="VWt-bS-YTo" firstAttribute="top" secondItem="0mu-k5-awJ" secondAttribute="bottom" id="GUd-E0-zu2"/>
  157 + <constraint firstItem="0mu-k5-awJ" firstAttribute="leading" secondItem="zL1-KT-WjN" secondAttribute="leading" id="P69-w1-xvo"/>
  158 + </constraints>
  159 + </view>
  160 + <navigationItem key="navigationItem" title="Title" id="Xi4-Cc-4Ao">
  161 + <barButtonItem key="leftBarButtonItem" image="icon_back" id="TNR-MX-Haz">
  162 + <connections>
  163 + <action selector="backAction:" destination="zHt-CL-DCL" id="CeC-PY-JdX"/>
  164 + </connections>
  165 + </barButtonItem>
  166 + <barButtonItem key="rightBarButtonItem" title="确定" id="H1P-q9-ZPp">
  167 + <connections>
  168 + <action selector="onDoneAction:" destination="zHt-CL-DCL" id="NnE-RV-tBW"/>
  169 + </connections>
  170 + </barButtonItem>
  171 + </navigationItem>
  172 + <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
  173 + <connections>
  174 + <outlet property="tableView" destination="0mu-k5-awJ" id="nrq-Fk-c3q"/>
  175 + </connections>
  176 + </viewController>
  177 + <placeholder placeholderIdentifier="IBFirstResponder" id="jgm-JW-7AL" userLabel="First Responder" sceneMemberID="firstResponder"/>
  178 + </objects>
  179 + <point key="canvasLocation" x="-600.79999999999995" y="265.81709145427288"/>
81 180 </scene>
82 181 <!--Live Infor View Controller-->
83 182 <scene sceneID="QrF-a4-VNS">
... ... @@ -372,6 +471,8 @@
372 471 <resources>
373 472 <image name="closeAlive" width="33" height="33"/>
374 473 <image name="defphoto.png" width="256" height="256"/>
  474 + <image name="icon_back" width="12" height="21"/>
  475 + <image name="resource_diselect" width="24" height="24"/>
375 476 <image name="screen_full" width="33" height="33"/>
376 477 <image name="starLive" width="22" height="22"/>
377 478 </resources>
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift
... ... @@ -8,7 +8,7 @@
8 8  
9 9 import UIKit
10 10  
11   -class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating {
  11 +class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating,UISearchBarDelegate {
12 12 @IBOutlet var tableView: UITableView!
13 13  
14 14 @IBOutlet var grayView: UIView!
... ... @@ -17,9 +17,10 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
17 17  
18 18 var searchController:UISearchController!
19 19 var dataSetAry:[String]=["葛建军","张道峰","徐晓杰","左承","段合江"]
20   - var searchAry:[String]=[]
  20 + var searchAry:[MicroCourseModel]=[]
21 21 var currentPage:Int=1 //当前页数,每次取十个数据
22 22 var resourceData:[MicroCourseModel]=[]
  23 + var parameter:Dictionary<String,AnyObject>?
23 24 override func viewDidLoad() {
24 25 super.viewDidLoad()
25 26 self.configTheme()
... ... @@ -30,11 +31,28 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
30 31 self.tableView.reloadData()
31 32 }
32 33 })
  34 + NotificationCenter.default.addObserver(self, selector: #selector(ResourceViewController.reloadTableView), name: NSNotification.Name(rawValue: "FilterReloadTableView"), object: nil)
  35 +
  36 + }
  37 + //筛选结束后刷新界面
  38 + func reloadTableView(noti:Notification){
  39 + let parameters=(noti.object as! Dictionary<String,AnyObject>)
  40 + if parameters["type"]?.int8Value==1{
  41 + parameter=parameters
  42 + currentPage=1
  43 + resourceData.removeAll()
  44 + refreshLivesAction(parameters: parameters, completionHandler: { (success) in
  45 + if success{
  46 + self.tableView.reloadData()
  47 + }
  48 + })
  49 + }
33 50 }
34 51 func addSearchController(){
35 52 self.definesPresentationContext=true
36 53 searchController=UISearchController(searchResultsController: nil)
37 54 searchController.delegate=self
  55 + searchController.searchBar.delegate=self
38 56 searchController.searchResultsUpdater=self
39 57 searchController.searchBar.barTintColor=UIColor.groupTableViewBackground
40 58 searchController.searchBar.placeholder="搜索"
... ... @@ -55,7 +73,11 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
55 73 //下拉刷新
56 74 self.currentPage=1
57 75 self.resourceData.removeAll()
58   - self.refreshLivesAction(parameters: ["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  76 + var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  77 + if self.parameter != nil {
  78 + p=self.parameter!
  79 + }
  80 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
59 81 if success{
60 82 self.tableView.reloadData()
61 83 }
... ... @@ -66,7 +88,11 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
66 88 tableView.mj_header=header
67 89 tableView.mj_footer=MJRefreshBackNormalFooter(refreshingBlock: {
68 90 //上拉加载更多
69   - self.refreshLivesAction(parameters: ["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  91 + var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  92 + if self.parameter != nil {
  93 + p=self.parameter!
  94 + }
  95 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
70 96 if success{
71 97 self.tableView.reloadData()
72 98 }
... ... @@ -75,17 +101,23 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
75 101 })
76 102 }
77 103 // MARK: - 刷新数据接口
78   - func refreshLivesAction(parameters:Dictionary<String,AnyObject>,completionHandler:@escaping (Bool) -> ()){
  104 + func refreshLivesAction(isSearch:Bool=false,parameters:Dictionary<String,AnyObject>,completionHandler:@escaping (Bool) -> ()){
79 105 AppDelegate.instance().httpServer.postResourceList(parameters: parameters) { (str, error) in
80 106 var success:Bool=true
81 107 if error==nil {
82 108 if JSON.fromString(jsonString: str)!["status"].intValue == 1{
83 109 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
84   - if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{
85   - self.currentPage+=1
86   - }
87   - for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
88   - self.resourceData.append(MicroCourseModel(j: item))
  110 + if isSearch{
  111 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  112 + self.searchAry.append(MicroCourseModel(j: item))
  113 + }
  114 + }else{
  115 + if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{
  116 + self.currentPage+=1
  117 + }
  118 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  119 + self.resourceData.append(MicroCourseModel(j: item))
  120 + }
89 121 }
90 122 success=true
91 123 }, failHandler: { (error) in
... ... @@ -106,6 +138,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
106 138 // MARK: - 跳转到筛选
107 139 @IBAction func jumpFilterVCAction(_ sender: UIButton) {
108 140 let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "FilterViewController") as! FilterViewController
  141 + vc.type=FilterParameter(type: 1)
109 142 self.present(vc.wrapWithNavigationController(), animated: true, completion: nil)
110 143 }
111 144  
... ... @@ -119,7 +152,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
119 152 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
120 153 if tableView==searchTableView {
121 154 let cell=tableView.dequeueReusableCell(withIdentifier: "cell")
122   - cell?.textLabel?.text=searchAry[indexPath.row]
  155 + cell?.textLabel?.text=searchAry[indexPath.row].f_Title
123 156 return cell!
124 157 }else{
125 158 let cell=tableView.dequeueReusableCell(withIdentifier: "identifier") as! ResourceViewControllerTableViewCell
... ... @@ -137,6 +170,9 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
137 170 }
138 171 //取消键盘输入状态
139 172 @IBAction func cancleSearchActivit(_ sender: UITapGestureRecognizer) {
  173 + self.searchAry.removeAll()
  174 + searchTableHeight.constant=44
  175 + self.searchTableView.reloadData()
140 176 searchController.isActive=false
141 177 }
142 178 func willPresentSearchController(_ searchController: UISearchController) {
... ... @@ -146,19 +182,41 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
146 182 searchTableHeight.constant=44
147 183 grayView.isHidden=true
148 184 }
  185 + //searchaBarDelegate
  186 + func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
  187 + refreshLivesAction(isSearch: true,parameters: ["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":1 as AnyObject,"keyword":searchBar.text as AnyObject,"pageSize":10 as AnyObject], completionHandler: { (success) in
  188 + if success{
  189 + if CGFloat((self.searchAry.count+1)*44)>(getScreenHeight()-64){
  190 + self.searchTableHeight.constant=getScreenHeight()-64
  191 + }else{
  192 + self.searchTableHeight.constant=CGFloat((self.searchAry.count+1)*44)
  193 + }
  194 + self.searchTableView.reloadData()
  195 + }
  196 + })
  197 + }
  198 + func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
  199 + self.searchAry.removeAll()
  200 + searchTableHeight.constant=44
  201 + self.searchTableView.reloadData()
  202 + searchController.isActive=false
  203 + }
149 204 //谓词搜索过滤
150 205 func updateSearchResults(for searchController: UISearchController) {
151   - let searchString=searchController.searchBar.text
152   - let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!)
153   - searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String]
154   - if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){
155   - searchTableHeight.constant=getScreenHeight()-64
156   - }else{
157   - searchTableHeight.constant=CGFloat((searchAry.count+1)*44)
158   - }
159   - searchTableView.reloadData()
  206 +// let searchString=searchController.searchBar.text
  207 +// let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!)
  208 +// searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String]
  209 +// if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){
  210 +// searchTableHeight.constant=getScreenHeight()-64
  211 +// }else{
  212 +// searchTableHeight.constant=CGFloat((searchAry.count+1)*44)
  213 +// }
  214 +// searchTableView.reloadData()
  215 + }
  216 + // MARK: - 销毁通知
  217 + deinit {
  218 + NotificationCenter.default.removeObserver(self)
160 219 }
161   -
162 220 }
163 221  
164 222  
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/View/FilterFootView.swift 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +//
  2 +// FilterFootView.swift
  3 +// YouerLiveVideo
  4 +//
  5 +// Created by 葛建军 on 17/5/24.
  6 +// Copyright © 2017年 左丞. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class FilterFootView: UIView {
  12 + var superVC:FilterViewController!
  13 + var array:[String]=["教材目录","知识点目录","考点目录"]
  14 + @IBAction func pushListAction(_ sender: UIButton) {
  15 + if superVC.type.schoolSection != nil && superVC.type.materials != nil && superVC.type.grade != nil && superVC.type.subject != nil{
  16 + let vc=UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "FilterListViewController") as! FilterListViewController
  17 + vc.superVC=superVC
  18 + vc.title=array[sender.tag]
  19 + vc.index=sender.tag
  20 + superVC.navigationController?.pushViewController(vc, animated: true)
  21 + }else{
  22 + superVC.view.makeToast("以上筛选条件都必选")
  23 + }
  24 + }
  25 +}
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/View/FilterFootView.xib 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
  8 + <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
  9 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  10 + </dependencies>
  11 + <objects>
  12 + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
  13 + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
  14 + <view contentMode="scaleToFill" restorationIdentifier="FilterFootView" id="iN0-l3-epB" customClass="FilterFootView" customModule="YouerLiveVideo" customModuleProvider="target">
  15 + <rect key="frame" x="0.0" y="0.0" width="431" height="74"/>
  16 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  17 + <subviews>
  18 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qkY-Fg-R07">
  19 + <rect key="frame" x="0.0" y="0.0" width="143.5" height="74"/>
  20 + <state key="normal" title="教材目录">
  21 + <color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
  22 + </state>
  23 + <connections>
  24 + <action selector="pushListAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="pw6-rP-H1d"/>
  25 + </connections>
  26 + </button>
  27 + <button opaque="NO" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9IP-30-ds0">
  28 + <rect key="frame" x="144" y="0.0" width="143" height="74"/>
  29 + <state key="normal" title="知识点目录">
  30 + <color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
  31 + </state>
  32 + <connections>
  33 + <action selector="pushListAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="Gge-fr-oCB"/>
  34 + </connections>
  35 + </button>
  36 + <button opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hSs-Ue-9q5">
  37 + <rect key="frame" x="287.5" y="0.0" width="143.5" height="74"/>
  38 + <state key="normal" title="考点目录">
  39 + <color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
  40 + </state>
  41 + <connections>
  42 + <action selector="pushListAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="FMb-2J-e1r"/>
  43 + </connections>
  44 + </button>
  45 + </subviews>
  46 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  47 + <constraints>
  48 + <constraint firstItem="hSs-Ue-9q5" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" multiplier="1:3" id="3ep-1I-NMw"/>
  49 + <constraint firstItem="qkY-Fg-R07" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="4MM-T2-3um"/>
  50 + <constraint firstAttribute="bottom" secondItem="9IP-30-ds0" secondAttribute="bottom" id="5M3-1d-KtT"/>
  51 + <constraint firstItem="hSs-Ue-9q5" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="7KG-n9-ZZJ"/>
  52 + <constraint firstItem="9IP-30-ds0" firstAttribute="leading" secondItem="qkY-Fg-R07" secondAttribute="trailing" id="C6x-TT-ZGB"/>
  53 + <constraint firstAttribute="bottom" secondItem="hSs-Ue-9q5" secondAttribute="bottom" id="CLg-CF-ZXB"/>
  54 + <constraint firstItem="qkY-Fg-R07" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" multiplier="1:3" id="R0D-P1-Z0B"/>
  55 + <constraint firstItem="9IP-30-ds0" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="RVd-2Y-GkH"/>
  56 + <constraint firstAttribute="trailing" secondItem="hSs-Ue-9q5" secondAttribute="trailing" id="TWF-ru-PiJ"/>
  57 + <constraint firstItem="qkY-Fg-R07" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="dPN-9C-qEw"/>
  58 + <constraint firstAttribute="bottom" secondItem="qkY-Fg-R07" secondAttribute="bottom" id="izw-3e-8LX"/>
  59 + <constraint firstItem="hSs-Ue-9q5" firstAttribute="leading" secondItem="9IP-30-ds0" secondAttribute="trailing" id="pqu-rt-gFv"/>
  60 + </constraints>
  61 + <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
  62 + <point key="canvasLocation" x="-26.5" y="-714"/>
  63 + </view>
  64 + </objects>
  65 +</document>
... ...