Commit 226b549c1f63b8b26210944eae34f25949ea794d
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 | -{ | |
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 | 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 | -{ | |
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 | 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
YouerLiveVideo/YouerLiveVideo/Assets.xcassets/z_NewIcon/MicroCourse/microCourse_default.imageset/Contents.json
0 → 100644
... | ... | @@ -0,0 +1,21 @@ |
1 | +{ | |
2 | + "images" : [ | |
3 | + { | |
4 | + "idiom" : "universal", | |
5 | + "scale" : "1x" | |
6 | + }, | |
7 | + { | |
8 | + "idiom" : "universal", | |
9 | + "filename" : "微课图标.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 | 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 @@ |
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 | 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 | 3 | <device id="retina4_7" orientation="portrait"> |
4 | 4 | <adaptation id="fullscreen"/> |
5 | 5 | </device> |
... | ... | @@ -423,7 +423,7 @@ |
423 | 423 | <rect key="frame" x="0.0" y="0.0" width="207" height="193"/> |
424 | 424 | <autoresizingMask key="autoresizingMask"/> |
425 | 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 | 427 | <rect key="frame" x="0.0" y="0.0" width="207" height="93.5"/> |
428 | 428 | <userDefinedRuntimeAttributes> |
429 | 429 | <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/> |
... | ... | @@ -1476,7 +1476,7 @@ |
1476 | 1476 | <rect key="frame" x="0.0" y="0.0" width="375" height="139"/> |
1477 | 1477 | <autoresizingMask key="autoresizingMask"/> |
1478 | 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 | 1480 | <rect key="frame" x="8" y="24" width="90" height="90"/> |
1481 | 1481 | <constraints> |
1482 | 1482 | <constraint firstAttribute="width" secondItem="qia-pR-e6p" secondAttribute="height" multiplier="1:1" id="6Zi-MO-Pqe"/> |
... | ... | @@ -1663,6 +1663,7 @@ |
1663 | 1663 | <image name="icon_tvstation" width="25" height="25"/> |
1664 | 1664 | <image name="icon_user" width="25" height="25"/> |
1665 | 1665 | <image name="icon_watchcount" width="12" height="7"/> |
1666 | + <image name="microCourse_default" width="100" height="100"/> | |
1666 | 1667 | <image name="starLive" width="30" height="30"/> |
1667 | 1668 | <image name="视窗.png" width="31" height="31"/> |
1668 | 1669 | </resources> | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift
... | ... | @@ -10,20 +10,30 @@ import UIKit |
10 | 10 | import AVKit |
11 | 11 | class MainHomeTableViewController: UITableViewController { |
12 | 12 | @IBOutlet var tableHeaderView: UIView! |
13 | - let current=AppDelegate.instance().accountManager | |
13 | + var user = AppDelegate.instance().accountManager | |
14 | + var photo:UIImageView! | |
14 | 15 | override func viewDidLoad() { |
15 | 16 | super.viewDidLoad() |
16 | 17 | tableHeaderView.frame.size.height=getScreenWidth()/12*5 |
17 | 18 | settingIconAndTitle() |
18 | 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 | 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 | 30 | photo.layer.cornerRadius=35/2 |
25 | 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 | 37 | self.navigationItem.leftBarButtonItem=leftBarButtonItem |
28 | 38 | self.configTheme() |
29 | 39 | self.navigationController?.navigationBar.barStyle=UIBarStyle.black |
... | ... | @@ -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 | 84 | override func didReceiveMemoryWarning() { |
66 | 85 | super.didReceiveMemoryWarning() |
67 | 86 | } |
... | ... | @@ -225,11 +244,24 @@ class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollec |
225 | 244 | } |
226 | 245 | } |
227 | 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 | 249 | let player = AVPlayerViewController() |
230 | 250 | player.player = AVPlayer(url: url!) |
231 | 251 | player.videoGravity = AVLayerVideoGravityResizeAspect |
232 | 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 | 266 | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
235 | 267 | return CGSize(width: (getScreenWidth()-45)/2, height: ((getScreenWidth()-45)/2/33*16+67)) |
... | ... | @@ -313,9 +345,9 @@ class HomeSecondCollectionViewCell: UICollectionViewCell { |
313 | 345 | @IBOutlet var dateLabel: UILabel! |
314 | 346 | @IBOutlet var readCountLabel: UILabel! |
315 | 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 | 349 | nameLabel.text=item.f_Title |
318 | - teacherNameLabel.text="主讲师:\(item.f_CreatorName) 老师" | |
350 | + teacherNameLabel.text="主讲师:\(item.f_CreatorName)" | |
319 | 351 | dateLabel.text=item.f_CreatorTime |
320 | 352 | readCountLabel.text="\(item.f_Pv)" |
321 | 353 | } |
... | ... | @@ -353,9 +385,22 @@ class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollect |
353 | 385 | let user=AppDelegate.instance().accountManager |
354 | 386 | //点击下载并打开资源文档 |
355 | 387 | if user.isOnline() && (user.roletype()==1 || user.roletype()==2 || user.roletype()==6){ |
388 | + let item=dataSet[indexPath.row] | |
356 | 389 | let download = DownLoad.share |
357 | 390 | download.superVC = ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).viewControllers[0] |
358 | 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 | 404 | }else{ |
360 | 405 | AppDelegate.instance().window?.makeToast("无权限查看资源") |
361 | 406 | } |
... | ... | @@ -379,9 +424,9 @@ class HomeThirdCollectionViewCell: UICollectionViewCell { |
379 | 424 | @IBOutlet var dateLabel: UILabel! |
380 | 425 | @IBOutlet var readCountLabel: UILabel! |
381 | 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 | 428 | nameLabel.text=item.f_Title |
384 | - teacherNameLabel.text="上传者:\(item.f_CreatorName) 老师" | |
429 | + teacherNameLabel.text="上传者:\(item.f_CreatorName)" | |
385 | 430 | dateLabel.text=item.f_CreatorTime |
386 | 431 | readCountLabel.text="\(item.f_DownloadSum)" |
387 | 432 | } |
... | ... | @@ -416,16 +461,21 @@ class HomeFourTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollecti |
416 | 461 | } |
417 | 462 | } |
418 | 463 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
419 | - //点击进入学校 appRootViewController() | |
464 | + //点击进入校园电视台 | |
465 | + let item=dataSet[indexPath.row] | |
420 | 466 | let vc = Story.instantiateViewControllerWithIdentifier("TVStationInforViewControllerVC", storyName: "TVStation") as! TVStationInforViewController |
421 | 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 | 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 | 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 | 480 | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
431 | 481 | return CGSize(width: (getScreenWidth()-40)/3, height: (getScreenWidth()-40)/3+30) |
... | ... | @@ -443,7 +493,7 @@ class HomeFourCollectionViewCell: UICollectionViewCell { |
443 | 493 | @IBOutlet var iconImageView: UIImageView! |
444 | 494 | @IBOutlet var nameLabel: UILabel! |
445 | 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 | 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 | 75 | self.resourceData.removeAll() |
76 | 76 | var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] |
77 | 77 | if self.parameter != nil { |
78 | + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
78 | 79 | p=self.parameter! |
79 | 80 | } |
80 | 81 | self.refreshLivesAction(parameters: p, completionHandler: { (success) in |
... | ... | @@ -90,6 +91,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie |
90 | 91 | //上拉加载更多 |
91 | 92 | var p:Dictionary<String,AnyObject>=["type":0 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] |
92 | 93 | if self.parameter != nil { |
94 | + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
93 | 95 | p=self.parameter! |
94 | 96 | } |
95 | 97 | self.refreshLivesAction(parameters: p, completionHandler: { (success) in |
... | ... | @@ -164,18 +166,39 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie |
164 | 166 | // let vc = UIStoryboard(name: "Resource", bundle: nil).instantiateViewController(withIdentifier: "LiveInforViewControllerVC") as! LiveInforViewController |
165 | 167 | // vc.item=item |
166 | 168 | // self.superVC.navigationController!.pushViewController(vc, animated: true) |
169 | + var item:MicroCourseModel! | |
167 | 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 | 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 | 260 | var superVC:MicroCourseViewController! |
238 | 261 | func setUpWith(item: MicroCourseModel){ |
239 | 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 | 264 | titleLabel.text=item.f_Title |
242 | - updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师" | |
265 | + updateTeacherLabel.text="主讲师:\(item.f_CreatorName)" | |
243 | 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 | 269 | @IBAction func pushDetailVC(_ sender: UIButton) { |
247 | 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 | 75 | self.resourceData.removeAll() |
76 | 76 | var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] |
77 | 77 | if self.parameter != nil { |
78 | + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
78 | 79 | p=self.parameter! |
79 | 80 | } |
80 | 81 | self.refreshLivesAction(parameters: p, completionHandler: { (success) in |
... | ... | @@ -90,6 +91,7 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa |
90 | 91 | //上拉加载更多 |
91 | 92 | var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] |
92 | 93 | if self.parameter != nil { |
94 | + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
93 | 95 | p=self.parameter! |
94 | 96 | } |
95 | 97 | self.refreshLivesAction(parameters: p, completionHandler: { (success) in |
... | ... | @@ -161,13 +163,37 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa |
161 | 163 | } |
162 | 164 | } |
163 | 165 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
166 | + var item:MicroCourseModel! | |
164 | 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 | 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 | 273 | func setUpWith(item: MicroCourseModel){ |
248 | 274 | iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) |
249 | 275 | titleLabel.text=item.f_Title |
250 | - updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师" | |
276 | + updateTeacherLabel.text="上传者:\(item.f_CreatorName)" | |
251 | 277 | timeLabel.text=setDateToString(date:dateFromISO8601(dateString: item.f_CreatorTime)) |
252 | 278 | downLoadCountLabel.text="\(item.f_DownloadSum)" |
253 | 279 | } | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/NewLoginViewController.swift
... | ... | @@ -19,17 +19,17 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
19 | 19 | constraintContentOffset.constant=20 |
20 | 20 | view.backgroundColor=UIColorFromRGB(0xf7f7f7) |
21 | 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 | 26 | override func viewWillAppear(_ animated: Bool) { |
24 | 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 | 28 | fieldAccount.tintColor=Theme.topBarColor() |
28 | 29 | fieldPassword.tintColor=Theme.topBarColor() |
29 | 30 | } |
30 | 31 | override func viewWillDisappear(_ animated: Bool) { |
31 | 32 | super.viewWillDisappear(animated) |
32 | - NotificationCenter.default.removeObserver(self) | |
33 | 33 | } |
34 | 34 | |
35 | 35 | |
... | ... | @@ -37,7 +37,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
37 | 37 | super.didReceiveMemoryWarning() |
38 | 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 | 44 | @IBAction func onLoginClicked(_ sender: UIButton) { |
42 | 45 | self.view.endEditing(true) |
43 | 46 | let account=fieldAccount.text |
... | ... | @@ -139,6 +142,10 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
139 | 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
YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift
... | ... | @@ -90,6 +90,8 @@ class UserEditViewController: UIViewController ,UIImagePickerControllerDelegate, |
90 | 90 | if finish{ |
91 | 91 | self.user=AppDelegate.instance().accountManager |
92 | 92 | self.tableView.reloadData() |
93 | + //发出刷新首页通知 | |
94 | + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil) | |
93 | 95 | } |
94 | 96 | }) |
95 | 97 | }, failHandler: { (error) in |
... | ... | @@ -157,6 +159,8 @@ extension UserEditViewController:UITableViewDelegate,UITableViewDataSource{ |
157 | 159 | self.user=AppDelegate.instance().accountManager |
158 | 160 | self.setContentArr() |
159 | 161 | self.tableView.reloadData() |
162 | + //发出刷新首页通知 | |
163 | + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil) | |
160 | 164 | } |
161 | 165 | }) |
162 | 166 | }, failHandler: { (error) in | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift
... | ... | @@ -36,7 +36,6 @@ class UserViewController: UIViewController { |
36 | 36 | userPhoto.layer.masksToBounds = true |
37 | 37 | userName.text = user.name() |
38 | 38 | userPhoto.sd_setImage(with: URL(string: user.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png")) |
39 | - | |
40 | 39 | } |
41 | 40 | |
42 | 41 | override func didReceiveMemoryWarning() { | ... | ... |
YouerLiveVideo/YouerLiveVideo/util/network.swift
... | ... | @@ -148,6 +148,7 @@ final class HTTPServer{ |
148 | 148 | static let URL_USERCENTERGETDELETERESOURCE=HOST+"/api/UserCenter/DeleteResource" //删除资源/微课/校园电视台 |
149 | 149 | static let URL_USERCENTERGETHIDERESOURCE=HOST+"/api/UserCenter/HideResource" //隐藏资源/微课/校园电视台 |
150 | 150 | static let URL_USERCENTERGETUPDATEDOWNLOADSUM=HOST+"/api/UserCenter/UpdateDownloadSum" //资源下载时更新下载量 |
151 | + static let URL_USERCENTERGETUPDATEPV=HOST+"/api/UserCenter/UpdatePv" //预览时增加预览量 | |
151 | 152 | static let URL_USERCENTERGETGETHISTORYVIEW=HOST+"/api/UserCenter/GetHistroyView" //历史记录 |
152 | 153 | static let URL_USERCENTERGETADDHISTORYVIEW=HOST+"/api/UserCenter/AddHistoryView" //添加历史记录 |
153 | 154 | static let URL_USERCENTERGETGETMYUSER=HOST+"/api/UserCenter/GetMyUser" //已开设账号 |
... | ... | @@ -393,7 +394,10 @@ final class HTTPServer{ |
393 | 394 | func updateDownloadSum(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ |
394 | 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 | 402 | func getHistroyView(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){ |
399 | 403 | KHttp.POST(url: HTTPServer.URL_USERCENTERGETGETHISTORYVIEW, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler) | ... | ... |