Commit fd07bc26c235c110ab98a25a1cdd731097c74f90
1 parent
1c8b61ab
Exists in
parentassistant
定义model,优化数据获取
Showing
5 changed files
with
94 additions
and
12 deletions
Show diff stats
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
| ... | ... | @@ -13,5 +13,21 @@ |
| 13 | 13 | stopOnStyle = "0"> |
| 14 | 14 | </BreakpointContent> |
| 15 | 15 | </BreakpointProxy> |
| 16 | + <BreakpointProxy | |
| 17 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | |
| 18 | + <BreakpointContent | |
| 19 | + shouldBeEnabled = "Yes" | |
| 20 | + ignoreCount = "0" | |
| 21 | + continueAfterRunningActions = "No" | |
| 22 | + filePath = "ParentAssistant/Classes/controllers/Grow/GrowViewController.swift" | |
| 23 | + timestampString = "545824470.67428" | |
| 24 | + startingColumnNumber = "9223372036854775807" | |
| 25 | + endingColumnNumber = "9223372036854775807" | |
| 26 | + startingLineNumber = "72" | |
| 27 | + endingLineNumber = "72" | |
| 28 | + landmarkName = "viewWillAppear(_:)" | |
| 29 | + landmarkType = "7"> | |
| 30 | + </BreakpointContent> | |
| 31 | + </BreakpointProxy> | |
| 16 | 32 | </Breakpoints> |
| 17 | 33 | </Bucket> | ... | ... |
ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift
| ... | ... | @@ -68,6 +68,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { |
| 68 | 68 | |
| 69 | 69 | override func viewWillAppear(_ animated: Bool) { |
| 70 | 70 | |
| 71 | + | |
| 72 | + let model = AccountManager.shared.getUserInfo() | |
| 73 | + print(model.name) | |
| 71 | 74 | var title = String() |
| 72 | 75 | if AccountManager.shared.isOnline() { |
| 73 | 76 | if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { | ... | ... |
ParentAssistant/ParentAssistant/Classes/controllers/Grow/Program/ProgramCardViewController.swift
| ... | ... | @@ -14,16 +14,16 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { |
| 14 | 14 | |
| 15 | 15 | lazy var cardView = { ()-> UIView in |
| 16 | 16 | |
| 17 | - let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 140)) | |
| 17 | + let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 100)) | |
| 18 | 18 | view.backgroundColor = UIColor.white |
| 19 | 19 | return view |
| 20 | 20 | }() |
| 21 | 21 | lazy var bottomBtn = {()-> UIButton in |
| 22 | - let btn = UIButton.init(frame: CGRect.init(x: screenWidth/2-100, y: screenHeight-66-60, width: 200, height: 40)) | |
| 22 | + let btn = UIButton.init(frame: CGRect.init(x: 20, y: screenHeight-66-60, width: screenWidth-40, height: 40)) | |
| 23 | 23 | btn.setTitle("申请补卡", for: UIControlState.normal) |
| 24 | 24 | btn.layer.cornerRadius = 5 |
| 25 | 25 | btn.clipsToBounds = true |
| 26 | - btn.setTitleColor(UIColor.black, for: UIControlState.normal) | |
| 26 | + btn.setTitleColor(UIColor.white, for: UIControlState.normal) | |
| 27 | 27 | btn.backgroundColor = Theme.topBarColor() |
| 28 | 28 | btn.addTarget(self, action: #selector(applyAction), for: UIControlEvents.touchUpInside) |
| 29 | 29 | return btn |
| ... | ... | @@ -87,18 +87,10 @@ class ProgramCardViewController: UIViewController,UITextFieldDelegate { |
| 87 | 87 | cardNumberInput.delegate = self |
| 88 | 88 | self.cardInputTextField = cardNumberInput |
| 89 | 89 | |
| 90 | - let cardDateLab = UILabel.init(frame: CGRect.init(x: 10, y: 90, width: 100, height: 30)) | |
| 91 | - cardDateLab.text = "考勤日期:" | |
| 92 | - | |
| 93 | - let cardDateInput = UILabel.init(frame: CGRect.init(x: 110, y: 90, width: screenWidth-120, height: 30)) | |
| 94 | - cardDateInput.text = "2018-02-12 09:40" | |
| 95 | - | |
| 96 | 90 | self.cardView.addSubview(cardLable) |
| 97 | 91 | self.cardView.addSubview(cardName) |
| 98 | 92 | self.cardView.addSubview(cardNumberLab) |
| 99 | 93 | self.cardView.addSubview(cardNumberInput) |
| 100 | - self.cardView.addSubview(cardDateLab) | |
| 101 | - self.cardView.addSubview(cardDateInput) | |
| 102 | 94 | |
| 103 | 95 | } |
| 104 | 96 | //收回键盘 | ... | ... |
ParentAssistant/ParentAssistant/Classes/util/account.swift
| ... | ... | @@ -20,11 +20,45 @@ class AccountManager: NSObject { |
| 20 | 20 | |
| 21 | 21 | override init(){ |
| 22 | 22 | rawUserInfo=Setting.getUserInfo() |
| 23 | - | |
| 24 | 23 | if let info=rawUserInfo{ |
| 25 | 24 | userid=info.contentData()["userid"].stringValue |
| 26 | 25 | } |
| 27 | 26 | } |
| 27 | + | |
| 28 | + //MARK: - 获取个人信息 | |
| 29 | + /// 获取用户信息 | |
| 30 | + /// | |
| 31 | + /// - Returns: 返回 UserInfoModel | |
| 32 | + func getUserInfo() -> UserInfoModel { | |
| 33 | + | |
| 34 | + var model = UserInfoModel() | |
| 35 | + let dic = Setting.getUserInfo()?.dictionary | |
| 36 | + let data = dic!["data"]?.dictionary | |
| 37 | + if let value = data { | |
| 38 | + model = UserInfoModel.deserialize(from: value)! | |
| 39 | + } | |
| 40 | + return model | |
| 41 | + } | |
| 42 | + //MARK: 获取孩子信息 | |
| 43 | + /// 获取用户孩子信息 | |
| 44 | + /// | |
| 45 | + /// - Returns: 返回 StudentClassInfoModel | |
| 46 | + func getChildClassInfo()-> Array<StudentClassInfoModel> { | |
| 47 | + var array = Array<StudentClassInfoModel>() | |
| 48 | + let dic = Setting.getUserInfo()?.dictionary | |
| 49 | + let data = dic!["data"]?.dictionary | |
| 50 | + let studentArr = data!["studentClass"]?.arrayValue | |
| 51 | + for i in 0..<studentArr!.count { | |
| 52 | + let studentDic = studentArr![i].dictionary | |
| 53 | + if let value = studentDic { | |
| 54 | + let model = StudentClassInfoModel.deserialize(from: value) | |
| 55 | + array.append(model!) | |
| 56 | + } | |
| 57 | + } | |
| 58 | + return array | |
| 59 | + } | |
| 60 | + | |
| 61 | + | |
| 28 | 62 | func setTokenInfo(tokenInfo:JSON?){ |
| 29 | 63 | if let info=tokenInfo{ |
| 30 | 64 | token="Bearer "+info["access_token"].stringValue |
| ... | ... | @@ -182,3 +216,40 @@ class AccountManager: NSObject { |
| 182 | 216 | }) |
| 183 | 217 | } |
| 184 | 218 | } |
| 219 | + | |
| 220 | +import HandyJSON | |
| 221 | +class UserInfoModel: HandyJSON { | |
| 222 | + var parentId = Int() | |
| 223 | + var name = String() | |
| 224 | + var bindSchoolFlag = Bool() | |
| 225 | + var mobile = String() | |
| 226 | + var image = String() | |
| 227 | + var userid = String() | |
| 228 | + var sex = Int() | |
| 229 | + required init(){} | |
| 230 | +} | |
| 231 | +class StudentClassInfoModel: HandyJSON { | |
| 232 | + | |
| 233 | + var photo = String() | |
| 234 | + var cityName = String() | |
| 235 | + var cardNumber = String() | |
| 236 | + var classId = Int() | |
| 237 | + var grade = Int() | |
| 238 | + var studentName = String() | |
| 239 | + var studentCode = String() | |
| 240 | + var parentId = Int() | |
| 241 | + var className = String() | |
| 242 | + var areaName = String() | |
| 243 | + var gradename = String() | |
| 244 | + var count = Int() | |
| 245 | + var schollId = Int() | |
| 246 | + var schoolName = String() | |
| 247 | + var studentUserId = String() | |
| 248 | + var studentId = Int() | |
| 249 | + var parentMobile = Int() | |
| 250 | + var sex = Int() | |
| 251 | + | |
| 252 | + required init(){} | |
| 253 | +} | |
| 254 | + | |
| 255 | + | ... | ... |