Commit bda90d811b34ab0d64069983e9cdcedf6b501dcb

Authored by 左丞
1 parent ab380ebb
Exists in newLive

no message

YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard
... ... @@ -50,11 +50,11 @@
50 50 <rect key="frame" x="0.0" y="28" width="375" height="143"/>
51 51 <autoresizingMask key="autoresizingMask"/>
52 52 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tO9-FG-1Ux" id="73f-qf-61d">
53   - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/>
  53 + <rect key="frame" x="0.0" y="0.0" width="375" height="143"/>
54 54 <autoresizingMask key="autoresizingMask"/>
55 55 <subviews>
56 56 <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="9sK-3H-gLf">
57   - <rect key="frame" x="4" y="4" width="367" height="134.5"/>
  57 + <rect key="frame" x="4" y="4" width="367" height="135"/>
58 58 <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="NNX-1c-rMt">
59 59 <size key="itemSize" width="110" height="136"/>
60 60 <size key="headerReferenceSize" width="0.0" height="0.0"/>
... ... @@ -547,40 +547,40 @@
547 547 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
548 548 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
549 549 <subviews>
550   - <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="143" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="IhH-sz-Bd2">
  550 + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="178" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="IhH-sz-Bd2">
551 551 <rect key="frame" x="0.0" y="64" width="375" height="554"/>
552 552 <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
553 553 <prototypes>
554   - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="143" id="8PR-k0-hwX" customClass="TVStationViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target">
555   - <rect key="frame" x="0.0" y="28" width="375" height="143"/>
  554 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="178" id="8PR-k0-hwX" customClass="TVStationViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target">
  555 + <rect key="frame" x="0.0" y="28" width="375" height="178"/>
556 556 <autoresizingMask key="autoresizingMask"/>
557 557 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8PR-k0-hwX" id="Bb0-oI-ccB">
558   - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/>
  558 + <rect key="frame" x="0.0" y="0.0" width="375" height="177"/>
559 559 <autoresizingMask key="autoresizingMask"/>
560 560 <subviews>
561 561 <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="m0I-jk-Iru">
562   - <rect key="frame" x="4" y="0.0" width="367" height="138"/>
  562 + <rect key="frame" x="0.0" y="0.0" width="375" height="177.5"/>
563 563 <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
564   - <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="Mv6-Xf-FOx">
565   - <size key="itemSize" width="142" height="131"/>
  564 + <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="8" minimumInteritemSpacing="8" id="Mv6-Xf-FOx">
  565 + <size key="itemSize" width="176" height="164"/>
566 566 <size key="headerReferenceSize" width="0.0" height="0.0"/>
567 567 <size key="footerReferenceSize" width="0.0" height="0.0"/>
568 568 <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
569 569 </collectionViewFlowLayout>
570 570 <cells>
571 571 <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="Xjm-Ee-xEo" customClass="TVStationViewControllerCollectionCell" customModule="YouerLiveVideo" customModuleProvider="target">
572   - <rect key="frame" x="0.0" y="4" width="142" height="131"/>
  572 + <rect key="frame" x="0.0" y="7" width="176" height="164"/>
573 573 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
574 574 <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
575   - <rect key="frame" x="0.0" y="0.0" width="142" height="131"/>
  575 + <rect key="frame" x="0.0" y="0.0" width="176" height="164"/>
576 576 <autoresizingMask key="autoresizingMask"/>
577 577 <subviews>
578 578 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="BvO-kc-ckg">
579   - <rect key="frame" x="0.0" y="0.0" width="142" height="94"/>
  579 + <rect key="frame" x="0.0" y="0.0" width="176" height="130"/>
580 580 </imageView>
581 581 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZGv-kv-0Rn">
582   - <rect key="frame" x="50" y="102" width="42" height="21"/>
583   - <fontDescription key="fontDescription" type="system" pointSize="17"/>
  582 + <rect key="frame" x="69.5" y="138" width="37.5" height="18"/>
  583 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
584 584 <nil key="textColor"/>
585 585 <nil key="highlightedColor"/>
586 586 </label>
... ... @@ -609,11 +609,14 @@
609 609 </subviews>
610 610 <constraints>
611 611 <constraint firstItem="m0I-jk-Iru" firstAttribute="top" secondItem="Bb0-oI-ccB" secondAttribute="top" id="1Jb-Lc-HqD"/>
612   - <constraint firstAttribute="bottom" secondItem="m0I-jk-Iru" secondAttribute="bottom" constant="4" id="ANa-WV-bP7"/>
613   - <constraint firstAttribute="trailing" secondItem="m0I-jk-Iru" secondAttribute="trailing" constant="4" id="Nmx-qu-r17"/>
614   - <constraint firstItem="m0I-jk-Iru" firstAttribute="leading" secondItem="Bb0-oI-ccB" secondAttribute="leading" constant="4" id="aMz-0M-R7W"/>
  612 + <constraint firstAttribute="bottom" secondItem="m0I-jk-Iru" secondAttribute="bottom" id="ANa-WV-bP7"/>
  613 + <constraint firstAttribute="trailing" secondItem="m0I-jk-Iru" secondAttribute="trailing" id="Nmx-qu-r17"/>
  614 + <constraint firstItem="m0I-jk-Iru" firstAttribute="leading" secondItem="Bb0-oI-ccB" secondAttribute="leading" id="aMz-0M-R7W"/>
615 615 </constraints>
616 616 </tableViewCellContentView>
  617 + <connections>
  618 + <outlet property="collectionView" destination="m0I-jk-Iru" id="UUs-Z9-Hac"/>
  619 + </connections>
617 620 </tableViewCell>
618 621 </prototypes>
619 622 <connections>
... ... @@ -626,16 +629,19 @@
626 629 <constraints>
627 630 <constraint firstAttribute="trailing" secondItem="IhH-sz-Bd2" secondAttribute="trailing" id="KVp-Qt-6LS"/>
628 631 <constraint firstItem="IhH-sz-Bd2" firstAttribute="top" secondItem="fIM-JF-YUx" secondAttribute="bottom" id="N08-aD-PC9"/>
  632 + <constraint firstItem="k5T-vX-htB" firstAttribute="top" secondItem="IhH-sz-Bd2" secondAttribute="bottom" id="Ooi-6e-ZhV"/>
629 633 <constraint firstItem="IhH-sz-Bd2" firstAttribute="leading" secondItem="KHY-Ri-Rc3" secondAttribute="leading" id="brw-xU-W7N"/>
630   - <constraint firstItem="k5T-vX-htB" firstAttribute="top" secondItem="IhH-sz-Bd2" secondAttribute="bottom" id="eYV-eZ-X6d"/>
631 634 </constraints>
632 635 </view>
633 636 <tabBarItem key="tabBarItem" tag="3" title="电视台" id="s3g-mh-Xtl"/>
634 637 <navigationItem key="navigationItem" id="4l0-y8-1gT"/>
  638 + <connections>
  639 + <outlet property="tableView" destination="IhH-sz-Bd2" id="ut2-uV-tkE"/>
  640 + </connections>
635 641 </viewController>
636 642 <placeholder placeholderIdentifier="IBFirstResponder" id="CMh-ol-5GE" userLabel="First Responder" sceneMemberID="firstResponder"/>
637 643 </objects>
638   - <point key="canvasLocation" x="430" y="2113"/>
  644 + <point key="canvasLocation" x="429.60000000000002" y="2112.5937031484259"/>
639 645 </scene>
640 646 </scenes>
641 647 <resources>
... ...
YouerLiveVideo/YouerLiveVideo/controllers/TVStation/MoreTVStationViewController.swift
... ... @@ -9,13 +9,89 @@
9 9 import UIKit
10 10  
11 11 class MoreTVStationViewController: UIViewController {
12   -
  12 +
  13 + @IBOutlet weak var collectionView: UICollectionView!
  14 +
  15 + var topTenTVStation:[TVStationInfor] = []
  16 + var xxcellentSchool:[TVStationInfor] = []
  17 + var excellentTVStationProgram:[TVStationSubject] = []
  18 + var type:Int = 0 //0:十佳电视台,1:优秀电视台,2:优秀校园节目
  19 + var pageIndex:Int = 2
13 20 override func viewDidLoad() {
14 21 super.viewDidLoad()
15 22  
  23 + if type != 0{
  24 + addCellAndRefresh()
  25 + }
16 26 // Do any additional setup after loading the view.
17 27 }
18 28  
  29 + func addCellAndRefresh(){
  30 + collectionView.mj_header=MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(MoreTVStationViewController.loadNewData))
  31 +
  32 + collectionView.mj_footer=MJRefreshAutoNormalFooter(refreshingTarget: self, refreshingAction: #selector(MoreTVStationViewController.loadMoreData))
  33 + }
  34 +
  35 + // MARK: - 下拉刷新
  36 + func loadNewData(){
  37 + pageIndex=1
  38 + getTVStation() { (finish) in
  39 + self.collectionView.mj_header.endRefreshing()
  40 + }
  41 + }
  42 + // MARK: - 上拉加载更多
  43 + func loadMoreData(){
  44 + getTVStation() { (finish) in
  45 + self.collectionView.mj_footer.endRefreshing()
  46 + }
  47 + }
  48 +
  49 + func getTVStation(finish: @escaping (Bool)->()){
  50 + if type == 1{
  51 + AppDelegate.instance().httpServer.postExcellentSchool(parameters: ["pageIndex":pageIndex as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in
  52 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  53 + if json.contentData().dictionaryValue["resultData"] != nil{
  54 + if self.pageIndex==1{
  55 + self.xxcellentSchool.removeAll()
  56 + }
  57 + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{
  58 + self.xxcellentSchool.append(TVStationInfor(json: item))
  59 + }
  60 + if json.contentData().dictionaryValue["resultData"]!.arrayValue.count > 0{
  61 + self.pageIndex=self.pageIndex+1
  62 + }
  63 + finish(true)
  64 + self.collectionView.reloadData()
  65 + }
  66 + }, failHandler: { (error) in
  67 + finish(false)
  68 +
  69 + })
  70 + }
  71 + }else if type == 2{
  72 + AppDelegate.instance().httpServer.postExcellentProgram(parameters: ["pageIndex":pageIndex as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in
  73 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  74 + if json.contentData().dictionaryValue["resultData"] != nil{
  75 + if self.pageIndex==1{
  76 + self.excellentTVStationProgram.removeAll()
  77 + }
  78 + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{
  79 + self.excellentTVStationProgram.append(TVStationSubject(json: item))
  80 + }
  81 + if json.contentData().dictionaryValue["resultData"]!.arrayValue.count > 0{
  82 + self.pageIndex=self.pageIndex+1
  83 + }
  84 + finish(true)
  85 + self.collectionView.reloadData()
  86 + }
  87 + }, failHandler: { (error) in
  88 + finish(false)
  89 + })
  90 + }
  91 + }
  92 + }
  93 +
  94 +
19 95 override func didReceiveMemoryWarning() {
20 96 super.didReceiveMemoryWarning()
21 97 // Dispose of any resources that can be recreated.
... ... @@ -37,15 +113,39 @@ class MoreTVStationViewController: UIViewController {
37 113 extension MoreTVStationViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{
38 114  
39 115 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
40   -
  116 + if type == 2{
  117 + let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController
  118 + vc.excellentTVStationProgram = excellentTVStationProgram[indexPath.row]
  119 + self.navigationController?.pushViewController(vc, animated: true)
  120 + }
  121 +
41 122 }
42 123 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
43 124 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! MoreTVStationViewCollectionCell
  125 + if type == 0{
  126 + cell.tvPicture.sd_setImage(with: URL(string: topTenTVStation[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon"))
  127 + cell.tvStationName.text = topTenTVStation[indexPath.row].f_SchoolName
  128 + }else if type == 1{
  129 + cell.tvPicture.sd_setImage(with: URL(string: xxcellentSchool[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon"))
  130 + cell.tvStationName.text = xxcellentSchool[indexPath.row].f_SchoolName
  131 + }else if type == 2{
  132 + cell.tvPicture.sd_setImage(with: URL(string: excellentTVStationProgram[indexPath.row].f_Img), placeholderImage: UIImage(named:"icon"))
  133 + cell.tvStationName.text = excellentTVStationProgram[indexPath.row].f_Title
  134 + }
44 135 return cell
45 136 }
46 137  
47 138 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
48   - return 5
  139 + switch type {
  140 + case 0:
  141 + return topTenTVStation.count
  142 + case 1:
  143 + return xxcellentSchool.count
  144 + case 2:
  145 + return excellentTVStationProgram.count
  146 + default:
  147 + return 0
  148 + }
49 149 }
50 150  
51 151 }
... ...
YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard
1 1 <?xml version="1.0" encoding="UTF-8"?>
2   -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
  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">
3 3 <device id="retina4_7" orientation="portrait">
4 4 <adaptation id="fullscreen"/>
5 5 </device>
6 6 <dependencies>
7   - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
  7 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
8 8 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
9 9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10 10 </dependencies>
... ... @@ -21,10 +21,9 @@
21 21 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22 22 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23 23 <subviews>
24   - <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="T5M-Yy-22h">
  24 + <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="T5M-Yy-22h">
25 25 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
26   - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
27   - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  26 + <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
28 27 <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="8" minimumInteritemSpacing="8" id="EWj-Hf-n52">
29 28 <size key="itemSize" width="180" height="182"/>
30 29 <size key="headerReferenceSize" width="0.0" height="0.0"/>
... ... @@ -40,11 +39,11 @@
40 39 <autoresizingMask key="autoresizingMask"/>
41 40 <subviews>
42 41 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x1d-Bc-juB">
43   - <rect key="frame" x="0.0" y="0.0" width="180" height="145"/>
  42 + <rect key="frame" x="0.0" y="0.0" width="180" height="148"/>
44 43 </imageView>
45 44 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8hi-XF-Vgx">
46   - <rect key="frame" x="69" y="153" width="42" height="21"/>
47   - <fontDescription key="fontDescription" type="system" pointSize="17"/>
  45 + <rect key="frame" x="71.5" y="156" width="37.5" height="18"/>
  46 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
48 47 <nil key="textColor"/>
49 48 <nil key="highlightedColor"/>
50 49 </label>
... ... @@ -71,7 +70,16 @@
71 70 </collectionView>
72 71 </subviews>
73 72 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  73 + <constraints>
  74 + <constraint firstItem="6DV-QE-ehs" firstAttribute="top" secondItem="T5M-Yy-22h" secondAttribute="bottom" id="7yG-A7-fjD"/>
  75 + <constraint firstItem="T5M-Yy-22h" firstAttribute="leading" secondItem="aBm-lU-NjM" secondAttribute="leading" id="RSk-Xn-5MG"/>
  76 + <constraint firstAttribute="trailing" secondItem="T5M-Yy-22h" secondAttribute="trailing" id="SAg-4R-dPR"/>
  77 + <constraint firstItem="T5M-Yy-22h" firstAttribute="top" secondItem="aBm-lU-NjM" secondAttribute="top" id="hpe-dB-RYs"/>
  78 + </constraints>
74 79 </view>
  80 + <connections>
  81 + <outlet property="collectionView" destination="T5M-Yy-22h" id="ZjI-XZ-T6D"/>
  82 + </connections>
75 83 </viewController>
76 84 <placeholder placeholderIdentifier="IBFirstResponder" id="e4N-p3-2Gw" userLabel="First Responder" sceneMemberID="firstResponder"/>
77 85 </objects>
... ... @@ -282,7 +290,7 @@
282 290 <rect key="frame" x="0.0" y="28" width="375" height="123"/>
283 291 <autoresizingMask key="autoresizingMask"/>
284 292 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MMn-tR-I0v" id="H7d-Zz-WAS">
285   - <rect key="frame" x="0.0" y="0.0" width="375" height="123"/>
  293 + <rect key="frame" x="0.0" y="0.0" width="375" height="122"/>
286 294 <autoresizingMask key="autoresizingMask"/>
287 295 <subviews>
288 296 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9Yk-8z-nas">
... ... @@ -389,6 +397,15 @@
389 397 <state key="normal" title=" 进入电视台 ">
390 398 <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
391 399 </state>
  400 + <userDefinedRuntimeAttributes>
  401 + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
  402 + <integer key="value" value="5"/>
  403 + </userDefinedRuntimeAttribute>
  404 + <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
  405 + </userDefinedRuntimeAttributes>
  406 + <connections>
  407 + <action selector="enterTVStationBtnClick:" destination="Cfe-bh-dEi" eventType="touchUpInside" id="rtA-lS-pCe"/>
  408 + </connections>
392 409 </button>
393 410 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="信息" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WpW-S4-jZJ">
394 411 <rect key="frame" x="16" y="340" width="35" height="21"/>
... ... @@ -415,6 +432,12 @@
415 432 <constraint firstAttribute="bottom" secondItem="Nwx-qi-TmG" secondAttribute="bottom" id="t7e-OT-6Bq"/>
416 433 </constraints>
417 434 </view>
  435 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="04n-fF-iSZ">
  436 + <rect key="frame" x="93" y="303" width="42" height="21"/>
  437 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  438 + <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
  439 + <nil key="highlightedColor"/>
  440 + </label>
418 441 </subviews>
419 442 <color key="backgroundColor" red="0.93503493070602417" green="0.93562394380569458" blue="0.96585971117019653" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
420 443 <constraints>
... ... @@ -427,14 +450,22 @@
427 450 <constraint firstAttribute="trailing" secondItem="YGJ-f7-llj" secondAttribute="trailing" constant="16" id="PeL-3c-MS9"/>
428 451 <constraint firstItem="tOg-Dx-FMX" firstAttribute="top" secondItem="xXj-8O-v1p" secondAttribute="bottom" constant="16" id="UDD-gx-z8G"/>
429 452 <constraint firstItem="WpW-S4-jZJ" firstAttribute="top" secondItem="tOg-Dx-FMX" secondAttribute="bottom" constant="16" id="XfY-Hk-spU"/>
  453 + <constraint firstItem="04n-fF-iSZ" firstAttribute="leading" secondItem="tOg-Dx-FMX" secondAttribute="trailing" constant="8" id="aSb-Em-tQr"/>
430 454 <constraint firstAttribute="trailing" secondItem="mAy-et-NIv" secondAttribute="trailing" constant="16" id="c3g-Bc-9IR"/>
431 455 <constraint firstItem="d7u-YA-nhi" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" id="dYc-wA-Jgf"/>
  456 + <constraint firstItem="04n-fF-iSZ" firstAttribute="top" secondItem="tOg-Dx-FMX" secondAttribute="top" id="jrU-bz-1oD"/>
432 457 <constraint firstItem="WpW-S4-jZJ" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" constant="16" id="k1f-og-KKF"/>
433 458 <constraint firstItem="mAy-et-NIv" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" constant="16" id="lcJ-n0-G71"/>
434 459 <constraint firstItem="mAy-et-NIv" firstAttribute="top" secondItem="LAX-SQ-uDA" secondAttribute="bottom" constant="16" id="lcX-72-Hm3"/>
435 460 <constraint firstItem="WsK-MC-j0I" firstAttribute="top" secondItem="d7u-YA-nhi" secondAttribute="bottom" id="rQT-Z8-VEq"/>
436 461 </constraints>
437 462 </view>
  463 + <connections>
  464 + <outlet property="creatTime" destination="04n-fF-iSZ" id="5Va-ls-AXn"/>
  465 + <outlet property="discreption" destination="Nwx-qi-TmG" id="1Zu-U4-60L"/>
  466 + <outlet property="tvImage" destination="mAy-et-NIv" id="cH8-85-Nba"/>
  467 + <outlet property="tvName" destination="xXj-8O-v1p" id="wMk-Wh-Udh"/>
  468 + </connections>
438 469 </viewController>
439 470 <placeholder placeholderIdentifier="IBFirstResponder" id="LfW-OZ-7Wz" userLabel="First Responder" sceneMemberID="firstResponder"/>
440 471 </objects>
... ...
YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationInforViewController.swift
... ... @@ -9,9 +9,19 @@
9 9 import UIKit
10 10  
11 11 class TVStationInforViewController: UIViewController {
12   -
  12 + var excellentTVStationProgram:TVStationSubject!
  13 +
  14 + @IBOutlet weak var tvImage: UIImageView!
  15 + @IBOutlet weak var creatTime: UILabel!
  16 + @IBOutlet weak var tvName: UILabel!
  17 + @IBOutlet weak var discreption: UITextView!
13 18 override func viewDidLoad() {
14 19 super.viewDidLoad()
  20 + tvImage.sd_setImage(with: URL(string: excellentTVStationProgram.f_Img), placeholderImage: UIImage(named:"icon"))
  21 + tvName.text = excellentTVStationProgram.f_Title
  22 + creatTime.text = setDateToString(date:dateFromISO8601(dateString: excellentTVStationProgram.f_CreatorTime))
  23 + discreption.text = excellentTVStationProgram.f_Detail
  24 +
15 25 // Do any additional setup after loading the view.
16 26 }
17 27  
... ... @@ -20,6 +30,9 @@ class TVStationInforViewController: UIViewController {
20 30 // Dispose of any resources that can be recreated.
21 31 }
22 32  
  33 + @IBAction func enterTVStationBtnClick(_ sender: Any) {
  34 +
  35 + }
23 36 /*
24 37 // MARK: - Navigation
25 38  
... ...
YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationViewController.swift
... ... @@ -10,7 +10,11 @@ import UIKit
10 10  
11 11 class TVStationViewController: UIViewController {
12 12 var dataSet:[AnyObject] = []
13   -
  13 + var topTenTVStation:[TVStationInfor] = []
  14 + var xxcellentSchool:[TVStationInfor] = []
  15 + var excellentTVStationProgram:[TVStationSubject] = []
  16 + @IBOutlet weak var tableView: UITableView!
  17 + var TVStationType:[String] = ["十佳电视台","优秀电视台","优秀校园节目"]
14 18 override func viewDidLoad() {
15 19 super.viewDidLoad()
16 20 self.configTheme()
... ... @@ -24,7 +28,41 @@ class TVStationViewController: UIViewController {
24 28 }
25 29  
26 30 func getDataList(){
27   -
  31 + AppDelegate.instance().httpServer.getTopTenSchool(parameters: nil) { (str, error) in
  32 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  33 + for item in json.contentData().arrayValue{
  34 + self.topTenTVStation.append(TVStationInfor(json: item))
  35 + }
  36 + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 0)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData()
  37 + }, failHandler: { (error) in
  38 +
  39 + })
  40 + }
  41 + AppDelegate.instance().httpServer.postExcellentSchool(parameters: ["pageIndex":1 as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in
  42 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  43 + if json.contentData().dictionaryValue["resultData"] != nil{
  44 + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{
  45 + self.xxcellentSchool.append(TVStationInfor(json: item))
  46 + }
  47 + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 1)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData()
  48 + }
  49 + }, failHandler: { (error) in
  50 +
  51 + })
  52 + }
  53 + AppDelegate.instance().httpServer.postExcellentProgram(parameters: ["pageIndex":1 as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in
  54 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  55 + if json.contentData().dictionaryValue["resultData"] != nil{
  56 + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{
  57 + self.excellentTVStationProgram.append(TVStationSubject(json: item))
  58 + }
  59 + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 2)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData()
  60 + }
  61 + }, failHandler: { (error) in
  62 +
  63 + })
  64 + }
  65 +
28 66 }
29 67  
30 68 override func didReceiveMemoryWarning() {
... ... @@ -34,6 +72,18 @@ class TVStationViewController: UIViewController {
34 72  
35 73 func moreBtnClick(sender:UIButton){
36 74 let vc = Story.instantiateViewControllerWithIdentifier("MoreTVStationViewControllerVC", storyName: "TVStation") as! MoreTVStationViewController
  75 + switch sender.tag {
  76 + case 0:
  77 + vc.topTenTVStation = topTenTVStation
  78 + case 1:
  79 + vc.xxcellentSchool = xxcellentSchool
  80 + case 2:
  81 + vc.excellentTVStationProgram = excellentTVStationProgram
  82 + default:
  83 + break
  84 + }
  85 + vc.type = sender.tag
  86 + vc.title = TVStationType[sender.tag]
37 87 self.navigationController?.pushViewController(vc, animated: true)
38 88 }
39 89 /*
... ... @@ -54,15 +104,16 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{
54 104 }
55 105  
56 106 func numberOfSections(in tableView: UITableView) -> Int {
57   - return 10
  107 + return TVStationType.count
58 108 }
59 109  
60 110 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
61 111 let view = UIView(frame: CGRect(x: 0, y: 0, width: getScreenWidth(), height: 44))
  112 + view.backgroundColor = tableView.backgroundColor
62 113 let imageView = UIImageView(frame: CGRect(x: 8, y: 8, width: 28, height: 28))
63 114 imageView.image = UIImage(named: "icon")
64 115 let label = UILabel(frame: CGRect(x: imageView.frame.maxX+8, y: 11, width: 100, height: 21))
65   - label.text = "世家电视台"
  116 + label.text = TVStationType[section]
66 117 label.textAlignment = .left
67 118 label.sizeToFit()
68 119 let btn = UIButton(frame: CGRect(x: getScreenWidth() - 8 - 30, y: 7, width: 30, height: 30))
... ... @@ -85,6 +136,7 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{
85 136  
86 137 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
87 138 let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TVStationViewControllerTableViewCell
  139 + cell.collectionView.tag = indexPath.section+1
88 140 return cell
89 141 }
90 142 }
... ... @@ -92,28 +144,160 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{
92 144 extension TVStationViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{
93 145  
94 146 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
95   - let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController
96   - self.navigationController?.pushViewController(vc, animated: true)
  147 + if collectionView.tag == 3{
  148 + let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController
  149 + vc.excellentTVStationProgram = excellentTVStationProgram[indexPath.row]
  150 + self.navigationController?.pushViewController(vc, animated: true)
  151 + }
97 152 }
98 153 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
99 154 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! TVStationViewControllerCollectionCell
  155 + if collectionView.tag == 1{
  156 + cell.image.sd_setImage(with: URL(string: topTenTVStation[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon"))
  157 + cell.tvStationName.text = topTenTVStation[indexPath.row].f_SchoolName
  158 + }else if collectionView.tag == 2{
  159 + cell.image.sd_setImage(with: URL(string: xxcellentSchool[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon"))
  160 + cell.tvStationName.text = xxcellentSchool[indexPath.row].f_SchoolName
  161 + }else if collectionView.tag == 3{
  162 + cell.image.sd_setImage(with: URL(string: excellentTVStationProgram[indexPath.row].f_Img), placeholderImage: UIImage(named:"icon"))
  163 + cell.tvStationName.text = excellentTVStationProgram[indexPath.row].f_Title
  164 + }
100 165 return cell
101 166 }
102 167  
103 168 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
104   - return 5
  169 + switch collectionView.tag {
  170 + case 1:
  171 + return topTenTVStation.count
  172 + case 2:
  173 + return xxcellentSchool.count
  174 + case 3:
  175 + return excellentTVStationProgram.count
  176 + default:
  177 + return 0
  178 + }
105 179 }
106 180  
107 181 }
108 182  
109 183 class TVStationViewControllerTableViewCell:UITableViewCell{
110 184  
  185 + @IBOutlet weak var collectionView: UICollectionView!
111 186 }
112 187  
113 188  
114 189 class TVStationViewControllerCollectionCell:UICollectionViewCell{
115   -
  190 + var index:Int!
116 191 @IBOutlet weak var image: UIImageView!
117 192 @IBOutlet weak var tvStationName: UILabel!
118 193  
119 194 }
  195 +
  196 +class TVStationInfor {
  197 + var f_Id:String! //标识字段,Guid标识 ,
  198 + var f_DeleteMark:Bool = false //删除标识,1-已删除 ,
  199 + var f_CreatorTime:String!//创建时间 ,
  200 + var f_CreatorUserId:String!//创建人员ID ,
  201 + var f_LastModifyTime:String! //最近一次编辑时间 ,
  202 + var f_LastModifyUserId:String! //最近一次编辑人员 ,
  203 + var f_DeleteTime:String! //删除时间 ,
  204 + var f_DeleteUserId:String! //删除人员 ,
  205 + var f_SchoolName:String! //学校名称 ,
  206 + var f_SchoolTypeId:String!// 学校类型 ,
  207 + var f_Logo:String! //校徽 ,
  208 + var f_IsTopTen:Bool = false //是否十佳校园电视台 ,
  209 + var f_IsExcellent:Bool = false //是否优秀校园电视台 ,
  210 + var f_Url:String!// 机构地址
  211 +
  212 + init(json:JSON){
  213 + f_Id = json["f_Id"].stringValue
  214 + f_DeleteMark = json["f_DeleteMark"].boolValue
  215 + f_CreatorTime = json["f_CreatorTime"].stringValue
  216 + f_CreatorUserId = json["f_CreatorUserId"].stringValue
  217 + f_LastModifyTime = json["f_LastModifyTime"].stringValue
  218 + f_LastModifyUserId = json["f_LastModifyUserId"].stringValue
  219 + f_DeleteTime = json["f_DeleteTime"].stringValue
  220 + f_DeleteUserId = json["f_DeleteUserId"].stringValue
  221 + f_SchoolName = json["f_SchoolName"].stringValue
  222 + f_SchoolTypeId = json["f_SchoolTypeId"].stringValue
  223 + f_Logo = json["f_Logo"].stringValue
  224 + f_IsTopTen = json["f_IsTopTen"].boolValue
  225 + f_IsExcellent = json["f_IsExcellent"].boolValue
  226 + f_Url = json["f_Url"].stringValue
  227 + }
  228 +}
  229 +
  230 +class TVStationSubject {
  231 + var f_Url:String!// 机构地址
  232 +
  233 + var f_WaveTitle:String!
  234 + var f_ChapterName:String!
  235 + var f_TopicName:String!
  236 + var f_TestName:String!
  237 + var f_Id:String!// 标识字段,Guid标识 ,
  238 + var f_DeleteMark:Bool = false // 删除标识,1-已删除 ,
  239 + var f_CreatorTime:String!// 创建时间 ,
  240 + var f_CreatorUserId:String!// 创建人员ID ,
  241 + var f_LastModifyTime:String!// 最近一次编辑时间 ,
  242 + var f_LastModifyUserId:String!//最近一次编辑人员 ,
  243 + var f_DeleteTime:String!//删除时间 ,
  244 + var f_DeleteUserId:String!// 删除人员 ,
  245 + var f_Img :String!//课件图标/微课封面 ,
  246 + var f_Title:String!//课件名称 ,
  247 + var f_CreatorName:String!// 上传人员昵称 ,
  248 + var f_Pv:Int!// 浏览量 ,
  249 + var f_DownloadSum:Int!// 下载量 ,
  250 + var f_LoveSum:Int!// 点赞量 ,
  251 + var f_Price:Int!// 价格 ,
  252 + var f_WaveId:String!// 所属教材ID ,
  253 + var f_ChapterId:String!// 所属章节 ,
  254 + var f_TopicId:String!//所属知识点 ,
  255 + var f_TestId:String!//所属考点 ,
  256 + var f_SchoolId:String!// 上传老师的学校ID ,
  257 + var f_IsExamine:Int!// 审核状态:0-未审核,1-审核通过,2-审核不通过 ,
  258 + var f_ExamineUserId :String!//审核人ID ,
  259 + var f_ExamineName:String!//审核人姓名 ,
  260 + var f_ExamineDatetime :String!// 审核日期 ,
  261 + var f_ResourceType:Int!// 资源类型 0-微课 1-资源 2-电视台 ,
  262 + var f_ResourceUrl:String!// 资源地址 ,
  263 + var f_IsOpen:Bool = false // 是否公开 ,
  264 + var f_Detail :String!// 资源简介 ,
  265 + var f_TelevisionId :String!//电视台目录
  266 + init(json:JSON){
  267 + f_Url = json["f_Url"].stringValue
  268 + f_WaveTitle = json["f_WaveTitle"].stringValue
  269 + f_ChapterName = json["f_ChapterName"].stringValue
  270 + f_TopicName = json["f_TopicName"].stringValue
  271 + f_TestName = json["f_TestName"].stringValue
  272 + f_Id = json["f_Id"].stringValue
  273 + f_DeleteMark = json["f_DeleteMark"].boolValue
  274 + f_CreatorTime = json["f_CreatorTime"].stringValue
  275 + f_CreatorUserId = json["f_CreatorUserId"].stringValue
  276 + f_LastModifyTime = json["f_LastModifyTime"].stringValue
  277 + f_LastModifyUserId = json["f_LastModifyUserId"].stringValue
  278 + f_DeleteTime = json["f_DeleteTime"].stringValue
  279 + f_DeleteUserId = json["f_DeleteUserId"].stringValue
  280 + f_Img = json["f_Img"].stringValue
  281 + f_Title = json["f_Title"].stringValue
  282 + f_CreatorName = json["f_CreatorName"].stringValue
  283 + f_Pv = json["f_Pv"].intValue
  284 + f_DownloadSum = json["f_DownloadSum"].intValue
  285 + f_LoveSum = json["f_LoveSum"].intValue
  286 + f_Price = json["f_Price"].intValue
  287 + f_WaveId = json["f_WaveId"].stringValue
  288 + f_ChapterId = json["f_ChapterId"].stringValue
  289 + f_TopicId = json["f_TopicId"].stringValue
  290 + f_TestId = json["f_TestId"].stringValue
  291 + f_SchoolId = json["f_SchoolId"].stringValue
  292 + f_IsExamine = json["f_IsExamine"].intValue
  293 + f_ExamineUserId = json["f_ExamineUserId"].stringValue
  294 + f_ExamineName = json["f_ExamineName"].stringValue
  295 + f_ExamineDatetime = json["f_ExamineDatetime"].stringValue
  296 + f_ResourceType = json["f_ResourceType"].intValue
  297 + f_ResourceUrl = json["f_ResourceUrl"].stringValue
  298 + f_IsOpen = json["f_IsOpen"].boolValue
  299 + f_Detail = json["f_Detail"].stringValue
  300 + f_TelevisionId = json["f_TelevisionId"].stringValue
  301 +
  302 + }
  303 +}
... ...
YouerLiveVideo/YouerLiveVideo/util/utiles.swift
... ... @@ -346,6 +346,39 @@ func resignTextFiledFirstResponder(){
346 346 firstView?.resignFirstResponder()
347 347 }
348 348 }
  349 +
  350 +///ISO8601相关
  351 +private var iso8601Formatter:DateFormatter?
  352 +func dateFromISO8601(dateString:String)->Date{
  353 + var dateFormatter:DateFormatter!
  354 + if let tmp=iso8601Formatter{
  355 + dateFormatter=tmp
  356 + }else{
  357 + iso8601Formatter = DateFormatter()
  358 + iso8601Formatter!.locale = Locale(identifier: "en_US_POSIX")
  359 + //iso8601Formatter!.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ"
  360 + //iso8601Formatter!.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SS"
  361 + dateFormatter=iso8601Formatter!
  362 + }
  363 + //不知道为什么服务器传回的时间有不同格式
  364 + let arr = ["yyyy-MM-dd'T'HH:mm:ss.SSS","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd HH:mm:ss.SSS'Z'","yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"]
  365 + for item in arr {
  366 + iso8601Formatter!.dateFormat = item
  367 + let ret=dateFormatter.date(from: dateString)
  368 + if let date=ret{
  369 + return date
  370 + }
  371 + }
  372 +
  373 + return Date(timeIntervalSince1970: 0)
  374 +}
  375 +
  376 +func setDateToString(date:Date)->String{
  377 + let timeFormatter = DateFormatter()
  378 + timeFormatter.dateFormat = "yyyy-MM-dd"
  379 + return timeFormatter.string(from: date)
  380 +}
  381 +
349 382 //时间处理
350 383 func currentTime()->String{
351 384 let format = creatDateFormate(dateFormat: "yyyy-MM-dd HH:mm:ss")
... ...