Commit 4f6c7b0b135c02b2909c59eefa3695e866735aa7
Exists in
newLive
Merge branch 'newLive' of http://git.shunzhi.net/iosgroup/newlive into newLive
Showing
4 changed files
with
49 additions
and
33 deletions
Show diff stats
YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift
| ... | ... | @@ -374,18 +374,25 @@ class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollect |
| 374 | 374 | let item=dataSet[indexPath.row] |
| 375 | 375 | let download = DownLoad.share |
| 376 | 376 | download.superVC = ((appRootViewController().childViewControllers[0] as! MViewController).selectedViewController as! UINavigationController).viewControllers[0] |
| 377 | - download.downLoadWithUrl(url: dataSet[indexPath.row].f_ResourceUrl) | |
| 378 | - AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in | |
| 379 | - if error==nil { | |
| 380 | - if JSON.fromString(jsonString: str)!["status"].intValue == 1{ | |
| 381 | - //更新下载量成功刷新页面 | |
| 382 | - self.getHotCourseList() | |
| 377 | + let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | |
| 378 | + let dicULR = documentsURL.appendingPathComponent(AppDelegate.instance().accountManager.id()).appendingPathComponent(item.f_Id) | |
| 379 | + let path=dicULR.path+(item.f_ResourceUrl as NSString).components(separatedBy: "/Resource")[1] | |
| 380 | + if FileManager.default.fileExists(atPath: path) { | |
| 381 | + download.openIt(name: path) | |
| 382 | + }else{ | |
| 383 | + download.downLoadWithUrl(item: item) | |
| 384 | + AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in | |
| 385 | + if error==nil { | |
| 386 | + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ | |
| 387 | + //更新下载量成功刷新页面 | |
| 388 | + self.getHotCourseList() | |
| 389 | + } | |
| 383 | 390 | } |
| 384 | 391 | } |
| 385 | - } | |
| 386 | - AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject, | |
| 387 | - "f_ViewId":item.f_Id as AnyObject, | |
| 388 | - "f_ViewName":item.f_Title as AnyObject]) { (str, error) in | |
| 392 | + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject, | |
| 393 | + "f_ViewId":item.f_Id as AnyObject, | |
| 394 | + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in | |
| 395 | + } | |
| 389 | 396 | } |
| 390 | 397 | }else{ |
| 391 | 398 | AppDelegate.instance().window?.makeToast("无权限查看资源") | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift
| ... | ... | @@ -185,6 +185,7 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie |
| 185 | 185 | self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") |
| 186 | 186 | p=self.parameter! |
| 187 | 187 | } |
| 188 | + self.tableView.reloadData() | |
| 188 | 189 | self.refreshLivesAction(parameters: p, completionHandler: { (success) in |
| 189 | 190 | if success{ |
| 190 | 191 | self.tableView.reloadData() | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift
| ... | ... | @@ -167,30 +167,38 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa |
| 167 | 167 | item=resourceData[indexPath.row] |
| 168 | 168 | } |
| 169 | 169 | let download = DownLoad.share |
| 170 | + let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | |
| 171 | + let dicULR = documentsURL.appendingPathComponent(AppDelegate.instance().accountManager.id()).appendingPathComponent(item.f_Id) | |
| 172 | + let path=dicULR.path+(item.f_ResourceUrl as NSString).components(separatedBy: "/Resource")[1] | |
| 170 | 173 | download.superVC = self |
| 171 | - download.downLoadWithUrl(url: item.f_ResourceUrl) | |
| 172 | - AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in | |
| 173 | - if error==nil { | |
| 174 | - if JSON.fromString(jsonString: str)!["status"].intValue == 1{ | |
| 175 | - //更新下载量成功刷新页面 | |
| 176 | - self.currentPage=1 | |
| 177 | - self.resourceData.removeAll() | |
| 178 | - var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] | |
| 179 | - if self.parameter != nil { | |
| 180 | - self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
| 181 | - p=self.parameter! | |
| 182 | - } | |
| 183 | - self.refreshLivesAction(parameters: p, completionHandler: { (success) in | |
| 184 | - if success{ | |
| 185 | - self.tableView.reloadData() | |
| 174 | + if FileManager.default.fileExists(atPath: path) { | |
| 175 | + download.openIt(name: path) | |
| 176 | + }else{ | |
| 177 | + download.downLoadWithUrl(item: item) | |
| 178 | + AppDelegate.instance().httpServer.updateDownloadSum(parameters: ["f_id":item.f_Id as AnyObject]) { (str, error) in | |
| 179 | + if error==nil { | |
| 180 | + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ | |
| 181 | + //更新下载量成功刷新页面 | |
| 182 | + self.currentPage=1 | |
| 183 | + self.resourceData.removeAll() | |
| 184 | + var p:Dictionary<String,AnyObject>=["type":1 as AnyObject,"orderby":1 as AnyObject,"pageIndex":self.currentPage as AnyObject,"pageSize":10 as AnyObject] | |
| 185 | + if self.parameter != nil { | |
| 186 | + self.parameter!.updateValue(self.currentPage as AnyObject, forKey: "pageIndex") | |
| 187 | + p=self.parameter! | |
| 186 | 188 | } |
| 187 | - }) | |
| 189 | + self.tableView.reloadData() | |
| 190 | + self.refreshLivesAction(parameters: p, completionHandler: { (success) in | |
| 191 | + if success{ | |
| 192 | + self.tableView.reloadData() | |
| 193 | + } | |
| 194 | + }) | |
| 195 | + } | |
| 188 | 196 | } |
| 189 | 197 | } |
| 190 | - } | |
| 191 | - AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject, | |
| 192 | - "f_ViewId":item.f_Id as AnyObject, | |
| 193 | - "f_ViewName":item.f_Title as AnyObject]) { (str, error) in | |
| 198 | + AppDelegate.instance().httpServer.addHistoryView(parameters: ["f_ViewType":1 as AnyObject, | |
| 199 | + "f_ViewId":item.f_Id as AnyObject, | |
| 200 | + "f_ViewName":item.f_Title as AnyObject]) { (str, error) in | |
| 201 | + } | |
| 194 | 202 | } |
| 195 | 203 | } |
| 196 | 204 | //取消键盘输入状态 | ... | ... |
YouerLiveVideo/YouerLiveVideo/util/DownLoad.swift
| ... | ... | @@ -13,17 +13,17 @@ class DownLoad :NSObject,QLPreviewControllerDataSource { |
| 13 | 13 | var superVC:UIViewController! |
| 14 | 14 | static let share=DownLoad() |
| 15 | 15 | private override init() {} |
| 16 | - func downLoadWithUrl(url:String){ | |
| 16 | + func downLoadWithUrl(item:MicroCourseModel){ | |
| 17 | 17 | SVProgressHUD.show(withStatus: "下载中...") |
| 18 | 18 | SVProgressHUD.setDefaultMaskType(.black) |
| 19 | 19 | let destination: DownloadRequest.DownloadFileDestination = { _, response in |
| 20 | 20 | let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] |
| 21 | - let dicULR = documentsURL.appendingPathComponent(self.ID) | |
| 21 | + let dicULR = documentsURL.appendingPathComponent(self.ID).appendingPathComponent(item.f_Id) | |
| 22 | 22 | let fileURL = dicULR.appendingPathComponent(response.suggestedFilename!) |
| 23 | 23 | //两个参数表示如果有同名文件则会覆盖,如果路径中文件夹不存在则会自动创建 |
| 24 | 24 | return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) |
| 25 | 25 | } |
| 26 | - download(url, to: destination) | |
| 26 | + download(item.f_ResourceUrl, to: destination) | |
| 27 | 27 | .response { response in |
| 28 | 28 | SVProgressHUD.dismiss() |
| 29 | 29 | if response.error==nil{ | ... | ... |