Commit 275826c16286ab80eee297d566a31f7239ecd971

Authored by Cao yang
1 parent fafdc552
Exists in parentassistant

commit

Showing 22 changed files with 1587 additions and 1578 deletions   Show diff stats
ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
@@ -105,8 +105,8 @@ @@ -105,8 +105,8 @@
105 BF406CDC2057C110000A6681 /* OrderDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDB2057C110000A6681 /* OrderDetailViewController.swift */; }; 105 BF406CDC2057C110000A6681 /* OrderDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDB2057C110000A6681 /* OrderDetailViewController.swift */; };
106 BF406CDE2057C537000A6681 /* OrderDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDD2057C537000A6681 /* OrderDetailTableViewCell.swift */; }; 106 BF406CDE2057C537000A6681 /* OrderDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDD2057C537000A6681 /* OrderDetailTableViewCell.swift */; };
107 BF406CE02057C708000A6681 /* OrderDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDF2057C708000A6681 /* OrderDetailCollectionViewCell.swift */; }; 107 BF406CE02057C708000A6681 /* OrderDetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CDF2057C708000A6681 /* OrderDetailCollectionViewCell.swift */; };
108 - BF5D166A204E675C00274489 /* account.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5D1669204E675C00274489 /* account.swift */; };  
109 - BF5D166C204E6A0300274489 /* network.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5D166B204E6A0300274489 /* network.swift */; }; 108 + BF5D166A204E675C00274489 /* AccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5D1669204E675C00274489 /* AccountManager.swift */; };
  109 + BF5D166C204E6A0300274489 /* HTTPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5D166B204E6A0300274489 /* HTTPServer.swift */; };
110 BF5D1678204F8E3300274489 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D1677204F8E3300274489 /* CoreTelephony.framework */; }; 110 BF5D1678204F8E3300274489 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D1677204F8E3300274489 /* CoreTelephony.framework */; };
111 BF5D167A204F8E3D00274489 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D1679204F8E3D00274489 /* libz.tbd */; }; 111 BF5D167A204F8E3D00274489 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D1679204F8E3D00274489 /* libz.tbd */; };
112 BF5D167C204F8E6000274489 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D167B204F8E6000274489 /* SystemConfiguration.framework */; }; 112 BF5D167C204F8E6000274489 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D167B204F8E6000274489 /* SystemConfiguration.framework */; };
@@ -288,8 +288,8 @@ @@ -288,8 +288,8 @@
288 BF406CDB2057C110000A6681 /* OrderDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailViewController.swift; sourceTree = "<group>"; }; 288 BF406CDB2057C110000A6681 /* OrderDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailViewController.swift; sourceTree = "<group>"; };
289 BF406CDD2057C537000A6681 /* OrderDetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailTableViewCell.swift; sourceTree = "<group>"; }; 289 BF406CDD2057C537000A6681 /* OrderDetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailTableViewCell.swift; sourceTree = "<group>"; };
290 BF406CDF2057C708000A6681 /* OrderDetailCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailCollectionViewCell.swift; sourceTree = "<group>"; }; 290 BF406CDF2057C708000A6681 /* OrderDetailCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailCollectionViewCell.swift; sourceTree = "<group>"; };
291 - BF5D1669204E675C00274489 /* account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = account.swift; sourceTree = "<group>"; };  
292 - BF5D166B204E6A0300274489 /* network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = network.swift; sourceTree = "<group>"; }; 291 + BF5D1669204E675C00274489 /* AccountManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = "<group>"; };
  292 + BF5D166B204E6A0300274489 /* HTTPServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPServer.swift; sourceTree = "<group>"; };
293 BF5D1677204F8E3300274489 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; 293 BF5D1677204F8E3300274489 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
294 BF5D1679204F8E3D00274489 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 294 BF5D1679204F8E3D00274489 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
295 BF5D167B204F8E6000274489 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 295 BF5D167B204F8E6000274489 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
@@ -471,11 +471,9 @@ @@ -471,11 +471,9 @@
471 599364E0204E62E700C8B371 /* Information */ = { 471 599364E0204E62E700C8B371 /* Information */ = {
472 isa = PBXGroup; 472 isa = PBXGroup;
473 children = ( 473 children = (
  474 + ADCDA074208B3FED004F1852 /* Controller */,
474 ADCDA073208B298D004F1852 /* Model */, 475 ADCDA073208B298D004F1852 /* Model */,
475 - 599364E1204E62E700C8B371 /* InformationViewController.swift */,  
476 - 599364DD204E62E700C8B371 /* ChannelViewController.swift */,  
477 - 599364DE204E62E700C8B371 /* Information.storyboard */,  
478 - 599364F4204E648C00C8B371 /* view */, 476 + 599364F4204E648C00C8B371 /* View */,
479 ); 477 );
480 path = Information; 478 path = Information;
481 sourceTree = "<group>"; 479 sourceTree = "<group>";
@@ -522,8 +520,8 @@ @@ -522,8 +520,8 @@
522 BFF9B7F02057A27C00F39B3E /* view */, 520 BFF9B7F02057A27C00F39B3E /* view */,
523 590944E12057DA73004478B5 /* utils.swift */, 521 590944E12057DA73004478B5 /* utils.swift */,
524 ADE33B302062202300BEA6E6 /* Macro.swift */, 522 ADE33B302062202300BEA6E6 /* Macro.swift */,
525 - BF5D1669204E675C00274489 /* account.swift */,  
526 - BF5D166B204E6A0300274489 /* network.swift */, 523 + BF5D1669204E675C00274489 /* AccountManager.swift */,
  524 + BF5D166B204E6A0300274489 /* HTTPServer.swift */,
527 AD639F062089C3950028BE73 /* LocationManger.swift */, 525 AD639F062089C3950028BE73 /* LocationManger.swift */,
528 BFA7446B208193D300845D30 /* MessageManager.swift */, 526 BFA7446B208193D300845D30 /* MessageManager.swift */,
529 599365282052553900C8B371 /* pinyin.c */, 527 599365282052553900C8B371 /* pinyin.c */,
@@ -532,7 +530,7 @@ @@ -532,7 +530,7 @@
532 path = util; 530 path = util;
533 sourceTree = "<group>"; 531 sourceTree = "<group>";
534 }; 532 };
535 - 599364F4204E648C00C8B371 /* view */ = { 533 + 599364F4204E648C00C8B371 /* View */ = {
536 isa = PBXGroup; 534 isa = PBXGroup;
537 children = ( 535 children = (
538 599364F5204E648C00C8B371 /* ChannelCollectionViewCell.swift */, 536 599364F5204E648C00C8B371 /* ChannelCollectionViewCell.swift */,
@@ -540,7 +538,7 @@ @@ -540,7 +538,7 @@
540 599364F9204E742000C8B371 /* ChannelSelectViewCollectionViewCell.swift */, 538 599364F9204E742000C8B371 /* ChannelSelectViewCollectionViewCell.swift */,
541 599364FA204E742000C8B371 /* ChannelSelectViewCollectionViewCell.xib */, 539 599364FA204E742000C8B371 /* ChannelSelectViewCollectionViewCell.xib */,
542 ); 540 );
543 - path = view; 541 + path = View;
544 sourceTree = "<group>"; 542 sourceTree = "<group>";
545 }; 543 };
546 599364FD204E941900C8B371 /* userCenter */ = { 544 599364FD204E941900C8B371 /* userCenter */ = {
@@ -655,6 +653,16 @@ @@ -655,6 +653,16 @@
655 path = Model; 653 path = Model;
656 sourceTree = "<group>"; 654 sourceTree = "<group>";
657 }; 655 };
  656 + ADCDA074208B3FED004F1852 /* Controller */ = {
  657 + isa = PBXGroup;
  658 + children = (
  659 + 599364DD204E62E700C8B371 /* ChannelViewController.swift */,
  660 + 599364DE204E62E700C8B371 /* Information.storyboard */,
  661 + 599364E1204E62E700C8B371 /* InformationViewController.swift */,
  662 + );
  663 + path = Controller;
  664 + sourceTree = "<group>";
  665 + };
658 B605235D289EDBCA5C5AF2C5 /* Frameworks */ = { 666 B605235D289EDBCA5C5AF2C5 /* Frameworks */ = {
659 isa = PBXGroup; 667 isa = PBXGroup;
660 children = ( 668 children = (
@@ -1133,7 +1141,7 @@ @@ -1133,7 +1141,7 @@
1133 AD639F072089C3950028BE73 /* LocationManger.swift in Sources */, 1141 AD639F072089C3950028BE73 /* LocationManger.swift in Sources */,
1134 590944E22057DA73004478B5 /* utils.swift in Sources */, 1142 590944E22057DA73004478B5 /* utils.swift in Sources */,
1135 BFEAAAC9205257460072FAAF /* NSDate+GFCalendar.m in Sources */, 1143 BFEAAAC9205257460072FAAF /* NSDate+GFCalendar.m in Sources */,
1136 - BF5D166A204E675C00274489 /* account.swift in Sources */, 1144 + BF5D166A204E675C00274489 /* AccountManager.swift in Sources */,
1137 BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */, 1145 BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */,
1138 599364F7204E648C00C8B371 /* ChannelCollectionViewCell.swift in Sources */, 1146 599364F7204E648C00C8B371 /* ChannelCollectionViewCell.swift in Sources */,
1139 BF7A4C36204CD55300460463 /* ViewController.swift in Sources */, 1147 BF7A4C36204CD55300460463 /* ViewController.swift in Sources */,
@@ -1157,7 +1165,7 @@ @@ -1157,7 +1165,7 @@
1157 BFEAAACA205257460072FAAF /* NSString+NCDate.m in Sources */, 1165 BFEAAACA205257460072FAAF /* NSString+NCDate.m in Sources */,
1158 BF388469205A4DE900A240EF /* StudentClassInfo.swift in Sources */, 1166 BF388469205A4DE900A240EF /* StudentClassInfo.swift in Sources */,
1159 59C0A9B8205375F800A8BB5A /* SelectCityViewController.swift in Sources */, 1167 59C0A9B8205375F800A8BB5A /* SelectCityViewController.swift in Sources */,
1160 - BF5D166C204E6A0300274489 /* network.swift in Sources */, 1168 + BF5D166C204E6A0300274489 /* HTTPServer.swift in Sources */,
1161 BF7A4C34204CD55300460463 /* AppDelegate.swift in Sources */, 1169 BF7A4C34204CD55300460463 /* AppDelegate.swift in Sources */,
1162 BFEAAAD720525D620072FAAF /* UIColor+Expanded.m in Sources */, 1170 BFEAAAD720525D620072FAAF /* UIColor+Expanded.m in Sources */,
1163 BFF9B7ED2057776100F39B3E /* MyChildrenViewController.swift in Sources */, 1171 BFF9B7ED2057776100F39B3E /* MyChildrenViewController.swift in Sources */,
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 ignoreCount = "0" 20 ignoreCount = "0"
21 continueAfterRunningActions = "No" 21 continueAfterRunningActions = "No"
22 filePath = "ParentAssistant/Classes/controllers/Grow/GrowViewController.swift" 22 filePath = "ParentAssistant/Classes/controllers/Grow/GrowViewController.swift"
23 - timestampString = "545996291.249851" 23 + timestampString = "545997467.221319"
24 startingColumnNumber = "9223372036854775807" 24 startingColumnNumber = "9223372036854775807"
25 endingColumnNumber = "9223372036854775807" 25 endingColumnNumber = "9223372036854775807"
26 startingLineNumber = "162" 26 startingLineNumber = "162"
ParentAssistant/ParentAssistant/Classes/controllers/Information/ChannelViewController.swift
@@ -1,261 +0,0 @@ @@ -1,261 +0,0 @@
1 -//  
2 -// ChannelViewController.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 左丞 on 2018/3/5.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import UIKit  
10 -  
11 -class ChannelViewController: UIViewController,UISearchBarDelegate {  
12 -  
13 - var data:ChannelDemol!  
14 - var topADs:[ADSModel]=[]  
15 - var channelId:Int=0  
16 - @IBOutlet weak var collectView: UICollectionView!  
17 - override func viewDidLoad() {  
18 - super.viewDidLoad()  
19 - let searchView = UISearchBar(frame: CGRect(x: 0, y: 7, width: getScreenWidth()-40, height: 30))  
20 - searchView.delegate = self  
21 - searchView.placeholder = "请输入搜索内容"  
22 - searchView.showsCancelButton = false  
23 - self.navigationItem.titleView = searchView  
24 - collectView.register(UINib(nibName: "ChannelCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "contentCell")  
25 - getData()  
26 - // Do any additional setup after loading the view.  
27 - }  
28 -  
29 - func getData(){  
30 - let topADsQueue = DispatchQueue(label: "topADs")  
31 - topADsQueue.async {  
32 - HTTPServer.shared.getAds(["position":2 as AnyObject], completionHandler: { (str, error) in  
33 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
34 - if json["status"] == 1 && error == nil{  
35 - self.topADs.removeAll()  
36 - for item in json.contentData().arrayValue{  
37 - self.topADs.append(ADSModel(j: item))  
38 - }  
39 - self.collectView.reloadData()  
40 - }  
41 - }, failHandler: { (error) in  
42 -  
43 - })  
44 - })  
45 - }  
46 - topADsQueue.async {  
47 - HTTPServer.shared.getChannelInfo([ "areaName": localAddress as AnyObject,"channel": self.channelId as AnyObject,"toFirstPage": 0 as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject], completionHandler: { (str, error) in  
48 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
49 - if json["status"] == 1 && error == nil{  
50 - self.data = ChannelDemol(j: json.contentData())  
51 - self.collectView.reloadData()  
52 - }  
53 - }, failHandler: { (error) in  
54 -  
55 - })  
56 - })  
57 - }  
58 - }  
59 -  
60 - func getList(key:String?) {  
61 - if key == nil{  
62 - return  
63 - }  
64 - HTTPServer.shared.getInformationTopic(["keyword":key as AnyObject, "areaName": localAddress as AnyObject,"channel": self.channelId as AnyObject,"toFirstPage": 0 as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject], completionHandler: { (str, error) in  
65 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
66 - if json["status"] == 1 && error == nil{  
67 - self.data.channelContent.removeAll()  
68 - for item in json.contentData()["channelList"].arrayValue{  
69 - self.data.channelContent.append(ChannelContentDemol(j: item))  
70 - }  
71 - self.collectView.reloadData()  
72 - }  
73 - }, failHandler: { (error) in  
74 -  
75 - })  
76 - })  
77 - }  
78 -  
79 -  
80 - func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {  
81 - searchBar.showsCancelButton = true  
82 - }  
83 -  
84 - func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {  
85 - searchData(searchBar)  
86 - }  
87 -  
88 - func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {  
89 - searchData(searchBar)  
90 - }  
91 -  
92 - //搜索资讯  
93 - func searchData(_ searchBar: UISearchBar){  
94 - getList(key: searchBar.text)  
95 - searchBar.resignFirstResponder()  
96 - searchBar.showsCancelButton = false  
97 -  
98 - }  
99 -  
100 - override func didReceiveMemoryWarning() {  
101 - super.didReceiveMemoryWarning()  
102 - // Dispose of any resources that can be recreated.  
103 - }  
104 -  
105 -  
106 - /*  
107 - // MARK: - Navigation  
108 -  
109 - // In a storyboard-based application, you will often want to do a little preparation before navigation  
110 - override func prepare(for segue: UIStoryboardSegue, sender: Any?) {  
111 - // Get the new view controller using segue.destinationViewController.  
112 - // Pass the selected object to the new view controller.  
113 - }  
114 - */  
115 -  
116 -}  
117 -extension ChannelViewController:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{  
118 - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {  
119 - switch section {  
120 - case 0:  
121 - return 1  
122 - case 1:  
123 - if data != nil && data.subchannel.count > 0{  
124 - return 1  
125 - }  
126 - return 0  
127 - default:  
128 - return data.channelContent.count  
129 - }  
130 -  
131 - }  
132 -  
133 - func numberOfSections(in collectionView: UICollectionView) -> Int {  
134 - return 3  
135 - }  
136 -  
137 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {  
138 - switch indexPath.section {  
139 - case 0:  
140 - return CGSize(width: getScreenWidth(), height: 161)  
141 - case 1:  
142 - return CGSize(width: getScreenWidth()-20, height: 92)  
143 - default:  
144 - // if indexPath.row == 0{  
145 - return CGSize(width: getScreenWidth()-20, height: 92)  
146 - // }  
147 - // return CGSize(width: getScreenWidth()-20, height: 180)  
148 - }  
149 -  
150 - }  
151 -  
152 - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {  
153 - switch indexPath.section {  
154 - case 0:  
155 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "topCell", for: indexPath) as! InformationViewTopCell  
156 - if topADs.count > 0 {  
157 - var arr:[String]=[]  
158 - for item in topADs{  
159 - arr.append(item.fileSrc)  
160 - }  
161 - cell.headerImageView.imageArray = arr  
162 - }  
163 - return cell  
164 - case 1:  
165 -  
166 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelSelectCell", for: indexPath) as! ChannelSelectView  
167 - cell.SubchannelList = data.subchannel  
168 - cell.superNC = self.navigationController  
169 - return cell  
170 - default:  
171 - /*  
172 - @IBOutlet weak var title: UILabel!  
173 - @IBOutlet weak var option: UILabel!  
174 - @IBOutlet weak var optionNum: UILabel!  
175 - @IBOutlet weak var shareNum: UILabel!  
176 - @IBOutlet weak var picture: UIImageView!  
177 - */  
178 - // if indexPath.row == 0{  
179 - let item = data.channelContent[indexPath.row]  
180 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "contentCell", for: indexPath) as! ChannelCollectionViewCell  
181 - cell.title.text = item.title  
182 - cell.option.text = item.content  
183 - cell.optionNum.text = "\(item.talkNum)"  
184 - cell.shareNum.text = "\(item.forwardingNum)"  
185 - cell.picture.sd_setImage(with: URL(string: (HOSTImage+item.image).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "navigationBar_backgrounImage"))  
186 - return cell  
187 - // }else{  
188 - // let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "adiouPlayerCell", for: indexPath) as! AdiouPlayerCell  
189 - // return cell  
190 - // }  
191 - }  
192 -  
193 - }  
194 -  
195 - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {  
196 - switch indexPath.section {  
197 - case 1:  
198 - let vc = Story.instantiateViewControllerWithIdentifier("ChannelViewControllerVC", storyName: "Information") as! ChannelViewController  
199 - self.navigationController?.pushViewController(vc, animated: true)  
200 - break  
201 - default:  
202 - let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController  
203 - vcs.webURL = "\(HOSTWAP!)/ParentOrderCenter.aspx?userid=\(AccountManager.shared.id())"  
204 - self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)  
205 - }  
206 - }  
207 -  
208 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {  
209 - return CGSize(width: getScreenWidth(), height: 10)  
210 - }  
211 -  
212 -}  
213 -  
214 -class InformationTopCell: UICollectionViewCell {  
215 -  
216 - @IBOutlet weak var headerImageView: XRCarouselView!  
217 - @IBOutlet weak var title: UILabel!  
218 -  
219 -}  
220 -  
221 -class InformationADCell: UICollectionViewCell {  
222 -  
223 -}  
224 -  
225 -//频道栏  
226 -class ChannelViewControllerCell: UICollectionViewCell {  
227 - var superNC:UINavigationController!  
228 - var SubchannelList:[SubchannelDemol]=[]  
229 - @IBOutlet weak var channelSelectCollectionView: UICollectionView!  
230 - override func awakeFromNib() {  
231 - channelSelectCollectionView.register(UINib(nibName: "ChannelSelectViewCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "channelcell")  
232 - }  
233 -  
234 -}  
235 -  
236 -extension ChannelViewControllerCell:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{  
237 - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {  
238 - return SubchannelList.count  
239 - }  
240 -  
241 - func numberOfSections(in collectionView: UICollectionView) -> Int {  
242 - return 1  
243 - }  
244 -  
245 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {  
246 - return CGSize(width: (getScreenWidth()-20)/5, height: 92)  
247 - }  
248 -  
249 - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {  
250 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelcell", for: indexPath) as! ChannelSelectViewCollectionViewCell  
251 - cell.image.sd_setImage(with: URL(string: (HOSTImage+SubchannelList[indexPath.row].channelImage).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: #imageLiteral(resourceName: "Information_bar_icon"))  
252 - cell.channelName.text = SubchannelList[indexPath.row].channelName  
253 - return cell  
254 -  
255 - }  
256 -  
257 - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {  
258 - let vc = Story.instantiateViewControllerWithIdentifier("ChannelViewControllerVC", storyName: "Information") as! ChannelViewController  
259 - superNC.pushViewController(vc, animated: true)  
260 - }  
261 -}  
ParentAssistant/ParentAssistant/Classes/controllers/Information/Controller/ChannelViewController.swift 0 → 100644
@@ -0,0 +1,261 @@ @@ -0,0 +1,261 @@
  1 +//
  2 +// ChannelViewController.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 左丞 on 2018/3/5.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class ChannelViewController: UIViewController,UISearchBarDelegate {
  12 +
  13 + var data:ChannelDemol!
  14 + var topADs:[ADSModel]=[]
  15 + var channelId:Int=0
  16 + @IBOutlet weak var collectView: UICollectionView!
  17 + override func viewDidLoad() {
  18 + super.viewDidLoad()
  19 + let searchView = UISearchBar(frame: CGRect(x: 0, y: 7, width: getScreenWidth()-40, height: 30))
  20 + searchView.delegate = self
  21 + searchView.placeholder = "请输入搜索内容"
  22 + searchView.showsCancelButton = false
  23 + self.navigationItem.titleView = searchView
  24 + collectView.register(UINib(nibName: "ChannelCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "contentCell")
  25 + getData()
  26 + // Do any additional setup after loading the view.
  27 + }
  28 +
  29 + func getData(){
  30 + let topADsQueue = DispatchQueue(label: "topADs")
  31 + topADsQueue.async {
  32 + HTTPServer.shared.getAds(["position":2 as AnyObject], completionHandler: { (str, error) in
  33 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  34 + if json["status"] == 1 && error == nil{
  35 + self.topADs.removeAll()
  36 + for item in json.contentData().arrayValue{
  37 + self.topADs.append(ADSModel(j: item))
  38 + }
  39 + self.collectView.reloadData()
  40 + }
  41 + }, failHandler: { (error) in
  42 +
  43 + })
  44 + })
  45 + }
  46 + topADsQueue.async {
  47 + HTTPServer.shared.getChannelInfo([ "areaName": localAddress as AnyObject,"channel": self.channelId as AnyObject,"toFirstPage": 0 as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject], completionHandler: { (str, error) in
  48 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  49 + if json["status"] == 1 && error == nil{
  50 + self.data = ChannelDemol(j: json.contentData())
  51 + self.collectView.reloadData()
  52 + }
  53 + }, failHandler: { (error) in
  54 +
  55 + })
  56 + })
  57 + }
  58 + }
  59 +
  60 + func getList(key:String?) {
  61 + if key == nil{
  62 + return
  63 + }
  64 + HTTPServer.shared.getInformationTopic(["keyword":key as AnyObject, "areaName": localAddress as AnyObject,"channel": self.channelId as AnyObject,"toFirstPage": 0 as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject], completionHandler: { (str, error) in
  65 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  66 + if json["status"] == 1 && error == nil{
  67 + self.data.channelContent.removeAll()
  68 + for item in json.contentData()["channelList"].arrayValue{
  69 + self.data.channelContent.append(ChannelContentDemol(j: item))
  70 + }
  71 + self.collectView.reloadData()
  72 + }
  73 + }, failHandler: { (error) in
  74 +
  75 + })
  76 + })
  77 + }
  78 +
  79 +
  80 + func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
  81 + searchBar.showsCancelButton = true
  82 + }
  83 +
  84 + func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
  85 + searchData(searchBar)
  86 + }
  87 +
  88 + func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
  89 + searchData(searchBar)
  90 + }
  91 +
  92 + //搜索资讯
  93 + func searchData(_ searchBar: UISearchBar){
  94 + getList(key: searchBar.text)
  95 + searchBar.resignFirstResponder()
  96 + searchBar.showsCancelButton = false
  97 +
  98 + }
  99 +
  100 + override func didReceiveMemoryWarning() {
  101 + super.didReceiveMemoryWarning()
  102 + // Dispose of any resources that can be recreated.
  103 + }
  104 +
  105 +
  106 + /*
  107 + // MARK: - Navigation
  108 +
  109 + // In a storyboard-based application, you will often want to do a little preparation before navigation
  110 + override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  111 + // Get the new view controller using segue.destinationViewController.
  112 + // Pass the selected object to the new view controller.
  113 + }
  114 + */
  115 +
  116 +}
  117 +extension ChannelViewController:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{
  118 + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  119 + switch section {
  120 + case 0:
  121 + return 1
  122 + case 1:
  123 + if data != nil && data.subchannel.count > 0{
  124 + return 1
  125 + }
  126 + return 0
  127 + default:
  128 + return data.channelContent.count
  129 + }
  130 +
  131 + }
  132 +
  133 + func numberOfSections(in collectionView: UICollectionView) -> Int {
  134 + return 3
  135 + }
  136 +
  137 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  138 + switch indexPath.section {
  139 + case 0:
  140 + return CGSize(width: getScreenWidth(), height: 161)
  141 + case 1:
  142 + return CGSize(width: getScreenWidth()-20, height: 92)
  143 + default:
  144 + // if indexPath.row == 0{
  145 + return CGSize(width: getScreenWidth()-20, height: 92)
  146 + // }
  147 + // return CGSize(width: getScreenWidth()-20, height: 180)
  148 + }
  149 +
  150 + }
  151 +
  152 + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  153 + switch indexPath.section {
  154 + case 0:
  155 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "topCell", for: indexPath) as! InformationViewTopCell
  156 + if topADs.count > 0 {
  157 + var arr:[String]=[]
  158 + for item in topADs{
  159 + arr.append(item.fileSrc)
  160 + }
  161 + cell.headerImageView.imageArray = arr
  162 + }
  163 + return cell
  164 + case 1:
  165 +
  166 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelSelectCell", for: indexPath) as! ChannelSelectView
  167 + cell.SubchannelList = data.subchannel
  168 + cell.superNC = self.navigationController
  169 + return cell
  170 + default:
  171 + /*
  172 + @IBOutlet weak var title: UILabel!
  173 + @IBOutlet weak var option: UILabel!
  174 + @IBOutlet weak var optionNum: UILabel!
  175 + @IBOutlet weak var shareNum: UILabel!
  176 + @IBOutlet weak var picture: UIImageView!
  177 + */
  178 + // if indexPath.row == 0{
  179 + let item = data.channelContent[indexPath.row]
  180 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "contentCell", for: indexPath) as! ChannelCollectionViewCell
  181 + cell.title.text = item.title
  182 + cell.option.text = item.content
  183 + cell.optionNum.text = "\(item.talkNum)"
  184 + cell.shareNum.text = "\(item.forwardingNum)"
  185 + cell.picture.sd_setImage(with: URL(string: (HOSTImage+item.image).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "navigationBar_backgrounImage"))
  186 + return cell
  187 + // }else{
  188 + // let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "adiouPlayerCell", for: indexPath) as! AdiouPlayerCell
  189 + // return cell
  190 + // }
  191 + }
  192 +
  193 + }
  194 +
  195 + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  196 + switch indexPath.section {
  197 + case 1:
  198 + let vc = Story.instantiateViewControllerWithIdentifier("ChannelViewControllerVC", storyName: "Information") as! ChannelViewController
  199 + self.navigationController?.pushViewController(vc, animated: true)
  200 + break
  201 + default:
  202 + let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController
  203 + vcs.webURL = "\(HOSTWAP!)/ParentOrderCenter.aspx?userid=\(AccountManager.shared.id())"
  204 + self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)
  205 + }
  206 + }
  207 +
  208 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
  209 + return CGSize(width: getScreenWidth(), height: 10)
  210 + }
  211 +
  212 +}
  213 +
  214 +class InformationTopCell: UICollectionViewCell {
  215 +
  216 + @IBOutlet weak var headerImageView: XRCarouselView!
  217 + @IBOutlet weak var title: UILabel!
  218 +
  219 +}
  220 +
  221 +class InformationADCell: UICollectionViewCell {
  222 +
  223 +}
  224 +
  225 +//频道栏
  226 +class ChannelViewControllerCell: UICollectionViewCell {
  227 + var superNC:UINavigationController!
  228 + var SubchannelList:[SubchannelDemol]=[]
  229 + @IBOutlet weak var channelSelectCollectionView: UICollectionView!
  230 + override func awakeFromNib() {
  231 + channelSelectCollectionView.register(UINib(nibName: "ChannelSelectViewCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "channelcell")
  232 + }
  233 +
  234 +}
  235 +
  236 +extension ChannelViewControllerCell:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{
  237 + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  238 + return SubchannelList.count
  239 + }
  240 +
  241 + func numberOfSections(in collectionView: UICollectionView) -> Int {
  242 + return 1
  243 + }
  244 +
  245 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  246 + return CGSize(width: (getScreenWidth()-20)/5, height: 92)
  247 + }
  248 +
  249 + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  250 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelcell", for: indexPath) as! ChannelSelectViewCollectionViewCell
  251 + cell.image.sd_setImage(with: URL(string: (HOSTImage+SubchannelList[indexPath.row].channelImage).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: #imageLiteral(resourceName: "Information_bar_icon"))
  252 + cell.channelName.text = SubchannelList[indexPath.row].channelName
  253 + return cell
  254 +
  255 + }
  256 +
  257 + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  258 + let vc = Story.instantiateViewControllerWithIdentifier("ChannelViewControllerVC", storyName: "Information") as! ChannelViewController
  259 + superNC.pushViewController(vc, animated: true)
  260 + }
  261 +}
ParentAssistant/ParentAssistant/Classes/controllers/Information/Controller/Information.storyboard 0 → 100644
@@ -0,0 +1,140 @@ @@ -0,0 +1,140 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <deployment identifier="iOS"/>
  8 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
  9 + <capability name="Safe area layout guides" minToolsVersion="9.0"/>
  10 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  11 + </dependencies>
  12 + <scenes>
  13 + <!--Channel View Controller-->
  14 + <scene sceneID="ABm-lX-clu">
  15 + <objects>
  16 + <viewController storyboardIdentifier="ChannelViewControllerVC" id="bVx-8B-9mN" customClass="ChannelViewController" customModule="ParentAssistant" customModuleProvider="target" sceneMemberID="viewController">
  17 + <view key="view" contentMode="scaleToFill" id="Tna-Gl-4Ek">
  18 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  19 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  20 + <subviews>
  21 + <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="JCs-3l-84a">
  22 + <rect key="frame" x="0.0" y="64" width="375" height="603"/>
  23 + <color key="backgroundColor" red="0.91372549020000005" green="0.91764705879999997" blue="0.92156862750000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  24 + <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="EZR-lc-xvu">
  25 + <size key="itemSize" width="335" height="161"/>
  26 + <size key="headerReferenceSize" width="0.0" height="0.0"/>
  27 + <size key="footerReferenceSize" width="0.0" height="0.0"/>
  28 + <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
  29 + </collectionViewFlowLayout>
  30 + <cells>
  31 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="topCell" id="C9Z-rg-SZk" customClass="InformationTopCell" customModule="ParentAssistant" customModuleProvider="target">
  32 + <rect key="frame" x="0.5" y="0.0" width="374" height="161"/>
  33 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  34 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
  35 + <rect key="frame" x="0.0" y="0.0" width="374" height="161"/>
  36 + <autoresizingMask key="autoresizingMask"/>
  37 + <subviews>
  38 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mlR-FH-5Nu" customClass="XRCarouselView">
  39 + <rect key="frame" x="0.0" y="0.0" width="374" height="161"/>
  40 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  41 + </view>
  42 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CtD-5W-zwV">
  43 + <rect key="frame" x="0.0" y="141" width="374" height="20"/>
  44 + <color key="backgroundColor" white="0.0" alpha="0.23335255872483221" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  45 + <constraints>
  46 + <constraint firstAttribute="height" constant="20" id="tlk-t1-rt0"/>
  47 + </constraints>
  48 + <fontDescription key="fontDescription" type="system" pointSize="13"/>
  49 + <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  50 + <nil key="highlightedColor"/>
  51 + </label>
  52 + </subviews>
  53 + </view>
  54 + <constraints>
  55 + <constraint firstAttribute="bottom" secondItem="CtD-5W-zwV" secondAttribute="bottom" id="BKJ-uT-MBo"/>
  56 + <constraint firstAttribute="trailing" secondItem="CtD-5W-zwV" secondAttribute="trailing" id="CfU-o0-rKa"/>
  57 + <constraint firstItem="mlR-FH-5Nu" firstAttribute="top" secondItem="C9Z-rg-SZk" secondAttribute="top" id="GzZ-7c-SJQ"/>
  58 + <constraint firstItem="CtD-5W-zwV" firstAttribute="leading" secondItem="C9Z-rg-SZk" secondAttribute="leading" id="LTu-nA-Cao"/>
  59 + <constraint firstItem="mlR-FH-5Nu" firstAttribute="leading" secondItem="C9Z-rg-SZk" secondAttribute="leading" id="Nb7-pB-Ghp"/>
  60 + <constraint firstAttribute="trailing" secondItem="mlR-FH-5Nu" secondAttribute="trailing" id="SxQ-N0-Y0N"/>
  61 + <constraint firstAttribute="bottom" secondItem="mlR-FH-5Nu" secondAttribute="bottom" id="tMq-AF-wX6"/>
  62 + </constraints>
  63 + <size key="customSize" width="374" height="161"/>
  64 + <connections>
  65 + <outlet property="headerImageView" destination="mlR-FH-5Nu" id="xSr-kh-gxk"/>
  66 + <outlet property="title" destination="CtD-5W-zwV" id="01f-Fi-QTy"/>
  67 + </connections>
  68 + </collectionViewCell>
  69 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ADCell" id="MF6-Kw-UCV" customClass="InformationADCell" customModule="ParentAssistant" customModuleProvider="target">
  70 + <rect key="frame" x="13.5" y="171" width="348" height="112"/>
  71 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  72 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
  73 + <rect key="frame" x="0.0" y="0.0" width="348" height="112"/>
  74 + <autoresizingMask key="autoresizingMask"/>
  75 + </view>
  76 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  77 + <size key="customSize" width="348" height="112"/>
  78 + </collectionViewCell>
  79 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell1" id="cWU-ha-KKs" customClass="ChannelViewControllerCell" customModule="ParentAssistant" customModuleProvider="target">
  80 + <rect key="frame" x="13.5" y="293" width="348" height="132"/>
  81 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  82 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
  83 + <rect key="frame" x="0.0" y="0.0" width="348" height="132"/>
  84 + <autoresizingMask key="autoresizingMask"/>
  85 + <subviews>
  86 + <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="UVy-LN-rIh">
  87 + <rect key="frame" x="0.0" y="0.0" width="348" height="132"/>
  88 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  89 + <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="N6m-Dl-7w9">
  90 + <size key="itemSize" width="50" height="50"/>
  91 + <size key="headerReferenceSize" width="0.0" height="0.0"/>
  92 + <size key="footerReferenceSize" width="0.0" height="0.0"/>
  93 + <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
  94 + </collectionViewFlowLayout>
  95 + <cells/>
  96 + <connections>
  97 + <outlet property="dataSource" destination="cWU-ha-KKs" id="ZxT-TP-u6g"/>
  98 + <outlet property="delegate" destination="cWU-ha-KKs" id="M8p-FM-wb0"/>
  99 + </connections>
  100 + </collectionView>
  101 + </subviews>
  102 + </view>
  103 + <constraints>
  104 + <constraint firstItem="UVy-LN-rIh" firstAttribute="leading" secondItem="cWU-ha-KKs" secondAttribute="leading" id="6jP-NG-yGT"/>
  105 + <constraint firstAttribute="bottom" secondItem="UVy-LN-rIh" secondAttribute="bottom" id="HLY-bl-LbB"/>
  106 + <constraint firstAttribute="trailing" secondItem="UVy-LN-rIh" secondAttribute="trailing" id="NIK-YL-djb"/>
  107 + <constraint firstItem="UVy-LN-rIh" firstAttribute="top" secondItem="cWU-ha-KKs" secondAttribute="top" id="i6X-zn-Awk"/>
  108 + </constraints>
  109 + <size key="customSize" width="348" height="132"/>
  110 + <connections>
  111 + <outlet property="channelSelectCollectionView" destination="UVy-LN-rIh" id="loe-wl-4L8"/>
  112 + </connections>
  113 + </collectionViewCell>
  114 + </cells>
  115 + <connections>
  116 + <outlet property="dataSource" destination="bVx-8B-9mN" id="KcK-UP-0pg"/>
  117 + <outlet property="delegate" destination="bVx-8B-9mN" id="Owl-6U-OK1"/>
  118 + </connections>
  119 + </collectionView>
  120 + </subviews>
  121 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  122 + <constraints>
  123 + <constraint firstItem="JCs-3l-84a" firstAttribute="trailing" secondItem="BIT-6f-Ard" secondAttribute="trailing" id="7OD-37-Wfz"/>
  124 + <constraint firstItem="JCs-3l-84a" firstAttribute="bottom" secondItem="BIT-6f-Ard" secondAttribute="bottom" id="A2F-z2-cUs"/>
  125 + <constraint firstItem="JCs-3l-84a" firstAttribute="leading" secondItem="BIT-6f-Ard" secondAttribute="leading" id="jio-Jz-czF"/>
  126 + <constraint firstItem="JCs-3l-84a" firstAttribute="top" secondItem="BIT-6f-Ard" secondAttribute="top" id="rxj-M1-acl"/>
  127 + </constraints>
  128 + <viewLayoutGuide key="safeArea" id="BIT-6f-Ard"/>
  129 + </view>
  130 + <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
  131 + <connections>
  132 + <outlet property="collectView" destination="JCs-3l-84a" id="rTr-7z-SHG"/>
  133 + </connections>
  134 + </viewController>
  135 + <placeholder placeholderIdentifier="IBFirstResponder" id="a4a-xX-AnY" userLabel="First Responder" sceneMemberID="firstResponder"/>
  136 + </objects>
  137 + <point key="canvasLocation" x="-41" y="179"/>
  138 + </scene>
  139 + </scenes>
  140 +</document>
ParentAssistant/ParentAssistant/Classes/controllers/Information/Controller/InformationViewController.swift 0 → 100644
@@ -0,0 +1,377 @@ @@ -0,0 +1,377 @@
  1 +//
  2 +// InformationViewController.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 葛建军 on 2018/3/5.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +class InformationViewController: UIViewController,UISearchBarDelegate {
  11 + @IBOutlet weak var collectView: UICollectionView!
  12 + var leftLabel:UILabel!
  13 + var data:ChannelDemol!
  14 + var topADs:[ADSModel]=[]
  15 + var isFirstviewController:Bool=true
  16 + var channel:Int=0
  17 +
  18 + //导航栏左侧按钮
  19 + lazy var leftCityView = {()-> UIView in
  20 + //左按钮
  21 + let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 70, height: 44))
  22 + let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44))
  23 +
  24 + titleLab.font = UIFont.systemFont(ofSize: 15)
  25 + titleLab.numberOfLines = 0
  26 + titleLab.adjustsFontSizeToFitWidth = true
  27 + titleLab.textAlignment = .center
  28 + titleLab.textColor = .white
  29 + titleLab.text = localAddress
  30 + self.leftLabel = titleLab
  31 + leftView.addSubview(titleLab)
  32 +
  33 + let imageView = UIImageView.init(frame: CGRect.init(x: 60, y: 11, width: 10, height: 22))
  34 + imageView.image = UIImage.init(named: "report_white_pull")
  35 + imageView.contentMode = .scaleAspectFit
  36 + leftView.addSubview(imageView)
  37 +
  38 + leftView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(EvaluationViewController.getAddreess(tap:))))
  39 + return leftView
  40 + }()
  41 +
  42 + override func viewDidLoad() {
  43 + super.viewDidLoad()
  44 +
  45 + let item = UIBarButtonItem.init(title: "返回", style: .plain, target: self, action: nil)
  46 + self.navigationItem.backBarButtonItem = item
  47 +
  48 + drawTopUI()
  49 +
  50 + }
  51 + override func viewWillAppear(_ animated: Bool) {
  52 + super.viewWillAppear(animated)
  53 +
  54 + if isFirstviewController{
  55 + let leftBtn = UIBarButtonItem.init(customView: self.leftCityView)
  56 + self.navigationItem.leftBarButtonItem = leftBtn
  57 + if localAddress == "未知" {
  58 + LocationManger.shared.block = { str in
  59 + localAddress = str
  60 + self.leftLabel.text = localAddress
  61 + self.getDataFromNet()
  62 + }
  63 + }
  64 + }
  65 + self.getDataFromNet()
  66 + }
  67 + func drawTopUI(){
  68 +
  69 + self.configTheme()
  70 + //搜索框
  71 + let searchView = SearchBarView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth-100, height: navigationBarHeight!))
  72 + //MARK:搜索框搜索回调
  73 + searchView.block = { str,type in
  74 + DebugLog(str)
  75 + switch type {
  76 + case .SearchType:
  77 + self.getList(key: str)
  78 + case .CancelType:
  79 + self.getDataFromNet()
  80 + }
  81 + }
  82 + self.navigationItem.titleView = searchView
  83 + }
  84 + override func viewWillDisappear(_ animated: Bool) {
  85 + super.viewWillDisappear(animated)
  86 + SVProgressHUD.dismiss()
  87 + }
  88 + //MARK: - 获取该城市下的数据
  89 + private func getDataFromNet(){
  90 + //position 广告位置0-首次广告位1-开屏广告位2-资讯首页3-频道首页4-频道内容5-文章内容页
  91 + SVProgressHUD.show()
  92 + let group = DispatchGroup()
  93 + var position:Int = 2
  94 + if !self.isFirstviewController {
  95 + position = 3
  96 + }
  97 + group.enter()
  98 + HTTPServer.shared.getAds(["position":position as AnyObject,"areaName":localAddress as AnyObject], completionHandler: { (str, error) in//getPercentEncodingString(str: localAddress)
  99 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  100 + if json["status"] == 1 && error == nil{
  101 + self.topADs.removeAll()
  102 + for item in json.contentData().arrayValue{
  103 + self.topADs.append(ADSModel(j: item))
  104 + }
  105 + }
  106 + }, failHandler: { (error) in
  107 +
  108 + })
  109 + group.leave()
  110 + })
  111 + group.enter()
  112 + let dic = self.getListDic()
  113 + HTTPServer.shared.getChannelInfo(dic, completionHandler: { (str, error) in
  114 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  115 + if json["status"] == 1 && error == nil{
  116 + self.data = ChannelDemol(j: json.contentData())
  117 + }
  118 + }, failHandler: { (error) in
  119 +
  120 + })
  121 + group.leave()
  122 + })
  123 + group.notify(queue: DispatchQueue.main) {
  124 + SVProgressHUD.dismiss()
  125 + self.collectView.reloadData()
  126 + }
  127 + }
  128 + //MARK: - 地址选择回调
  129 + @objc func getAddreess(tap:UITapGestureRecognizer){
  130 + tap.view?.isUserInteractionEnabled = false
  131 + LZCityPickerController.showPicker(in: self
  132 + , select: { (address, province, city, area, isSelect) in
  133 + if isSelect{
  134 + tap.view?.isUserInteractionEnabled = true
  135 + self.leftLabel.text = area!
  136 + localAddress = area!
  137 + self.getDataFromNet()
  138 + }
  139 + }) {
  140 + tap.view?.isUserInteractionEnabled = true
  141 + }
  142 + }
  143 +
  144 + //MARK: - 搜索框搜索咨询
  145 + func getList(key:String?) {
  146 + if key == nil{
  147 + return
  148 + }
  149 + var dic = getListDic()
  150 + dic.updateValue(key as AnyObject, forKey: "keyword")
  151 +
  152 + HTTPServer.shared.getInformationTopic(dic, completionHandler: { (str, error) in
  153 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  154 + if json["status"] == 1 && error == nil{
  155 + self.data.channelContent.removeAll()
  156 + for item in json.contentData()["channelList"].arrayValue{
  157 + self.data.channelContent.append(ChannelContentDemol(j: item))
  158 + }
  159 + self.collectView.reloadData()
  160 + }
  161 + }, failHandler: { (error) in
  162 +
  163 + })
  164 + })
  165 + }
  166 +
  167 + //获得请求参数
  168 + func getListDic()->[String:AnyObject]{
  169 + var dic = [ "areaName": localAddress as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject]
  170 + var toFirstPage:Int = 1
  171 + var ch:Int = 0
  172 + if !isFirstviewController{
  173 + toFirstPage = 0
  174 + ch = channel
  175 + }
  176 + dic.updateValue(ch as AnyObject, forKey: "channel")
  177 + dic.updateValue(toFirstPage as AnyObject, forKey: "toFirstPage")
  178 + return dic
  179 + }
  180 +
  181 +
  182 + override func didReceiveMemoryWarning() {
  183 + super.didReceiveMemoryWarning()
  184 + // Dispose of any resources that can be recreated.
  185 + }
  186 +
  187 + //点击资讯进入详情
  188 + func pushToInfoView(index:Int){
  189 + let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController
  190 + if data.channelContent[index].url != "" {
  191 + vcs.webURL = data.channelContent[index].url
  192 + }else{
  193 + vcs.webURL = (HOSTWAP+"/InformationDetail.aspx?id="+"\(data.channelContent[index].id)"+"&areaname="+localAddress).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
  194 + }
  195 + self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)
  196 + }
  197 +
  198 +}
  199 +
  200 +extension InformationViewController:XRCarouselViewDelegate{
  201 + func carouselView(_ carouselView: XRCarouselView!, clickImageAt index: Int) {
  202 + pushToInfoView(index: index)
  203 + }
  204 +}
  205 +
  206 +//整体分三个部分1.轮播图,2频道栏,3列表
  207 +extension InformationViewController:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{
  208 + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  209 + switch section {
  210 + case 0:
  211 + return 1
  212 + case 1:
  213 + if data != nil && data.subchannel.count > 0{
  214 + return 1
  215 + }
  216 + return 0
  217 + default:
  218 + return data != nil ? data.channelContent.count : 0
  219 + }
  220 + }
  221 +
  222 + func numberOfSections(in collectionView: UICollectionView) -> Int {
  223 + return 3
  224 + }
  225 +
  226 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  227 + switch indexPath.section {
  228 + case 0:
  229 + return CGSize(width: getScreenWidth(), height: getScreenWidth()/375*200)
  230 + case 1:
  231 + return CGSize(width: getScreenWidth()-20, height: 92)
  232 + default:
  233 +// if indexPath.row == 0{
  234 + return CGSize(width: getScreenWidth()-20, height: 92)
  235 +// }
  236 +// return CGSize(width: getScreenWidth()-20, height: 180)
  237 + }
  238 + }
  239 +
  240 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
  241 + if section == 2{
  242 + return CGSize(width: getScreenWidth()-20, height: 40)
  243 + }else{
  244 + return CGSize(width: getScreenWidth(), height: 10)
  245 + }
  246 + }
  247 +
  248 + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  249 + collectionView.register(UINib(nibName: "ChannelCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "contentCell")
  250 + switch indexPath.section {
  251 + case 0:
  252 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "topCell", for: indexPath) as! InformationViewTopCell
  253 + if topADs.count > 0 {
  254 + var arr:[String]=[]
  255 + for item in topADs{
  256 + arr.append(HOSTImage+item.fileSrc)
  257 + }
  258 + cell.headerImageView.imageArray = arr
  259 + }
  260 + return cell
  261 + case 1:
  262 +
  263 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelSelectCell", for: indexPath) as! ChannelSelectView
  264 + cell.SubchannelList = data.subchannel
  265 + cell.superNC = self.navigationController
  266 + return cell
  267 + default:
  268 +// if indexPath.row == 0{
  269 + let item = data.channelContent[indexPath.row]
  270 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "contentCell", for: indexPath) as! ChannelCollectionViewCell
  271 + cell.title.text = item.title
  272 + cell.option.text = item.content
  273 + cell.optionNum.text = "\(item.lookNum)"
  274 + cell.shareNum.text = "\(item.forwardingNum)"
  275 + cell.picture.sd_setImage(with: URL(string: (HOSTImage+item.image).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "navigationBar_backgrounImage"))
  276 + return cell
  277 +// }else{
  278 +// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "adiouPlayerCell", for: indexPath) as! AdiouPlayerCell
  279 +// return cell
  280 +// }
  281 + }
  282 + }
  283 +
  284 + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  285 + switch indexPath.section {
  286 + case 1:
  287 + let vc = Story.instantiateViewControllerWithIdentifier("InformationViewControllerVC", storyName: "Main") as! InformationViewController
  288 + vc.channel = data.subchannel[indexPath.row].id
  289 + vc.isFirstviewController = false
  290 + self.navigationController?.pushViewController(vc, animated: true)
  291 + break
  292 + default:
  293 + let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController
  294 + if data.channelContent[indexPath.row].url != "" {
  295 + vcs.webURL = data.channelContent[indexPath.row].url
  296 + }else{
  297 + vcs.webURL = (HOSTWAP+"/InformationDetail.aspx?id="+"\(data.channelContent[indexPath.row].id)"+"&areaname="+localAddress).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
  298 + }
  299 + self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)
  300 +
  301 +// pushToInfoView(index: indexPath.row)
  302 + }
  303 + }
  304 +
  305 + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
  306 + var reusableview:UICollectionReusableView?
  307 + if kind == UICollectionElementKindSectionHeader{
  308 + let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerView", for: indexPath) as! InformationSectionHeader
  309 + headerView.title.text = "咨讯话题"
  310 + reusableview = headerView
  311 + }
  312 + if indexPath.section == 2{
  313 + reusableview?.isHidden = false
  314 + }else{
  315 + reusableview?.isHidden = true
  316 + }
  317 + return reusableview!
  318 + }
  319 +}
  320 +
  321 +
  322 +class InformationSectionHeader: UICollectionReusableView {
  323 + @IBOutlet weak var title: UILabel!
  324 +
  325 +}
  326 +
  327 +//首页的轮播图所在的cell
  328 +class InformationViewTopCell: UICollectionViewCell {
  329 +
  330 + @IBOutlet weak var headerImageView: XRCarouselView!
  331 +
  332 +}
  333 +
  334 +//视频cell
  335 +class AdiouPlayerCell: UICollectionViewCell {
  336 +
  337 +}
  338 +
  339 +//频道栏
  340 +class ChannelSelectView: UICollectionViewCell {
  341 + var superNC:UINavigationController!
  342 + var SubchannelList:[SubchannelDemol]=[]
  343 + @IBOutlet weak var channelSelectCollectionView: UICollectionView!
  344 + override func awakeFromNib() {
  345 + channelSelectCollectionView.register(UINib(nibName: "ChannelSelectViewCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "channelcell")
  346 + }
  347 +}
  348 +
  349 +extension ChannelSelectView:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{
  350 + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  351 + return SubchannelList.count
  352 + }
  353 +
  354 + func numberOfSections(in collectionView: UICollectionView) -> Int {
  355 + return 1
  356 + }
  357 +
  358 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  359 + return CGSize(width: (getScreenWidth()-20)/4, height: 92)
  360 + }
  361 +
  362 + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  363 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelcell", for: indexPath) as! ChannelSelectViewCollectionViewCell
  364 + cell.image.sd_setImage(with: URL(string: (HOSTImage+SubchannelList[indexPath.row].channelImage).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "evaluation_icon_highSchoolEnter"))
  365 + cell.channelName.text = SubchannelList[indexPath.row].channelName
  366 + return cell
  367 + }
  368 +
  369 + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  370 + let vc = Story.instantiateViewControllerWithIdentifier("InformationViewControllerVC", storyName: "Main") as! InformationViewController
  371 + vc.channel = SubchannelList[indexPath.row].id
  372 + vc.isFirstviewController = false
  373 + superNC.pushViewController(vc, animated: true)
  374 + }
  375 +}
  376 +
  377 +
ParentAssistant/ParentAssistant/Classes/controllers/Information/Information.storyboard
@@ -1,140 +0,0 @@ @@ -1,140 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">  
3 - <device id="retina4_7" orientation="portrait">  
4 - <adaptation id="fullscreen"/>  
5 - </device>  
6 - <dependencies>  
7 - <deployment identifier="iOS"/>  
8 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>  
9 - <capability name="Safe area layout guides" minToolsVersion="9.0"/>  
10 - <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>  
11 - </dependencies>  
12 - <scenes>  
13 - <!--Channel View Controller-->  
14 - <scene sceneID="ABm-lX-clu">  
15 - <objects>  
16 - <viewController storyboardIdentifier="ChannelViewControllerVC" id="bVx-8B-9mN" customClass="ChannelViewController" customModule="ParentAssistant" customModuleProvider="target" sceneMemberID="viewController">  
17 - <view key="view" contentMode="scaleToFill" id="Tna-Gl-4Ek">  
18 - <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>  
19 - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>  
20 - <subviews>  
21 - <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="JCs-3l-84a">  
22 - <rect key="frame" x="0.0" y="64" width="375" height="603"/>  
23 - <color key="backgroundColor" red="0.91372549020000005" green="0.91764705879999997" blue="0.92156862750000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>  
24 - <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="EZR-lc-xvu">  
25 - <size key="itemSize" width="335" height="161"/>  
26 - <size key="headerReferenceSize" width="0.0" height="0.0"/>  
27 - <size key="footerReferenceSize" width="0.0" height="0.0"/>  
28 - <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>  
29 - </collectionViewFlowLayout>  
30 - <cells>  
31 - <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="topCell" id="C9Z-rg-SZk" customClass="InformationTopCell" customModule="ParentAssistant" customModuleProvider="target">  
32 - <rect key="frame" x="0.5" y="0.0" width="374" height="161"/>  
33 - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>  
34 - <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">  
35 - <rect key="frame" x="0.0" y="0.0" width="374" height="161"/>  
36 - <autoresizingMask key="autoresizingMask"/>  
37 - <subviews>  
38 - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mlR-FH-5Nu" customClass="XRCarouselView">  
39 - <rect key="frame" x="0.0" y="0.0" width="374" height="161"/>  
40 - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>  
41 - </view>  
42 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CtD-5W-zwV">  
43 - <rect key="frame" x="0.0" y="141" width="374" height="20"/>  
44 - <color key="backgroundColor" white="0.0" alpha="0.23335255872483221" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>  
45 - <constraints>  
46 - <constraint firstAttribute="height" constant="20" id="tlk-t1-rt0"/>  
47 - </constraints>  
48 - <fontDescription key="fontDescription" type="system" pointSize="13"/>  
49 - <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>  
50 - <nil key="highlightedColor"/>  
51 - </label>  
52 - </subviews>  
53 - </view>  
54 - <constraints>  
55 - <constraint firstAttribute="bottom" secondItem="CtD-5W-zwV" secondAttribute="bottom" id="BKJ-uT-MBo"/>  
56 - <constraint firstAttribute="trailing" secondItem="CtD-5W-zwV" secondAttribute="trailing" id="CfU-o0-rKa"/>  
57 - <constraint firstItem="mlR-FH-5Nu" firstAttribute="top" secondItem="C9Z-rg-SZk" secondAttribute="top" id="GzZ-7c-SJQ"/>  
58 - <constraint firstItem="CtD-5W-zwV" firstAttribute="leading" secondItem="C9Z-rg-SZk" secondAttribute="leading" id="LTu-nA-Cao"/>  
59 - <constraint firstItem="mlR-FH-5Nu" firstAttribute="leading" secondItem="C9Z-rg-SZk" secondAttribute="leading" id="Nb7-pB-Ghp"/>  
60 - <constraint firstAttribute="trailing" secondItem="mlR-FH-5Nu" secondAttribute="trailing" id="SxQ-N0-Y0N"/>  
61 - <constraint firstAttribute="bottom" secondItem="mlR-FH-5Nu" secondAttribute="bottom" id="tMq-AF-wX6"/>  
62 - </constraints>  
63 - <size key="customSize" width="374" height="161"/>  
64 - <connections>  
65 - <outlet property="headerImageView" destination="mlR-FH-5Nu" id="xSr-kh-gxk"/>  
66 - <outlet property="title" destination="CtD-5W-zwV" id="01f-Fi-QTy"/>  
67 - </connections>  
68 - </collectionViewCell>  
69 - <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ADCell" id="MF6-Kw-UCV" customClass="InformationADCell" customModule="ParentAssistant" customModuleProvider="target">  
70 - <rect key="frame" x="13.5" y="171" width="348" height="112"/>  
71 - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>  
72 - <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">  
73 - <rect key="frame" x="0.0" y="0.0" width="348" height="112"/>  
74 - <autoresizingMask key="autoresizingMask"/>  
75 - </view>  
76 - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>  
77 - <size key="customSize" width="348" height="112"/>  
78 - </collectionViewCell>  
79 - <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell1" id="cWU-ha-KKs" customClass="ChannelViewControllerCell" customModule="ParentAssistant" customModuleProvider="target">  
80 - <rect key="frame" x="13.5" y="293" width="348" height="132"/>  
81 - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>  
82 - <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">  
83 - <rect key="frame" x="0.0" y="0.0" width="348" height="132"/>  
84 - <autoresizingMask key="autoresizingMask"/>  
85 - <subviews>  
86 - <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="UVy-LN-rIh">  
87 - <rect key="frame" x="0.0" y="0.0" width="348" height="132"/>  
88 - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>  
89 - <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="N6m-Dl-7w9">  
90 - <size key="itemSize" width="50" height="50"/>  
91 - <size key="headerReferenceSize" width="0.0" height="0.0"/>  
92 - <size key="footerReferenceSize" width="0.0" height="0.0"/>  
93 - <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>  
94 - </collectionViewFlowLayout>  
95 - <cells/>  
96 - <connections>  
97 - <outlet property="dataSource" destination="cWU-ha-KKs" id="ZxT-TP-u6g"/>  
98 - <outlet property="delegate" destination="cWU-ha-KKs" id="M8p-FM-wb0"/>  
99 - </connections>  
100 - </collectionView>  
101 - </subviews>  
102 - </view>  
103 - <constraints>  
104 - <constraint firstItem="UVy-LN-rIh" firstAttribute="leading" secondItem="cWU-ha-KKs" secondAttribute="leading" id="6jP-NG-yGT"/>  
105 - <constraint firstAttribute="bottom" secondItem="UVy-LN-rIh" secondAttribute="bottom" id="HLY-bl-LbB"/>  
106 - <constraint firstAttribute="trailing" secondItem="UVy-LN-rIh" secondAttribute="trailing" id="NIK-YL-djb"/>  
107 - <constraint firstItem="UVy-LN-rIh" firstAttribute="top" secondItem="cWU-ha-KKs" secondAttribute="top" id="i6X-zn-Awk"/>  
108 - </constraints>  
109 - <size key="customSize" width="348" height="132"/>  
110 - <connections>  
111 - <outlet property="channelSelectCollectionView" destination="UVy-LN-rIh" id="loe-wl-4L8"/>  
112 - </connections>  
113 - </collectionViewCell>  
114 - </cells>  
115 - <connections>  
116 - <outlet property="dataSource" destination="bVx-8B-9mN" id="KcK-UP-0pg"/>  
117 - <outlet property="delegate" destination="bVx-8B-9mN" id="Owl-6U-OK1"/>  
118 - </connections>  
119 - </collectionView>  
120 - </subviews>  
121 - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>  
122 - <constraints>  
123 - <constraint firstItem="JCs-3l-84a" firstAttribute="trailing" secondItem="BIT-6f-Ard" secondAttribute="trailing" id="7OD-37-Wfz"/>  
124 - <constraint firstItem="JCs-3l-84a" firstAttribute="bottom" secondItem="BIT-6f-Ard" secondAttribute="bottom" id="A2F-z2-cUs"/>  
125 - <constraint firstItem="JCs-3l-84a" firstAttribute="leading" secondItem="BIT-6f-Ard" secondAttribute="leading" id="jio-Jz-czF"/>  
126 - <constraint firstItem="JCs-3l-84a" firstAttribute="top" secondItem="BIT-6f-Ard" secondAttribute="top" id="rxj-M1-acl"/>  
127 - </constraints>  
128 - <viewLayoutGuide key="safeArea" id="BIT-6f-Ard"/>  
129 - </view>  
130 - <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>  
131 - <connections>  
132 - <outlet property="collectView" destination="JCs-3l-84a" id="rTr-7z-SHG"/>  
133 - </connections>  
134 - </viewController>  
135 - <placeholder placeholderIdentifier="IBFirstResponder" id="a4a-xX-AnY" userLabel="First Responder" sceneMemberID="firstResponder"/>  
136 - </objects>  
137 - <point key="canvasLocation" x="-41" y="179"/>  
138 - </scene>  
139 - </scenes>  
140 -</document>  
ParentAssistant/ParentAssistant/Classes/controllers/Information/InformationViewController.swift
@@ -1,377 +0,0 @@ @@ -1,377 +0,0 @@
1 -//  
2 -// InformationViewController.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 葛建军 on 2018/3/5.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import UIKit  
10 -class InformationViewController: UIViewController,UISearchBarDelegate {  
11 - @IBOutlet weak var collectView: UICollectionView!  
12 - var leftLabel:UILabel!  
13 - var data:ChannelDemol!  
14 - var topADs:[ADSModel]=[]  
15 - var isFirstviewController:Bool=true  
16 - var channel:Int=0  
17 -  
18 - //导航栏左侧按钮  
19 - lazy var leftCityView = {()-> UIView in  
20 - //左按钮  
21 - let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 70, height: 44))  
22 - let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44))  
23 -  
24 - titleLab.font = UIFont.systemFont(ofSize: 15)  
25 - titleLab.numberOfLines = 0  
26 - titleLab.adjustsFontSizeToFitWidth = true  
27 - titleLab.textAlignment = .center  
28 - titleLab.textColor = .white  
29 - titleLab.text = localAddress  
30 - self.leftLabel = titleLab  
31 - leftView.addSubview(titleLab)  
32 -  
33 - let imageView = UIImageView.init(frame: CGRect.init(x: 60, y: 11, width: 10, height: 22))  
34 - imageView.image = UIImage.init(named: "report_white_pull")  
35 - imageView.contentMode = .scaleAspectFit  
36 - leftView.addSubview(imageView)  
37 -  
38 - leftView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(EvaluationViewController.getAddreess(tap:))))  
39 - return leftView  
40 - }()  
41 -  
42 - override func viewDidLoad() {  
43 - super.viewDidLoad()  
44 -  
45 - let item = UIBarButtonItem.init(title: "返回", style: .plain, target: self, action: nil)  
46 - self.navigationItem.backBarButtonItem = item  
47 -  
48 - drawTopUI()  
49 -  
50 - }  
51 - override func viewWillAppear(_ animated: Bool) {  
52 - super.viewWillAppear(animated)  
53 -  
54 - if isFirstviewController{  
55 - let leftBtn = UIBarButtonItem.init(customView: self.leftCityView)  
56 - self.navigationItem.leftBarButtonItem = leftBtn  
57 - if localAddress == "未知" {  
58 - LocationManger.shared.block = { str in  
59 - localAddress = str  
60 - self.leftLabel.text = localAddress  
61 - self.getDataFromNet()  
62 - }  
63 - }  
64 - }  
65 - self.getDataFromNet()  
66 - }  
67 - func drawTopUI(){  
68 -  
69 - self.configTheme()  
70 - //搜索框  
71 - let searchView = SearchBarView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth-100, height: navigationBarHeight!))  
72 - //MARK:搜索框搜索回调  
73 - searchView.block = { str,type in  
74 - DebugLog(str)  
75 - switch type {  
76 - case .SearchType:  
77 - self.getList(key: str)  
78 - case .CancelType:  
79 - self.getDataFromNet()  
80 - }  
81 - }  
82 - self.navigationItem.titleView = searchView  
83 - }  
84 - override func viewWillDisappear(_ animated: Bool) {  
85 - super.viewWillDisappear(animated)  
86 - SVProgressHUD.dismiss()  
87 - }  
88 - //MARK: - 获取该城市下的数据  
89 - private func getDataFromNet(){  
90 - //position 广告位置0-首次广告位1-开屏广告位2-资讯首页3-频道首页4-频道内容5-文章内容页  
91 - SVProgressHUD.show()  
92 - let group = DispatchGroup()  
93 - var position:Int = 2  
94 - if !self.isFirstviewController {  
95 - position = 3  
96 - }  
97 - group.enter()  
98 - HTTPServer.shared.getAds(["position":position as AnyObject,"areaName":localAddress as AnyObject], completionHandler: { (str, error) in//getPercentEncodingString(str: localAddress)  
99 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
100 - if json["status"] == 1 && error == nil{  
101 - self.topADs.removeAll()  
102 - for item in json.contentData().arrayValue{  
103 - self.topADs.append(ADSModel(j: item))  
104 - }  
105 - }  
106 - }, failHandler: { (error) in  
107 -  
108 - })  
109 - group.leave()  
110 - })  
111 - group.enter()  
112 - let dic = self.getListDic()  
113 - HTTPServer.shared.getChannelInfo(dic, completionHandler: { (str, error) in  
114 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
115 - if json["status"] == 1 && error == nil{  
116 - self.data = ChannelDemol(j: json.contentData())  
117 - }  
118 - }, failHandler: { (error) in  
119 -  
120 - })  
121 - group.leave()  
122 - })  
123 - group.notify(queue: DispatchQueue.main) {  
124 - SVProgressHUD.dismiss()  
125 - self.collectView.reloadData()  
126 - }  
127 - }  
128 - //MARK: - 地址选择回调  
129 - @objc func getAddreess(tap:UITapGestureRecognizer){  
130 - tap.view?.isUserInteractionEnabled = false  
131 - LZCityPickerController.showPicker(in: self  
132 - , select: { (address, province, city, area, isSelect) in  
133 - if isSelect{  
134 - tap.view?.isUserInteractionEnabled = true  
135 - self.leftLabel.text = area!  
136 - localAddress = area!  
137 - self.getDataFromNet()  
138 - }  
139 - }) {  
140 - tap.view?.isUserInteractionEnabled = true  
141 - }  
142 - }  
143 -  
144 - //MARK: - 搜索框搜索咨询  
145 - func getList(key:String?) {  
146 - if key == nil{  
147 - return  
148 - }  
149 - var dic = getListDic()  
150 - dic.updateValue(key as AnyObject, forKey: "keyword")  
151 -  
152 - HTTPServer.shared.getInformationTopic(dic, completionHandler: { (str, error) in  
153 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) in  
154 - if json["status"] == 1 && error == nil{  
155 - self.data.channelContent.removeAll()  
156 - for item in json.contentData()["channelList"].arrayValue{  
157 - self.data.channelContent.append(ChannelContentDemol(j: item))  
158 - }  
159 - self.collectView.reloadData()  
160 - }  
161 - }, failHandler: { (error) in  
162 -  
163 - })  
164 - })  
165 - }  
166 -  
167 - //获得请求参数  
168 - func getListDic()->[String:AnyObject]{  
169 - var dic = [ "areaName": localAddress as AnyObject,"pageIndex": 1 as AnyObject,"pageSize": 20 as AnyObject]  
170 - var toFirstPage:Int = 1  
171 - var ch:Int = 0  
172 - if !isFirstviewController{  
173 - toFirstPage = 0  
174 - ch = channel  
175 - }  
176 - dic.updateValue(ch as AnyObject, forKey: "channel")  
177 - dic.updateValue(toFirstPage as AnyObject, forKey: "toFirstPage")  
178 - return dic  
179 - }  
180 -  
181 -  
182 - override func didReceiveMemoryWarning() {  
183 - super.didReceiveMemoryWarning()  
184 - // Dispose of any resources that can be recreated.  
185 - }  
186 -  
187 - //点击资讯进入详情  
188 - func pushToInfoView(index:Int){  
189 - let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController  
190 - if data.channelContent[index].url != "" {  
191 - vcs.webURL = data.channelContent[index].url  
192 - }else{  
193 - vcs.webURL = (HOSTWAP+"/InformationDetail.aspx?id="+"\(data.channelContent[index].id)"+"&areaname="+localAddress).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!  
194 - }  
195 - self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)  
196 - }  
197 -  
198 -}  
199 -  
200 -extension InformationViewController:XRCarouselViewDelegate{  
201 - func carouselView(_ carouselView: XRCarouselView!, clickImageAt index: Int) {  
202 - pushToInfoView(index: index)  
203 - }  
204 -}  
205 -  
206 -//整体分三个部分1.轮播图,2频道栏,3列表  
207 -extension InformationViewController:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{  
208 - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {  
209 - switch section {  
210 - case 0:  
211 - return 1  
212 - case 1:  
213 - if data != nil && data.subchannel.count > 0{  
214 - return 1  
215 - }  
216 - return 0  
217 - default:  
218 - return data != nil ? data.channelContent.count : 0  
219 - }  
220 - }  
221 -  
222 - func numberOfSections(in collectionView: UICollectionView) -> Int {  
223 - return 3  
224 - }  
225 -  
226 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {  
227 - switch indexPath.section {  
228 - case 0:  
229 - return CGSize(width: getScreenWidth(), height: getScreenWidth()/375*200)  
230 - case 1:  
231 - return CGSize(width: getScreenWidth()-20, height: 92)  
232 - default:  
233 -// if indexPath.row == 0{  
234 - return CGSize(width: getScreenWidth()-20, height: 92)  
235 -// }  
236 -// return CGSize(width: getScreenWidth()-20, height: 180)  
237 - }  
238 - }  
239 -  
240 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {  
241 - if section == 2{  
242 - return CGSize(width: getScreenWidth()-20, height: 40)  
243 - }else{  
244 - return CGSize(width: getScreenWidth(), height: 10)  
245 - }  
246 - }  
247 -  
248 - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {  
249 - collectionView.register(UINib(nibName: "ChannelCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "contentCell")  
250 - switch indexPath.section {  
251 - case 0:  
252 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "topCell", for: indexPath) as! InformationViewTopCell  
253 - if topADs.count > 0 {  
254 - var arr:[String]=[]  
255 - for item in topADs{  
256 - arr.append(HOSTImage+item.fileSrc)  
257 - }  
258 - cell.headerImageView.imageArray = arr  
259 - }  
260 - return cell  
261 - case 1:  
262 -  
263 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelSelectCell", for: indexPath) as! ChannelSelectView  
264 - cell.SubchannelList = data.subchannel  
265 - cell.superNC = self.navigationController  
266 - return cell  
267 - default:  
268 -// if indexPath.row == 0{  
269 - let item = data.channelContent[indexPath.row]  
270 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "contentCell", for: indexPath) as! ChannelCollectionViewCell  
271 - cell.title.text = item.title  
272 - cell.option.text = item.content  
273 - cell.optionNum.text = "\(item.lookNum)"  
274 - cell.shareNum.text = "\(item.forwardingNum)"  
275 - cell.picture.sd_setImage(with: URL(string: (HOSTImage+item.image).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "navigationBar_backgrounImage"))  
276 - return cell  
277 -// }else{  
278 -// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "adiouPlayerCell", for: indexPath) as! AdiouPlayerCell  
279 -// return cell  
280 -// }  
281 - }  
282 - }  
283 -  
284 - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {  
285 - switch indexPath.section {  
286 - case 1:  
287 - let vc = Story.instantiateViewControllerWithIdentifier("InformationViewControllerVC", storyName: "Main") as! InformationViewController  
288 - vc.channel = data.subchannel[indexPath.row].id  
289 - vc.isFirstviewController = false  
290 - self.navigationController?.pushViewController(vc, animated: true)  
291 - break  
292 - default:  
293 - let vcs = Story.instantiateViewControllerWithIdentifier("JSViewController", storyName: "JS") as! JSViewController  
294 - if data.channelContent[indexPath.row].url != "" {  
295 - vcs.webURL = data.channelContent[indexPath.row].url  
296 - }else{  
297 - vcs.webURL = (HOSTWAP+"/InformationDetail.aspx?id="+"\(data.channelContent[indexPath.row].id)"+"&areaname="+localAddress).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!  
298 - }  
299 - self.navigationController?.present(vcs.wrapWithNavigationController(), animated: true, completion: nil)  
300 -  
301 -// pushToInfoView(index: indexPath.row)  
302 - }  
303 - }  
304 -  
305 - func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {  
306 - var reusableview:UICollectionReusableView?  
307 - if kind == UICollectionElementKindSectionHeader{  
308 - let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerView", for: indexPath) as! InformationSectionHeader  
309 - headerView.title.text = "咨讯话题"  
310 - reusableview = headerView  
311 - }  
312 - if indexPath.section == 2{  
313 - reusableview?.isHidden = false  
314 - }else{  
315 - reusableview?.isHidden = true  
316 - }  
317 - return reusableview!  
318 - }  
319 -}  
320 -  
321 -  
322 -class InformationSectionHeader: UICollectionReusableView {  
323 - @IBOutlet weak var title: UILabel!  
324 -  
325 -}  
326 -  
327 -//首页的轮播图所在的cell  
328 -class InformationViewTopCell: UICollectionViewCell {  
329 -  
330 - @IBOutlet weak var headerImageView: XRCarouselView!  
331 -  
332 -}  
333 -  
334 -//视频cell  
335 -class AdiouPlayerCell: UICollectionViewCell {  
336 -  
337 -}  
338 -  
339 -//频道栏  
340 -class ChannelSelectView: UICollectionViewCell {  
341 - var superNC:UINavigationController!  
342 - var SubchannelList:[SubchannelDemol]=[]  
343 - @IBOutlet weak var channelSelectCollectionView: UICollectionView!  
344 - override func awakeFromNib() {  
345 - channelSelectCollectionView.register(UINib(nibName: "ChannelSelectViewCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "channelcell")  
346 - }  
347 -}  
348 -  
349 -extension ChannelSelectView:UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{  
350 - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {  
351 - return SubchannelList.count  
352 - }  
353 -  
354 - func numberOfSections(in collectionView: UICollectionView) -> Int {  
355 - return 1  
356 - }  
357 -  
358 - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {  
359 - return CGSize(width: (getScreenWidth()-20)/4, height: 92)  
360 - }  
361 -  
362 - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {  
363 - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelcell", for: indexPath) as! ChannelSelectViewCollectionViewCell  
364 - cell.image.sd_setImage(with: URL(string: (HOSTImage+SubchannelList[indexPath.row].channelImage).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!), placeholderImage: UIImage(named: "evaluation_icon_highSchoolEnter"))  
365 - cell.channelName.text = SubchannelList[indexPath.row].channelName  
366 - return cell  
367 - }  
368 -  
369 - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {  
370 - let vc = Story.instantiateViewControllerWithIdentifier("InformationViewControllerVC", storyName: "Main") as! InformationViewController  
371 - vc.channel = SubchannelList[indexPath.row].id  
372 - vc.isFirstviewController = false  
373 - superNC.pushViewController(vc, animated: true)  
374 - }  
375 -}  
376 -  
377 -  
ParentAssistant/ParentAssistant/Classes/controllers/Information/View/ChannelCollectionViewCell.swift 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +//
  2 +// ChannelCollectionViewCell.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 左丞 on 2018/3/6.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class ChannelCollectionViewCell: UICollectionViewCell {
  12 +
  13 + @IBOutlet weak var title: UILabel!
  14 + @IBOutlet weak var option: UILabel!
  15 + @IBOutlet weak var optionNum: UILabel!
  16 + @IBOutlet weak var shareNum: UILabel!
  17 + @IBOutlet weak var picture: UIImageView!
  18 +
  19 + override func awakeFromNib() {
  20 + super.awakeFromNib()
  21 + // Initialization code
  22 + }
  23 +
  24 +}
ParentAssistant/ParentAssistant/Classes/controllers/Information/View/ChannelCollectionViewCell.xib 0 → 100644
@@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <deployment identifier="iOS"/>
  8 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
  9 + <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
  10 + <capability name="Safe area layout guides" minToolsVersion="9.0"/>
  11 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  12 + </dependencies>
  13 + <objects>
  14 + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
  15 + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
  16 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="contentCell" id="gTV-IL-0wX" customClass="ChannelCollectionViewCell" customModule="ParentAssistant" customModuleProvider="target">
  17 + <rect key="frame" x="0.0" y="0.0" width="356" height="92"/>
  18 + <autoresizingMask key="autoresizingMask"/>
  19 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
  20 + <rect key="frame" x="0.0" y="0.0" width="356" height="92"/>
  21 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  22 + <subviews>
  23 + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="evaluation_bar_icon_select" translatesAutoresizingMaskIntoConstraints="NO" id="eQ3-Og-YNl">
  24 + <rect key="frame" x="233.5" y="0.0" width="122.5" height="92"/>
  25 + <constraints>
  26 + <constraint firstAttribute="width" secondItem="eQ3-Og-YNl" secondAttribute="height" multiplier="4:3" id="tCt-vK-QBF"/>
  27 + </constraints>
  28 + </imageView>
  29 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="学校初一段家长统一测试使用家长会得到良好反馈评论" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OQ2-lU-wfc">
  30 + <rect key="frame" x="8" y="8" width="212.5" height="31.5"/>
  31 + <fontDescription key="fontDescription" type="system" pointSize="13"/>
  32 + <nil key="textColor"/>
  33 + <nil key="highlightedColor"/>
  34 + </label>
  35 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="家长表示对孩子学习情况更加了解" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rCP-jW-BhO">
  36 + <rect key="frame" x="8" y="47.5" width="199" height="16"/>
  37 + <fontDescription key="fontDescription" type="system" pointSize="13"/>
  38 + <color key="textColor" red="0.27503338459999999" green="0.50970917940000005" blue="0.90092128520000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  39 + <nil key="highlightedColor"/>
  40 + </label>
  41 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="浏览量:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lvp-kr-OuU">
  42 + <rect key="frame" x="8" y="72" width="34" height="12"/>
  43 + <fontDescription key="fontDescription" type="system" pointSize="10"/>
  44 + <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
  45 + <nil key="highlightedColor"/>
  46 + </label>
  47 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="30" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3KK-be-Vix">
  48 + <rect key="frame" x="50" y="72" width="13" height="12"/>
  49 + <fontDescription key="fontDescription" type="system" pointSize="10"/>
  50 + <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
  51 + <nil key="highlightedColor"/>
  52 + </label>
  53 + <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="转发:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wMQ-5O-LNi">
  54 + <rect key="frame" x="182" y="72" width="24" height="12"/>
  55 + <fontDescription key="fontDescription" type="system" pointSize="10"/>
  56 + <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
  57 + <nil key="highlightedColor"/>
  58 + </label>
  59 + <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="15" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dfn-o9-z6k">
  60 + <rect key="frame" x="214" y="72" width="11.5" height="12"/>
  61 + <fontDescription key="fontDescription" type="system" pointSize="10"/>
  62 + <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
  63 + <nil key="highlightedColor"/>
  64 + </label>
  65 + </subviews>
  66 + </view>
  67 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  68 + <constraints>
  69 + <constraint firstAttribute="bottom" secondItem="Lvp-kr-OuU" secondAttribute="bottom" constant="8" id="Byp-df-Jy7"/>
  70 + <constraint firstItem="Lvp-kr-OuU" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="Fk1-Tk-asI"/>
  71 + <constraint firstItem="Dfn-o9-z6k" firstAttribute="leading" secondItem="wMQ-5O-LNi" secondAttribute="trailing" constant="8" id="Gc2-EO-NVm"/>
  72 + <constraint firstAttribute="bottom" secondItem="eQ3-Og-YNl" secondAttribute="bottom" id="I4I-3J-xap"/>
  73 + <constraint firstItem="Dfn-o9-z6k" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="Jef-4L-wjV"/>
  74 + <constraint firstItem="rCP-jW-BhO" firstAttribute="top" secondItem="OQ2-lU-wfc" secondAttribute="bottom" constant="8" id="Mrr-we-WzT"/>
  75 + <constraint firstItem="OQ2-lU-wfc" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="Nb3-bA-CI7"/>
  76 + <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="OQ2-lU-wfc" secondAttribute="trailing" constant="8" id="SHC-MY-WAd"/>
  77 + <constraint firstAttribute="trailing" secondItem="eQ3-Og-YNl" secondAttribute="trailing" id="VIw-Gd-Dvd"/>
  78 + <constraint firstItem="OQ2-lU-wfc" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="8" id="Z2B-aQ-k1m"/>
  79 + <constraint firstItem="3KK-be-Vix" firstAttribute="leading" secondItem="Lvp-kr-OuU" secondAttribute="trailing" constant="8" id="ZrX-iC-mgd"/>
  80 + <constraint firstItem="wMQ-5O-LNi" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="afZ-7s-EpS"/>
  81 + <constraint firstItem="eQ3-Og-YNl" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="hk0-np-mNK"/>
  82 + <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" secondItem="Dfn-o9-z6k" secondAttribute="trailing" constant="8" id="loX-Pj-ebX"/>
  83 + <constraint firstItem="rCP-jW-BhO" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="qbH-za-saN"/>
  84 + <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="rCP-jW-BhO" secondAttribute="trailing" constant="8" id="xYy-wE-zrW"/>
  85 + <constraint firstItem="3KK-be-Vix" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="yji-Eb-5jx"/>
  86 + </constraints>
  87 + <viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
  88 + <size key="customSize" width="402" height="109"/>
  89 + <connections>
  90 + <outlet property="option" destination="rCP-jW-BhO" id="ct6-xZ-Y3V"/>
  91 + <outlet property="optionNum" destination="3KK-be-Vix" id="5Cz-Ly-1tm"/>
  92 + <outlet property="picture" destination="eQ3-Og-YNl" id="JUz-7i-ANc"/>
  93 + <outlet property="shareNum" destination="Dfn-o9-z6k" id="h2t-eK-3a8"/>
  94 + <outlet property="title" destination="OQ2-lU-wfc" id="sJJ-Eb-zWE"/>
  95 + </connections>
  96 + <point key="canvasLocation" x="12" y="85.5"/>
  97 + </collectionViewCell>
  98 + </objects>
  99 + <resources>
  100 + <image name="evaluation_bar_icon_select" width="22" height="21"/>
  101 + </resources>
  102 +</document>
ParentAssistant/ParentAssistant/Classes/controllers/Information/View/ChannelSelectViewCollectionViewCell.swift 0 → 100644
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +//
  2 +// ChannelSelectViewCollectionViewCell.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 左丞 on 2018/3/6.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +
  11 +class ChannelSelectViewCollectionViewCell: UICollectionViewCell {
  12 +
  13 + @IBOutlet weak var image: UIImageView!
  14 + @IBOutlet weak var channelName: UILabel!
  15 +
  16 + override func awakeFromNib() {
  17 + super.awakeFromNib()
  18 + // Initialization code
  19 + }
  20 +
  21 +}
ParentAssistant/ParentAssistant/Classes/controllers/Information/View/ChannelSelectViewCollectionViewCell.xib 0 → 100644
@@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <deployment identifier="iOS"/>
  8 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
  9 + <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
  10 + <capability name="Safe area layout guides" minToolsVersion="9.0"/>
  11 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  12 + </dependencies>
  13 + <objects>
  14 + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
  15 + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
  16 + <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="channelcell" id="gTV-IL-0wX" customClass="ChannelSelectViewCollectionViewCell" customModule="ParentAssistant" customModuleProvider="target">
  17 + <rect key="frame" x="0.0" y="0.0" width="89" height="92"/>
  18 + <autoresizingMask key="autoresizingMask"/>
  19 + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
  20 + <rect key="frame" x="0.0" y="0.0" width="89" height="92"/>
  21 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  22 + <subviews>
  23 + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="evaluation_icon_highSchoolEnter" translatesAutoresizingMaskIntoConstraints="NO" id="Eco-Nm-1SK">
  24 + <rect key="frame" x="18.5" y="8" width="52" height="52"/>
  25 + <constraints>
  26 + <constraint firstAttribute="width" secondItem="Eco-Nm-1SK" secondAttribute="height" multiplier="1:1" id="8K9-ZW-Cxu"/>
  27 + </constraints>
  28 + <userDefinedRuntimeAttributes>
  29 + <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
  30 + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
  31 + <integer key="value" value="0"/>
  32 + </userDefinedRuntimeAttribute>
  33 + </userDefinedRuntimeAttributes>
  34 + </imageView>
  35 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c3X-8c-2EH">
  36 + <rect key="frame" x="28" y="68" width="33" height="16"/>
  37 + <constraints>
  38 + <constraint firstAttribute="height" constant="16" id="Zvs-7M-0pT"/>
  39 + </constraints>
  40 + <fontDescription key="fontDescription" type="system" pointSize="13"/>
  41 + <color key="textColor" red="0.27450980390000002" green="0.50980392159999999" blue="0.90196078430000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  42 + <nil key="highlightedColor"/>
  43 + </label>
  44 + </subviews>
  45 + </view>
  46 + <constraints>
  47 + <constraint firstAttribute="bottom" secondItem="c3X-8c-2EH" secondAttribute="bottom" constant="8" id="LNs-qC-rfU"/>
  48 + <constraint firstItem="c3X-8c-2EH" firstAttribute="top" secondItem="Eco-Nm-1SK" secondAttribute="bottom" constant="8" id="Z84-pm-JFu"/>
  49 + <constraint firstItem="Eco-Nm-1SK" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="elr-rq-5kH"/>
  50 + <constraint firstItem="Eco-Nm-1SK" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="8" id="oPj-M0-Aap"/>
  51 + <constraint firstItem="c3X-8c-2EH" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="wIz-FB-ESA"/>
  52 + </constraints>
  53 + <viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
  54 + <size key="customSize" width="96" height="108"/>
  55 + <connections>
  56 + <outlet property="channelName" destination="c3X-8c-2EH" id="trZ-23-1dk"/>
  57 + <outlet property="image" destination="Eco-Nm-1SK" id="jsu-CI-9Ti"/>
  58 + </connections>
  59 + <point key="canvasLocation" x="48" y="63"/>
  60 + </collectionViewCell>
  61 + </objects>
  62 + <resources>
  63 + <image name="evaluation_icon_highSchoolEnter" width="44" height="44"/>
  64 + </resources>
  65 +</document>
ParentAssistant/ParentAssistant/Classes/controllers/Information/view/ChannelCollectionViewCell.swift
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -//  
2 -// ChannelCollectionViewCell.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 左丞 on 2018/3/6.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import UIKit  
10 -  
11 -class ChannelCollectionViewCell: UICollectionViewCell {  
12 -  
13 - @IBOutlet weak var title: UILabel!  
14 - @IBOutlet weak var option: UILabel!  
15 - @IBOutlet weak var optionNum: UILabel!  
16 - @IBOutlet weak var shareNum: UILabel!  
17 - @IBOutlet weak var picture: UIImageView!  
18 -  
19 - override func awakeFromNib() {  
20 - super.awakeFromNib()  
21 - // Initialization code  
22 - }  
23 -  
24 -}  
ParentAssistant/ParentAssistant/Classes/controllers/Information/view/ChannelCollectionViewCell.xib
@@ -1,102 +0,0 @@ @@ -1,102 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">  
3 - <device id="retina4_7" orientation="portrait">  
4 - <adaptation id="fullscreen"/>  
5 - </device>  
6 - <dependencies>  
7 - <deployment identifier="iOS"/>  
8 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>  
9 - <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>  
10 - <capability name="Safe area layout guides" minToolsVersion="9.0"/>  
11 - <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>  
12 - </dependencies>  
13 - <objects>  
14 - <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>  
15 - <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>  
16 - <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="contentCell" id="gTV-IL-0wX" customClass="ChannelCollectionViewCell" customModule="ParentAssistant" customModuleProvider="target">  
17 - <rect key="frame" x="0.0" y="0.0" width="356" height="92"/>  
18 - <autoresizingMask key="autoresizingMask"/>  
19 - <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">  
20 - <rect key="frame" x="0.0" y="0.0" width="356" height="92"/>  
21 - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>  
22 - <subviews>  
23 - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="evaluation_bar_icon_select" translatesAutoresizingMaskIntoConstraints="NO" id="eQ3-Og-YNl">  
24 - <rect key="frame" x="233.5" y="0.0" width="122.5" height="92"/>  
25 - <constraints>  
26 - <constraint firstAttribute="width" secondItem="eQ3-Og-YNl" secondAttribute="height" multiplier="4:3" id="tCt-vK-QBF"/>  
27 - </constraints>  
28 - </imageView>  
29 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="学校初一段家长统一测试使用家长会得到良好反馈评论" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OQ2-lU-wfc">  
30 - <rect key="frame" x="8" y="8" width="212.5" height="31.5"/>  
31 - <fontDescription key="fontDescription" type="system" pointSize="13"/>  
32 - <nil key="textColor"/>  
33 - <nil key="highlightedColor"/>  
34 - </label>  
35 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="家长表示对孩子学习情况更加了解" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rCP-jW-BhO">  
36 - <rect key="frame" x="8" y="47.5" width="199" height="16"/>  
37 - <fontDescription key="fontDescription" type="system" pointSize="13"/>  
38 - <color key="textColor" red="0.27503338459999999" green="0.50970917940000005" blue="0.90092128520000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>  
39 - <nil key="highlightedColor"/>  
40 - </label>  
41 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="浏览量:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lvp-kr-OuU">  
42 - <rect key="frame" x="8" y="72" width="34" height="12"/>  
43 - <fontDescription key="fontDescription" type="system" pointSize="10"/>  
44 - <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>  
45 - <nil key="highlightedColor"/>  
46 - </label>  
47 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="30" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3KK-be-Vix">  
48 - <rect key="frame" x="50" y="72" width="13" height="12"/>  
49 - <fontDescription key="fontDescription" type="system" pointSize="10"/>  
50 - <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>  
51 - <nil key="highlightedColor"/>  
52 - </label>  
53 - <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="转发:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wMQ-5O-LNi">  
54 - <rect key="frame" x="182" y="72" width="24" height="12"/>  
55 - <fontDescription key="fontDescription" type="system" pointSize="10"/>  
56 - <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>  
57 - <nil key="highlightedColor"/>  
58 - </label>  
59 - <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="15" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dfn-o9-z6k">  
60 - <rect key="frame" x="214" y="72" width="11.5" height="12"/>  
61 - <fontDescription key="fontDescription" type="system" pointSize="10"/>  
62 - <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>  
63 - <nil key="highlightedColor"/>  
64 - </label>  
65 - </subviews>  
66 - </view>  
67 - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>  
68 - <constraints>  
69 - <constraint firstAttribute="bottom" secondItem="Lvp-kr-OuU" secondAttribute="bottom" constant="8" id="Byp-df-Jy7"/>  
70 - <constraint firstItem="Lvp-kr-OuU" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="Fk1-Tk-asI"/>  
71 - <constraint firstItem="Dfn-o9-z6k" firstAttribute="leading" secondItem="wMQ-5O-LNi" secondAttribute="trailing" constant="8" id="Gc2-EO-NVm"/>  
72 - <constraint firstAttribute="bottom" secondItem="eQ3-Og-YNl" secondAttribute="bottom" id="I4I-3J-xap"/>  
73 - <constraint firstItem="Dfn-o9-z6k" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="Jef-4L-wjV"/>  
74 - <constraint firstItem="rCP-jW-BhO" firstAttribute="top" secondItem="OQ2-lU-wfc" secondAttribute="bottom" constant="8" id="Mrr-we-WzT"/>  
75 - <constraint firstItem="OQ2-lU-wfc" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="Nb3-bA-CI7"/>  
76 - <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="OQ2-lU-wfc" secondAttribute="trailing" constant="8" id="SHC-MY-WAd"/>  
77 - <constraint firstAttribute="trailing" secondItem="eQ3-Og-YNl" secondAttribute="trailing" id="VIw-Gd-Dvd"/>  
78 - <constraint firstItem="OQ2-lU-wfc" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="8" id="Z2B-aQ-k1m"/>  
79 - <constraint firstItem="3KK-be-Vix" firstAttribute="leading" secondItem="Lvp-kr-OuU" secondAttribute="trailing" constant="8" id="ZrX-iC-mgd"/>  
80 - <constraint firstItem="wMQ-5O-LNi" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="afZ-7s-EpS"/>  
81 - <constraint firstItem="eQ3-Og-YNl" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="hk0-np-mNK"/>  
82 - <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" secondItem="Dfn-o9-z6k" secondAttribute="trailing" constant="8" id="loX-Pj-ebX"/>  
83 - <constraint firstItem="rCP-jW-BhO" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="qbH-za-saN"/>  
84 - <constraint firstItem="eQ3-Og-YNl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="rCP-jW-BhO" secondAttribute="trailing" constant="8" id="xYy-wE-zrW"/>  
85 - <constraint firstItem="3KK-be-Vix" firstAttribute="centerY" secondItem="Lvp-kr-OuU" secondAttribute="centerY" id="yji-Eb-5jx"/>  
86 - </constraints>  
87 - <viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>  
88 - <size key="customSize" width="402" height="109"/>  
89 - <connections>  
90 - <outlet property="option" destination="rCP-jW-BhO" id="ct6-xZ-Y3V"/>  
91 - <outlet property="optionNum" destination="3KK-be-Vix" id="5Cz-Ly-1tm"/>  
92 - <outlet property="picture" destination="eQ3-Og-YNl" id="JUz-7i-ANc"/>  
93 - <outlet property="shareNum" destination="Dfn-o9-z6k" id="h2t-eK-3a8"/>  
94 - <outlet property="title" destination="OQ2-lU-wfc" id="sJJ-Eb-zWE"/>  
95 - </connections>  
96 - <point key="canvasLocation" x="12" y="85.5"/>  
97 - </collectionViewCell>  
98 - </objects>  
99 - <resources>  
100 - <image name="evaluation_bar_icon_select" width="22" height="21"/>  
101 - </resources>  
102 -</document>  
ParentAssistant/ParentAssistant/Classes/controllers/Information/view/ChannelSelectViewCollectionViewCell.swift
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -//  
2 -// ChannelSelectViewCollectionViewCell.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 左丞 on 2018/3/6.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import UIKit  
10 -  
11 -class ChannelSelectViewCollectionViewCell: UICollectionViewCell {  
12 -  
13 - @IBOutlet weak var image: UIImageView!  
14 - @IBOutlet weak var channelName: UILabel!  
15 -  
16 - override func awakeFromNib() {  
17 - super.awakeFromNib()  
18 - // Initialization code  
19 - }  
20 -  
21 -}  
ParentAssistant/ParentAssistant/Classes/controllers/Information/view/ChannelSelectViewCollectionViewCell.xib
@@ -1,65 +0,0 @@ @@ -1,65 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">  
3 - <device id="retina4_7" orientation="portrait">  
4 - <adaptation id="fullscreen"/>  
5 - </device>  
6 - <dependencies>  
7 - <deployment identifier="iOS"/>  
8 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>  
9 - <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>  
10 - <capability name="Safe area layout guides" minToolsVersion="9.0"/>  
11 - <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>  
12 - </dependencies>  
13 - <objects>  
14 - <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>  
15 - <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>  
16 - <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="channelcell" id="gTV-IL-0wX" customClass="ChannelSelectViewCollectionViewCell" customModule="ParentAssistant" customModuleProvider="target">  
17 - <rect key="frame" x="0.0" y="0.0" width="89" height="92"/>  
18 - <autoresizingMask key="autoresizingMask"/>  
19 - <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">  
20 - <rect key="frame" x="0.0" y="0.0" width="89" height="92"/>  
21 - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>  
22 - <subviews>  
23 - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="evaluation_icon_highSchoolEnter" translatesAutoresizingMaskIntoConstraints="NO" id="Eco-Nm-1SK">  
24 - <rect key="frame" x="18.5" y="8" width="52" height="52"/>  
25 - <constraints>  
26 - <constraint firstAttribute="width" secondItem="Eco-Nm-1SK" secondAttribute="height" multiplier="1:1" id="8K9-ZW-Cxu"/>  
27 - </constraints>  
28 - <userDefinedRuntimeAttributes>  
29 - <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>  
30 - <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">  
31 - <integer key="value" value="0"/>  
32 - </userDefinedRuntimeAttribute>  
33 - </userDefinedRuntimeAttributes>  
34 - </imageView>  
35 - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c3X-8c-2EH">  
36 - <rect key="frame" x="28" y="68" width="33" height="16"/>  
37 - <constraints>  
38 - <constraint firstAttribute="height" constant="16" id="Zvs-7M-0pT"/>  
39 - </constraints>  
40 - <fontDescription key="fontDescription" type="system" pointSize="13"/>  
41 - <color key="textColor" red="0.27450980390000002" green="0.50980392159999999" blue="0.90196078430000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>  
42 - <nil key="highlightedColor"/>  
43 - </label>  
44 - </subviews>  
45 - </view>  
46 - <constraints>  
47 - <constraint firstAttribute="bottom" secondItem="c3X-8c-2EH" secondAttribute="bottom" constant="8" id="LNs-qC-rfU"/>  
48 - <constraint firstItem="c3X-8c-2EH" firstAttribute="top" secondItem="Eco-Nm-1SK" secondAttribute="bottom" constant="8" id="Z84-pm-JFu"/>  
49 - <constraint firstItem="Eco-Nm-1SK" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="elr-rq-5kH"/>  
50 - <constraint firstItem="Eco-Nm-1SK" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="8" id="oPj-M0-Aap"/>  
51 - <constraint firstItem="c3X-8c-2EH" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="wIz-FB-ESA"/>  
52 - </constraints>  
53 - <viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>  
54 - <size key="customSize" width="96" height="108"/>  
55 - <connections>  
56 - <outlet property="channelName" destination="c3X-8c-2EH" id="trZ-23-1dk"/>  
57 - <outlet property="image" destination="Eco-Nm-1SK" id="jsu-CI-9Ti"/>  
58 - </connections>  
59 - <point key="canvasLocation" x="48" y="63"/>  
60 - </collectionViewCell>  
61 - </objects>  
62 - <resources>  
63 - <image name="evaluation_icon_highSchoolEnter" width="44" height="44"/>  
64 - </resources>  
65 -</document>  
ParentAssistant/ParentAssistant/Classes/util/AccountManager.swift 0 → 100644
@@ -0,0 +1,257 @@ @@ -0,0 +1,257 @@
  1 +//
  2 +// account.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 葛建军 on 2018/3/6.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import Foundation
  10 +class AccountManager: NSObject {
  11 + var rawUserInfo:JSON?
  12 + var userid:String=""
  13 + var token:String?
  14 + var refreshToken:String=""
  15 +// var address:String = "未知"
  16 +
  17 +
  18 + //单例
  19 + static let shared = AccountManager()
  20 +
  21 + override init(){
  22 + rawUserInfo=Setting.getUserInfo()
  23 + if let info=rawUserInfo{
  24 + userid=info.contentData()["userid"].stringValue
  25 + }
  26 + }
  27 +
  28 + //MARK: - 获取个人信息
  29 + /// 获取用户信息
  30 + ///
  31 + /// - Returns: 返回 UserInfoModel
  32 + func getUserInfo() -> UserInfoModel {
  33 +
  34 + var model = UserInfoModel()
  35 + if let dic = Setting.getUserInfo()?.dictionary {
  36 + let data = dic["data"]?.dictionary
  37 + if let value = data {
  38 + model = UserInfoModel.deserialize(from: value)!
  39 + }
  40 + }
  41 + return model
  42 + }
  43 + //MARK: 获取孩子信息
  44 + /// 获取用户孩子信息
  45 + ///
  46 + /// - Returns: 返回 StudentClassInfoModel
  47 + func getChildClassInfo()-> Array<StudentClassInfoModel> {
  48 + var array = Array<StudentClassInfoModel>()
  49 + if let dic = Setting.getUserInfo()?.dictionary {
  50 + let data = dic["data"]?.dictionary
  51 + let studentArr = data!["studentClass"]?.arrayValue
  52 + for i in 0..<studentArr!.count {
  53 + let studentDic = studentArr![i].dictionary
  54 + if let value = studentDic {
  55 + let model = StudentClassInfoModel.deserialize(from: value)
  56 + array.append(model!)
  57 + }
  58 + }
  59 + }
  60 + return array
  61 + }
  62 +
  63 +
  64 + func setTokenInfo(tokenInfo:JSON?){
  65 + if let info=tokenInfo{
  66 + token="Bearer "+info["access_token"].stringValue
  67 + refreshToken=info["refresh_token"].stringValue
  68 + }else{
  69 + token=""
  70 + }
  71 + }
  72 + func loadToken()->JSON?{
  73 + if let token=Setting.getJson("_token"){
  74 + return token
  75 + }
  76 + return nil
  77 + }
  78 + func saveToken(tokenInfo:JSON){
  79 + _=Setting.saveJson(tokenInfo, forKey: "_token")
  80 + }
  81 + //是否登录
  82 + func isOnline() -> Bool {
  83 + if id() != "" {
  84 + return true
  85 + }else{
  86 + return false
  87 + }
  88 + }
  89 + func id()->String{
  90 + if let info=rawUserInfo{
  91 + return info.contentData()["userid"].stringValue
  92 + }
  93 + return ""
  94 + }
  95 + func name()->String{
  96 + if let info=rawUserInfo{
  97 + return info.contentData()["name"].stringValue
  98 + }
  99 + return ""
  100 + }
  101 + func photo()->String{
  102 + if let info=rawUserInfo{
  103 + return info.contentData()["image"].stringValue
  104 + }
  105 + return "defphoto"
  106 + }
  107 + func phone()->String{
  108 + if let info=rawUserInfo{
  109 + return info.contentData()["mobile"].stringValue
  110 + }
  111 + return ""
  112 + }
  113 + func sex()->Int{
  114 + if let info=rawUserInfo{
  115 + return info.contentData()["sex"].intValue
  116 + }
  117 + return 0
  118 + }
  119 +
  120 + func parentId()->Int{
  121 + if let info=rawUserInfo{
  122 + return info.contentData()["parentId"].intValue
  123 + }
  124 + return 0
  125 + }
  126 +
  127 + func studentClass()->[JSON]{
  128 + if let info=rawUserInfo{
  129 + return info.contentData()["studentClass"].arrayValue
  130 + }
  131 + return []
  132 + }
  133 +
  134 + func isNew()->Int{
  135 + if let info=rawUserInfo{
  136 + return info.contentData()["isNew"].intValue
  137 + }
  138 + return 0
  139 + }
  140 +
  141 + func isHeaderTeacher()->Bool{
  142 + if let info=rawUserInfo{
  143 + return info.contentData()["f_Identity"].intValue == 2 ? true : false
  144 + }
  145 + return false
  146 + }
  147 + func logOut(auto:Bool? = false){
  148 + //退出登录
  149 + cleanUserInfoAndPoptoRootVC(auto: auto)
  150 + }
  151 + func cleanUserInfoAndPoptoRootVC(auto:Bool? = false){
  152 + rawUserInfo=nil
  153 + userid=""
  154 + _=Setting.saveUserInfo("")
  155 + UserDefaults.standard.removeObject(forKey: "_token")
  156 + refreshToken = ""
  157 + token = ""
  158 + if auto! {
  159 + if self.appRootViewController().classForCoder==TabBarController.classForCoder(){
  160 + ((self.appRootViewController() as! TabBarController).selectedViewController! as! UINavigationController).popToRootViewController(animated: true)
  161 + }else{
  162 + self.appRootViewController().dismiss(animated: false, completion: {
  163 + (self.appRootViewController() as! UINavigationController).popToRootViewController(animated: true)
  164 + })
  165 + }
  166 + }
  167 + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "loginOutSuccess"), object: nil)
  168 + //取消之前注册的所有本地推送通知
  169 +// UIApplication.shared.cancelAllLocalNotifications()
  170 + //发出刷新首页通知
  171 +// NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil)
  172 + }
  173 + func appRootViewController()->UIViewController {
  174 + let appRootVC=UIApplication.shared.keyWindow?.rootViewController
  175 + var topVC=appRootVC
  176 + while topVC!.presentedViewController != nil {
  177 + topVC=topVC!.presentedViewController
  178 + }
  179 + return topVC!
  180 + }
  181 + func refreshUserInfo(_ mobile:String,completionHandler:((Bool) -> Void)?){
  182 + HTTPServer.shared.getParentInfo(["mobile":mobile as AnyObject], completionHandler: { (str, error) -> Void in
  183 + if error == nil {
  184 + if JSON.fromString(str)!["status"].intValue==4 {
  185 + HTTPServer.shared.refreshToken(completionHandler: { (str, error) in
  186 + if error == nil && JSON.fromString(str)!["status"].intValue==1 {
  187 + self.setTokenInfo(tokenInfo: JSON.fromString(str))
  188 + if let call=completionHandler{
  189 + call(true)
  190 + }
  191 + }else{
  192 + self.logOut()
  193 + appDelegate.window!.makeToast("登录信息已过期,请重新登录", duration: 2, position: CSToastPositionBottom)
  194 + if let call=completionHandler{
  195 + call(false)
  196 + }
  197 + }
  198 + }, token: self.refreshToken)
  199 + }else{
  200 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in
  201 + _=Setting.saveUserInfo(str)
  202 + self.rawUserInfo=json
  203 + self.userid=json.contentData()["userid"].stringValue
  204 + if let call=completionHandler{
  205 + call(true)
  206 + }
  207 + }, failHandler: { (error) -> Void in
  208 + if let call=completionHandler{
  209 + call(false)
  210 + }
  211 + })
  212 + }
  213 + }else{
  214 + if let call=completionHandler{
  215 + call(false)
  216 + }
  217 + }
  218 + })
  219 + }
  220 +}
  221 +
  222 +import HandyJSON
  223 +class UserInfoModel: HandyJSON {
  224 + var parentId = Int()
  225 + var name = String()
  226 + var bindSchoolFlag = Bool()
  227 + var mobile = String()
  228 + var image = String()
  229 + var userid = String()
  230 + var sex = Int()
  231 + required init(){}
  232 +}
  233 +class StudentClassInfoModel: HandyJSON {
  234 +
  235 + var photo = String()
  236 + var cityName = String()
  237 + var cardNumber = String()
  238 + var classId = Int()
  239 + var grade = Int()
  240 + var studentName = String()
  241 + var studentCode = String()
  242 + var parentId = Int()
  243 + var className = String()
  244 + var areaName = String()
  245 + var gradename = String()
  246 + var count = Int()
  247 + var schollId = Int()
  248 + var schoolName = String()
  249 + var studentUserId = String()
  250 + var studentId = Int()
  251 + var parentMobile = Int()
  252 + var sex = Int()
  253 +
  254 + required init(){}
  255 +}
  256 +
  257 +
ParentAssistant/ParentAssistant/Classes/util/HTTPServer.swift 0 → 100644
@@ -0,0 +1,315 @@ @@ -0,0 +1,315 @@
  1 +//
  2 +// network.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 葛建军 on 2018/3/6.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import Foundation
  10 +import Alamofire
  11 +import AlamofireImage
  12 +//http工具
  13 +final class KHttp{
  14 + private static func http(method:HTTPMethod,url:String,parameters: [String: AnyObject]? = nil,encoding: ParameterEncoding = URLEncoding.default,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> ()){
  15 + //认证相关设置
  16 + // let manager = Manager.sharedInstance
  17 + // manager.delegate.sessionDidReceiveChallenge = { session, challenge in
  18 + // //认证服务器证书
  19 + // if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
  20 + // let serverTrust:SecTrustRef = challenge.protectionSpace.serverTrust!
  21 + // let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0)!
  22 + // let remoteCertificateData = CFBridgingRetain(SecCertificateCopyData(certificate))!
  23 + // let cerPath = NSBundle.mainBundle().pathForResource("pub",ofType: "cer")!
  24 + // let localCertificateData = NSData(contentsOfFile:cerPath)!
  25 + // if (remoteCertificateData.isEqualToData(localCertificateData) == true) {
  26 + // let credential = NSURLCredential(forTrust: serverTrust)
  27 + // challenge.sender?.useCredential(credential,
  28 + // forAuthenticationChallenge: challenge)
  29 + // return (NSURLSessionAuthChallengeDisposition.UseCredential,
  30 + // NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!))
  31 + // }else{
  32 + // return (.CancelAuthenticationChallenge, nil)
  33 + // }
  34 + // }else{
  35 + // return (.CancelAuthenticationChallenge, nil)
  36 + // }
  37 + // }
  38 +
  39 + let requestUrl = HOST + url
  40 + request(requestUrl, method: method, parameters: parameters, encoding: encoding, headers: headers).responseString { (response) -> Void in
  41 + let error=response.result.error
  42 + let str=response.result.value
  43 + if let er=error{
  44 + if (er as NSError).code==NSURLErrorNotConnectedToInternet{
  45 + appDelegate.window!.makeToast("网络连接不可用", duration: 1, position: CSToastPositionBottom)
  46 + }else if (er as NSError).code==NSURLErrorCannotConnectToHost{
  47 + appDelegate.window!.makeToast("未能连接到服务器", duration: 1, position: CSToastPositionBottom)
  48 + }else{
  49 + appDelegate.window!.makeToast("加载失败:\(er.localizedDescription)", duration: 1, position: CSToastPositionBottom)
  50 + }
  51 + NSLog("ERROR: url:\(requestUrl),error:\(er)")
  52 + }
  53 + completionHandler(str,error as NSError?)
  54 + }
  55 + }
  56 +
  57 + static func POST(url:String,parameters: [String: AnyObject]? = nil,encoding: ParameterEncoding = URLEncoding.default,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> ()){
  58 + var header:[String: String]
  59 + if let hd=headers {
  60 + header=hd
  61 + header.updateValue(getSign(), forKey: "sign")
  62 + }else{
  63 + header=["sign":getSign()]
  64 + }
  65 + KHttp.http(method: .post, url: url, parameters: parameters,encoding:encoding,headers:header,completionHandler:completionHandler)
  66 + }
  67 + static func GET(url:String,parameters: [String: AnyObject]? = nil,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> Void){
  68 + var header:[String: String]
  69 + if let hd=headers {
  70 + header=hd
  71 + header.updateValue(getSign(), forKey: "sign")
  72 + }else{
  73 + header=["sign":getSign()]
  74 + }
  75 + KHttp.http(method: .get, url: url, parameters: parameters,headers:header,completionHandler:completionHandler)
  76 + }
  77 + static func getSign()->String{
  78 + let timeFormatter=DateFormatter()
  79 + timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"
  80 + let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"// let appKey="1e5b32490ad2e41ecc817849ea1310c6"
  81 + let appSecret="5d744518ac1c"
  82 + return (time.md5()+"/"+time.md5()+appSecret).md5().data(using: .ascii)?.base64EncodedString(options: []) ?? ""
  83 + }
  84 +}
  85 +final class HTTPServer{
  86 +
  87 + //单例
  88 + static let shared = HTTPServer()
  89 + init() {}
  90 +
  91 + var token:String?{
  92 + return AccountManager.shared.token
  93 + }
  94 +
  95 + //上传图片
  96 + func uploadFile(file:NSURL,progress:((Int64, Int64, Int64) -> Void)? = nil,completionHandler: @escaping (String?, NSError?) -> Void){
  97 + upload(multipartFormData: { (multipartFormData) in
  98 + multipartFormData.append(file as URL, withName: "file")
  99 + }, usingThreshold: SessionManager.multipartFormDataEncodingMemoryThreshold, to: URL_UPLOAD_FILE, method: .post, headers: nil) { (encodingResult) in
  100 + switch encodingResult {
  101 + case .success(let upload, _, _):
  102 + upload.responseString(completionHandler: { (response) in
  103 + completionHandler(response.result.value,response.result.error as NSError?)
  104 + })
  105 + case .failure(let encodingError):
  106 + completionHandler(nil,encodingError as NSError?)
  107 + }
  108 + }
  109 + }
  110 + //MARK:-User个人信息有关
  111 + //登录
  112 + func login(completionHandler:@escaping (String?, NSError?) -> (),phone:String, password:String){
  113 + let timeFormatter=DateFormatter()
  114 + timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"
  115 + let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"
  116 + let appSecret="5d744518ac1c"
  117 + let authorization=(time.md5()+":"+(time.md5()+appSecret).md5()).data(using: String.Encoding.ascii)?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) ?? ""
  118 + KHttp.POST(url: URL_OAUTH_TOKEN,parameters: ["grant_type":"password" as AnyObject,"username":phone as AnyObject,"password":password as AnyObject], encoding: URLEncoding.default,headers:["Authorization":"Basic "+authorization], completionHandler: completionHandler)
  119 + }
  120 + //更新token
  121 + func refreshToken(completionHandler:@escaping (String?, NSError?) -> Void,token refresh_token:String){
  122 + let timeFormatter=DateFormatter()
  123 + timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"
  124 + let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"
  125 + let appSecret="5d744518ac1c"
  126 + let authorization=(time.md5()+":"+(time.md5()+appSecret).md5()).data(using: String.Encoding.ascii)?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) ?? ""
  127 + KHttp.POST(url: URL_OAUTH_TOKEN, parameters:["grant_type":"refresh_token" as AnyObject,"refresh_token":refresh_token as AnyObject], headers:["Authorization":"Basic "+authorization],completionHandler: completionHandler)
  128 + }
  129 + //获取开屏广告URL
  130 + func getOpenAds(completionHandler:@escaping (String?, NSError?) -> ()){
  131 + KHttp.GET(url: URL_GETOPENADS,headers:["Authorization":token!], completionHandler: completionHandler)
  132 + }
  133 + //我的课程提醒
  134 + func getMyLiveRemind(completionHandler:@escaping (String?, NSError?) -> ()){
  135 + KHttp.GET(url: URL_USER_MYLIVEREMIND, headers:["Authorization":token!], completionHandler: completionHandler)
  136 + }
  137 + //更新本地个人信息
  138 + func uplocalUserInfo(completionHandler:@escaping (String?, NSError?) -> ()){
  139 + KHttp.GET(url: URL_USER_USERINFO, headers:["Authorization":token!], completionHandler: completionHandler)
  140 + }
  141 + //修改密码
  142 + func updatePassword(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  143 + KHttp.POST(url: URL_USER_UPDATEPASSWORD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  144 + }
  145 +
  146 +
  147 +
  148 + //家长注册
  149 + func parentRegister(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  150 + KHttp.POST(url: URL_PARENTREGISTER, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  151 + }
  152 + //获取注册验证码
  153 + func getCaptcha(_ mobile:String,completionHandler:@escaping (String?, NSError?) -> Void){
  154 + KHttp.GET(url: URL_CAPTCHA,parameters:["mobile":mobile as AnyObject],headers:["Authorization":token!], completionHandler: completionHandler)
  155 + }
  156 + //找回密码
  157 + func resetPassWord(_ mobile:String,pw:String?=nil,code:String,completionHandler:@escaping (String?, NSError?) -> Void){
  158 + var p:[String:String]!
  159 + if let pass=pw{
  160 + p=["captcha":code,"Mobile":mobile,"pass":pass]
  161 + }else{
  162 + p=["captcha":code,"Mobile":mobile,"pass":"Empty"]
  163 + }
  164 + //,headers:["Authorization":anonymousToken ?? ""]
  165 +
  166 + KHttp.GET(url: URL_RESTPW,parameters:p! as [String : AnyObject], completionHandler: completionHandler)
  167 + }
  168 + //登录获取家长信息(包括关联的孩子信息区分绑定状态
  169 + func getParentInfo(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  170 + KHttp.POST(url: URL_GETPARENTINFO,parameters:parameters, headers:["Authorization":token!], completionHandler: completionHandler)
  171 + }
  172 + //更新姓名和性别
  173 + func updateParentInfo(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  174 + KHttp.POST(url: URL_UPDATEPARENTINFO, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  175 + }
  176 + //获取我的短信包列表
  177 + func getOrderList(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  178 + KHttp.GET(url: URL_GETORDERLIST,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  179 + }
  180 + //解绑孩子
  181 + func getUnBindStudent(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  182 + KHttp.GET(url: URL_UNBINDSTUDENT,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  183 + }
  184 +
  185 + //根据选择的市获取该地区的学校或者根据关键字搜索学校
  186 + func getAreaSchool(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  187 + // var urlStr = URL_GETAREASCHOOL+"?AreaName=\(getPercentEncodingString(str: parameters["AreaName"]! as! String))"
  188 + // if let str = parameters["Keyword"]{
  189 + // urlStr = urlStr + "&Keyword=\(getPercentEncodingString(str: str as! String))"
  190 + // }
  191 +
  192 + KHttp.POST(url: URL_GETAREASCHOOL, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  193 + }
  194 +
  195 + //获取该学校的年级或班级
  196 + func getClassOrGrade(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  197 + KHttp.GET(url: URL_GETCLASSORGRADE,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  198 + }
  199 + //MARK: ---- ParentService -----
  200 + //获取工具入口和活动
  201 + func getActivityTool(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  202 + KHttp.GET(url: URL_PARENTSERVICE_GETACTIVITYTOOL,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  203 + }
  204 + //绑定孩子信息(合作学校绑定返回null,非合作学校返回“汇作业”账号和密码)
  205 + func bindlingChildren(parameters: [String : AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  206 + KHttp.POST(url: URL_BINDLINGCHILDREN, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  207 + }
  208 +
  209 +
  210 + //获取频道资讯
  211 + func getChannelInfo(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  212 + KHttp.POST(url: URL_PARENTSERVICE_GETCHANNELINFO,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  213 + }
  214 +
  215 + //获取首页资讯话题/搜索资讯
  216 + func getInformationTopic(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  217 + KHttp.POST(url: URL_PARENTSERVICE_GETINFORMATIONTOPIC,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  218 + }
  219 +
  220 + //获取订购的报告或科目
  221 + func getOrderSubject(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  222 + KHttp.GET(url: URL_PARENTSERVICE_GETORDERSUBJECT,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  223 + }
  224 +
  225 + //获取报告列表
  226 + func workReport(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  227 + KHttp.POST(url: URL_PARENTSERVICE_WORKREPORT, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  228 + }
  229 +
  230 + //MARK: - 成长
  231 + //MARK: 应用
  232 + ///补卡
  233 + func postStudentMendCard(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  234 + KHttp.POST(url: URL_POST_MEND_CARD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  235 + }
  236 + ///考勤
  237 + func getStudentCheckList(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  238 + KHttp.GET(url: URL_GET_ATTENDANCE_LIST, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  239 + }
  240 + //MARK:量规评价
  241 + //获取报告详情
  242 + func workReportDetails(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  243 + KHttp.POST(url: URL_PARENTSERVICE_WORKREPORTDETAILS, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  244 + }
  245 + //获取德育报告-总体详情
  246 + func getEvaluationSceneAnalysis(parameters:[String:AnyObject]?,completionHandler:@escaping (String?,NSError?)->()){
  247 + KHttp.POST(url: URL_POST_EVALUATION_ANALYSIS, parameters: parameters, headers: ["Authorization":token!], completionHandler: completionHandler)
  248 + }
  249 + //获取德育报告-场景详情
  250 + func getEvaluationSceneAnalysisDetails(parameters:[String:AnyObject]?,completionHandler:@escaping (String?,NSError?)->()){
  251 + KHttp.POST(url: URL_POST_EVALUATION_ANALYSIS_DETAILS, parameters: parameters, headers: ["Authorization":token!], completionHandler: completionHandler)
  252 + }
  253 + //订购信息
  254 + func orderCenter(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){
  255 + KHttp.POST(url: URL_PARENTSERVICE_ORDERCENTER, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  256 + }
  257 +
  258 + //查看订购详情
  259 + func orderServiceDetails(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  260 + KHttp.GET(url: URL_PARENTSERVICE_ORDERSERVICEDETAILS,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  261 + }
  262 +
  263 + //获取广告位信息
  264 + func getAds(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){
  265 + KHttp.GET(url: URL_PARENTSERVICE_GETADS,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)
  266 + }
  267 +
  268 +
  269 +}
  270 +let SERVER_MESSAGE=393939
  271 +func httpJsonResule(jsonString:String?,error:NSError?,successHandler:(JSON)->Void,failHandler:(NSError)->Void){
  272 + let json=JSON.fromString(jsonString)
  273 + if let info=json{
  274 + if info.isSuccess(){
  275 + successHandler(info)
  276 + }else{
  277 + failHandler(NSError(domain: "shunzhi.net",
  278 + code: SERVER_MESSAGE,
  279 + userInfo: [NSLocalizedDescriptionKey:info["message"].stringValue]))
  280 + }
  281 + }else{
  282 + if let e=error{
  283 + failHandler(e)
  284 + }else{
  285 + failHandler(NSError(domain: "shunzhi.net",
  286 + code: 0,
  287 + userInfo: [NSLocalizedDescriptionKey:"not a json!!"]))
  288 + }
  289 + }
  290 +}
  291 +
  292 +// MARK: - 对UIImageView的网络加载图片扩展
  293 +extension UIImageView {
  294 +
  295 + /// 网络加载图片
  296 + ///
  297 + /// - Parameters:
  298 + /// - urlStr: 图片网络地址字符串
  299 + /// - placeholder: 默认替代图片
  300 + func setImageWithUrl(urlStr:String,placeholder:String?) {
  301 + if !(urlStr.isEmpty){
  302 + let imageUrl = URL.init(string: urlStr)
  303 + if placeholder == nil {
  304 + self.af_setImage(withURL: imageUrl!)
  305 + }else{
  306 + self.af_setImage(withURL: imageUrl!, placeholderImage: UIImage.init(named: placeholder!))
  307 + }
  308 + }else{
  309 + if let image = placeholder {
  310 + self.image = UIImage.init(named: image)
  311 + }
  312 + }
  313 + }
  314 +}
  315 +
ParentAssistant/ParentAssistant/Classes/util/account.swift
@@ -1,257 +0,0 @@ @@ -1,257 +0,0 @@
1 -//  
2 -// account.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 葛建军 on 2018/3/6.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import Foundation  
10 -class AccountManager: NSObject {  
11 - var rawUserInfo:JSON?  
12 - var userid:String=""  
13 - var token:String?  
14 - var refreshToken:String=""  
15 -// var address:String = "未知"  
16 -  
17 -  
18 - //单例  
19 - static let shared = AccountManager()  
20 -  
21 - override init(){  
22 - rawUserInfo=Setting.getUserInfo()  
23 - if let info=rawUserInfo{  
24 - userid=info.contentData()["userid"].stringValue  
25 - }  
26 - }  
27 -  
28 - //MARK: - 获取个人信息  
29 - /// 获取用户信息  
30 - ///  
31 - /// - Returns: 返回 UserInfoModel  
32 - func getUserInfo() -> UserInfoModel {  
33 -  
34 - var model = UserInfoModel()  
35 - if let dic = Setting.getUserInfo()?.dictionary {  
36 - let data = dic["data"]?.dictionary  
37 - if let value = data {  
38 - model = UserInfoModel.deserialize(from: value)!  
39 - }  
40 - }  
41 - return model  
42 - }  
43 - //MARK: 获取孩子信息  
44 - /// 获取用户孩子信息  
45 - ///  
46 - /// - Returns: 返回 StudentClassInfoModel  
47 - func getChildClassInfo()-> Array<StudentClassInfoModel> {  
48 - var array = Array<StudentClassInfoModel>()  
49 - if let dic = Setting.getUserInfo()?.dictionary {  
50 - let data = dic["data"]?.dictionary  
51 - let studentArr = data!["studentClass"]?.arrayValue  
52 - for i in 0..<studentArr!.count {  
53 - let studentDic = studentArr![i].dictionary  
54 - if let value = studentDic {  
55 - let model = StudentClassInfoModel.deserialize(from: value)  
56 - array.append(model!)  
57 - }  
58 - }  
59 - }  
60 - return array  
61 - }  
62 -  
63 -  
64 - func setTokenInfo(tokenInfo:JSON?){  
65 - if let info=tokenInfo{  
66 - token="Bearer "+info["access_token"].stringValue  
67 - refreshToken=info["refresh_token"].stringValue  
68 - }else{  
69 - token=""  
70 - }  
71 - }  
72 - func loadToken()->JSON?{  
73 - if let token=Setting.getJson("_token"){  
74 - return token  
75 - }  
76 - return nil  
77 - }  
78 - func saveToken(tokenInfo:JSON){  
79 - _=Setting.saveJson(tokenInfo, forKey: "_token")  
80 - }  
81 - //是否登录  
82 - func isOnline() -> Bool {  
83 - if id() != "" {  
84 - return true  
85 - }else{  
86 - return false  
87 - }  
88 - }  
89 - func id()->String{  
90 - if let info=rawUserInfo{  
91 - return info.contentData()["userid"].stringValue  
92 - }  
93 - return ""  
94 - }  
95 - func name()->String{  
96 - if let info=rawUserInfo{  
97 - return info.contentData()["name"].stringValue  
98 - }  
99 - return ""  
100 - }  
101 - func photo()->String{  
102 - if let info=rawUserInfo{  
103 - return info.contentData()["image"].stringValue  
104 - }  
105 - return "defphoto"  
106 - }  
107 - func phone()->String{  
108 - if let info=rawUserInfo{  
109 - return info.contentData()["mobile"].stringValue  
110 - }  
111 - return ""  
112 - }  
113 - func sex()->Int{  
114 - if let info=rawUserInfo{  
115 - return info.contentData()["sex"].intValue  
116 - }  
117 - return 0  
118 - }  
119 -  
120 - func parentId()->Int{  
121 - if let info=rawUserInfo{  
122 - return info.contentData()["parentId"].intValue  
123 - }  
124 - return 0  
125 - }  
126 -  
127 - func studentClass()->[JSON]{  
128 - if let info=rawUserInfo{  
129 - return info.contentData()["studentClass"].arrayValue  
130 - }  
131 - return []  
132 - }  
133 -  
134 - func isNew()->Int{  
135 - if let info=rawUserInfo{  
136 - return info.contentData()["isNew"].intValue  
137 - }  
138 - return 0  
139 - }  
140 -  
141 - func isHeaderTeacher()->Bool{  
142 - if let info=rawUserInfo{  
143 - return info.contentData()["f_Identity"].intValue == 2 ? true : false  
144 - }  
145 - return false  
146 - }  
147 - func logOut(auto:Bool? = false){  
148 - //退出登录  
149 - cleanUserInfoAndPoptoRootVC(auto: auto)  
150 - }  
151 - func cleanUserInfoAndPoptoRootVC(auto:Bool? = false){  
152 - rawUserInfo=nil  
153 - userid=""  
154 - _=Setting.saveUserInfo("")  
155 - UserDefaults.standard.removeObject(forKey: "_token")  
156 - refreshToken = ""  
157 - token = ""  
158 - if auto! {  
159 - if self.appRootViewController().classForCoder==TabBarController.classForCoder(){  
160 - ((self.appRootViewController() as! TabBarController).selectedViewController! as! UINavigationController).popToRootViewController(animated: true)  
161 - }else{  
162 - self.appRootViewController().dismiss(animated: false, completion: {  
163 - (self.appRootViewController() as! UINavigationController).popToRootViewController(animated: true)  
164 - })  
165 - }  
166 - }  
167 - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "loginOutSuccess"), object: nil)  
168 - //取消之前注册的所有本地推送通知  
169 -// UIApplication.shared.cancelAllLocalNotifications()  
170 - //发出刷新首页通知  
171 -// NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshFirstVC"), object: nil)  
172 - }  
173 - func appRootViewController()->UIViewController {  
174 - let appRootVC=UIApplication.shared.keyWindow?.rootViewController  
175 - var topVC=appRootVC  
176 - while topVC!.presentedViewController != nil {  
177 - topVC=topVC!.presentedViewController  
178 - }  
179 - return topVC!  
180 - }  
181 - func refreshUserInfo(_ mobile:String,completionHandler:((Bool) -> Void)?){  
182 - HTTPServer.shared.getParentInfo(["mobile":mobile as AnyObject], completionHandler: { (str, error) -> Void in  
183 - if error == nil {  
184 - if JSON.fromString(str)!["status"].intValue==4 {  
185 - HTTPServer.shared.refreshToken(completionHandler: { (str, error) in  
186 - if error == nil && JSON.fromString(str)!["status"].intValue==1 {  
187 - self.setTokenInfo(tokenInfo: JSON.fromString(str))  
188 - if let call=completionHandler{  
189 - call(true)  
190 - }  
191 - }else{  
192 - self.logOut()  
193 - appDelegate.window!.makeToast("登录信息已过期,请重新登录", duration: 2, position: CSToastPositionBottom)  
194 - if let call=completionHandler{  
195 - call(false)  
196 - }  
197 - }  
198 - }, token: self.refreshToken)  
199 - }else{  
200 - httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in  
201 - _=Setting.saveUserInfo(str)  
202 - self.rawUserInfo=json  
203 - self.userid=json.contentData()["userid"].stringValue  
204 - if let call=completionHandler{  
205 - call(true)  
206 - }  
207 - }, failHandler: { (error) -> Void in  
208 - if let call=completionHandler{  
209 - call(false)  
210 - }  
211 - })  
212 - }  
213 - }else{  
214 - if let call=completionHandler{  
215 - call(false)  
216 - }  
217 - }  
218 - })  
219 - }  
220 -}  
221 -  
222 -import HandyJSON  
223 -class UserInfoModel: HandyJSON {  
224 - var parentId = Int()  
225 - var name = String()  
226 - var bindSchoolFlag = Bool()  
227 - var mobile = String()  
228 - var image = String()  
229 - var userid = String()  
230 - var sex = Int()  
231 - required init(){}  
232 -}  
233 -class StudentClassInfoModel: HandyJSON {  
234 -  
235 - var photo = String()  
236 - var cityName = String()  
237 - var cardNumber = String()  
238 - var classId = Int()  
239 - var grade = Int()  
240 - var studentName = String()  
241 - var studentCode = String()  
242 - var parentId = Int()  
243 - var className = String()  
244 - var areaName = String()  
245 - var gradename = String()  
246 - var count = Int()  
247 - var schollId = Int()  
248 - var schoolName = String()  
249 - var studentUserId = String()  
250 - var studentId = Int()  
251 - var parentMobile = Int()  
252 - var sex = Int()  
253 -  
254 - required init(){}  
255 -}  
256 -  
257 -  
ParentAssistant/ParentAssistant/Classes/util/network.swift
@@ -1,315 +0,0 @@ @@ -1,315 +0,0 @@
1 -//  
2 -// network.swift  
3 -// ParentAssistant  
4 -//  
5 -// Created by 葛建军 on 2018/3/6.  
6 -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.  
7 -//  
8 -  
9 -import Foundation  
10 -import Alamofire  
11 -import AlamofireImage  
12 -//http工具  
13 -final class KHttp{  
14 - private static func http(method:HTTPMethod,url:String,parameters: [String: AnyObject]? = nil,encoding: ParameterEncoding = URLEncoding.default,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> ()){  
15 - //认证相关设置  
16 - // let manager = Manager.sharedInstance  
17 - // manager.delegate.sessionDidReceiveChallenge = { session, challenge in  
18 - // //认证服务器证书  
19 - // if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {  
20 - // let serverTrust:SecTrustRef = challenge.protectionSpace.serverTrust!  
21 - // let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0)!  
22 - // let remoteCertificateData = CFBridgingRetain(SecCertificateCopyData(certificate))!  
23 - // let cerPath = NSBundle.mainBundle().pathForResource("pub",ofType: "cer")!  
24 - // let localCertificateData = NSData(contentsOfFile:cerPath)!  
25 - // if (remoteCertificateData.isEqualToData(localCertificateData) == true) {  
26 - // let credential = NSURLCredential(forTrust: serverTrust)  
27 - // challenge.sender?.useCredential(credential,  
28 - // forAuthenticationChallenge: challenge)  
29 - // return (NSURLSessionAuthChallengeDisposition.UseCredential,  
30 - // NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!))  
31 - // }else{  
32 - // return (.CancelAuthenticationChallenge, nil)  
33 - // }  
34 - // }else{  
35 - // return (.CancelAuthenticationChallenge, nil)  
36 - // }  
37 - // }  
38 -  
39 - let requestUrl = HOST + url  
40 - request(requestUrl, method: method, parameters: parameters, encoding: encoding, headers: headers).responseString { (response) -> Void in  
41 - let error=response.result.error  
42 - let str=response.result.value  
43 - if let er=error{  
44 - if (er as NSError).code==NSURLErrorNotConnectedToInternet{  
45 - appDelegate.window!.makeToast("网络连接不可用", duration: 1, position: CSToastPositionBottom)  
46 - }else if (er as NSError).code==NSURLErrorCannotConnectToHost{  
47 - appDelegate.window!.makeToast("未能连接到服务器", duration: 1, position: CSToastPositionBottom)  
48 - }else{  
49 - appDelegate.window!.makeToast("加载失败:\(er.localizedDescription)", duration: 1, position: CSToastPositionBottom)  
50 - }  
51 - NSLog("ERROR: url:\(requestUrl),error:\(er)")  
52 - }  
53 - completionHandler(str,error as NSError?)  
54 - }  
55 - }  
56 -  
57 - static func POST(url:String,parameters: [String: AnyObject]? = nil,encoding: ParameterEncoding = URLEncoding.default,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> ()){  
58 - var header:[String: String]  
59 - if let hd=headers {  
60 - header=hd  
61 - header.updateValue(getSign(), forKey: "sign")  
62 - }else{  
63 - header=["sign":getSign()]  
64 - }  
65 - KHttp.http(method: .post, url: url, parameters: parameters,encoding:encoding,headers:header,completionHandler:completionHandler)  
66 - }  
67 - static func GET(url:String,parameters: [String: AnyObject]? = nil,headers:[String: String]?=nil,completionHandler: @escaping (String?, NSError?) -> Void){  
68 - var header:[String: String]  
69 - if let hd=headers {  
70 - header=hd  
71 - header.updateValue(getSign(), forKey: "sign")  
72 - }else{  
73 - header=["sign":getSign()]  
74 - }  
75 - KHttp.http(method: .get, url: url, parameters: parameters,headers:header,completionHandler:completionHandler)  
76 - }  
77 - static func getSign()->String{  
78 - let timeFormatter=DateFormatter()  
79 - timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"  
80 - let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"// let appKey="1e5b32490ad2e41ecc817849ea1310c6"  
81 - let appSecret="5d744518ac1c"  
82 - return (time.md5()+"/"+time.md5()+appSecret).md5().data(using: .ascii)?.base64EncodedString(options: []) ?? ""  
83 - }  
84 -}  
85 -final class HTTPServer{  
86 -  
87 - //单例  
88 - static let shared = HTTPServer()  
89 - init() {}  
90 -  
91 - var token:String?{  
92 - return AccountManager.shared.token  
93 - }  
94 -  
95 - //上传图片  
96 - func uploadFile(file:NSURL,progress:((Int64, Int64, Int64) -> Void)? = nil,completionHandler: @escaping (String?, NSError?) -> Void){  
97 - upload(multipartFormData: { (multipartFormData) in  
98 - multipartFormData.append(file as URL, withName: "file")  
99 - }, usingThreshold: SessionManager.multipartFormDataEncodingMemoryThreshold, to: URL_UPLOAD_FILE, method: .post, headers: nil) { (encodingResult) in  
100 - switch encodingResult {  
101 - case .success(let upload, _, _):  
102 - upload.responseString(completionHandler: { (response) in  
103 - completionHandler(response.result.value,response.result.error as NSError?)  
104 - })  
105 - case .failure(let encodingError):  
106 - completionHandler(nil,encodingError as NSError?)  
107 - }  
108 - }  
109 - }  
110 - //MARK:-User个人信息有关  
111 - //登录  
112 - func login(completionHandler:@escaping (String?, NSError?) -> (),phone:String, password:String){  
113 - let timeFormatter=DateFormatter()  
114 - timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"  
115 - let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"  
116 - let appSecret="5d744518ac1c"  
117 - let authorization=(time.md5()+":"+(time.md5()+appSecret).md5()).data(using: String.Encoding.ascii)?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) ?? ""  
118 - KHttp.POST(url: URL_OAUTH_TOKEN,parameters: ["grant_type":"password" as AnyObject,"username":phone as AnyObject,"password":password as AnyObject], encoding: URLEncoding.default,headers:["Authorization":"Basic "+authorization], completionHandler: completionHandler)  
119 - }  
120 - //更新token  
121 - func refreshToken(completionHandler:@escaping (String?, NSError?) -> Void,token refresh_token:String){  
122 - let timeFormatter=DateFormatter()  
123 - timeFormatter.dateFormat="yyyy-MM-dd-HH:mm:ss:sss"  
124 - let time=timeFormatter.string(from: Date())+"\(arc4random()%10000)"  
125 - let appSecret="5d744518ac1c"  
126 - let authorization=(time.md5()+":"+(time.md5()+appSecret).md5()).data(using: String.Encoding.ascii)?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) ?? ""  
127 - KHttp.POST(url: URL_OAUTH_TOKEN, parameters:["grant_type":"refresh_token" as AnyObject,"refresh_token":refresh_token as AnyObject], headers:["Authorization":"Basic "+authorization],completionHandler: completionHandler)  
128 - }  
129 - //获取开屏广告URL  
130 - func getOpenAds(completionHandler:@escaping (String?, NSError?) -> ()){  
131 - KHttp.GET(url: URL_GETOPENADS,headers:["Authorization":token!], completionHandler: completionHandler)  
132 - }  
133 - //我的课程提醒  
134 - func getMyLiveRemind(completionHandler:@escaping (String?, NSError?) -> ()){  
135 - KHttp.GET(url: URL_USER_MYLIVEREMIND, headers:["Authorization":token!], completionHandler: completionHandler)  
136 - }  
137 - //更新本地个人信息  
138 - func uplocalUserInfo(completionHandler:@escaping (String?, NSError?) -> ()){  
139 - KHttp.GET(url: URL_USER_USERINFO, headers:["Authorization":token!], completionHandler: completionHandler)  
140 - }  
141 - //修改密码  
142 - func updatePassword(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
143 - KHttp.POST(url: URL_USER_UPDATEPASSWORD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
144 - }  
145 -  
146 -  
147 -  
148 - //家长注册  
149 - func parentRegister(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
150 - KHttp.POST(url: URL_PARENTREGISTER, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
151 - }  
152 - //获取注册验证码  
153 - func getCaptcha(_ mobile:String,completionHandler:@escaping (String?, NSError?) -> Void){  
154 - KHttp.GET(url: URL_CAPTCHA,parameters:["mobile":mobile as AnyObject],headers:["Authorization":token!], completionHandler: completionHandler)  
155 - }  
156 - //找回密码  
157 - func resetPassWord(_ mobile:String,pw:String?=nil,code:String,completionHandler:@escaping (String?, NSError?) -> Void){  
158 - var p:[String:String]!  
159 - if let pass=pw{  
160 - p=["captcha":code,"Mobile":mobile,"pass":pass]  
161 - }else{  
162 - p=["captcha":code,"Mobile":mobile,"pass":"Empty"]  
163 - }  
164 - //,headers:["Authorization":anonymousToken ?? ""]  
165 -  
166 - KHttp.GET(url: URL_RESTPW,parameters:p! as [String : AnyObject], completionHandler: completionHandler)  
167 - }  
168 - //登录获取家长信息(包括关联的孩子信息区分绑定状态  
169 - func getParentInfo(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
170 - KHttp.POST(url: URL_GETPARENTINFO,parameters:parameters, headers:["Authorization":token!], completionHandler: completionHandler)  
171 - }  
172 - //更新姓名和性别  
173 - func updateParentInfo(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
174 - KHttp.POST(url: URL_UPDATEPARENTINFO, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
175 - }  
176 - //获取我的短信包列表  
177 - func getOrderList(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
178 - KHttp.GET(url: URL_GETORDERLIST,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
179 - }  
180 - //解绑孩子  
181 - func getUnBindStudent(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
182 - KHttp.GET(url: URL_UNBINDSTUDENT,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
183 - }  
184 -  
185 - //根据选择的市获取该地区的学校或者根据关键字搜索学校  
186 - func getAreaSchool(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
187 - // var urlStr = URL_GETAREASCHOOL+"?AreaName=\(getPercentEncodingString(str: parameters["AreaName"]! as! String))"  
188 - // if let str = parameters["Keyword"]{  
189 - // urlStr = urlStr + "&Keyword=\(getPercentEncodingString(str: str as! String))"  
190 - // }  
191 -  
192 - KHttp.POST(url: URL_GETAREASCHOOL, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
193 - }  
194 -  
195 - //获取该学校的年级或班级  
196 - func getClassOrGrade(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
197 - KHttp.GET(url: URL_GETCLASSORGRADE,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
198 - }  
199 - //MARK: ---- ParentService -----  
200 - //获取工具入口和活动  
201 - func getActivityTool(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
202 - KHttp.GET(url: URL_PARENTSERVICE_GETACTIVITYTOOL,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
203 - }  
204 - //绑定孩子信息(合作学校绑定返回null,非合作学校返回“汇作业”账号和密码)  
205 - func bindlingChildren(parameters: [String : AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
206 - KHttp.POST(url: URL_BINDLINGCHILDREN, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
207 - }  
208 -  
209 -  
210 - //获取频道资讯  
211 - func getChannelInfo(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
212 - KHttp.POST(url: URL_PARENTSERVICE_GETCHANNELINFO,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
213 - }  
214 -  
215 - //获取首页资讯话题/搜索资讯  
216 - func getInformationTopic(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
217 - KHttp.POST(url: URL_PARENTSERVICE_GETINFORMATIONTOPIC,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
218 - }  
219 -  
220 - //获取订购的报告或科目  
221 - func getOrderSubject(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
222 - KHttp.GET(url: URL_PARENTSERVICE_GETORDERSUBJECT,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
223 - }  
224 -  
225 - //获取报告列表  
226 - func workReport(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
227 - KHttp.POST(url: URL_PARENTSERVICE_WORKREPORT, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
228 - }  
229 -  
230 - //MARK: - 成长  
231 - //MARK: 应用  
232 - ///补卡  
233 - func postStudentMendCard(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
234 - KHttp.POST(url: URL_POST_MEND_CARD, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
235 - }  
236 - ///考勤  
237 - func getStudentCheckList(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
238 - KHttp.GET(url: URL_GET_ATTENDANCE_LIST, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
239 - }  
240 - //MARK:量规评价  
241 - //获取报告详情  
242 - func workReportDetails(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
243 - KHttp.POST(url: URL_PARENTSERVICE_WORKREPORTDETAILS, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
244 - }  
245 - //获取德育报告-总体详情  
246 - func getEvaluationSceneAnalysis(parameters:[String:AnyObject]?,completionHandler:@escaping (String?,NSError?)->()){  
247 - KHttp.POST(url: URL_POST_EVALUATION_ANALYSIS, parameters: parameters, headers: ["Authorization":token!], completionHandler: completionHandler)  
248 - }  
249 - //获取德育报告-场景详情  
250 - func getEvaluationSceneAnalysisDetails(parameters:[String:AnyObject]?,completionHandler:@escaping (String?,NSError?)->()){  
251 - KHttp.POST(url: URL_POST_EVALUATION_ANALYSIS_DETAILS, parameters: parameters, headers: ["Authorization":token!], completionHandler: completionHandler)  
252 - }  
253 - //订购信息  
254 - func orderCenter(parameters: [String : AnyObject]?,completionHandler:@escaping (String?, NSError?) -> ()){  
255 - KHttp.POST(url: URL_PARENTSERVICE_ORDERCENTER, parameters: parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
256 - }  
257 -  
258 - //查看订购详情  
259 - func orderServiceDetails(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
260 - KHttp.GET(url: URL_PARENTSERVICE_ORDERSERVICEDETAILS,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
261 - }  
262 -  
263 - //获取广告位信息  
264 - func getAds(_ parameters:[String:AnyObject],completionHandler:@escaping (String?, NSError?) -> ()){  
265 - KHttp.GET(url: URL_PARENTSERVICE_GETADS,parameters:parameters,headers:["Authorization":token!], completionHandler: completionHandler)  
266 - }  
267 -  
268 -  
269 -}  
270 -let SERVER_MESSAGE=393939  
271 -func httpJsonResule(jsonString:String?,error:NSError?,successHandler:(JSON)->Void,failHandler:(NSError)->Void){  
272 - let json=JSON.fromString(jsonString)  
273 - if let info=json{  
274 - if info.isSuccess(){  
275 - successHandler(info)  
276 - }else{  
277 - failHandler(NSError(domain: "shunzhi.net",  
278 - code: SERVER_MESSAGE,  
279 - userInfo: [NSLocalizedDescriptionKey:info["message"].stringValue]))  
280 - }  
281 - }else{  
282 - if let e=error{  
283 - failHandler(e)  
284 - }else{  
285 - failHandler(NSError(domain: "shunzhi.net",  
286 - code: 0,  
287 - userInfo: [NSLocalizedDescriptionKey:"not a json!!"]))  
288 - }  
289 - }  
290 -}  
291 -  
292 -// MARK: - 对UIImageView的网络加载图片扩展  
293 -extension UIImageView {  
294 -  
295 - /// 网络加载图片  
296 - ///  
297 - /// - Parameters:  
298 - /// - urlStr: 图片网络地址字符串  
299 - /// - placeholder: 默认替代图片  
300 - func setImageWithUrl(urlStr:String,placeholder:String?) {  
301 - if !(urlStr.isEmpty){  
302 - let imageUrl = URL.init(string: urlStr)  
303 - if placeholder == nil {  
304 - self.af_setImage(withURL: imageUrl!)  
305 - }else{  
306 - self.af_setImage(withURL: imageUrl!, placeholderImage: UIImage.init(named: placeholder!))  
307 - }  
308 - }else{  
309 - if let image = placeholder {  
310 - self.image = UIImage.init(named: image)  
311 - }  
312 - }  
313 - }  
314 -}  
315 -  
ParentAssistant/ParentAssistant/Classes/util/utils.swift
@@ -207,7 +207,8 @@ extension String{ @@ -207,7 +207,8 @@ extension String{
207 for i in 0 ..< digestLen { 207 for i in 0 ..< digestLen {
208 hash.appendFormat("%02x", result[i]) 208 hash.appendFormat("%02x", result[i])
209 } 209 }
210 - result.deinitialize() 210 +// result.deinitialize()
  211 + result.deinitialize(count: digestLen)
211 return hash.uppercased 212 return hash.uppercased
212 } 213 }
213 } 214 }