Commit 226b549c1f63b8b26210944eae34f25949ea794d

Authored by 左丞
2 parents 1914bba1 2843d18b
Exists in newLive

Merge branch 'newLive' of http://git.shunzhi.net/iosgroup/newlive into newLive

Showing 18 changed files with 208 additions and 89 deletions   Show diff stats
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/Contents.json
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -{  
2 - "images" : [  
3 - {  
4 - "idiom" : "universal",  
5 - "scale" : "1x"  
6 - },  
7 - {  
8 - "idiom" : "universal",  
9 - "filename" : "微课图标.jpg",  
10 - "scale" : "2x"  
11 - },  
12 - {  
13 - "idiom" : "universal",  
14 - "scale" : "3x"  
15 - }  
16 - ],  
17 - "info" : {  
18 - "version" : 1,  
19 - "author" : "xcode"  
20 - }  
21 -}  
22 \ No newline at end of file 0 \ No newline at end of file
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/icon_course_placeholder.imageset/微课图标.jpg

16 KB

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

17.7 KB

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

16 KB

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

17.7 KB

YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq"> 1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq">
3 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
@@ -423,7 +423,7 @@ @@ -423,7 +423,7 @@
423 <rect key="frame" x="0.0" y="0.0" width="207" height="193"/> 423 <rect key="frame" x="0.0" y="0.0" width="207" height="193"/>
424 <autoresizingMask key="autoresizingMask"/> 424 <autoresizingMask key="autoresizingMask"/>
425 <subviews> 425 <subviews>
426 - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="5g9-CD-vXa"> 426 + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="microCourse_default" translatesAutoresizingMaskIntoConstraints="NO" id="5g9-CD-vXa">
427 <rect key="frame" x="0.0" y="0.0" width="207" height="93.5"/> 427 <rect key="frame" x="0.0" y="0.0" width="207" height="93.5"/>
428 <userDefinedRuntimeAttributes> 428 <userDefinedRuntimeAttributes>
429 <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/> 429 <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
@@ -1476,7 +1476,7 @@ @@ -1476,7 +1476,7 @@
1476 <rect key="frame" x="0.0" y="0.0" width="375" height="139"/> 1476 <rect key="frame" x="0.0" y="0.0" width="375" height="139"/>
1477 <autoresizingMask key="autoresizingMask"/> 1477 <autoresizingMask key="autoresizingMask"/>
1478 <subviews> 1478 <subviews>
1479 - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="qia-pR-e6p"> 1479 + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="microCourse_default" translatesAutoresizingMaskIntoConstraints="NO" id="qia-pR-e6p">
1480 <rect key="frame" x="8" y="24" width="90" height="90"/> 1480 <rect key="frame" x="8" y="24" width="90" height="90"/>
1481 <constraints> 1481 <constraints>
1482 <constraint firstAttribute="width" secondItem="qia-pR-e6p" secondAttribute="height" multiplier="1:1" id="6Zi-MO-Pqe"/> 1482 <constraint firstAttribute="width" secondItem="qia-pR-e6p" secondAttribute="height" multiplier="1:1" id="6Zi-MO-Pqe"/>
@@ -1663,6 +1663,7 @@ @@ -1663,6 +1663,7 @@
1663 <image name="icon_tvstation" width="25" height="25"/> 1663 <image name="icon_tvstation" width="25" height="25"/>
1664 <image name="icon_user" width="25" height="25"/> 1664 <image name="icon_user" width="25" height="25"/>
1665 <image name="icon_watchcount" width="12" height="7"/> 1665 <image name="icon_watchcount" width="12" height="7"/>
  1666 + <image name="microCourse_default" width="100" height="100"/>
1666 <image name="starLive" width="30" height="30"/> 1667 <image name="starLive" width="30" height="30"/>
1667 <image name="视窗.png" width="31" height="31"/> 1668 <image name="视窗.png" width="31" height="31"/>
1668 </resources> 1669 </resources>
YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift
@@ -10,20 +10,30 @@ import UIKit @@ -10,20 +10,30 @@ import UIKit
10 import AVKit 10 import AVKit
11 class MainHomeTableViewController: UITableViewController { 11 class MainHomeTableViewController: UITableViewController {
12 @IBOutlet var tableHeaderView: UIView! 12 @IBOutlet var tableHeaderView: UIView!
13 - let current=AppDelegate.instance().accountManager 13 + var user = AppDelegate.instance().accountManager
  14 + var photo:UIImageView!
14 override func viewDidLoad() { 15 override func viewDidLoad() {
15 super.viewDidLoad() 16 super.viewDidLoad()
16 tableHeaderView.frame.size.height=getScreenWidth()/12*5 17 tableHeaderView.frame.size.height=getScreenWidth()/12*5
17 settingIconAndTitle() 18 settingIconAndTitle()
18 settingCarouselView() 19 settingCarouselView()
  20 + //更新头像
  21 + NotificationCenter.default.addObserver(self, selector: #selector(MainHomeTableViewController.setUserInfor), name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil)
  22 + }
  23 + func setUserInfor(){
  24 + photo.sd_setImage(with: URL(string: user.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png"))
19 } 25 }
20 //设置左上角头像及背景色等 26 //设置左上角头像及背景色等
21 func settingIconAndTitle(){ 27 func settingIconAndTitle(){
22 - let photo=UIImageView(frame: CGRect(x: 0, y: 0, width: 35, height: 35))  
23 - photo.sd_setImage(with: URL(string: current.photo()), placeholderImage: UIImage(named: "defphoto")) 28 + photo=UIImageView(frame: CGRect(x: 0, y: 0, width: 35, height: 35))
  29 + photo.sd_setImage(with: URL(string: user.photo()), placeholderImage: UIImage(named: "defphoto"))
24 photo.layer.cornerRadius=35/2 30 photo.layer.cornerRadius=35/2
25 photo.layer.masksToBounds=true 31 photo.layer.masksToBounds=true
26 - let leftBarButtonItem=UIBarButtonItem(customView: photo) 32 + let btn=UIButton(type: UIButtonType.custom)
  33 + btn.frame=CGRect(x: 0, y: 0, width: 35, height: 35)
  34 + btn.addTarget(self, action: #selector(MainHomeTableViewController.userInfo), for: UIControlEvents.touchUpInside)
  35 + btn.addSubview(photo)
  36 + let leftBarButtonItem=UIBarButtonItem(customView: btn)
27 self.navigationItem.leftBarButtonItem=leftBarButtonItem 37 self.navigationItem.leftBarButtonItem=leftBarButtonItem
28 self.configTheme() 38 self.configTheme()
29 self.navigationController?.navigationBar.barStyle=UIBarStyle.black 39 self.navigationController?.navigationBar.barStyle=UIBarStyle.black
@@ -60,8 +70,17 @@ class MainHomeTableViewController: UITableViewController { @@ -60,8 +70,17 @@ class MainHomeTableViewController: UITableViewController {
60 } 70 }
61 } 71 }
62 } 72 }
63 -  
64 - 73 + //点击头像 跳转
  74 + func userInfo(){
  75 + if user.isOnline(){
  76 + let vc = Story.instantiateViewControllerWithIdentifier("UserEditViewControllerVC", storyName: "User") as! UserEditViewController
  77 + vc.title = "个人信息"
  78 + self.navigationController?.pushViewController(vc, animated: true)
  79 + }else{
  80 + let vc=Story.instantiateViewControllerWithIdentifier("NewLoginViewControllerVC", storyName: "Login") as! NewLoginViewController
  81 + self.navigationController?.pushViewController(vc, animated: true)
  82 + }
  83 + }
65 override func didReceiveMemoryWarning() { 84 override func didReceiveMemoryWarning() {
66 super.didReceiveMemoryWarning() 85 super.didReceiveMemoryWarning()
67 } 86 }
@@ -225,11 +244,24 @@ class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollec @@ -225,11 +244,24 @@ class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollec
225 } 244 }
226 } 245 }
227 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 246 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
228 - let url = URL(string:dataSet[indexPath.row].f_ResourceUrl) 247 + let item=dataSet[indexPath.row]
  248 + let url = URL(string:item.f_ResourceUrl)
229 let player = AVPlayerViewController() 249 let player = AVPlayerViewController()
230 player.player = AVPlayer(url: url!) 250 player.player = AVPlayer(url: url!)
231 player.videoGravity = AVLayerVideoGravityResizeAspect 251 player.videoGravity = AVLayerVideoGravityResizeAspect
232 appRootViewController().present(player, animated: true, completion: nil) 252 appRootViewController().present(player, animated: true, completion: nil)
  253 + AppDelegate.instance().httpServer.updatePv(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in
  254 + if error==nil {
  255 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  256 + //更新阅读量成功刷新页面
  257 + self.getHotCourseList()
  258 + }
  259 + }
  260 + }
  261 + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":0 as AnyObject,
  262 + "f_ViewId":item.f_Id as AnyObject,
  263 + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in
  264 + }
233 } 265 }
234 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 266 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
235 return CGSize(width: (getScreenWidth()-45)/2, height: ((getScreenWidth()-45)/2/33*16+67)) 267 return CGSize(width: (getScreenWidth()-45)/2, height: ((getScreenWidth()-45)/2/33*16+67))
@@ -313,9 +345,9 @@ class HomeSecondCollectionViewCell: UICollectionViewCell { @@ -313,9 +345,9 @@ class HomeSecondCollectionViewCell: UICollectionViewCell {
313 @IBOutlet var dateLabel: UILabel! 345 @IBOutlet var dateLabel: UILabel!
314 @IBOutlet var readCountLabel: UILabel! 346 @IBOutlet var readCountLabel: UILabel!
315 func setUpWithItem(item:MicroCourseModel){ 347 func setUpWithItem(item:MicroCourseModel){
316 - iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) 348 + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "microCourse_default"))
317 nameLabel.text=item.f_Title 349 nameLabel.text=item.f_Title
318 - teacherNameLabel.text="主讲师:\(item.f_CreatorName) 老师" 350 + teacherNameLabel.text="主讲师:\(item.f_CreatorName)"
319 dateLabel.text=item.f_CreatorTime 351 dateLabel.text=item.f_CreatorTime
320 readCountLabel.text="\(item.f_Pv)" 352 readCountLabel.text="\(item.f_Pv)"
321 } 353 }
@@ -353,9 +385,22 @@ class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollect @@ -353,9 +385,22 @@ class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollect
353 let user=AppDelegate.instance().accountManager 385 let user=AppDelegate.instance().accountManager
354 //点击下载并打开资源文档 386 //点击下载并打开资源文档
355 if user.isOnline() && (user.roletype()==1 || user.roletype()==2 || user.roletype()==6){ 387 if user.isOnline() && (user.roletype()==1 || user.roletype()==2 || user.roletype()==6){
  388 + let item=dataSet[indexPath.row]
356 let download = DownLoad.share 389 let download = DownLoad.share
357 download.superVC = ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).viewControllers[0] 390 download.superVC = ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).viewControllers[0]
358 download.downLoadWithUrl(url: dataSet[indexPath.row].f_ResourceUrl) 391 download.downLoadWithUrl(url: dataSet[indexPath.row].f_ResourceUrl)
  392 + AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in
  393 + if error==nil {
  394 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  395 + //更新下载量成功刷新页面
  396 + self.getHotCourseList()
  397 + }
  398 + }
  399 + }
  400 + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject,
  401 + "f_ViewId":item.f_Id as AnyObject,
  402 + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in
  403 + }
359 }else{ 404 }else{
360 AppDelegate.instance().window?.makeToast("无权限查看资源") 405 AppDelegate.instance().window?.makeToast("无权限查看资源")
361 } 406 }
@@ -379,9 +424,9 @@ class HomeThirdCollectionViewCell: UICollectionViewCell { @@ -379,9 +424,9 @@ class HomeThirdCollectionViewCell: UICollectionViewCell {
379 @IBOutlet var dateLabel: UILabel! 424 @IBOutlet var dateLabel: UILabel!
380 @IBOutlet var readCountLabel: UILabel! 425 @IBOutlet var readCountLabel: UILabel!
381 func setUpWithItem(item:MicroCourseModel){ 426 func setUpWithItem(item:MicroCourseModel){
382 - iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) 427 + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "microCourse_default"))
383 nameLabel.text=item.f_Title 428 nameLabel.text=item.f_Title
384 - teacherNameLabel.text="上传者:\(item.f_CreatorName) 老师" 429 + teacherNameLabel.text="上传者:\(item.f_CreatorName)"
385 dateLabel.text=item.f_CreatorTime 430 dateLabel.text=item.f_CreatorTime
386 readCountLabel.text="\(item.f_DownloadSum)" 431 readCountLabel.text="\(item.f_DownloadSum)"
387 } 432 }
@@ -416,16 +461,21 @@ class HomeFourTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollecti @@ -416,16 +461,21 @@ class HomeFourTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollecti
416 } 461 }
417 } 462 }
418 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 463 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
419 - //点击进入学校 appRootViewController() 464 + //点击进入校园电视台
  465 + let item=dataSet[indexPath.row]
420 let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController 466 let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController
421 if collectionView.tag == 1{ 467 if collectionView.tag == 1{
422 - vc.TVStationProgram = TVStationInfor(item: dataSet[indexPath.row])  
423 - vc.title = dataSet[indexPath.row].f_Title 468 + vc.TVStationProgram = TVStationInfor(item: item)
  469 + vc.title = item.f_Title
424 }else if collectionView.tag == 3{ 470 }else if collectionView.tag == 3{
425 - vc.title = dataSet[indexPath.row].f_Title  
426 - vc.excellentTVStationProgram = TVStationSubject(item: dataSet[indexPath.row]) 471 + vc.title = item.f_Title
  472 + vc.excellentTVStationProgram = TVStationSubject(item: item)
427 } 473 }
428 ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).pushViewController(vc, animated: true) 474 ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).pushViewController(vc, animated: true)
  475 + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":2 as AnyObject,
  476 + "f_ViewId":item.f_Id as AnyObject,
  477 + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in
  478 + }
429 } 479 }
430 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 480 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
431 return CGSize(width: (getScreenWidth()-40)/3, height: (getScreenWidth()-40)/3+30) 481 return CGSize(width: (getScreenWidth()-40)/3, height: (getScreenWidth()-40)/3+30)
@@ -443,7 +493,7 @@ class HomeFourCollectionViewCell: UICollectionViewCell { @@ -443,7 +493,7 @@ class HomeFourCollectionViewCell: UICollectionViewCell {
443 @IBOutlet var iconImageView: UIImageView! 493 @IBOutlet var iconImageView: UIImageView!
444 @IBOutlet var nameLabel: UILabel! 494 @IBOutlet var nameLabel: UILabel!
445 func setUpWithItem(item:MicroCourseModel){ 495 func setUpWithItem(item:MicroCourseModel){
446 - iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) 496 + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "microCourse_default"))
447 nameLabel.text=item.f_Title 497 nameLabel.text=item.f_Title
448 } 498 }
449 } 499 }
YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift
@@ -75,6 +75,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie @@ -75,6 +75,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
75 self.resourceData.removeAll() 75 self.resourceData.removeAll()
76 var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] 76 var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
77 if self.parameter != nil { 77 if self.parameter != nil {
  78 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
78 p=self.parameter! 79 p=self.parameter!
79 } 80 }
80 self.refreshLivesAction(parameters: p, completionHandler: { (success) in 81 self.refreshLivesAction(parameters: p, completionHandler: { (success) in
@@ -90,6 +91,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie @@ -90,6 +91,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
90 //上拉加载更多 91 //上拉加载更多
91 var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] 92 var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
92 if self.parameter != nil { 93 if self.parameter != nil {
  94 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
93 p=self.parameter! 95 p=self.parameter!
94 } 96 }
95 self.refreshLivesAction(parameters: p, completionHandler: { (success) in 97 self.refreshLivesAction(parameters: p, completionHandler: { (success) in
@@ -164,18 +166,39 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie @@ -164,18 +166,39 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie
164 // let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController 166 // let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController
165 // vc.item=item 167 // vc.item=item
166 // self.superVC.navigationController!.pushViewController(vc, animated: true) 168 // self.superVC.navigationController!.pushViewController(vc, animated: true)
  169 + var item:MicroCourseModel!
167 if tableView==searchTableView { 170 if tableView==searchTableView {
168 - let url = URL(string:searchAry[indexPath.row].f_ResourceUrl)  
169 - let player = AVPlayerViewController()  
170 - player.player = AVPlayer(url: url!)  
171 - player.videoGravity = AVLayerVideoGravityResizeAspect  
172 - self.present(player, animated: true, completion: nil) 171 + item=searchAry[indexPath.row]
173 }else{ 172 }else{
174 - let url = URL(string:resourceData[indexPath.row].f_ResourceUrl)  
175 - let player = AVPlayerViewController()  
176 - player.player = AVPlayer(url: url!)  
177 - player.videoGravity = AVLayerVideoGravityResizeAspect  
178 - self.present(player, animated: true, completion: nil) 173 + item=resourceData[indexPath.row]
  174 + }
  175 + let url = URL(string:item.f_ResourceUrl)
  176 + let player = AVPlayerViewController()
  177 + player.player = AVPlayer(url: url!)
  178 + player.videoGravity = AVLayerVideoGravityResizeAspect
  179 + self.present(player, animated: true, completion: nil)
  180 + AppDelegate.instance().httpServer.updatePv(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in
  181 + if error==nil {
  182 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  183 + //更新阅读量成功刷新页面
  184 + self.currentPage=1
  185 + self.resourceData.removeAll()
  186 + var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  187 + if self.parameter != nil {
  188 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
  189 + p=self.parameter!
  190 + }
  191 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
  192 + if success{
  193 + self.tableView.reloadData()
  194 + }
  195 + })
  196 + }
  197 + }
  198 + }
  199 + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":0 as AnyObject,
  200 + "f_ViewId":item.f_Id as AnyObject,
  201 + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in
179 } 202 }
180 } 203 }
181 //取消键盘输入状态 204 //取消键盘输入状态
@@ -237,11 +260,11 @@ class MicroCourseViewControllerTableViewCell:UITableViewCell{ @@ -237,11 +260,11 @@ class MicroCourseViewControllerTableViewCell:UITableViewCell{
237 var superVC:MicroCourseViewController! 260 var superVC:MicroCourseViewController!
238 func setUpWith(item: MicroCourseModel){ 261 func setUpWith(item: MicroCourseModel){
239 self.item=item 262 self.item=item
240 - iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) 263 + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "microCourse_default"))
241 titleLabel.text=item.f_Title 264 titleLabel.text=item.f_Title
242 - updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师" 265 + updateTeacherLabel.text="主讲师:\(item.f_CreatorName)"
243 timeLabel.text=setDateToString(date:dateFromISO8601(dateString: item.f_CreatorTime)) 266 timeLabel.text=setDateToString(date:dateFromISO8601(dateString: item.f_CreatorTime))
244 - downLoadCountLabel.text="\(item.f_DownloadSum)" 267 + downLoadCountLabel.text="\(item.f_Pv)"
245 } 268 }
246 @IBAction func pushDetailVC(_ sender: UIButton) { 269 @IBAction func pushDetailVC(_ sender: UIButton) {
247 // let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController 270 // let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController
YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift
@@ -75,6 +75,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa @@ -75,6 +75,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
75 self.resourceData.removeAll() 75 self.resourceData.removeAll()
76 var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] 76 var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
77 if self.parameter != nil { 77 if self.parameter != nil {
  78 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
78 p=self.parameter! 79 p=self.parameter!
79 } 80 }
80 self.refreshLivesAction(parameters: p, completionHandler: { (success) in 81 self.refreshLivesAction(parameters: p, completionHandler: { (success) in
@@ -90,6 +91,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa @@ -90,6 +91,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
90 //上拉加载更多 91 //上拉加载更多
91 var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] 92 var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
92 if self.parameter != nil { 93 if self.parameter != nil {
  94 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
93 p=self.parameter! 95 p=self.parameter!
94 } 96 }
95 self.refreshLivesAction(parameters: p, completionHandler: { (success) in 97 self.refreshLivesAction(parameters: p, completionHandler: { (success) in
@@ -161,13 +163,37 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa @@ -161,13 +163,37 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa
161 } 163 }
162 } 164 }
163 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 165 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  166 + var item:MicroCourseModel!
164 if tableView==searchTableView { 167 if tableView==searchTableView {
165 - let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController  
166 - self.navigationController?.pushViewController(vc, animated: true) 168 + item=searchAry[indexPath.row]
167 }else{ 169 }else{
168 - let download = DownLoad.share  
169 - download.superVC = self  
170 - download.downLoadWithUrl(url: resourceData[indexPath.row].f_ResourceUrl) 170 + item=resourceData[indexPath.row]
  171 + }
  172 + let download = DownLoad.share
  173 + download.superVC = self
  174 + download.downLoadWithUrl(url: item.f_ResourceUrl)
  175 + AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in
  176 + if error==nil {
  177 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  178 + //更新下载量成功刷新页面
  179 + self.currentPage=1
  180 + self.resourceData.removeAll()
  181 + var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject]
  182 + if self.parameter != nil {
  183 + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex")
  184 + p=self.parameter!
  185 + }
  186 + self.refreshLivesAction(parameters: p, completionHandler: { (success) in
  187 + if success{
  188 + self.tableView.reloadData()
  189 + }
  190 + })
  191 + }
  192 + }
  193 + }
  194 + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject,
  195 + "f_ViewId":item.f_Id as AnyObject,
  196 + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in
171 } 197 }
172 } 198 }
173 //取消键盘输入状态 199 //取消键盘输入状态
@@ -247,7 +273,7 @@ class ResourceViewControllerTableViewCell:UITableViewCell{ @@ -247,7 +273,7 @@ class ResourceViewControllerTableViewCell:UITableViewCell{
247 func setUpWith(item: MicroCourseModel){ 273 func setUpWith(item: MicroCourseModel){
248 iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) 274 iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder"))
249 titleLabel.text=item.f_Title 275 titleLabel.text=item.f_Title
250 - updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师" 276 + updateTeacherLabel.text="上传者:\(item.f_CreatorName)"
251 timeLabel.text=setDateToString(date:dateFromISO8601(dateString: item.f_CreatorTime)) 277 timeLabel.text=setDateToString(date:dateFromISO8601(dateString: item.f_CreatorTime))
252 downLoadCountLabel.text="\(item.f_DownloadSum)" 278 downLoadCountLabel.text="\(item.f_DownloadSum)"
253 } 279 }
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/NewLoginViewController.swift
@@ -19,17 +19,17 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -19,17 +19,17 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
19 constraintContentOffset.constant=20 19 constraintContentOffset.constant=20
20 view.backgroundColor=UIColorFromRGB(0xf7f7f7) 20 view.backgroundColor=UIColorFromRGB(0xf7f7f7)
21 Theme.configButton(buttonLogin) 21 Theme.configButton(buttonLogin)
  22 + NotificationCenter.default.addObserver(self, selector: #selector(NewLoginViewController.refreshUser), name: NSNotification.Name(rawValue: "refreshLoginUser"), object: nil)
  23 + NotificationCenter.default.addObserver(self, selector: #selector(NewLoginViewController.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
  24 + NotificationCenter.default.addObserver(self, selector: #selector(NewLoginViewController.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
22 } 25 }
23 override func viewWillAppear(_ animated: Bool) { 26 override func viewWillAppear(_ animated: Bool) {
24 super.viewWillAppear(animated) 27 super.viewWillAppear(animated)
25 - NotificationCenter.default.addObserver(self, selector: #selector(NewLoginViewController.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)  
26 - NotificationCenter.default.addObserver(self, selector: #selector(NewLoginViewController.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)  
27 fieldAccount.tintColor=Theme.topBarColor() 28 fieldAccount.tintColor=Theme.topBarColor()
28 fieldPassword.tintColor=Theme.topBarColor() 29 fieldPassword.tintColor=Theme.topBarColor()
29 } 30 }
30 override func viewWillDisappear(_ animated: Bool) { 31 override func viewWillDisappear(_ animated: Bool) {
31 super.viewWillDisappear(animated) 32 super.viewWillDisappear(animated)
32 - NotificationCenter.default.removeObserver(self)  
33 } 33 }
34 34
35 35
@@ -37,7 +37,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -37,7 +37,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
37 super.didReceiveMemoryWarning() 37 super.didReceiveMemoryWarning()
38 // Dispose of any resources that can be recreated. 38 // Dispose of any resources that can be recreated.
39 } 39 }
40 - 40 + //注册完了后自动填充账号
  41 + func refreshUser(noti:Notification){
  42 + fieldAccount.text = "\(noti.object!)"
  43 + }
41 @IBAction func onLoginClicked(_ sender: UIButton) { 44 @IBAction func onLoginClicked(_ sender: UIButton) {
42 self.view.endEditing(true) 45 self.view.endEditing(true)
43 let account=fieldAccount.text 46 let account=fieldAccount.text
@@ -139,6 +142,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -139,6 +142,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
139 self.viewContent.layoutIfNeeded() 142 self.viewContent.layoutIfNeeded()
140 }) 143 })
141 } 144 }
  145 + // MARK: - 销毁通知
  146 + deinit {
  147 + NotificationCenter.default.removeObserver(self)
  148 + }
142 } 149 }
143 150
144 151
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/RegisterViewController.swift
@@ -25,7 +25,6 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -25,7 +25,6 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker
25 var timer :Timer! 25 var timer :Timer!
26 override func viewDidLoad() { 26 override func viewDidLoad() {
27 super.viewDidLoad() 27 super.viewDidLoad()
28 - self.configTheme()  
29 } 28 }
30 29
31 @IBAction func touchAction(_ sender: AnyObject) { 30 @IBAction func touchAction(_ sender: AnyObject) {
YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift
@@ -90,6 +90,8 @@ class UserEditViewController: UIViewController ,UIImagePickerControllerDelegate, @@ -90,6 +90,8 @@ class UserEditViewController: UIViewController ,UIImagePickerControllerDelegate,
90 if finish{ 90 if finish{
91 self.user=AppDelegate.instance().accountManager 91 self.user=AppDelegate.instance().accountManager
92 self.tableView.reloadData() 92 self.tableView.reloadData()
  93 + //发出刷新首页通知
  94 + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil)
93 } 95 }
94 }) 96 })
95 }, failHandler: { (error) in 97 }, failHandler: { (error) in
@@ -157,6 +159,8 @@ extension UserEditViewController:UITableViewDelegate,UITableViewDataSource{ @@ -157,6 +159,8 @@ extension UserEditViewController:UITableViewDelegate,UITableViewDataSource{
157 self.user=AppDelegate.instance().accountManager 159 self.user=AppDelegate.instance().accountManager
158 self.setContentArr() 160 self.setContentArr()
159 self.tableView.reloadData() 161 self.tableView.reloadData()
  162 + //发出刷新首页通知
  163 + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil)
160 } 164 }
161 }) 165 })
162 }, failHandler: { (error) in 166 }, failHandler: { (error) in
YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift
@@ -36,7 +36,6 @@ class UserViewController: UIViewController { @@ -36,7 +36,6 @@ class UserViewController: UIViewController {
36 userPhoto.layer.masksToBounds = true 36 userPhoto.layer.masksToBounds = true
37 userName.text = user.name() 37 userName.text = user.name()
38 userPhoto.sd_setImage(with: URL(string: user.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png")) 38 userPhoto.sd_setImage(with: URL(string: user.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png"))
39 -  
40 } 39 }
41 40
42 override func didReceiveMemoryWarning() { 41 override func didReceiveMemoryWarning() {
YouerLiveVideo/YouerLiveVideo/util/network.swift
@@ -148,6 +148,7 @@ final class HTTPServer{ @@ -148,6 +148,7 @@ final class HTTPServer{
148 static let URL_USERCENTERGETDELETERESOURCE=HOST+"/api/UserCenter/DeleteResource" //删除资源/微课/校园电视台 148 static let URL_USERCENTERGETDELETERESOURCE=HOST+"/api/UserCenter/DeleteResource" //删除资源/微课/校园电视台
149 static let URL_USERCENTERGETHIDERESOURCE=HOST+"/api/UserCenter/HideResource" //隐藏资源/微课/校园电视台 149 static let URL_USERCENTERGETHIDERESOURCE=HOST+"/api/UserCenter/HideResource" //隐藏资源/微课/校园电视台
150 static let URL_USERCENTERGETUPDATEDOWNLOADSUM=HOST+"/api/UserCenter/UpdateDownloadSum" //资源下载时更新下载量 150 static let URL_USERCENTERGETUPDATEDOWNLOADSUM=HOST+"/api/UserCenter/UpdateDownloadSum" //资源下载时更新下载量
  151 + static let URL_USERCENTERGETUPDATEPV=HOST+"/api/UserCenter/UpdatePv" //预览时增加预览量
151 static let URL_USERCENTERGETGETHISTORYVIEW=HOST+"/api/UserCenter/GetHistroyView" //历史记录 152 static let URL_USERCENTERGETGETHISTORYVIEW=HOST+"/api/UserCenter/GetHistroyView" //历史记录
152 static let URL_USERCENTERGETADDHISTORYVIEW=HOST+"/api/UserCenter/AddHistoryView" //添加历史记录 153 static let URL_USERCENTERGETADDHISTORYVIEW=HOST+"/api/UserCenter/AddHistoryView" //添加历史记录
153 static let URL_USERCENTERGETGETMYUSER=HOST+"/api/UserCenter/GetMyUser" //已开设账号 154 static let URL_USERCENTERGETGETMYUSER=HOST+"/api/UserCenter/GetMyUser" //已开设账号
@@ -393,7 +394,10 @@ final class HTTPServer{ @@ -393,7 +394,10 @@ final class HTTPServer{
393 func updateDownloadSum(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ 394 func updateDownloadSum(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
394 KHttp.GET(url: HTTPServer.URL_USERCENTERGETUPDATEDOWNLOADSUM, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) 395 KHttp.GET(url: HTTPServer.URL_USERCENTERGETUPDATEDOWNLOADSUM, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
395 } 396 }
396 - 397 + //预览时增加预览量
  398 + func updatePv(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  399 + KHttp.GET(url: HTTPServer.URL_USERCENTERGETUPDATEPV, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  400 + }
397 //历史记录 401 //历史记录
398 func getHistroyView(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ 402 func getHistroyView(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
399 KHttp.POST(url: HTTPServer.URL_USERCENTERGETGETHISTORYVIEW, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) 403 KHttp.POST(url: HTTPServer.URL_USERCENTERGETGETHISTORYVIEW, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)