From aa410649316e0fd23f6f9e740d81c1f92abc6dfd Mon Sep 17 00:00:00 2001 From: 葛建军 Date: Fri, 19 May 2017 16:33:09 +0800 Subject: [PATCH] 教育视频云首页界面搭建及数据填充 --- YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj | 8 ++++---- YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json | 21 +++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg | Bin 0 -> 16434 bytes YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/Contents.json | 21 +++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/mologo.jpg | Bin 0 -> 18081 bytes YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard | 664 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------- YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePageViewController.swift | 62 -------------------------------------------------------------- YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift | 405 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift | 2 +- YouerLiveVideo/YouerLiveVideo/lib/Carousel/JYScrollBanner/JYScrollView.m | 2 +- YouerLiveVideo/YouerLiveVideo/util/account.swift | 16 ++++------------ YouerLiveVideo/YouerLiveVideo/util/utiles.swift | 9 ++++++++- 12 files changed, 1052 insertions(+), 158 deletions(-) create mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json create mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg create mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/Contents.json create mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/mologo.jpg delete mode 100644 YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePageViewController.swift create mode 100644 YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift diff --git a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj index facfff0..5cf2a95 100644 --- a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj +++ b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 5904FC511ECA8B8C00E631FF /* TVStationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5904FC4B1ECA8B8C00E631FF /* TVStationViewController.swift */; }; 5904FC531ECA8BB500E631FF /* MicroCourse.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5904FC521ECA8BB500E631FF /* MicroCourse.storyboard */; }; 5904FC551ECA8BCB00E631FF /* HomePage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5904FC541ECA8BCB00E631FF /* HomePage.storyboard */; }; - 5904FC5D1ECA8ED400E631FF /* HomePageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5904FC5C1ECA8ED400E631FF /* HomePageViewController.swift */; }; 5904FC611ECA930D00E631FF /* MViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5904FC601ECA930D00E631FF /* MViewController.swift */; }; 5960263B1DD94D3100C6B5E8 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 5960263A1DD94D3100C6B5E8 /* libsqlite3.tbd */; }; 5960263D1DD94D5E00C6B5E8 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 5960263C1DD94D5E00C6B5E8 /* libc++.tbd */; }; @@ -126,6 +125,7 @@ BF3E4A781E2F30B700D90659 /* 礼物数量.png in Resources */ = {isa = PBXBuildFile; fileRef = BF3E4A731E2F30B700D90659 /* 礼物数量.png */; }; BF3E4A791E2F30B700D90659 /* 上传封面.png in Resources */ = {isa = PBXBuildFile; fileRef = BF3E4A741E2F30B700D90659 /* 上传封面.png */; }; BF3E4A7A1E2F30B700D90659 /* 直播-最热.png in Resources */ = {isa = PBXBuildFile; fileRef = BF3E4A751E2F30B700D90659 /* 直播-最热.png */; }; + BF682F1E1ECE8772007632CA /* MainHomeTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF682F1D1ECE8772007632CA /* MainHomeTableViewController.swift */; }; BF6977871E2DC264006FA934 /* 我的充值.png in Resources */ = {isa = PBXBuildFile; fileRef = BF6977821E2DC264006FA934 /* 我的充值.png */; }; BF6977881E2DC264006FA934 /* 我的关注.png in Resources */ = {isa = PBXBuildFile; fileRef = BF6977831E2DC264006FA934 /* 我的关注.png */; }; BF69778A1E2DC264006FA934 /* 直播历史.png in Resources */ = {isa = PBXBuildFile; fileRef = BF6977851E2DC264006FA934 /* 直播历史.png */; }; @@ -217,7 +217,6 @@ 5904FC4B1ECA8B8C00E631FF /* TVStationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TVStationViewController.swift; sourceTree = ""; }; 5904FC521ECA8BB500E631FF /* MicroCourse.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MicroCourse.storyboard; sourceTree = ""; }; 5904FC541ECA8BCB00E631FF /* HomePage.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = HomePage.storyboard; sourceTree = ""; }; - 5904FC5C1ECA8ED400E631FF /* HomePageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomePageViewController.swift; sourceTree = ""; }; 5904FC601ECA930D00E631FF /* MViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MViewController.swift; sourceTree = ""; }; 5960263A1DD94D3100C6B5E8 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; 5960263C1DD94D5E00C6B5E8 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; @@ -440,6 +439,7 @@ BF3E4A731E2F30B700D90659 /* 礼物数量.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "礼物数量.png"; sourceTree = ""; }; BF3E4A741E2F30B700D90659 /* 上传封面.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "上传封面.png"; sourceTree = ""; }; BF3E4A751E2F30B700D90659 /* 直播-最热.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "直播-最热.png"; sourceTree = ""; }; + BF682F1D1ECE8772007632CA /* MainHomeTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainHomeTableViewController.swift; sourceTree = ""; }; BF6977821E2DC264006FA934 /* 我的充值.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "我的充值.png"; sourceTree = ""; }; BF6977831E2DC264006FA934 /* 我的关注.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "我的关注.png"; sourceTree = ""; }; BF6977851E2DC264006FA934 /* 直播历史.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "直播历史.png"; sourceTree = ""; }; @@ -591,7 +591,7 @@ 5904FC431ECA8B8C00E631FF /* HomePage */ = { isa = PBXGroup; children = ( - 5904FC5C1ECA8ED400E631FF /* HomePageViewController.swift */, + BF682F1D1ECE8772007632CA /* MainHomeTableViewController.swift */, 5904FC541ECA8BCB00E631FF /* HomePage.storyboard */, ); path = HomePage; @@ -1476,7 +1476,6 @@ 5904FC511ECA8B8C00E631FF /* TVStationViewController.swift in Sources */, BFBB83D31ECBEB4E008B404B /* JYScrollView.m in Sources */, BF25E0081DDAA36A003EC0C1 /* UIView+WebCache.m in Sources */, - 5904FC5D1ECA8ED400E631FF /* HomePageViewController.swift in Sources */, BFBB83A91ECAE35E008B404B /* LeadViewController.swift in Sources */, BF7B759C1E305A6D0011D5C7 /* MJRefreshAutoNormalFooter.m in Sources */, 5904FC4F1ECA8B8C00E631FF /* SearchTVStationListViewController.swift in Sources */, @@ -1501,6 +1500,7 @@ BF25DFF81DDAA36A003EC0C1 /* NSData+ImageContentType.m in Sources */, BF25E0151DDAAF73003EC0C1 /* SVIndefiniteAnimatedView.m in Sources */, BFF5F4921DD5B7CA00D33B89 /* SwiftyJSON.swift in Sources */, + BF682F1E1ECE8772007632CA /* MainHomeTableViewController.swift in Sources */, BF7B75A91E305A6D0011D5C7 /* UIView+MJExtension.m in Sources */, BF25DFEE1DDAA36A003EC0C1 /* Result.swift in Sources */, BFDFDED21DD55C0D0040F102 /* network.swift in Sources */, diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json new file mode 100644 index 0000000..42f885a --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "微课图标.jpg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg new file mode 100644 index 0000000..10be673 Binary files /dev/null and b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg differ diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/Contents.json b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/Contents.json new file mode 100644 index 0000000..828c35d --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "mologo.jpg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/mologo.jpg b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/mologo.jpg new file mode 100644 index 0000000..606452f Binary files /dev/null and b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_school_placeholder.imageset/mologo.jpg differ diff --git a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard index 084ab52..b995df4 100644 --- a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - - + + @@ -7,6 +7,7 @@ + @@ -50,7 +51,7 @@ - + @@ -106,6 +107,556 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -122,7 +673,7 @@ - + @@ -146,6 +697,12 @@ + + + + + + @@ -345,12 +902,6 @@ - - - - - - @@ -370,49 +921,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -429,7 +938,7 @@ - + @@ -440,30 +949,11 @@ - - - - - - - - - - - - - - - - - - - - + @@ -482,7 +972,7 @@ - + @@ -501,7 +991,7 @@ - + @@ -520,7 +1010,7 @@ - + @@ -643,6 +1133,25 @@ + + + + + + + + + + + + + + + + + + + @@ -653,5 +1162,6 @@ + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePageViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePageViewController.swift deleted file mode 100644 index 2652057..0000000 --- a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/HomePageViewController.swift +++ /dev/null @@ -1,62 +0,0 @@ -// -// HomePageViewController.swift -// YouerLiveVideo -// -// Created by 左丞 on 2017/5/16. -// Copyright © 2017年 左丞. All rights reserved. -// - -import UIKit - -class HomePageViewController: UIViewController { - @IBOutlet var jsScrollView: JYScrollView! - let current=AppDelegate.instance().accountManager - override func viewDidLoad() { - super.viewDidLoad() - settingIconAndTitle() - settingCarouselView() - } - //设置左上角头像及背景色等 - func settingIconAndTitle(){ - let photo=UIImageView(frame: CGRect(x: 0, y: 0, width: 35, height: 35)) - photo.sd_setImage(with: URL(string: current.photo()), placeholderImage: UIImage(named: "defphoto")) - photo.layer.cornerRadius=5 - photo.layer.masksToBounds=true - let leftBarButtonItem=UIBarButtonItem(customView: photo) - self.navigationItem.leftBarButtonItem=leftBarButtonItem - self.configTheme() - self.navigationController?.navigationBar.barStyle=UIBarStyle.black - } - //设置轮播图 - func settingCarouselView(){ - let jyScrollViews=JYScrollView(frame: CGRect(x: 0, y: 0, width: getScreenWidth(), height: getScreenWidth()/16*9)) - jyScrollViews.banner(with: ["http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1212/27/c0/16922592_1356570394404.jpg","http://p9.qhimg.com/t01665b2df63f2dc61b.jpg"], imageType: JYImageType.urlType, placeHolder: "default") { (index) in - NSLog("点击了轮播图click NO\(index)") - } - jyScrollViews.timeInterval=2 - self.view.addSubview(jyScrollViews) - } - //右上角搜索按钮点击方法 - @IBAction func rightBarButtonAction(_ sender: UIBarButtonItem) { - - } - override var preferredStatusBarStyle: UIStatusBarStyle{ - return UIStatusBarStyle.lightContent - } - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destinationViewController. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift new file mode 100644 index 0000000..2149d69 --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift @@ -0,0 +1,405 @@ +// +// MainHomeTableViewController.swift +// YouerLiveVideo +// +// Created by 葛建军 on 17/5/19. +// Copyright © 2017年 左丞. All rights reserved. +// + +import UIKit + +class MainHomeTableViewController: UITableViewController { + @IBOutlet var tableHeaderView: UIView! + let current=AppDelegate.instance().accountManager + override func viewDidLoad() { + super.viewDidLoad() + tableHeaderView.frame.size.height=getScreenWidth()/12*5 + settingIconAndTitle() + settingCarouselView() + } + //设置左上角头像及背景色等 + func settingIconAndTitle(){ + let photo=UIImageView(frame: CGRect(x: 0, y: 0, width: 35, height: 35)) + photo.sd_setImage(with: URL(string: current.photo()), placeholderImage: UIImage(named: "defphoto")) + photo.layer.cornerRadius=5 + photo.layer.masksToBounds=true + let leftBarButtonItem=UIBarButtonItem(customView: photo) + self.navigationItem.leftBarButtonItem=leftBarButtonItem + self.configTheme() + self.navigationController?.navigationBar.barStyle=UIBarStyle.black + } + //设置轮播图 + func settingCarouselView(){ + AppDelegate.instance().httpServer.getLunboList(parameters: ["type": 0 as AnyObject]) { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + var lineAry:[String]=[] + var lineModelAry:[InLineModel]=[] + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + lineModelAry.append(InLineModel(j: item)) + lineAry.append(item["f_Img"].stringValue) + } + if lineModelAry.count>0{ + let jyScrollViews=JYScrollView(frame: CGRect(x: 0, y: 0, width: getScreenWidth(), height: getScreenWidth()/12*5)) + jyScrollViews.banner(with: lineAry, imageType: JYImageType.urlType, placeHolder: "default") { (index) in + + NSLog("点击了轮播图 图片ID:\(lineModelAry[index].f_Id)") + } + jyScrollViews.timeInterval=2 + self.tableHeaderView.addSubview(jyScrollViews) + } + }, failHandler: { (error) in + self.view.makeToast("获取轮播图失败:\(error.localizedDescription)") + }) + }else{ + self.view.makeToast("获取轮播图失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + self.view.makeToast("获取轮播图失败:\(error!.description)") + } + } + } + //右上角搜索按钮点击方法 + @IBAction func rightBarButtonAction(_ sender: UIBarButtonItem) { + + } + + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + + // MARK: - Table view data source + + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 4 + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row==0 || indexPath.row==1{ + return (getScreenWidth()-16)/2+86 + }else if indexPath.row==2{ + return (getScreenWidth()-16)/3+103+86 + }else{ + return (getScreenWidth()-30)/3+30+86 + } + } + override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + return tableHeaderView + } + + /* + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.row==0{ + let cell = tableView.dequeueReusableCell(withIdentifier: "cell0", for: indexPath) as! HomeFirstTableViewCell + return cell + }else if indexPath.row==1{ + let cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) + return cell + }else if indexPath.row==2{ + let cell = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) + return cell + }else{ + let cell = tableView.dequeueReusableCell(withIdentifier: "cell3", for: indexPath) + return cell + } + } + */ + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + NSLog("点击了第\(indexPath.row)个cell") + } + + +} +class InLineModel: NSObject { + 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_Type:Int=0 //轮播图位置 0-视频云前端轮播图 1-校园电视台轮播图 + init(j:JSON) { + f_Id=j["f_Id"].stringValue + f_DeleteMark=j["f_DeleteMark"].boolValue + f_CreatorTime=j["f_CreatorTime"].stringValue + f_CreatorUserId=j["f_CreatorUserId"].stringValue + f_LastModifyTime=j["f_LastModifyTime"].stringValue + f_LastModifyUserId=j["f_LastModifyUserId"].stringValue + f_DeleteTime=j["f_DeleteTime"].stringValue + f_DeleteUserId=j["f_DeleteUserId"].stringValue + f_Img=j["f_Img"].stringValue + f_Type=j["f_Type"].intValue + } +} +class HomeFirstTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + if indexPath.row==0{ + //点击进入学校 appRootViewController() + }else{ + //点击进入教师 + } + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: (getScreenWidth()-16)/2, height: (getScreenWidth()-16)/2) + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 2 + } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell=collectionView.dequeueReusableCell(withReuseIdentifier: "HomeFirstCollectionViewCell", for: indexPath) as! HomeFirstCollectionViewCell + if indexPath.row==0{ + cell.nameLabel.text="学校" + }else{ + cell.nameLabel.text="教师" + } + return cell + } +} +class HomeFirstCollectionViewCell: UICollectionViewCell { + @IBOutlet var nameLabel: UILabel! + @IBOutlet var iconImageView: UIImageView! +} +class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource { + var dataSet:[MicroCourseModel]=[] + override func awakeFromNib() { + super.awakeFromNib() + getHotCourseList() + } + //获取热门微课前两门 + func getHotCourseList(){ + let parameters:Dictionary=["type":0 as AnyObject,"pageIndex":0 as AnyObject,"pageSize":2 as AnyObject] + AppDelegate.instance().httpServer.getHotRescourse(parameters: parameters) { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + self.dataSet.removeAll() + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + self.dataSet.append(MicroCourseModel(j: item)) + } + (self.viewWithTag(1) as! UICollectionView).reloadData() + }, failHandler: { (error) in + appRootViewController().view.makeToast("获取热门微课失败:\(error.localizedDescription)") + }) + }else{ + appRootViewController().view.makeToast("获取热门微课失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + appRootViewController().view.makeToast("获取热门微课失败:\(error!.description)") + } + } + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + //点击进入学校 appRootViewController() + NSLog("点击了****\(dataSet[indexPath.row])") + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: (getScreenWidth()-16)/2, height: (getScreenWidth()-16)/2) + } + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return dataSet.count + } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell=collectionView.dequeueReusableCell(withReuseIdentifier: "HomeSecondCollectionViewCell", for: indexPath) as! HomeSecondCollectionViewCell + cell.setUpWithItem(item: dataSet[indexPath.row]) + return cell + } +} +//MARK: - 排行model +class MicroCourseModel:NSObject { + 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=0 //浏览量 + var f_DownloadSum:Int=0 //下载量 + var f_LoveSum:Int=0 //点赞量 + var f_Price:Int=0 //价格 + 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 //审核状态:0-未审核,1-审核通过,2-审核不通过 + var f_ExamineUserId:String="" //审核人ID + var f_ExamineName:String="" //审核人姓名 + var f_ExamineDatetime:String="" //审核日期 + var f_ResourceType:Int=0 //资源类型 0-微课 1-资源 2-电视台 + var f_ResourceUrl:String="" //资源地址 + var f_IsOpen:Bool=false //是否公开 + var f_Detail:String="" //资源简介 + var f_TelevisionId:String="" //电视台目录 + init(j:JSON) { + f_Id=j["f_Id"].stringValue + f_DeleteMark=j["f_DeleteMark"].boolValue + f_CreatorTime=j["f_CreatorTime"].stringValue + f_CreatorUserId=j["f_CreatorUserId"].stringValue + f_LastModifyTime=j["f_LastModifyTime"].stringValue + f_LastModifyUserId=j["f_LastModifyUserId"].stringValue + f_DeleteTime=j["f_DeleteTime"].stringValue + f_DeleteUserId=j["f_DeleteUserId"].stringValue + f_Img=j["f_Img"].stringValue + f_Title=j["f_Title"].stringValue + f_CreatorName=j["f_CreatorName"].stringValue + f_Pv=j["f_Pv"].intValue + f_DownloadSum=j["f_DownloadSum"].intValue + f_LoveSum=j["f_LoveSum"].intValue + f_Price=j["f_Price"].intValue + f_WaveId=j["f_WaveId"].stringValue + f_ChapterId=j["f_ChapterId"].stringValue + f_TopicId=j["f_TopicId"].stringValue + f_TestId=j["f_TestId"].stringValue + f_SchoolId=j["f_SchoolId"].stringValue + f_IsExamine=j["f_IsExamine"].intValue + f_ExamineUserId=j["f_ExamineUserId"].stringValue + f_ExamineName=j["f_ExamineName"].stringValue + f_ExamineDatetime=j["f_ExamineDatetime"].stringValue + f_ResourceType=j["f_ResourceType"].intValue + f_ResourceUrl=j["f_ResourceUrl"].stringValue + f_IsOpen=j["f_IsOpen"].boolValue + f_Detail=j["f_Detail"].stringValue + f_TelevisionId=j["f_TelevisionId"].stringValue + } +} +class HomeSecondCollectionViewCell: UICollectionViewCell { + @IBOutlet var iconImageView: UIImageView! + @IBOutlet var nameLabel: UILabel! + @IBOutlet var teacherNameLabel: UILabel! + @IBOutlet var dateLabel: UILabel! + @IBOutlet var readCountLabel: UILabel! + func setUpWithItem(item:MicroCourseModel){ + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) + nameLabel.text=item.f_Title + teacherNameLabel.text="主讲师:\(item.f_CreatorName) 老师" + dateLabel.text=item.f_CreatorTime + readCountLabel.text="\(item.f_Pv)" + } +} +class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource { + var dataSet:[MicroCourseModel]=[] + override func awakeFromNib() { + super.awakeFromNib() + getHotCourseList() + } + //获取资源前三门 + func getHotCourseList(){ + let parameters:Dictionary=["type":1 as AnyObject,"pageIndex":0 as AnyObject,"pageSize":3 as AnyObject] + AppDelegate.instance().httpServer.getHotRescourse(parameters: parameters) { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + self.dataSet.removeAll() + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + self.dataSet.append(MicroCourseModel(j: item)) + } + (self.viewWithTag(1) as! UICollectionView).reloadData() + }, failHandler: { (error) in + appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)") + }) + }else{ + appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + appRootViewController().view.makeToast("获取资源失败:\(error!.description)") + } + } + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + //点击进入学校 appRootViewController() + NSLog("点击了****\(dataSet[indexPath.row])") + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: (getScreenWidth()-16)/3, height: (getScreenWidth()-16)/3+103) + } + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return dataSet.count + } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell=collectionView.dequeueReusableCell(withReuseIdentifier: "HomeThirdCollectionViewCell", for: indexPath) as! HomeThirdCollectionViewCell + cell.setUpWithItem(item: dataSet[indexPath.row]) + return cell + } +} +class HomeThirdCollectionViewCell: UICollectionViewCell { + @IBOutlet var iconImageView: UIImageView! + @IBOutlet var nameLabel: UILabel! + @IBOutlet var teacherNameLabel: UILabel! + @IBOutlet var dateLabel: UILabel! + @IBOutlet var readCountLabel: UILabel! + func setUpWithItem(item:MicroCourseModel){ + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) + nameLabel.text=item.f_Title + teacherNameLabel.text="上传者:\(item.f_CreatorName) 老师" + dateLabel.text=item.f_CreatorTime + readCountLabel.text="\(item.f_DownloadSum)" + } +} +class HomeFourTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource { + var dataSet:[MicroCourseModel]=[] + override func awakeFromNib() { + super.awakeFromNib() + getHotCourseList() + } + //获取校园电视台前三门 + func getHotCourseList(){ + let parameters:Dictionary=["type":2 as AnyObject,"pageIndex":0 as AnyObject,"pageSize":3 as AnyObject] + AppDelegate.instance().httpServer.getHotRescourse(parameters: parameters) { (str, error) in + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + self.dataSet.removeAll() + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + self.dataSet.append(MicroCourseModel(j: item)) + } + (self.viewWithTag(1) as! UICollectionView).reloadData() + }, failHandler: { (error) in + appRootViewController().view.makeToast("获取校园电视台失败:\(error.localizedDescription)") + }) + }else{ + appRootViewController().view.makeToast("获取校园电视台失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + appRootViewController().view.makeToast("获取校园电视台失败:\(error!.description)") + } + } + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + //点击进入学校 appRootViewController() + NSLog("点击了****\(dataSet[indexPath.row])") + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: (getScreenWidth()-32)/3, height: (getScreenWidth()-32)/3+30) + } + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return dataSet.count + } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell=collectionView.dequeueReusableCell(withReuseIdentifier: "HomeFourCollectionViewCell", for: indexPath) as! HomeFourCollectionViewCell + cell.setUpWithItem(item: dataSet[indexPath.row]) + return cell + } +} +class HomeFourCollectionViewCell: UICollectionViewCell { + @IBOutlet var iconImageView: UIImageView! + @IBOutlet var nameLabel: UILabel! + func setUpWithItem(item:MicroCourseModel){ + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) + nameLabel.text=item.f_Title + } +} + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift index db52c6c..c538a7e 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/MViewController.swift @@ -11,7 +11,7 @@ import UIKit class MViewController: UITabBarController { override class func initialize() { var attrs = [String: NSObject]() - attrs[NSForegroundColorAttributeName] = UIColor(red: 23/255.0, green: 70/255.0, blue: 151/255.0, alpha:1.0) + attrs[NSForegroundColorAttributeName] = Theme.topBarColor() // 设置tabBar字体颜色 UITabBarItem.appearance().setTitleTextAttributes(attrs, for:.selected) } diff --git a/YouerLiveVideo/YouerLiveVideo/lib/Carousel/JYScrollBanner/JYScrollView.m b/YouerLiveVideo/YouerLiveVideo/lib/Carousel/JYScrollBanner/JYScrollView.m index f7b6bbc..3355e8c 100644 --- a/YouerLiveVideo/YouerLiveVideo/lib/Carousel/JYScrollBanner/JYScrollView.m +++ b/YouerLiveVideo/YouerLiveVideo/lib/Carousel/JYScrollBanner/JYScrollView.m @@ -123,7 +123,7 @@ pageControl.hidesForSinglePage = YES; pageControl.numberOfPages = 1; pageControl.currentPage = 0; - pageControl.pageIndicatorTintColor = [UIColor blackColor]; + pageControl.pageIndicatorTintColor = [UIColor lightGrayColor]; pageControl.currentPageIndicatorTintColor = [UIColor whiteColor]; pageControl.userInteractionEnabled = NO; [self addSubview:pageControl]; diff --git a/YouerLiveVideo/YouerLiveVideo/util/account.swift b/YouerLiveVideo/YouerLiveVideo/util/account.swift index 18c1952..b99436a 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/account.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/account.swift @@ -85,11 +85,11 @@ class AccountManager{ rawUserInfo=nil userid="" _=Setting.saveUserInfo("") - if self.appRootViewController().classForCoder==UINavigationController.classForCoder(){ - (self.appRootViewController() as! UINavigationController).popToRootViewController(animated: false) + if appRootViewController().classForCoder==UINavigationController.classForCoder(){ + (appRootViewController() as! UINavigationController).popToRootViewController(animated: false) }else{ - self.appRootViewController().dismiss(animated: false, completion: { - (self.appRootViewController() as! UINavigationController).popToRootViewController(animated: true) + appRootViewController().dismiss(animated: false, completion: { + (appRootViewController() as! UINavigationController).popToRootViewController(animated: true) }) } //发出刷新首页通知 @@ -97,14 +97,6 @@ class AccountManager{ LeadViewController.instance.removeAll() LeadViewController.instance.showLogin() } - func appRootViewController()->UIViewController { - let appRootVC=UIApplication.shared.keyWindow?.rootViewController - var topVC=appRootVC - while topVC!.presentedViewController != nil { - topVC=topVC!.presentedViewController - } - return topVC! - } func refreshUserInfo(completionHandler:((Bool) -> Void)?){ AppDelegate.instance().httpServer.getCurrentInfo { (str, error) -> Void in if error == nil { diff --git a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift index 9783108..9a39733 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift @@ -106,7 +106,14 @@ class Story{ return Story.getStory(sname)?.instantiateViewController(withIdentifier: sid) } } - +func appRootViewController()->UIViewController { + let appRootVC=UIApplication.shared.keyWindow?.rootViewController + var topVC=appRootVC + while topVC!.presentedViewController != nil { + topVC=topVC!.presentedViewController + } + return topVC! +} extension AppDelegate{ static func instance()->AppDelegate{ -- libgit2 0.21.0