From 235e5ed1981a9df19ed17a53afa6b1f2be1fa64c Mon Sep 17 00:00:00 2001 From: 左丞 Date: Tue, 23 May 2017 14:56:18 +0800 Subject: [PATCH] no message --- YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj | 12 ++++++++++++ YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/Contents.json | 5 +---- YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/arrow.png | Bin 1002 -> 0 bytes YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/收拢.png | Bin 0 -> 3126 bytes YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift | 20 +++++++++++++++----- YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard | 10 +++++----- YouerLiveVideo/YouerLiveVideo/controllers/User/AppSettingViewController.swift | 35 +++++++++++++++++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/controllers/User/HistoryViewController.swift | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/controllers/User/User.storyboard | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ YouerLiveVideo/YouerLiveVideo/util/account.swift | 14 ++++++++++++++ 13 files changed, 864 insertions(+), 21 deletions(-) delete mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/arrow.png create mode 100644 YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/收拢.png create mode 100644 YouerLiveVideo/YouerLiveVideo/controllers/User/AppSettingViewController.swift create mode 100644 YouerLiveVideo/YouerLiveVideo/controllers/User/HistoryViewController.swift create mode 100644 YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift diff --git a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj index 788e11f..12bdfbd 100644 --- a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj +++ b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj @@ -25,6 +25,9 @@ 596026501DDD469200C6B5E8 /* RiverRunCommentManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5960264C1DDD469200C6B5E8 /* RiverRunCommentManager.m */; }; 596026511DDD469200C6B5E8 /* RiverRunCommentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 5960264E1DDD469200C6B5E8 /* RiverRunCommentUtil.m */; }; 597185B51ECA990C00D7F478 /* Resource.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 597185B41ECA990C00D7F478 /* Resource.storyboard */; }; + 598939491ED3CFD8005DA462 /* UserEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 598939481ED3CFD8005DA462 /* UserEditViewController.swift */; }; + 5989394B1ED3CFF4005DA462 /* AppSettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5989394A1ED3CFF4005DA462 /* AppSettingViewController.swift */; }; + 5989394D1ED4016D005DA462 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5989394C1ED4016D005DA462 /* HistoryViewController.swift */; }; 598A0E531E51941300273AB8 /* libNIMSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598A0E4D1E51941300273AB8 /* libNIMSDK.a */; }; 598A0E541E51941300273AB8 /* libaacplus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598A0E4F1E51941300273AB8 /* libaacplus.a */; }; 598A0E551E51941300273AB8 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598A0E501E51941300273AB8 /* libcrypto.a */; }; @@ -238,6 +241,9 @@ 5960264D1DDD469200C6B5E8 /* RiverRunCommentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RiverRunCommentUtil.h; sourceTree = ""; }; 5960264E1DDD469200C6B5E8 /* RiverRunCommentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RiverRunCommentUtil.m; sourceTree = ""; }; 597185B41ECA990C00D7F478 /* Resource.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Resource.storyboard; sourceTree = ""; }; + 598939481ED3CFD8005DA462 /* UserEditViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserEditViewController.swift; sourceTree = ""; }; + 5989394A1ED3CFF4005DA462 /* AppSettingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppSettingViewController.swift; sourceTree = ""; }; + 5989394C1ED4016D005DA462 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = ""; }; 598A0E121E51941300273AB8 /* NIMChatroom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NIMChatroom.h; sourceTree = ""; }; 598A0E131E51941300273AB8 /* NIMChatroomEnterRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NIMChatroomEnterRequest.h; sourceTree = ""; }; 598A0E141E51941300273AB8 /* NIMChatroomMember.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NIMChatroomMember.h; sourceTree = ""; }; @@ -1175,6 +1181,9 @@ children = ( BFBB83D91ECC445D008B404B /* User.storyboard */, BFBB83E21ECC445D008B404B /* UserViewController.swift */, + 598939481ED3CFD8005DA462 /* UserEditViewController.swift */, + 5989394A1ED3CFF4005DA462 /* AppSettingViewController.swift */, + 5989394C1ED4016D005DA462 /* HistoryViewController.swift */, BFBB83DA1ECC445D008B404B /* UserCenter */, ); path = User; @@ -1506,12 +1515,14 @@ BFC076781E3445F3008BAC79 /* DownLoad.swift in Sources */, 59AE3DFF1ECFDAFD003E2C62 /* TVStationChannelViewController.swift in Sources */, BF25DFE71DDAA36A003EC0C1 /* MultipartFormData.swift in Sources */, + 5989394D1ED4016D005DA462 /* HistoryViewController.swift in Sources */, BF25DFF71DDAA36A003EC0C1 /* MKAnnotationView+WebCache.m in Sources */, BF25DFFB1DDAA36A003EC0C1 /* SDImageCacheConfig.m in Sources */, 5904FC4D1ECA8B8C00E631FF /* MicroCourseViewController.swift in Sources */, BFBB83E61ECC445D008B404B /* LoginViewController.swift in Sources */, BF25DFE21DDAA36A003EC0C1 /* AFError.swift in Sources */, BF25DFEF1DDAA36A003EC0C1 /* ServerTrustPolicy.swift in Sources */, + 598939491ED3CFD8005DA462 /* UserEditViewController.swift in Sources */, BF25E0061DDAA36A003EC0C1 /* UIImageView+HighlightedWebCache.m in Sources */, BF25DFE41DDAA36A003EC0C1 /* DispatchQueue+Alamofire.swift in Sources */, BF25DFE81DDAA36A003EC0C1 /* NetworkReachabilityManager.swift in Sources */, @@ -1527,6 +1538,7 @@ BF25DFF81DDAA36A003EC0C1 /* NSData+ImageContentType.m in Sources */, BF25E0151DDAAF73003EC0C1 /* SVIndefiniteAnimatedView.m in Sources */, BFF5F4921DD5B7CA00D33B89 /* SwiftyJSON.swift in Sources */, + 5989394B1ED3CFF4005DA462 /* AppSettingViewController.swift in Sources */, BF682F1E1ECE8772007632CA /* MainHomeTableViewController.swift in Sources */, BF7B75A91E305A6D0011D5C7 /* UIView+MJExtension.m in Sources */, BF25DFEE1DDAA36A003EC0C1 /* Result.swift in Sources */, diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/Contents.json b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/Contents.json index 2c3f4d1..9680f5d 100644 --- a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/Contents.json +++ b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/Contents.json @@ -6,7 +6,7 @@ }, { "idiom" : "universal", - "filename" : "arrow.png", + "filename" : "收拢.png", "scale" : "2x" }, { @@ -17,8 +17,5 @@ "info" : { "version" : 1, "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" } } \ No newline at end of file diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/arrow.png b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/arrow.png deleted file mode 100644 index da7cfa5..0000000 Binary files a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/arrow.png and /dev/null differ diff --git a/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/收拢.png b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/收拢.png new file mode 100644 index 0000000..fca616b Binary files /dev/null and b/YouerLiveVideo/YouerLiveVideo/Assets.xcassets/arrow.imageset/收拢.png differ diff --git a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard index a7e53c9..5486213 100644 --- a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - - + + @@ -823,13 +823,124 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1182,7 +1293,7 @@ - + @@ -1518,7 +1629,7 @@ - + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift index 1d3458b..ffee5a5 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift @@ -7,7 +7,7 @@ // import UIKit - +import AVKit class ExcellentTVViewController: UIViewController { @IBOutlet weak var AllTitleView: UIView! @@ -204,6 +204,7 @@ extension ExcellentTVViewController:UICollectionViewDelegate,UICollectionViewDat func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ExcellentTVViewCell + cell.superNacigation = self.navigationController AppDelegate.instance().httpServer.postExcellentProgram(parameters: ["f_TelevisionId":TVStationClasses[titleSelectBtn].ch[classSelectBtn].id as AnyObject,"pageIndex":1 as AnyObject]) { (str, error) in httpJsonResule(jsonString: str, error: error, successHandler: { (json) in for item in json.contentData()["resultData"].arrayValue{ @@ -236,7 +237,7 @@ class ExcellentTVViewCell: UICollectionViewCell,UICollectionViewDelegate,UIColl var f_TelevisionId:String! @IBOutlet weak var inforCollectionView: UICollectionView! var datatSet:[TVStationSubject] = [] - + var superNacigation:UINavigationController! override func awakeFromNib() { @@ -251,6 +252,7 @@ class ExcellentTVViewCell: UICollectionViewCell,UICollectionViewDelegate,UIColl let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as! ExcellentTVInforViewCell let item = datatSet[indexPath.row] cell.model = item + cell.superNavigation = superNacigation return cell } @@ -274,7 +276,7 @@ class ExcellentTVInforViewCell: UICollectionViewCell{ @IBOutlet weak var tvStationLogo: UIImageView! @IBOutlet weak var subjectType: UILabel! @IBOutlet weak var playCount: UILabel! - + var superNavigation:UINavigationController! var model:TVStationSubject? { didSet{ self.tvStationLogo.sd_setImage(with: URL(string: model!.f_Img), placeholderImage: #imageLiteral(resourceName: "placeholder")) @@ -285,9 +287,17 @@ class ExcellentTVInforViewCell: UICollectionViewCell{ } @IBAction func playBtnClick(_ sender: UIButton) { - + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":self.model!.f_ResourceType as AnyObject,"f_ViewId":self.model!.f_Id as AnyObject,"f_ViewName":self.model!.f_Title as AnyObject]) { (str, error) in + if JSON.fromString(jsonString: str)?["status"].intValue == 1{ + + } + } + let url = URL(string:self.model!.f_ResourceUrl) + let player = AVPlayerViewController() + player.player = AVPlayer(url: url!) + player.videoGravity = AVLayerVideoGravityResizeAspect + superNavigation.present(player, animated: true, completion: nil) } - } class TVSubjectInfor{ diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard index 1f77a8b..b2bd79e 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/TVStation.storyboard @@ -159,14 +159,14 @@ @@ -712,6 +712,6 @@ - + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/User/AppSettingViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/User/AppSettingViewController.swift new file mode 100644 index 0000000..aa0c3ca --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/AppSettingViewController.swift @@ -0,0 +1,35 @@ +// +// AppSettingViewController.swift +// YouerLiveVideo +// +// Created by 左丞 on 2017/5/23. +// Copyright © 2017年 左丞. All rights reserved. +// + +import UIKit + +class AppSettingViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + 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/User/HistoryViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/User/HistoryViewController.swift new file mode 100644 index 0000000..3a6d4a6 --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/HistoryViewController.swift @@ -0,0 +1,88 @@ +// +// HistoryViewController.swift +// YouerLiveVideo +// +// Created by 左丞 on 2017/5/23. +// Copyright © 2017年 左丞. All rights reserved. +// + +import UIKit + +class HistoryViewController: UIViewController { + + @IBOutlet weak var collectionView: UICollectionView! + + var datatSet:[TVStationSubject] = [] + var type:Int = 0// 资源类型 0-微课 1-资源 2-电视台 + override func viewDidLoad() { + super.viewDidLoad() + AppDelegate.instance().httpServer.getHistroyView(parameters: ["f_ViewType":type as AnyObject,"pageIndex":1 as AnyObject]) { (str, error) in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + for item in json.contentData()["resultData"].arrayValue{ + self.datatSet.append(TVStationSubject(json: item)) + } + self.collectionView.reloadData() + }, failHandler: { (error) in + + }) + } + // Do any additional setup after loading the view. + } + + 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. + } + */ + +} + +extension HistoryViewController:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{ + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! TVStationClassCell + let item = datatSet[indexPath.row] + cell.model = item + return cell + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return datatSet.count + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: (getScreenWidth()-30)/2, height: 200) + } + + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsetsMake(10, 10, 10, 10) + } + +} + +class TVStationClassCell: UICollectionViewCell { + + @IBOutlet weak var name: UILabel! + @IBOutlet weak var photo: UIImageView! + var model:TVStationSubject?{ + didSet{ + name.text = model!.f_Title + photo.sd_setImage(with: URL(string:model!.f_Img), placeholderImage: #imageLiteral(resourceName: "placeholder")) + } + } +} diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/User/User.storyboard b/YouerLiveVideo/YouerLiveVideo/controllers/User/User.storyboard index c26d9fd..868eb27 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/User/User.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/User.storyboard @@ -5,6 +5,264 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift new file mode 100644 index 0000000..fea4af7 --- /dev/null +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/UserEditViewController.swift @@ -0,0 +1,211 @@ +// +// UserEditViewController.swift +// YouerLiveVideo +// +// Created by 左丞 on 2017/5/23. +// Copyright © 2017年 左丞. All rights reserved. +// + +import UIKit + +class UserEditViewController: UIViewController ,UIImagePickerControllerDelegate,UINavigationControllerDelegate{ + + @IBOutlet weak var tableView: UITableView! + + + var user = AppDelegate.instance().accountManager + var titleArr:[String] = ["昵称","账号","身份","所属学校"] + var contentArr:[String] = [] + override func viewDidLoad() { + super.viewDidLoad() + setContentArr() + + // Do any additional setup after loading the view. + } + + func setContentArr(){ + var ident = "" + if user.isParent(){ + ident = "家长" + }else{ + ident = "教师" + } + contentArr = [user.name(),user.userid,ident,user.schoolName()] + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + // MARK: -UIImagePickerControllerDelegate + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { + picker.dismiss(animated: true, completion: { () -> Void in + var oimage = info[UIImagePickerControllerOriginalImage] as? UIImage + oimage = oimage!.imageScaledToScale() + let filePath=FilesManager.imageFilePath(String(format:"%f.jpg",Date().timeIntervalSince1970)) + try? UIImageJPEGRepresentation(oimage!,0.7)!.write(to: URL(fileURLWithPath: filePath), options: [.atomic]) + self.updateImage(file: filePath) + }) + } + func updateImage(file:String){ + SVProgressHUD.show(withStatus: "图片上传中...") + SVProgressHUD.setDefaultMaskType(.black) + AppDelegate.instance().httpServer.uploadFile(file: NSURL(fileURLWithPath: file)) { (str, error) in + SVProgressHUD.dismiss() + if error == nil{ + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + let str=json.contentData().arrayValue[0].stringValue + AppDelegate.instance().httpServer.postUpdateUser(parameters: ["nickname":self.user.name() as AnyObject,"headimg":str as AnyObject], completionHandler: { (str, error) in + if error == nil{ + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + AppDelegate.instance().accountManager.refreshUserInfo(completionHandler: { (finish) in + if finish{ + self.user=AppDelegate.instance().accountManager + self.tableView.reloadData() + } + }) + }, failHandler: { (error) in + self.view.makeToast("头像修改失败") + }) + }else{ + self.view.makeToast("头像修改失败") + } + } + }) + }, failHandler: { (error) in + self.view.makeToast("图片上传失败") + }) + }else{ + self.view.makeToast("图片上传失败") + } + } + } + } + + + /* + // 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. + } + */ + +} + +extension UserEditViewController:UITableViewDelegate,UITableViewDataSource{ + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch indexPath.row { + case 0: + let action=UIAlertController(title:"修改头像",message:nil,preferredStyle:UIAlertControllerStyle.actionSheet) + let photoAction=UIAlertAction(title: "从相册选择", style: UIAlertActionStyle.default) { (action) in + if cameraOrPhotPermissions(0, view: self.view){ + let vc = UIImagePickerController() + vc.delegate = self + vc.sourceType = .photoLibrary + self.present(vc, animated: true, completion: nil) + } + } + let cancleAction=UIAlertAction(title: "取消", style: UIAlertActionStyle.cancel) { (action) in + } + action.addAction(photoAction) + action.addAction(cancleAction) + self.present(action, animated: true, completion: nil) + case 1: + let alert=UIAlertController(title: "修改昵称", message: nil, preferredStyle: UIAlertControllerStyle.alert) + let cancle=UIAlertAction(title: "取消", style: UIAlertActionStyle.cancel, handler: nil) + let get=UIAlertAction(title: "修改", style: UIAlertActionStyle.default, handler: { (action) in + if alert.textFields![0].text != "" { + AppDelegate.instance().httpServer.postUpdateUser(parameters: ["nickname":alert.textFields![0].text! as AnyObject,"headimg":self.user.photo() as AnyObject], completionHandler: { (str, error) in + if error == nil{ + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + self.view.makeToast("昵称修改成功") + AppDelegate.instance().accountManager.refreshUserInfo(completionHandler: { (finish) in + if finish{ + self.user=AppDelegate.instance().accountManager + self.setContentArr() + self.tableView.reloadData() + } + }) + }, failHandler: { (error) in + self.view.makeToast("昵称修改失败") + }) + }else{ + self.view.makeToast("昵称修改失败") + } + } + }) + }else{ + self.view.makeToast("昵称修改不能为空") + } + }) + alert.addTextField(configurationHandler: { (textfield) in + textfield.placeholder="请输入修改的昵称" + }) + alert.addAction(cancle) + alert.addAction(get) + self.present(alert, animated: true, completion: nil) + break + default: + return + } + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.row == 0{ + let cell = tableView.dequeueReusableCell(withIdentifier: "UserPhotoCell") as! UserPhotoCell + cell.userPhoto.sd_setImage(with: URL(string:self.user.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png")) + return cell + }else{ + let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! UserEditCell + cell.titleName.text = titleArr[indexPath.row-1] + cell.name.text = contentArr[indexPath.row-1] + if indexPath.row == 0{ + cell.changeBtn.isHidden = false + cell.changeBtn.tag = indexPath.row+100 + } + return cell + } + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return titleArr.count+1 + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row == 0{ + return 140 + } + return 65 + } + + +} + +class UserEditCell: UITableViewCell { + + @IBOutlet weak var changeBtn: UILabel! + @IBOutlet weak var titleName: UILabel! + @IBOutlet weak var name: UILabel! + override func awakeFromNib() { + changeBtn.isHidden = true + } +} + +class UserPhotoCell:UITableViewCell{ + + @IBOutlet weak var userPhoto: UIImageView! + + override func awakeFromNib() { + userPhoto.layer.cornerRadius = userPhoto.frame.size.height/2 + userPhoto.layer.masksToBounds = true + } +} diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift index ba8431c..5063eb2 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift @@ -10,18 +10,50 @@ import UIKit class UserViewController: UIViewController { + + @IBOutlet weak var historyList: UITableView! + @IBOutlet weak var userName: UILabel! + @IBOutlet weak var userPhoto: UIImageView! + var historyType:[String] = ["微课","校园资源库","校园电视台"] + var isCloseHistoryList:Bool = false override func viewDidLoad() { super.viewDidLoad() self.configTheme() + self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "radio_s"), style: .plain, target: self, action: #selector(UserViewController.editBtnClick)) + setUserInfor() // Do any additional setup after loading the view. } + + func setUserInfor(){ + userPhoto.layer.cornerRadius = userPhoto.frame.size.height/2 + userPhoto.layer.masksToBounds = true + userName.text = AppDelegate.instance().accountManager.name() + userPhoto.sd_setImage(with: URL(string: AppDelegate.instance().accountManager.photo()), placeholderImage: #imageLiteral(resourceName: "defphoto.png")) + + } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } + @IBAction func userEditClcik(_ sender: Any) { + print("编译个人资料") + let vc = Story.instantiateViewControllerWithIdentifier("UserEditViewControllerVC", storyName: "User") as! UserEditViewController + self.navigationController?.pushViewController(vc, animated: true) + } + + func editBtnClick(){ + print("编译设置") + let vc = Story.instantiateViewControllerWithIdentifier("AppSettingViewControllerVC", storyName: "User") as! AppSettingViewController + self.navigationController?.pushViewController(vc, animated: true) + } + func headerTap(tap:UITapGestureRecognizer){ + isCloseHistoryList = !isCloseHistoryList + historyList.reloadData() + } + /* // MARK: - Navigation @@ -33,3 +65,78 @@ class UserViewController: UIViewController { */ } + +extension UserViewController:UITableViewDelegate,UITableViewDataSource{ + + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let vc = Story.instantiateViewControllerWithIdentifier("HistoryViewControllerVC", storyName: "User") as! HistoryViewController + vc.type = indexPath.row + vc.title = historyType[indexPath.row] + self.navigationController?.pushViewController(vc, animated: true) + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! UserCenterHistoryCell + cell.titleName.text = historyType[indexPath.row] + return cell + } + + func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if isCloseHistoryList { + return 0 + } + return historyType.count + } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let headerView = UIView(frame: CGRect(x: 0, y: 0, width: getScreenWidth(), height: 44)) + headerView.backgroundColor = UIColor.white + let label = UILabel(frame: CGRect(x: 8, y: headerView.frame.height/2-10, width: 100, height: 21)) + label.text = "历史记录" + label.sizeToFit() + headerView.addSubview(label) + + let image = UIImageView(frame: CGRect(x: 0, y: 0, width: 9, height: 15)) + image.center = CGPoint(x: getScreenWidth() - 20, y: headerView.frame.height/2) + image.image = #imageLiteral(resourceName: "arrow") + image.isUserInteractionEnabled = true + var angle:Double = 0 + if !isCloseHistoryList{ + angle = M_PI_2 + } + image.transform = CGAffineTransform(rotationAngle: CGFloat(angle)) + headerView.addSubview(image) + + let line = UILabel(frame: CGRect(x: 0, y: headerView.frame.height-1, width: getScreenWidth(), height: 1)) + line.backgroundColor = historyList.backgroundColor + headerView.addSubview(line) + + headerView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(UserViewController.headerTap(tap:)))) + return headerView + } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + return 44 + } + + func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { + return 1 + } + + + +} + +class UserCenterHistoryCell:UITableViewCell{ + + @IBOutlet weak var titleName: UILabel! + + + +} + diff --git a/YouerLiveVideo/YouerLiveVideo/util/account.swift b/YouerLiveVideo/YouerLiveVideo/util/account.swift index b99436a..79f6601 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/account.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/account.swift @@ -71,6 +71,20 @@ class AccountManager{ return "" } + func schoolName()->String{ + if let info=rawUserInfo{ + return info.contentData()["f_SchoolName"].stringValue + } + return "" + } + + func isParent()->Bool{ + if let info=rawUserInfo{ + return info.contentData()["f_Identity"].boolValue + } + return false + } + func logOut(){ //退出云信登录 -- libgit2 0.21.0