diff --git a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard index 478c52a..084ab52 100644 --- a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard @@ -50,11 +50,11 @@ <rect key="frame" x="0.0" y="28" width="375" height="143"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tO9-FG-1Ux" id="73f-qf-61d"> - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="143"/> <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="9sK-3H-gLf"> - <rect key="frame" x="4" y="4" width="367" height="134.5"/> + <rect key="frame" x="4" y="4" width="367" height="135"/> <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="NNX-1c-rMt"> <size key="itemSize" width="110" height="136"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> @@ -547,40 +547,40 @@ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <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"> + <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"> <rect key="frame" x="0.0" y="64" width="375" height="554"/> <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <prototypes> - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="143" id="8PR-k0-hwX" customClass="TVStationViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target"> - <rect key="frame" x="0.0" y="28" width="375" height="143"/> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="178" id="8PR-k0-hwX" customClass="TVStationViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target"> + <rect key="frame" x="0.0" y="28" width="375" height="178"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8PR-k0-hwX" id="Bb0-oI-ccB"> - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="177"/> <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="m0I-jk-Iru"> - <rect key="frame" x="4" y="0.0" width="367" height="138"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="177.5"/> <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> - <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="Mv6-Xf-FOx"> - <size key="itemSize" width="142" height="131"/> + <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="8" minimumInteritemSpacing="8" id="Mv6-Xf-FOx"> + <size key="itemSize" width="176" height="164"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="footerReferenceSize" width="0.0" height="0.0"/> <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> </collectionViewFlowLayout> <cells> <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="Xjm-Ee-xEo" customClass="TVStationViewControllerCollectionCell" customModule="YouerLiveVideo" customModuleProvider="target"> - <rect key="frame" x="0.0" y="4" width="142" height="131"/> + <rect key="frame" x="0.0" y="7" width="176" height="164"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> - <rect key="frame" x="0.0" y="0.0" width="142" height="131"/> + <rect key="frame" x="0.0" y="0.0" width="176" height="164"/> <autoresizingMask key="autoresizingMask"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="BvO-kc-ckg"> - <rect key="frame" x="0.0" y="0.0" width="142" height="94"/> + <rect key="frame" x="0.0" y="0.0" width="176" height="130"/> </imageView> <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"> - <rect key="frame" x="50" y="102" width="42" height="21"/> - <fontDescription key="fontDescription" type="system" pointSize="17"/> + <rect key="frame" x="69.5" y="138" width="37.5" height="18"/> + <fontDescription key="fontDescription" type="system" pointSize="15"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> @@ -609,11 +609,14 @@ </subviews> <constraints> <constraint firstItem="m0I-jk-Iru" firstAttribute="top" secondItem="Bb0-oI-ccB" secondAttribute="top" id="1Jb-Lc-HqD"/> - <constraint firstAttribute="bottom" secondItem="m0I-jk-Iru" secondAttribute="bottom" constant="4" id="ANa-WV-bP7"/> - <constraint firstAttribute="trailing" secondItem="m0I-jk-Iru" secondAttribute="trailing" constant="4" id="Nmx-qu-r17"/> - <constraint firstItem="m0I-jk-Iru" firstAttribute="leading" secondItem="Bb0-oI-ccB" secondAttribute="leading" constant="4" id="aMz-0M-R7W"/> + <constraint firstAttribute="bottom" secondItem="m0I-jk-Iru" secondAttribute="bottom" id="ANa-WV-bP7"/> + <constraint firstAttribute="trailing" secondItem="m0I-jk-Iru" secondAttribute="trailing" id="Nmx-qu-r17"/> + <constraint firstItem="m0I-jk-Iru" firstAttribute="leading" secondItem="Bb0-oI-ccB" secondAttribute="leading" id="aMz-0M-R7W"/> </constraints> </tableViewCellContentView> + <connections> + <outlet property="collectionView" destination="m0I-jk-Iru" id="UUs-Z9-Hac"/> + </connections> </tableViewCell> </prototypes> <connections> @@ -626,16 +629,19 @@ <constraints> <constraint firstAttribute="trailing" secondItem="IhH-sz-Bd2" secondAttribute="trailing" id="KVp-Qt-6LS"/> <constraint firstItem="IhH-sz-Bd2" firstAttribute="top" secondItem="fIM-JF-YUx" secondAttribute="bottom" id="N08-aD-PC9"/> + <constraint firstItem="k5T-vX-htB" firstAttribute="top" secondItem="IhH-sz-Bd2" secondAttribute="bottom" id="Ooi-6e-ZhV"/> <constraint firstItem="IhH-sz-Bd2" firstAttribute="leading" secondItem="KHY-Ri-Rc3" secondAttribute="leading" id="brw-xU-W7N"/> - <constraint firstItem="k5T-vX-htB" firstAttribute="top" secondItem="IhH-sz-Bd2" secondAttribute="bottom" id="eYV-eZ-X6d"/> </constraints> </view> <tabBarItem key="tabBarItem" tag="3" title="电视台" id="s3g-mh-Xtl"/> <navigationItem key="navigationItem" id="4l0-y8-1gT"/> + <connections> + <outlet property="tableView" destination="IhH-sz-Bd2" id="ut2-uV-tkE"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="CMh-ol-5GE" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="430" y="2113"/> + <point key="canvasLocation" x="429.60000000000002" y="2112.5937031484259"/> </scene> </scenes> <resources> diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/MoreTVStationViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/MoreTVStationViewController.swift index 5dc9ba2..4df689d 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/MoreTVStationViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/MoreTVStationViewController.swift @@ -9,13 +9,89 @@ import UIKit class MoreTVStationViewController: UIViewController { - + + @IBOutlet weak var collectionView: UICollectionView! + + var topTenTVStation:[TVStationInfor] = [] + var xxcellentSchool:[TVStationInfor] = [] + var excellentTVStationProgram:[TVStationSubject] = [] + var type:Int = 0 //0:十佳电视台,1:优秀电视台,2:优秀校园节目 + var pageIndex:Int = 2 override func viewDidLoad() { super.viewDidLoad() + if type != 0{ + addCellAndRefresh() + } // Do any additional setup after loading the view. } + func addCellAndRefresh(){ + collectionView.mj_header=MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(MoreTVStationViewController.loadNewData)) + + collectionView.mj_footer=MJRefreshAutoNormalFooter(refreshingTarget: self, refreshingAction: #selector(MoreTVStationViewController.loadMoreData)) + } + + // MARK: - 下拉刷新 + func loadNewData(){ + pageIndex=1 + getTVStation() { (finish) in + self.collectionView.mj_header.endRefreshing() + } + } + // MARK: - 上拉加载更多 + func loadMoreData(){ + getTVStation() { (finish) in + self.collectionView.mj_footer.endRefreshing() + } + } + + func getTVStation(finish: @escaping (Bool)->()){ + if type == 1{ + AppDelegate.instance().httpServer.postExcellentSchool(parameters: ["pageIndex":pageIndex as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + if json.contentData().dictionaryValue["resultData"] != nil{ + if self.pageIndex==1{ + self.xxcellentSchool.removeAll() + } + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{ + self.xxcellentSchool.append(TVStationInfor(json: item)) + } + if json.contentData().dictionaryValue["resultData"]!.arrayValue.count > 0{ + self.pageIndex=self.pageIndex+1 + } + finish(true) + self.collectionView.reloadData() + } + }, failHandler: { (error) in + finish(false) + + }) + } + }else if type == 2{ + AppDelegate.instance().httpServer.postExcellentProgram(parameters: ["pageIndex":pageIndex as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + if json.contentData().dictionaryValue["resultData"] != nil{ + if self.pageIndex==1{ + self.excellentTVStationProgram.removeAll() + } + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{ + self.excellentTVStationProgram.append(TVStationSubject(json: item)) + } + if json.contentData().dictionaryValue["resultData"]!.arrayValue.count > 0{ + self.pageIndex=self.pageIndex+1 + } + finish(true) + self.collectionView.reloadData() + } + }, failHandler: { (error) in + finish(false) + }) + } + } + } + + override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. @@ -37,15 +113,39 @@ class MoreTVStationViewController: UIViewController { extension MoreTVStationViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - + if type == 2{ + let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController + vc.excellentTVStationProgram = excellentTVStationProgram[indexPath.row] + self.navigationController?.pushViewController(vc, animated: true) + } + } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! MoreTVStationViewCollectionCell + if type == 0{ + cell.tvPicture.sd_setImage(with: URL(string: topTenTVStation[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = topTenTVStation[indexPath.row].f_SchoolName + }else if type == 1{ + cell.tvPicture.sd_setImage(with: URL(string: xxcellentSchool[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = xxcellentSchool[indexPath.row].f_SchoolName + }else if type == 2{ + cell.tvPicture.sd_setImage(with: URL(string: excellentTVStationProgram[indexPath.row].f_Img), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = excellentTVStationProgram[indexPath.row].f_Title + } return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 5 + switch type { + case 0: + return topTenTVStation.count + case 1: + return xxcellentSchool.count + case 2: + return excellentTVStationProgram.count + default: + return 0 + } } } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard index 20b9dde..21ba817 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> -<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"> +<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"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/> <capability name="Aspect ratio constraints" minToolsVersion="5.1"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> @@ -21,10 +21,9 @@ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="T5M-Yy-22h"> + <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="T5M-Yy-22h"> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <color key="backgroundColor" red="0.93503493069999999" green="0.93562394380000002" blue="0.96585971120000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="8" minimumInteritemSpacing="8" id="EWj-Hf-n52"> <size key="itemSize" width="180" height="182"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> @@ -40,11 +39,11 @@ <autoresizingMask key="autoresizingMask"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x1d-Bc-juB"> - <rect key="frame" x="0.0" y="0.0" width="180" height="145"/> + <rect key="frame" x="0.0" y="0.0" width="180" height="148"/> </imageView> <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"> - <rect key="frame" x="69" y="153" width="42" height="21"/> - <fontDescription key="fontDescription" type="system" pointSize="17"/> + <rect key="frame" x="71.5" y="156" width="37.5" height="18"/> + <fontDescription key="fontDescription" type="system" pointSize="15"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> @@ -71,7 +70,16 @@ </collectionView> </subviews> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <constraints> + <constraint firstItem="6DV-QE-ehs" firstAttribute="top" secondItem="T5M-Yy-22h" secondAttribute="bottom" id="7yG-A7-fjD"/> + <constraint firstItem="T5M-Yy-22h" firstAttribute="leading" secondItem="aBm-lU-NjM" secondAttribute="leading" id="RSk-Xn-5MG"/> + <constraint firstAttribute="trailing" secondItem="T5M-Yy-22h" secondAttribute="trailing" id="SAg-4R-dPR"/> + <constraint firstItem="T5M-Yy-22h" firstAttribute="top" secondItem="aBm-lU-NjM" secondAttribute="top" id="hpe-dB-RYs"/> + </constraints> </view> + <connections> + <outlet property="collectionView" destination="T5M-Yy-22h" id="ZjI-XZ-T6D"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="e4N-p3-2Gw" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> @@ -282,7 +290,7 @@ <rect key="frame" x="0.0" y="28" width="375" height="123"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MMn-tR-I0v" id="H7d-Zz-WAS"> - <rect key="frame" x="0.0" y="0.0" width="375" height="123"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="122"/> <autoresizingMask key="autoresizingMask"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9Yk-8z-nas"> @@ -389,6 +397,15 @@ <state key="normal" title=" 进入电视台 "> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </state> + <userDefinedRuntimeAttributes> + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> + <integer key="value" value="5"/> + </userDefinedRuntimeAttribute> + <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/> + </userDefinedRuntimeAttributes> + <connections> + <action selector="enterTVStationBtnClick:" destination="Cfe-bh-dEi" eventType="touchUpInside" id="rtA-lS-pCe"/> + </connections> </button> <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"> <rect key="frame" x="16" y="340" width="35" height="21"/> @@ -415,6 +432,12 @@ <constraint firstAttribute="bottom" secondItem="Nwx-qi-TmG" secondAttribute="bottom" id="t7e-OT-6Bq"/> </constraints> </view> + <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"> + <rect key="frame" x="93" y="303" width="42" height="21"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> + <nil key="highlightedColor"/> + </label> </subviews> <color key="backgroundColor" red="0.93503493070602417" green="0.93562394380569458" blue="0.96585971117019653" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <constraints> @@ -427,14 +450,22 @@ <constraint firstAttribute="trailing" secondItem="YGJ-f7-llj" secondAttribute="trailing" constant="16" id="PeL-3c-MS9"/> <constraint firstItem="tOg-Dx-FMX" firstAttribute="top" secondItem="xXj-8O-v1p" secondAttribute="bottom" constant="16" id="UDD-gx-z8G"/> <constraint firstItem="WpW-S4-jZJ" firstAttribute="top" secondItem="tOg-Dx-FMX" secondAttribute="bottom" constant="16" id="XfY-Hk-spU"/> + <constraint firstItem="04n-fF-iSZ" firstAttribute="leading" secondItem="tOg-Dx-FMX" secondAttribute="trailing" constant="8" id="aSb-Em-tQr"/> <constraint firstAttribute="trailing" secondItem="mAy-et-NIv" secondAttribute="trailing" constant="16" id="c3g-Bc-9IR"/> <constraint firstItem="d7u-YA-nhi" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" id="dYc-wA-Jgf"/> + <constraint firstItem="04n-fF-iSZ" firstAttribute="top" secondItem="tOg-Dx-FMX" secondAttribute="top" id="jrU-bz-1oD"/> <constraint firstItem="WpW-S4-jZJ" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" constant="16" id="k1f-og-KKF"/> <constraint firstItem="mAy-et-NIv" firstAttribute="leading" secondItem="mu2-dt-yBu" secondAttribute="leading" constant="16" id="lcJ-n0-G71"/> <constraint firstItem="mAy-et-NIv" firstAttribute="top" secondItem="LAX-SQ-uDA" secondAttribute="bottom" constant="16" id="lcX-72-Hm3"/> <constraint firstItem="WsK-MC-j0I" firstAttribute="top" secondItem="d7u-YA-nhi" secondAttribute="bottom" id="rQT-Z8-VEq"/> </constraints> </view> + <connections> + <outlet property="creatTime" destination="04n-fF-iSZ" id="5Va-ls-AXn"/> + <outlet property="discreption" destination="Nwx-qi-TmG" id="1Zu-U4-60L"/> + <outlet property="tvImage" destination="mAy-et-NIv" id="cH8-85-Nba"/> + <outlet property="tvName" destination="xXj-8O-v1p" id="wMk-Wh-Udh"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="LfW-OZ-7Wz" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationInforViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationInforViewController.swift index fbcc256..7178d8c 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationInforViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationInforViewController.swift @@ -9,9 +9,19 @@ import UIKit class TVStationInforViewController: UIViewController { - + var excellentTVStationProgram:TVStationSubject! + + @IBOutlet weak var tvImage: UIImageView! + @IBOutlet weak var creatTime: UILabel! + @IBOutlet weak var tvName: UILabel! + @IBOutlet weak var discreption: UITextView! override func viewDidLoad() { super.viewDidLoad() + tvImage.sd_setImage(with: URL(string: excellentTVStationProgram.f_Img), placeholderImage: UIImage(named:"icon")) + tvName.text = excellentTVStationProgram.f_Title + creatTime.text = setDateToString(date:dateFromISO8601(dateString: excellentTVStationProgram.f_CreatorTime)) + discreption.text = excellentTVStationProgram.f_Detail + // Do any additional setup after loading the view. } @@ -20,6 +30,9 @@ class TVStationInforViewController: UIViewController { // Dispose of any resources that can be recreated. } + @IBAction func enterTVStationBtnClick(_ sender: Any) { + + } /* // MARK: - Navigation diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationViewController.swift index f48771d..e15b5bb 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStationViewController.swift @@ -10,7 +10,11 @@ import UIKit class TVStationViewController: UIViewController { var dataSet:[AnyObject] = [] - + var topTenTVStation:[TVStationInfor] = [] + var xxcellentSchool:[TVStationInfor] = [] + var excellentTVStationProgram:[TVStationSubject] = [] + @IBOutlet weak var tableView: UITableView! + var TVStationType:[String] = ["十佳电视台","优秀电视台","优秀校园节目"] override func viewDidLoad() { super.viewDidLoad() self.configTheme() @@ -24,7 +28,41 @@ class TVStationViewController: UIViewController { } func getDataList(){ - + AppDelegate.instance().httpServer.getTopTenSchool(parameters: nil) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + for item in json.contentData().arrayValue{ + self.topTenTVStation.append(TVStationInfor(json: item)) + } + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 0)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData() + }, failHandler: { (error) in + + }) + } + AppDelegate.instance().httpServer.postExcellentSchool(parameters: ["pageIndex":1 as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + if json.contentData().dictionaryValue["resultData"] != nil{ + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{ + self.xxcellentSchool.append(TVStationInfor(json: item)) + } + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 1)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData() + } + }, failHandler: { (error) in + + }) + } + AppDelegate.instance().httpServer.postExcellentProgram(parameters: ["pageIndex":1 as AnyObject,"pageSize":8 as AnyObject]) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + if json.contentData().dictionaryValue["resultData"] != nil{ + for item in json.contentData().dictionaryValue["resultData"]!.arrayValue{ + self.excellentTVStationProgram.append(TVStationSubject(json: item)) + } + (self.tableView.cellForRow(at: IndexPath(item: 0, section: 2)) as? TVStationViewControllerTableViewCell)?.collectionView.reloadData() + } + }, failHandler: { (error) in + + }) + } + } override func didReceiveMemoryWarning() { @@ -34,6 +72,18 @@ class TVStationViewController: UIViewController { func moreBtnClick(sender:UIButton){ let vc = Story.instantiateViewControllerWithIdentifier("MoreTVStationViewControllerVC", storyName: "TVStation") as! MoreTVStationViewController + switch sender.tag { + case 0: + vc.topTenTVStation = topTenTVStation + case 1: + vc.xxcellentSchool = xxcellentSchool + case 2: + vc.excellentTVStationProgram = excellentTVStationProgram + default: + break + } + vc.type = sender.tag + vc.title = TVStationType[sender.tag] self.navigationController?.pushViewController(vc, animated: true) } /* @@ -54,15 +104,16 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{ } func numberOfSections(in tableView: UITableView) -> Int { - return 10 + return TVStationType.count } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView(frame: CGRect(x: 0, y: 0, width: getScreenWidth(), height: 44)) + view.backgroundColor = tableView.backgroundColor let imageView = UIImageView(frame: CGRect(x: 8, y: 8, width: 28, height: 28)) imageView.image = UIImage(named: "icon") let label = UILabel(frame: CGRect(x: imageView.frame.maxX+8, y: 11, width: 100, height: 21)) - label.text = "世家电视台" + label.text = TVStationType[section] label.textAlignment = .left label.sizeToFit() let btn = UIButton(frame: CGRect(x: getScreenWidth() - 8 - 30, y: 7, width: 30, height: 30)) @@ -85,6 +136,7 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TVStationViewControllerTableViewCell + cell.collectionView.tag = indexPath.section+1 return cell } } @@ -92,28 +144,160 @@ extension TVStationViewController:UITableViewDelegate,UITableViewDataSource{ extension TVStationViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController - self.navigationController?.pushViewController(vc, animated: true) + if collectionView.tag == 3{ + let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController + vc.excellentTVStationProgram = excellentTVStationProgram[indexPath.row] + self.navigationController?.pushViewController(vc, animated: true) + } } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! TVStationViewControllerCollectionCell + if collectionView.tag == 1{ + cell.image.sd_setImage(with: URL(string: topTenTVStation[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = topTenTVStation[indexPath.row].f_SchoolName + }else if collectionView.tag == 2{ + cell.image.sd_setImage(with: URL(string: xxcellentSchool[indexPath.row].f_Logo), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = xxcellentSchool[indexPath.row].f_SchoolName + }else if collectionView.tag == 3{ + cell.image.sd_setImage(with: URL(string: excellentTVStationProgram[indexPath.row].f_Img), placeholderImage: UIImage(named:"icon")) + cell.tvStationName.text = excellentTVStationProgram[indexPath.row].f_Title + } return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 5 + switch collectionView.tag { + case 1: + return topTenTVStation.count + case 2: + return xxcellentSchool.count + case 3: + return excellentTVStationProgram.count + default: + return 0 + } } } class TVStationViewControllerTableViewCell:UITableViewCell{ + @IBOutlet weak var collectionView: UICollectionView! } class TVStationViewControllerCollectionCell:UICollectionViewCell{ - + var index:Int! @IBOutlet weak var image: UIImageView! @IBOutlet weak var tvStationName: UILabel! } + +class TVStationInfor { + var f_Id:String! //标识字段,Guid标识 , + var f_DeleteMark:Bool = false //删除标识,1-已删除 , + var f_CreatorTime:String!//创建时间 , + var f_CreatorUserId:String!//创建人员ID , + var f_LastModifyTime:String! //最近一次编辑时间 , + var f_LastModifyUserId:String! //最近一次编辑人员 , + var f_DeleteTime:String! //删除时间 , + var f_DeleteUserId:String! //删除人员 , + var f_SchoolName:String! //学校名称 , + var f_SchoolTypeId:String!// 学校类型 , + var f_Logo:String! //校徽 , + var f_IsTopTen:Bool = false //是否十佳校园电视台 , + var f_IsExcellent:Bool = false //是否优秀校园电视台 , + var f_Url:String!// 机构地址 + + init(json:JSON){ + f_Id = json["f_Id"].stringValue + f_DeleteMark = json["f_DeleteMark"].boolValue + f_CreatorTime = json["f_CreatorTime"].stringValue + f_CreatorUserId = json["f_CreatorUserId"].stringValue + f_LastModifyTime = json["f_LastModifyTime"].stringValue + f_LastModifyUserId = json["f_LastModifyUserId"].stringValue + f_DeleteTime = json["f_DeleteTime"].stringValue + f_DeleteUserId = json["f_DeleteUserId"].stringValue + f_SchoolName = json["f_SchoolName"].stringValue + f_SchoolTypeId = json["f_SchoolTypeId"].stringValue + f_Logo = json["f_Logo"].stringValue + f_IsTopTen = json["f_IsTopTen"].boolValue + f_IsExcellent = json["f_IsExcellent"].boolValue + f_Url = json["f_Url"].stringValue + } +} + +class TVStationSubject { + var f_Url:String!// 机构地址 + + var f_WaveTitle:String! + var f_ChapterName:String! + var f_TopicName:String! + var f_TestName:String! + var f_Id:String!// 标识字段,Guid标识 , + var f_DeleteMark:Bool = false // 删除标识,1-已删除 , + var f_CreatorTime:String!// 创建时间 , + var f_CreatorUserId:String!// 创建人员ID , + var f_LastModifyTime:String!// 最近一次编辑时间 , + var f_LastModifyUserId:String!//最近一次编辑人员 , + var f_DeleteTime:String!//删除时间 , + var f_DeleteUserId:String!// 删除人员 , + var f_Img :String!//课件图标/微课封面 , + var f_Title:String!//课件名称 , + var f_CreatorName:String!// 上传人员昵称 , + var f_Pv:Int!// 浏览量 , + var f_DownloadSum:Int!// 下载量 , + var f_LoveSum:Int!// 点赞量 , + var f_Price:Int!// 价格 , + var f_WaveId:String!// 所属教材ID , + var f_ChapterId:String!// 所属章节 , + var f_TopicId:String!//所属知识点 , + var f_TestId:String!//所属考点 , + var f_SchoolId:String!// 上传老师的学校ID , + var f_IsExamine:Int!// 审核状态:0-未审核,1-审核通过,2-审核不通过 , + var f_ExamineUserId :String!//审核人ID , + var f_ExamineName:String!//审核人姓名 , + var f_ExamineDatetime :String!// 审核日期 , + var f_ResourceType:Int!// 资源类型 0-微课 1-资源 2-电视台 , + var f_ResourceUrl:String!// 资源地址 , + var f_IsOpen:Bool = false // 是否公开 , + var f_Detail :String!// 资源简介 , + var f_TelevisionId :String!//电视台目录 + init(json:JSON){ + f_Url = json["f_Url"].stringValue + f_WaveTitle = json["f_WaveTitle"].stringValue + f_ChapterName = json["f_ChapterName"].stringValue + f_TopicName = json["f_TopicName"].stringValue + f_TestName = json["f_TestName"].stringValue + f_Id = json["f_Id"].stringValue + f_DeleteMark = json["f_DeleteMark"].boolValue + f_CreatorTime = json["f_CreatorTime"].stringValue + f_CreatorUserId = json["f_CreatorUserId"].stringValue + f_LastModifyTime = json["f_LastModifyTime"].stringValue + f_LastModifyUserId = json["f_LastModifyUserId"].stringValue + f_DeleteTime = json["f_DeleteTime"].stringValue + f_DeleteUserId = json["f_DeleteUserId"].stringValue + f_Img = json["f_Img"].stringValue + f_Title = json["f_Title"].stringValue + f_CreatorName = json["f_CreatorName"].stringValue + f_Pv = json["f_Pv"].intValue + f_DownloadSum = json["f_DownloadSum"].intValue + f_LoveSum = json["f_LoveSum"].intValue + f_Price = json["f_Price"].intValue + f_WaveId = json["f_WaveId"].stringValue + f_ChapterId = json["f_ChapterId"].stringValue + f_TopicId = json["f_TopicId"].stringValue + f_TestId = json["f_TestId"].stringValue + f_SchoolId = json["f_SchoolId"].stringValue + f_IsExamine = json["f_IsExamine"].intValue + f_ExamineUserId = json["f_ExamineUserId"].stringValue + f_ExamineName = json["f_ExamineName"].stringValue + f_ExamineDatetime = json["f_ExamineDatetime"].stringValue + f_ResourceType = json["f_ResourceType"].intValue + f_ResourceUrl = json["f_ResourceUrl"].stringValue + f_IsOpen = json["f_IsOpen"].boolValue + f_Detail = json["f_Detail"].stringValue + f_TelevisionId = json["f_TelevisionId"].stringValue + + } +} diff --git a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift index 9b48ca5..9783108 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift @@ -346,6 +346,39 @@ func resignTextFiledFirstResponder(){ firstView?.resignFirstResponder() } } + +///ISO8601相关 +private var iso8601Formatter:DateFormatter? +func dateFromISO8601(dateString:String)->Date{ + var dateFormatter:DateFormatter! + if let tmp=iso8601Formatter{ + dateFormatter=tmp + }else{ + iso8601Formatter = DateFormatter() + iso8601Formatter!.locale = Locale(identifier: "en_US_POSIX") + //iso8601Formatter!.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ" + //iso8601Formatter!.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SS" + dateFormatter=iso8601Formatter! + } + //不知道为什么服务器传回的时间有不同格式 + 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'"] + for item in arr { + iso8601Formatter!.dateFormat = item + let ret=dateFormatter.date(from: dateString) + if let date=ret{ + return date + } + } + + return Date(timeIntervalSince1970: 0) +} + +func setDateToString(date:Date)->String{ + let timeFormatter = DateFormatter() + timeFormatter.dateFormat = "yyyy-MM-dd" + return timeFormatter.string(from: date) +} + //时间处理 func currentTime()->String{ let format = creatDateFormate(dateFormat: "yyyy-MM-dd HH:mm:ss") -- libgit2 0.21.0