diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift index facc3b2..11f09a2 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/MainHomeTableViewController.swift @@ -60,13 +60,8 @@ class MainHomeTableViewController: UITableViewController { self.tableHeaderView.addSubview(jyScrollViews) } }, failHandler: { (error) in - self.view.makeToast("获取轮播图失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取轮播图失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取轮播图失败:\(error!.description)") } } } @@ -233,13 +228,8 @@ class HomeSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollec } (self.viewWithTag(1) as! UICollectionView).reloadData() }, failHandler: { (error) in - appRootViewController().view.makeToast("获取热门微课失败:\(error.localizedDescription)") }) - }else{ - appRootViewController().view.makeToast("获取热门微课失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - appRootViewController().view.makeToast("获取热门微课失败:\(error!.description)") } } } @@ -371,13 +361,8 @@ class HomeThirdTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollect } (self.viewWithTag(1) as! UICollectionView).reloadData() }, failHandler: { (error) in - appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)") }) - }else{ - appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - appRootViewController().view.makeToast("获取资源失败:\(error!.description)") } } } @@ -450,13 +435,8 @@ class HomeFourTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollecti } (self.viewWithTag(1) as! UICollectionView).reloadData() }, failHandler: { (error) in - appRootViewController().view.makeToast("获取校园电视台失败:\(error.localizedDescription)") }) - }else{ - appRootViewController().view.makeToast("获取校园电视台失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - appRootViewController().view.makeToast("获取校园电视台失败:\(error!.description)") } } } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift index 4a69343..9752985 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/HomePage/RankingTableViewController.swift @@ -31,13 +31,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 0) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getSchoolUpload { (str, error) in @@ -51,13 +46,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 1) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getSchoolDownloads { (str, error) in @@ -71,13 +61,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 2) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getSchoolPv { (str, error) in @@ -91,13 +76,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 3) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getTeacherGenerals { (str, error) in @@ -111,13 +91,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 4) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getTeacherUpload { (str, error) in @@ -131,13 +106,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 5) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getTeacherDownload { (str, error) in @@ -151,13 +121,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 6) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } AppDelegate.instance().httpServer.getTeacherPvs { (str, error) in @@ -171,13 +136,8 @@ class RankingTableViewController: UITableViewController { self.allDic.updateValue(lineAry, forKey: 7) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("排名失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取排名失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取排名失败:\(error!.description)") } } } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift index db020f8..01fe14a 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/MicroCourse/MicroCourseViewController.swift @@ -124,15 +124,12 @@ class MicroCourseViewController: UIViewController,UITableViewDelegate,UITableVie success=true }, failHandler: { (error) in success=false - appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)") }) }else{ success=false - appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } }else{ success=false - appRootViewController().view.makeToast("获取资源失败:\(error!.description)") } completionHandler(success) } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterListViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterListViewController.swift index 75f3a40..d6bd088 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterListViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterListViewController.swift @@ -32,13 +32,8 @@ class FilterListViewController: UIViewController,UITableViewDelegate,UITableView self.currentItem=filterListModel(array: self.dataSet) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("获取教材目录失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取教材目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取教材目录失败:\(error!.description)") } } case 1: @@ -52,13 +47,8 @@ class FilterListViewController: UIViewController,UITableViewDelegate,UITableView self.currentItem=filterListModel(array: self.dataSet) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("获取知识点目录失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取知识点目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取知识点目录失败:\(error!.description)") } } case 2: @@ -72,13 +62,8 @@ class FilterListViewController: UIViewController,UITableViewDelegate,UITableView self.currentItem=filterListModel(array: self.dataSet) self.tableView.reloadData() }, failHandler: { (error) in - self.view.makeToast("获取考点目录失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取考点目录失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取考点目录失败:\(error!.description)") } } default: diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterViewController.swift index 7c3ce5b..a04375e 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/FilterViewController.swift @@ -77,13 +77,8 @@ class FilterViewController: UIViewController,FilterViewDelegate { self.dataSchoolSection.append(SchoolSection(j: item)) } }, failHandler: { (error) in - self.view.makeToast("获取学段失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取学段失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取学段失败:\(error!.description)") } let filterView=Bundle.main.loadNibNamed("FilterView", owner: nil, options: nil)![0] as! FilterView filterView.frame.size=CGSize(width: getScreenWidth(), height: 60+(getScreenWidth()-80)/12) @@ -163,13 +158,8 @@ class FilterViewController: UIViewController,FilterViewDelegate { self.dataGrade.append(Grade(j: item)) } }, failHandler: { (error) in - self.view.makeToast("获取年级失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取年级失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取年级失败:\(error!.description)") } self.setupFilterView(index: index, arry: self.dataGrade) if self.type.schoolSection != nil && self.type.grade != nil && self.type.subject != nil{ @@ -191,13 +181,8 @@ class FilterViewController: UIViewController,FilterViewDelegate { self.dataSubject.append(Subject(j: item)) } }, failHandler: { (error) in - self.view.makeToast("获取学科失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取学科失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取学科失败:\(error!.description)") } self.setupFilterView(index: index, arry: self.dataSubject) if self.type.schoolSection != nil && self.type.grade != nil && self.type.subject != nil{ @@ -223,13 +208,8 @@ class FilterViewController: UIViewController,FilterViewDelegate { self.dataMaterials.append(Material(j: item)) } }, failHandler: { (error) in - self.view.makeToast("获取教材失败:\(error.localizedDescription)") }) - }else{ - self.view.makeToast("获取教材失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.view.makeToast("获取教材失败:\(error!.description)") } self.setupFilterView(index: index, arry: self.dataMaterials) } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift index e0669b5..220896a 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift @@ -124,15 +124,12 @@ class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDa success=true }, failHandler: { (error) in success=false - appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)") }) }else{ success=false - appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } }else{ success=false - appRootViewController().view.makeToast("获取资源失败:\(error!.description)") } completionHandler(success) } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift index 194ac53..aa90c7d 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/TVStation/ExcellentTVViewController.swift @@ -179,13 +179,8 @@ class ExcellentTVInforHeaderView:UICollectionReusableView{ self.lunboView.addSubview(jyScrollViews) } }, failHandler: { (error) in - self.superViewController.view.makeToast("获取轮播图失败:\(error.localizedDescription)") }) - }else{ - self.superViewController.view.makeToast("获取轮播图失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") } - }else{ - self.superViewController.view.makeToast("获取轮播图失败:\(error!.description)") } } } diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift index fb0f4bc..d03be49 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift @@ -91,10 +91,7 @@ class ChangePassWordViewController: UIViewController { self.navigationController!.popViewController(animated: true) AppDelegate.instance().window?.makeToast("修改成功") }, failHandler: { (error) in - self.view.makeToast("修改失败") }) - }else{ - self.view.makeToast("修改失败") } } } @@ -122,7 +119,7 @@ class ChangePassWordViewController: UIViewController { self.view.makeToast("验证码发送成功") self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ChangePassWordViewController.timerFire), userInfo: sender, repeats: true) }, failHandler: { (error) in - self.view.makeToast("验证码发送失败:\(error.localizedDescription)") + self.view.makeToast("验证码发送失败") }) }else{ self.view.makeToast("验证码发送失败") diff --git a/YouerLiveVideo/YouerLiveVideo/util/network.swift b/YouerLiveVideo/YouerLiveVideo/util/network.swift index 9248a37..cf1b659 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/network.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/network.swift @@ -53,7 +53,14 @@ final class KHttp{ let error=response.result.error let str=response.result.value if let er=error{ - AppDelegate.instance().window?.makeToast("加载失败:\(er.localizedDescription)", duration: 1, position: CSToastPositionBottom) + if (er as NSError).code==NSURLErrorNotConnectedToInternet{ + AppDelegate.instance().window?.makeToast("网络连接不可用", duration: 1, position: CSToastPositionBottom) + }else if (er as NSError).code==NSURLErrorCannotConnectToHost{ + AppDelegate.instance().window?.makeToast("未能连接到服务器", duration: 1, position: CSToastPositionBottom) + }else{ + AppDelegate.instance().window?.makeToast("加载失败:\(er.localizedDescription)", duration: 1, position: CSToastPositionBottom) + } + NSLog("ERROR: url:\(url),error:\(er)") } completionHandler(str,error as NSError?) } -- libgit2 0.21.0