diff --git a/EClass/EClass.xcodeproj/project.pbxproj b/EClass/EClass.xcodeproj/project.pbxproj index 2376c7e..454f093 100644 --- a/EClass/EClass.xcodeproj/project.pbxproj +++ b/EClass/EClass.xcodeproj/project.pbxproj @@ -420,6 +420,7 @@ 45264C0C1F47096100933C50 /* language */ = { isa = PBXGroup; children = ( + 45264C411F47097200933C50 /* major */, 45264C0D1F47096100933C50 /* language0.png */, 45264C0E1F47096100933C50 /* language1.png */, 45264C0F1F47096100933C50 /* language2.png */, @@ -475,7 +476,8 @@ 45264C481F47097200933C50 /* major6.png */, 45264C491F47097200933C50 /* major7.png */, ); - path = major; + name = major; + path = ../major; sourceTree = ""; }; 45264C521F47097700933C50 /* hobby */ = { @@ -553,8 +555,8 @@ 45A57FA91F357C45001F5C1A /* SelfDescriptionTableViewCell.swift */, 451BC7FD1F4D519700D11AA6 /* ChangePasswordViewController.swift */, 45264B701F3C962E00933C50 /* SlideOutMenu.storyboard */, - 45A57FAB1F357C4C001F5C1A /* ProfileImageTableViewCell.swift */, 45264B021F3C7E5B00933C50 /* InputUserDataTableViewCell.swift */, + 45A57FAB1F357C4C001F5C1A /* ProfileImageTableViewCell.swift */, 45264B001F3C7DDB00933C50 /* InputUserGenderTableViewCell.swift */, 45A57FAD1F357C56001F5C1A /* ProfileTableViewCell.swift */, 45A57FAF1F357C5D001F5C1A /* DetailChangeUserInfoViewController.swift */, @@ -630,6 +632,7 @@ 75D1B27E1F357C6A0068C20C /* MainPage.storyboard */, 75346BC61F4DB4A000F580FC /* SearchTextViewController.swift */, 75D1B2A01F3581D10068C20C /* AppDelegate.swift */, + 75D1B21D1F357C3C0068C20C /* MainTableViewController.swift */, 75D1B27F1F357C6A0068C20C /* RecommendCollectionViewCell.swift */, 75D1B2801F357C6A0068C20C /* RecommendTableViewCell.swift */, 75D1B2811F357C6A0068C20C /* CategoryTableViewCell.swift */, @@ -651,7 +654,6 @@ 451BC8051F4D68C700D11AA6 /* RegisterLectureImage */, 45264C631F47097C00933C50 /* sports */, 45264C521F47097700933C50 /* hobby */, - 45264C411F47097200933C50 /* major */, 45264C2E1F47096B00933C50 /* music */, 45264C1D1F47096600933C50 /* health */, 45264C0C1F47096100933C50 /* language */, @@ -681,7 +683,6 @@ 75D1B2081F3575F80068C20C /* EClass */ = { isa = PBXGroup; children = ( - 75D1B21D1F357C3C0068C20C /* MainTableViewController.swift */, 75D1B2121F3575F80068C20C /* LaunchScreen.storyboard */, 45264C961F47EEB600933C50 /* elass_logo.png */, 75BC38201F3AC6D000AA9E96 /* MainPage */, diff --git a/EClass/EClass/AppDelegate.swift b/EClass/EClass/AppDelegate.swift index 1a19215..a79a1ea 100644 --- a/EClass/EClass/AppDelegate.swift +++ b/EClass/EClass/AppDelegate.swift @@ -16,19 +16,24 @@ import SwiftyJSON class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - + + func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + + return true + } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) + print("뭐가먼저불리나") loadLecture() - - + return true } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { + print("궁금하군") return SDKApplicationDelegate.shared.application(app, open:url, options:options) } @@ -63,6 +68,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LectureList.lectureList = lectureData + } } diff --git a/EClass/EClass/ChangeUserInfomationViewController.swift b/EClass/EClass/ChangeUserInfomationViewController.swift index cbc5475..94ae699 100644 --- a/EClass/EClass/ChangeUserInfomationViewController.swift +++ b/EClass/EClass/ChangeUserInfomationViewController.swift @@ -8,16 +8,15 @@ import UIKit -var currentUserData = DataCenter.shared.realUser -//func refreshCurrentUserData() -//{ -// currenUserData = DataCenter.shared.realUser -//} + +func refreshCurrentUserData() +{ + currentUserData = DataCenter.shared.realUser +} class ChangeUserInfomationViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{ - var userData = DataCenter.shared.realUser // func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { // scrollView.delegate = self // scrollView.alwaysBounceVertical = false @@ -35,7 +34,7 @@ class ChangeUserInfomationViewController: UIViewController, UITableViewDataSourc switch indexPath.section { case 0: let cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) as! ProfileImageTableViewCell - cell.userNameLabel.text = userData?.userName ?? "guest" + cell.userNameLabel.text = currentUserData?.userName ?? "guest" cell.profileImageOutlet.image = currentUserData?.profileImage cell.selectionStyle = .none @@ -195,7 +194,6 @@ class ChangeUserInfomationViewController: UIViewController, UITableViewDataSourc override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - userData = DataCenter.shared.realUser tv.reloadData() print("viewwillappear") diff --git a/EClass/EClass/DataCenter.swift b/EClass/EClass/DataCenter.swift index cbfb4f8..1b7d171 100644 --- a/EClass/EClass/DataCenter.swift +++ b/EClass/EClass/DataCenter.swift @@ -21,10 +21,10 @@ extension UIImageView //전역 변수 & 함수 -//유저 primaryKey 회원 가입 시 +1 됨 var currentUserPrimaryKey:Int = 0 var currentUserToken:String = "" var currentUserTuTorPK:Int = 0 +var currentUserData = DataCenter.shared.realUser //각종 알람 @@ -212,19 +212,19 @@ struct User { var userName:String var nickName:String? - var password:String? +// var password:String? var email:String? var name:String? var phone:String? // var tutorPK:String? var profileImage:UIImage? - var studiedLecture:[Lecture]? - var selectedLecture:[Lecture]? - var wishedLecture:[Lecture]? - var selfDescription:String? - var tutorAuthorize:Bool = false - var registeredLecture:[Lecture]? - var careerDescription:String? +// var studiedLecture:[Lecture]? +// var selectedLecture:[Lecture]? +// var wishedLecture:[Lecture]? +// var selfDescription:String? +// var tutorAuthorize:Bool = false +// var registeredLecture:[Lecture]? +// var careerDescription:String? var token:String? @@ -233,7 +233,7 @@ struct User userName = json["username"].stringValue nickName = json["nickname"].stringValue email = json["email"].stringValue - password = json["password"].stringValue +// password = json["password"].stringValue name = json["name"].stringValue phone = json["phone"].stringValue @@ -248,36 +248,38 @@ struct User } } -// 수강했던 목록 - studiedLecture = json["studiedLecture"].arrayValue.map({ (json) -> Lecture in - return Lecture(with: json) - }) - -// 현재 수강 신청한 목록 - selectedLecture = json["seletecLecture"].arrayValue.map({ (json) -> Lecture in - return Lecture(with: json) - }) - -// 찜한 목록 - wishedLecture = json["wishedLecture"].arrayValue.map({ (json) -> Lecture in - return Lecture(with: json) - }) - -// 자기 소개 - selfDescription = json["selfDescription"].stringValue - -// 튜터 권한 default 는 false - tutorAuthorize = json["tutorAuthorize"].bool ?? false - -// 개설한 강의(튜터 전용) - registeredLecture = json["registeredLecture"].arrayValue.map({ (json) -> Lecture in - return Lecture(with:json) }) - -// 경력 소개(튜터 전용) - careerDescription = json["careerDescription"].stringValue - } } +//// 수강했던 목록 +// studiedLecture = json["studiedLecture"].arrayValue.map({ (json) -> Lecture in +// return Lecture(with: json) +// }) +// +//// 현재 수강 신청한 목록 +// selectedLecture = json["seletecLecture"].arrayValue.map({ (json) -> Lecture in +// return Lecture(with: json) +// }) +// +//// 찜한 목록 +// wishedLecture = json["wishedLecture"].arrayValue.map({ (json) -> Lecture in +// return Lecture(with: json) +// }) +// +//// 자기 소개 +// selfDescription = json["selfDescription"].stringValue +// +//// 튜터 권한 default 는 false +// tutorAuthorize = json["tutorAuthorize"].bool ?? false +// +//// 개설한 강의(튜터 전용) +// registeredLecture = json["registeredLecture"].arrayValue.map({ (json) -> Lecture in +// return Lecture(with:json) }) +// +//// 경력 소개(튜터 전용) +// careerDescription = json["careerDescription"].stringValue +// +// } + struct ReviewList { var description:String? diff --git a/EClass/EClass/DetailChangeUserInfoViewController.swift b/EClass/EClass/DetailChangeUserInfoViewController.swift index 3ed8d2a..be90212 100644 --- a/EClass/EClass/DetailChangeUserInfoViewController.swift +++ b/EClass/EClass/DetailChangeUserInfoViewController.swift @@ -17,9 +17,6 @@ import SwiftyJSON class DetailChangeUserInfoViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ChangeSelfDescriptionTableViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { let propertyList = ["이름","닉네임" , "이메일" , "휴대전화"] var cell1:ChangeSelfDescriptionTableViewCell? - - var userData = DataCenter.shared.realUser - func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { if section == 0 { @@ -47,10 +44,10 @@ class DetailChangeUserInfoViewController: UIViewController, UITableViewDelegate, func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if indexPath.section == 0 { - return 70 + return 55 }else { - return 146 + return 130 } } @@ -135,82 +132,89 @@ class DetailChangeUserInfoViewController: UIViewController, UITableViewDelegate, let cell3 = tv.cellForRow(at: IndexPath(row: 3, section: 0)) as! InputUserDataTableViewCell let cell4 = tv.cellForRow(at: IndexPath(row: 0, section: 1)) as! ChangeSelfDescriptionTableViewCell + let image = cell4.imageOutlet.image + + let myParameter:[String:Any] = ["name":"\(cell0.userDataTextField.text!)","nickname":"\(cell1.userDataTextField.text!)","email":"\(cell2.userDataTextField.text!)","phone":"\(cell3.userDataTextField.text!)","my_photo":image!] + let token:HTTPHeaders = ["Authorization":"Token " + "\(currentUserToken)"] -// let baseString3 = JSONEncoding(options: JSONSerialization.WritingOptions) - -// var params = [String:AnyObject]() -// params["content"] = "something" as AnyObject? -// params["location_id"] = "201" as AnyObject? + print(myParameter) + + Alamofire.upload(multipartFormData: { (data) in + for (key, value) in myParameter { + if value is String || value is Int { + data.append("\(value)".data(using: .utf8)!, withName: key) + print(data) + print(key, value) + } + if value is UIImage { + data.append(UIImagePNGRepresentation(value as! UIImage)!, withName: key, fileName: "profile", mimeType: "image/png") + } + } + }, usingThreshold: UInt64.init(), to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", method: .put, headers: token) { (result) in + + switch result{ + case .success(let upload,_ ,_): + print("일단 석세스") + print(upload.response) + print("일단 석세스") + + upload.responseJSON { (response) in + + if response.result.isSuccess + { + + guard let data = response.value else + { + return + } + print("제이슨") + let realData = JSON(data) + currentUserData = User(with: realData) + print(realData) +// currentUserData = DataCenter.shared.realUser + self.navigationController?.popViewController(animated: true) + self.tv.reloadData() + }else + { + self.present( presentAlert("잘못된 양식을 입력하셨습니다.", message: "다시 확인해주세요", alertActionTitle: "확인"), animated: true, completion: nil) + } + } + + case .failure(let encodingError): + self.present( presentAlert("잘못된 양식을 입력하셨습니다.", message: "다시 확인해주세요", alertActionTitle: "확인"), animated: true, completion: nil) + print(encodingError) + print("fail인가") + break + + } + print("여긴 들어오니") + print(result) - // Grab your image from some variable or imageView. Here self.profileImage is a UIImage object -// if let profileImageData = image { -// if let imageData = UIImageJPEGRepresentation(profileImageData, 0.5) { -// params["my_photo"] = imageData as AnyObject? -// APIManager.apiMultipart(serviceName: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", parameters: params, completionHandler: { (response:JSON?, error:NSError?) in -// //Handle response -// currentUserData = User(with: response!) -// print(response) -// }) -// } else { -// print("Image problem") -// } -// } - let image = cell4.imageOutlet.image - let imageData = UIImagePNGRepresentation(image!) - let imageData2 = UIImageJPEGRepresentation(image!, 1) - let baseString4 = imageData?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue:0)) + } + } + // Do any additional setup after loading the view, typically from a nib + + - let baseString5 = imageUrl2?.absoluteString -// Alamofire.upload(multipartFormData: { (multiPartFormData) in -// multiPartFormData.append(imageData2!, withName: "my_photo") -// }, to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/") { (encodidngResult) in -// switch encodidngResult { +// Alamofire.upload(multipartFormData: { (multipart) in +// multipart.append(imageData2!, withName: "my_photo", fileName:"my_photo.png", mimeType: "image/jpeg") +//// multipart.append(<#T##fileURL: URL##URL#>, withName: <#T##String#>, fileName: <#T##String#>, mimeType: <#T##String#>) +//// multipart.append(self.imageUrl2!, withName: "my_photo") +// }, to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", method: .put, headers: ["Authorization":"Token " + "\(currentUserToken)"]) { (encodingResult) in +// switch encodingResult { // case .success(let upload, _, _): -// upload.responseJSON { response in +// upload.response { response in +// print("이미지 업로드 성공") // debugPrint(response) +// self.navigationController?.popViewController(animated: true) // } // case .failure(let encodingError): // print(encodingError) -// } -// } -// Alamofire.upload(imageData!, to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", method: .put, headers: ["Authorization":"Token " + "\(currentUserToken)"]).responseJSON { (response) in -// -// print("000000") -// print("\(response.result)") -// print("11111") -// if response.result.isSuccess -// { -// print("이미지 업로드 성공") -// print("\(response.value)") -// }else -// { // print("이미지 업로드 실패") // } -// } - Alamofire.upload(multipartFormData: { (multipart) in - multipart.append(imageData2!, withName: "my_photo", fileName:"my_photo.png", mimeType: "image/jpeg") -// multipart.append(<#T##fileURL: URL##URL#>, withName: <#T##String#>, fileName: <#T##String#>, mimeType: <#T##String#>) -// multipart.append(self.imageUrl2!, withName: "my_photo") - }, to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", method: .put, headers: ["Authorization":"Token " + "\(currentUserToken)"]) { (encodingResult) in - switch encodingResult { - case .success(let upload, _, _): - upload.response { response in - print("이미지 업로드 성공") - debugPrint(response) - self.navigationController?.popViewController(animated: true) - } - case .failure(let encodingError): - print(encodingError) - print("이미지 업로드 실패") - } - } - -// Alamofire.upload(multipartFormData: <#T##(MultipartFormData) -> Void#>, to: <#T##URLConvertible#>, encodingCompletion: <#T##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##(SessionManager.MultipartFormDataEncodingResult) -> Void#>) -// Alamofire.upload(multipartFormData: <#T##(MultipartFormData) -> Void#>, with: <#T##URLRequestConvertible#>, encodingCompletion: <#T##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##(SessionManager.MultipartFormDataEncodingResult) -> Void#>) -// Alamofire.upload(multipartFormData: <#T##(MultipartFormData) -> Void#>, usingThreshold: <#T##UInt64#>, with: <#T##URLRequestConvertible#>, encodingCompletion: <#T##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##((SessionManager.MultipartFormDataEncodingResult) -> Void)?##(SessionManager.MultipartFormDataEncodingResult) -> Void#>) // Alamofire.upload(imageUrl2!, to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/" + "\(currentUserPrimaryKey)/", method: .put, headers: ["Authorization":"Token " + "\(currentUserToken)"]).responseJSON { (response) in // // print("000000") @@ -292,7 +296,6 @@ class DetailChangeUserInfoViewController: UIViewController, UITableViewDelegate, // } // print(DataCenter.shared.realUser?.phone ?? "뭔가 안됨") // self.navigationController?.popViewController(animated: true) - } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.section == 0 { @@ -363,12 +366,16 @@ class DetailChangeUserInfoViewController: UIViewController, UITableViewDelegate, self.dismiss(animated: true, completion: nil) } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - - userData = DataCenter.shared.realUser - tv.reloadData() - } +// override func viewDidDisappear(_ animated: Bool) { +// super.viewDidDisappear(animated) +// tv.reloadData() +// } + +// override func viewWillAppear(_ animated: Bool) { +// super.viewWillAppear(animated) +// +// tv.reloadData() +// } override func viewDidLoad() { super.viewDidLoad() picker.delegate = self diff --git a/EClass/EClass/DetailLogInViewController.swift b/EClass/EClass/DetailLogInViewController.swift index 962d75f..eb998cc 100644 --- a/EClass/EClass/DetailLogInViewController.swift +++ b/EClass/EClass/DetailLogInViewController.swift @@ -12,16 +12,17 @@ import SwiftyJSON import SwiftyGif var loginSuccess:Bool = false - - - class DetailLogInViewController: UIViewController, UITextFieldDelegate{ + @IBAction func backButtonTouched(_ sender: UIButton) { + self.navigationController?.popViewController(animated: true) + } + func textFieldShouldReturn(_ textField: UITextField) -> Bool { @@ -60,14 +61,20 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ currentUserPrimaryKey = realData["user"]["user_pk"].intValue currentUserToken = realData["token"].stringValue - currentUserTuTorPK = realData["user"]["tutor_pk"].intValue + currentUserTuTorPK = realData["user"]["tutor_pk"].int ?? 0 if response.result.isSuccess { if realData["detail"] == nil { DataCenter.shared.realUser = User(with: realData) - +// DispatchQueue.global().async { +// currentUserData = DataCenter.shared.realUser +// } +// currentUserData = DataCenter.shared.realUser +// refreshCurrentUserData() +// currentUserData = DataCenter.shared.realUser +// let user = currentUserData let result = JSON(response.value!) @@ -76,8 +83,6 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ let userPk = result["user"]["user_pk"].intValue let userNickname = result["user"]["nickname"].stringValue - let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) - let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") UserDefaults.standard.set(self.passWordTextField.text, forKey: "UserPassword") @@ -92,6 +97,8 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") self.present(pushMainView, animated: true, completion: nil) +// print("제이슨!!") +// print(currentUserData) } } @@ -118,9 +125,8 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ override func viewDidLoad() { super.viewDidLoad() - DispatchQueue.main.async { self.outletSet() - } + passWordTextField.delegate = self userNameTextField.delegate = self @@ -158,7 +164,9 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ // detailLoginImageView = UIImageView(gifImage: gif, manager: gifManager) // detailLoginImageView.clipsToBounds = true //// detailLoginImageView.alpha = 0.6 - self.navigationController?.navigationBar.alpha = 0.3 +// self.navigationController?.navigationBar.backgroundColor = .clear +// self.navigationController?.navigationBar.alpha = 0.3 + self.navigationItem.leftBarButtonItem?.tintColor = .black self.navigationController?.navigationBar.barTintColor = .black self.navigationController?.isNavigationBarHidden = true @@ -166,7 +174,6 @@ class DetailLogInViewController: UIViewController, UITextFieldDelegate{ // self.navigationController?.navigationItem.backBarButtonItem?.tintColor = .black logInButtonOutlet.setBasicColor() logInButtonOutlet.layer.cornerRadius = 5 - logInButtonOutlet.layer.borderWidth = 1 marginView1.backgroundColor = .clear marginView2.backgroundColor = .clear marginView3.backgroundColor = .clear diff --git a/EClass/EClass/DetailPage.storyboard b/EClass/EClass/DetailPage.storyboard index b3fae16..6a40379 100644 --- a/EClass/EClass/DetailPage.storyboard +++ b/EClass/EClass/DetailPage.storyboard @@ -30,10 +30,10 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + @@ -242,7 +242,7 @@ - + + + @@ -667,7 +682,7 @@ - + diff --git a/EClass/EClass/DetailTableViewController.swift b/EClass/EClass/DetailTableViewController.swift index 9a6e048..0db4389 100644 --- a/EClass/EClass/DetailTableViewController.swift +++ b/EClass/EClass/DetailTableViewController.swift @@ -14,13 +14,37 @@ import SwiftyStarRatingView class DetailTableViewController: UIViewController { - var averageReviewtotalScore:Double? - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - +// var isWished:Bool = false + + @IBAction func wishList(_ sender: UIBarButtonItem) { } + + + func checkWish(){ + + Alamofire.upload(multipartFormData: { (data) in + data.append(self.detailData["id"].stringValue.data(using: .utf8)!, withName: "lecture_id") + }, usingThreshold: UInt64.init(), to: "http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/class/likeclass/", method: .post, headers: ["Authorization":"Token \(UserDefaults.standard.string(forKey: "UserToken")!)"]) { (result) in + print(result) + +// if self.isWished == false{ +// self.isWished = true +// }else{ +// self.isWished = false +// } + let ac = UIAlertController.init(title: "찜하기가 완료되었습니다", message: "나의 위리스트에서 확인해보세요", preferredStyle: .alert) + let action = UIAlertAction.init(title: "확인", style: .default, handler: nil) + ac.addAction(action) + self.present(ac, animated: true, completion: nil) + + } + + } + + var averageReviewtotalScore:Double? + // @IBAction func askTutorButtonTouched(_ sender: UIButton) { // // let alert = UIAlertController.init(title: "튜터에게 문의하기", message: (, preferredStyle: <#T##UIAlertControllerStyle#>) @@ -35,28 +59,37 @@ class DetailTableViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - + let rightBtNotSelected:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.bookmarks, target: self, action: #selector(checkWish)) +// let rightBtSelected:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(checkWish)) reloadList() + Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/class/list/", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: nil).responseJSON { (response) in + guard let data = response.result.value else{return} + + let lectureData = JSON(data) + print("000000") + print(lectureData[0]) + print("xxxxxx") + LectureList.lectureList = lectureData + } + + myTableView.reloadData() +// if isWished == false { + self.navigationItem.rightBarButtonItem = rightBtNotSelected + +// }else{ +// self.navigationItem.rightBarButtonItem = rightBtSelected +// } - myData = LectureGenerator.getLecture(detailData["class_intro"].stringValue, detailData["class_intro"].stringValue) + myData = LectureGenerator.getLecture(detailData["class_intro"].stringValue, detailData["class_intro"].stringValue) reviewAverage = makeReviewAverageScore() loadDetailData(detailData["id"].intValue) - - + myTableView.reloadData() - print("Lecture ID") - - - print("AAAA") - - - - self.navigationItem.title = "강의정보" myTableView.estimatedRowHeight = 100 myTableView.rowHeight = UITableViewAutomaticDimension @@ -70,12 +103,8 @@ class DetailTableViewController: UIViewController { print("Detail Data End!!!!!!") lectureRegistBt.backgroundColor = UIColor(red: 255/255, green: 125/255, blue: 83/255, alpha: 1) - // Do any additional setup after loading the view. - - } - override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. @@ -103,7 +132,7 @@ extension DetailTableViewController:UITableViewDelegate, UITableViewDataSource, - cell.setLectureInfo(self.detailData["title"].stringValue, self.detailData["locations"][0]["location2"].stringValue, "\(self.detailData["max_member"].stringValue) 명", "회 당 \(self.detailData["price"].stringValue) 원", "주 \(self.detailData["basic_class_time"]) 회", "총 8회 16시간", "\(attendanceCount) 명 참여중") + cell.setLectureInfo(self.detailData["title"].stringValue, self.detailData["locations"][0]["location2"].stringValue, "\(self.detailData["max_member"].stringValue) 명", "회 당 \(self.detailData["price"].stringValue) 원", "주 \(self.detailData["basic_class_time"]) 회", "" , "\(attendanceCount) 명 참여중") cell.selectionStyle = .none cell.attendanceCount.layer.cornerRadius = 10 cell.attendanceCount.textColor = .white @@ -142,6 +171,19 @@ extension DetailTableViewController:UITableViewDelegate, UITableViewDataSource, }else if indexPath.row == 4{ let cell = tableView.dequeueReusableCell(withIdentifier: CustomsTableViewCell.mapLocation, for: indexPath) as! MapLocationTableViewCell + + + let regionRadius:CLLocationDistance = 100 + func centerMapLocation(location:CLLocation) { + let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, regionRadius * 2.0, regionRadius * 2.0) + + cell.locationMap.setRegion(coordinateRegion, animated: true) + + } + let initialLocation = CLLocation(latitude: 37.563756, longitude: 126.908421) + + centerMapLocation(location:initialLocation ) + let cellData = detailData["locations"][0] cell.additionalCgLb.text = detailData["locations"][0]["location_etc_text"].stringValue + " 원" @@ -151,13 +193,26 @@ extension DetailTableViewController:UITableViewDelegate, UITableViewDataSource, if cellData["class_weekday"].stringValue == "sun" { cell.dayIndicateBt.setTitle("일", for: .normal) + }else if cellData["class_weekday"].stringValue == "mon" { + cell.dayIndicateBt.setTitle("월", for: .normal) + }else if cellData["class_weekday"].stringValue == "tue" { + cell.dayIndicateBt.setTitle("화", for: .normal) + }else if cellData["class_weekday"].stringValue == "wed" { + cell.dayIndicateBt.setTitle("수", for: .normal) + }else if cellData["class_weekday"].stringValue == "thu" { + cell.dayIndicateBt.setTitle("목", for: .normal) + }else if cellData["class_weekday"].stringValue == "fri" { + cell.dayIndicateBt.setTitle("금", for: .normal) + }else if cellData["class_weekday"].stringValue == "sat" { + cell.dayIndicateBt.setTitle("토", for: .normal) + }else{ + print("AA") } + cell.dayIndicateBt.makeCornerRound3() cell.dayIndicateBt.backgroundColor = UIColor(red: 255/255, green: 125/255, blue: 83/255, alpha: 1) cell.dayIndicateBt.setTitleColor(.white, for: .normal) - - cell.selectionStyle = .none return cell @@ -306,10 +361,10 @@ extension DetailTableViewController:UITableViewDelegate, UITableViewDataSource, func loadDetailData(_ lectureId:Int) { - Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/class/detail/", method: .post, parameters: ["lecture_id":lectureId], encoding: JSONEncoding.prettyPrinted, headers: ["Content-type":"application/json"]).responseJSON { (aa) in + Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/class/detail/", method: .post, parameters: ["lecture_id":lectureId], encoding: JSONEncoding.prettyPrinted, headers: ["Content-type":"application/json"]).responseJSON { (data) in - self.detailData = JSON(aa.result.value) + self.detailData = JSON(data.result.value) self.myTableView.reloadData() } diff --git a/EClass/EClass/FAQViewController.storyboard b/EClass/EClass/FAQViewController.storyboard index 0dd04b5..3e20e3e 100644 --- a/EClass/EClass/FAQViewController.storyboard +++ b/EClass/EClass/FAQViewController.storyboard @@ -25,10 +25,10 @@ - + - + diff --git a/EClass/EClass/Info.plist b/EClass/EClass/Info.plist index b208f2e..6a12dc3 100644 --- a/EClass/EClass/Info.plist +++ b/EClass/EClass/Info.plist @@ -55,6 +55,8 @@ armv7 + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/EClass/EClass/LectureImageCollectionViewCell.swift b/EClass/EClass/LectureImageCollectionViewCell.swift index d396a2d..4c9d12b 100644 --- a/EClass/EClass/LectureImageCollectionViewCell.swift +++ b/EClass/EClass/LectureImageCollectionViewCell.swift @@ -14,7 +14,7 @@ class LectureImageCollectionViewCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() - lectureImage.contentMode = .scaleAspectFit + lectureImage.contentMode = .scaleToFill // Initialization code } diff --git a/EClass/EClass/LetureRegistViewController.swift b/EClass/EClass/LetureRegistViewController.swift index cc4ac27..e7644a7 100644 --- a/EClass/EClass/LetureRegistViewController.swift +++ b/EClass/EClass/LetureRegistViewController.swift @@ -9,6 +9,8 @@ import UIKit import SwiftyJSON import Kingfisher +import Alamofire + class LetureRegistViewController: UIViewController, UITextViewDelegate{ @@ -52,6 +54,43 @@ class LetureRegistViewController: UIViewController, UITextViewDelegate{ } @IBAction func lectureRegistButtonTouched(_ sender: Any) { + + print("CCCCCC") + print("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/lecture/register/\(detailData["id"].intValue)") + print("XXXXXX") + + + + let ac = UIAlertController.init(title: "수강신청", message: "수강신청하시겠어요?", preferredStyle: .alert) + let okAction = UIAlertAction.init(title: "넵!", style: .default, handler: { (action) in + print(action) + + Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/regiclass/lecture/register/\(self.detailData["id"].intValue)/", method: .post, parameters: ["to_tutor":self.userCommentTfv.text!], encoding: JSONEncoding.default, headers: ["Authorization":"Token \(UserDefaults.standard.string(forKey: "UserToken")!)"]).responseJSON { (result) in + print("-------") + print(result) + print(result.result.value) + print("-------") + + } + let doneAlert = UIAlertController.init(title: "신청이 완료되었습니다", message: "나의 강의목록에서 확인해보세요!", preferredStyle: .alert) + let doneAction = UIAlertAction.init(title: "돌아가기", style: .default, handler: { (go) in + self.navigationController?.popViewController(animated: true) + }) + doneAlert.addAction(doneAction) + self.present(doneAlert, animated: true, completion: nil) + + }) + let cancelAction = UIAlertAction.init(title: "다시 생각해볼게요", style: .cancel + , handler: nil) + + ac.addAction(okAction) + ac.addAction(cancelAction) + + self.present(ac, animated: true, completion: nil) + + + + } } /* // MARK: - Navigation @@ -63,4 +102,4 @@ class LetureRegistViewController: UIViewController, UITextViewDelegate{ } */ -} + diff --git a/EClass/EClass/ListOfLecture.storyboard b/EClass/EClass/ListOfLecture.storyboard index f9937b7..fa4dbe8 100644 --- a/EClass/EClass/ListOfLecture.storyboard +++ b/EClass/EClass/ListOfLecture.storyboard @@ -1,12 +1,11 @@ - + - - + @@ -39,58 +38,52 @@ - + - - + + - + - - + - - - + - + + - - - - - - - - - + + + + + + + - diff --git a/EClass/EClass/ListOfLectureViewController.swift b/EClass/EClass/ListOfLectureViewController.swift index 2265d78..13fce35 100644 --- a/EClass/EClass/ListOfLectureViewController.swift +++ b/EClass/EClass/ListOfLectureViewController.swift @@ -7,14 +7,52 @@ // import UIKit +import Alamofire +import SwiftyJSON +import Kingfisher class ListOfLectureViewController: UIViewController, UITabBarDelegate, UITableViewDelegate, UITableViewDataSource { var selectTabBar:Bool = true + var myLectureList:JSON = [] + var wishListJson:JSON = [] + + @IBOutlet weak var wishList: UITabBarItem! @IBOutlet weak var takeLectureList: UITabBarItem! @IBOutlet weak var tabBarOutlet: UITabBar! + + func loadMyLecture()->JSON{ + + var lectureList:JSON = [] + + Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/class/list/", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization":"Token \(UserDefaults.standard.string(forKey: "UserToken")!)"]).responseJSON { (data) in + var result = JSON(data.result.value) + + let lectureData = result["results"] + + self.myLectureList = lectureData + + } + + return lectureList + } + + func loadWishList(){ + Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/like/class/list/", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization":"Token \(UserDefaults.standard.string(forKey: "UserToken")!)"]).responseJSON { (data) in + + var result = JSON(data.result.value) + + let lectureData = result["results"] + + self.wishListJson = lectureData + + + } + + + } func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { @@ -30,7 +68,12 @@ class ListOfLectureViewController: UIViewController, UITabBarDelegate, UITableVi @IBOutlet weak var tv: UITableView! func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 0 + + if selectTabBar { + return myLectureList.count + }else{ + return wishListJson.count + } } @@ -38,10 +81,26 @@ class ListOfLectureViewController: UIViewController, UITabBarDelegate, UITableVi if selectTabBar { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ListOfLectureTableViewCell + + let cellData = myLectureList[indexPath.row]["lecture"] + + cell.introduceOfLectureLabel.text = cellData["title"].stringValue + cell.tutorProfileImage.kf.setImage(with: URL(fileURLWithPath: cellData["tutor"]["my_photo"].stringValue)) + cell.priceOfLectureLabel.text = cellData["tutor"]["nickname"].stringValue + + + return cell }else { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ListOfLectureTableViewCell + + let cellData = wishListJson[indexPath.row]["lecture"] + + cell.introduceOfLectureLabel.text = cellData["title"].stringValue + cell.tutorProfileImage.kf.setImage(with: URL(fileURLWithPath: cellData["tutor"]["my_photo"].stringValue)) + cell.priceOfLectureLabel.text = cellData["tutor"]["nickname"].stringValue + return cell } @@ -50,12 +109,18 @@ class ListOfLectureViewController: UIViewController, UITabBarDelegate, UITableVi super.viewDidLoad() tabBarOutlet.delegate = self + loadWishList() + myLectureList = loadMyLecture() + print(myLectureList) + tv.reloadData() // tabBarOutlet.selectedItem = takeLectureList // Do any additional setup after loading the view. } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + loadWishList() + loadMyLecture() tv.reloadData() } diff --git a/EClass/EClass/LocationSelectViewController.swift b/EClass/EClass/LocationSelectViewController.swift index d7f6560..0b600ca 100644 --- a/EClass/EClass/LocationSelectViewController.swift +++ b/EClass/EClass/LocationSelectViewController.swift @@ -54,7 +54,7 @@ extension LocationSelectViewController:UICollectionViewDelegate, UICollectionVie func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { print(locationStrings[indexPath.item]) - NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: "LocationName"), object: nil, userInfo:["LocationName":locationStrings[indexPath.item]]) + NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: "LocationName"), object: nil, userInfo:["locationName":locationStrings[indexPath.item]]) self.navigationController?.popViewController(animated: true) } diff --git a/EClass/EClass/LogInViewController.swift b/EClass/EClass/LogInViewController.swift index b26d8c5..b940c03 100644 --- a/EClass/EClass/LogInViewController.swift +++ b/EClass/EClass/LogInViewController.swift @@ -39,42 +39,70 @@ class LogInViewController: UIViewController { print("\(userInfo.appId)") print("\(userInfo.userId!)") - let params = ["username":userInfo.userId,"password":userInfo.authenticationToken] + let params = ["username":userInfo.userId,"token":userInfo.authenticationToken] Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/login/facebook/", method: .post, parameters: params, encoding: JSONEncoding.default, headers: nil).responseJSON { (response) in + guard let data = response.result.value else + { + return + } + let realData = JSON(data) + print("제이슨") + print(realData) + currentUserPrimaryKey = realData["user"]["user_pk"].intValue + currentUserToken = realData["token"].stringValue + + currentUserTuTorPK = realData["user"]["tutor_pk"].int ?? 0 if response.result.isSuccess { - print(response.description) - print("response") - print(response) - print("data") - print(JSON(response.value)) - print("data끝") - print(JSON(response.data)) - print(response.timeline) - print(response.metrics) - print(response.request) - print(response.response) - Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/\(userInfo.userId)/", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization":"\(response.data)"]).responseJSON(completionHandler: { (response) in - guard let data = response.result.value else - { - return - } - let jsonData = JSON(data) - print("여기서부터제이슨") - print(jsonData) - print("여기까지") - }) - print("go") - let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) - let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") - self.present(pushMainView, animated: true, completion: nil) - }else - { - print(response.result) + + DataCenter.shared.realUser = User(with: realData) + + let result = JSON(response.value!) + + + let userToken = result["token"].stringValue + let userName = result["user"]["username"].stringValue + let userPk = result["user"]["user_pk"].intValue + let userNickname = result["user"]["nickname"].stringValue + + + +// UserDefaults.standard.set(self.passWordTextField.text, forKey: "UserPassword") + UserDefaults.standard.set(userToken, forKey: "UserToken") + UserDefaults.standard.set(userName, forKey: "UserName") + UserDefaults.standard.set(userPk, forKey: "UserPK") + UserDefaults.standard.set(userNickname, forKey: "UserNickname") + + + if !(userToken == ""){ + + let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) + let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") + self.present(pushMainView, animated: true, completion: nil) + // print("제이슨!!") + // print(currentUserData) + + } } + + +// Alamofire.request("http://eb-yykdev-taling-dev.ap-northeast-2.elasticbeanstalk.com/member/profile/\(userInfo.userId)/", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization":"\(response.data)"]).responseJSON(completionHandler: { (response) in +// guard let data = response.result.value else +// { +// return +// } +// let jsonData = JSON(data) +// print("여기서부터제이슨") +// print(jsonData) +// print("여기까지") +// }) + print("go") + let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) + let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") + self.present(pushMainView, animated: true, completion: nil) } @@ -100,6 +128,24 @@ class LogInViewController: UIViewController { @IBOutlet weak var marginView2: UIView! @IBOutlet weak var marginView1: UIView! override func viewDidLoad() { + +// if UserDefaults.standard.string(forKey: "UserPK") != nil +// { +// currentUserPrimaryKey = UserDefaults.standard.integer(forKey: "UserPK") +// currentUserToken = UserDefaults.standard.string(forKey: "UserToken")! +// +// currentUserTuTorPK = UserDefaults.standard.integer(forKey: "TutorPK") +// +//// currentUserName = UserDefaults.standard.string(forKey: "UserName") +//// currentUserNickname = UserDefaults.standard.string(forKey: "UserNickname") ?? "Default" +// currentUserData = DataCenter.shared.realUser +// +// +// let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) +// let pushMainView = mainStoryBoard.instantiateViewController(withIdentifier: "reveal1") +// self.present(pushMainView, animated: false, completion: nil) +// } + self.navigationController?.navigationBar.isHidden = true super.viewDidLoad() @@ -114,7 +160,7 @@ class LogInViewController: UIViewController { outletSet() -// + // if !(UserDefaults.standard.string(forKey: "UserToken")! == "") { // // let mainStoryBoard = UIStoryboard(name: "MainPage", bundle: nil) diff --git a/EClass/EClass/Main2.storyboard b/EClass/EClass/Main2.storyboard index aa97c29..903ddfb 100644 --- a/EClass/EClass/Main2.storyboard +++ b/EClass/EClass/Main2.storyboard @@ -1,11 +1,11 @@ - + - + @@ -132,10 +132,10 @@ - + - + @@ -165,10 +165,10 @@ - + - + @@ -198,10 +198,10 @@ - + - + @@ -288,10 +288,10 @@ - + - + - + - + - + - + @@ -437,7 +437,7 @@ @@ -486,7 +486,7 @@ - + @@ -522,6 +522,16 @@ + @@ -529,8 +539,10 @@ + + @@ -575,7 +587,7 @@ @@ -643,13 +655,25 @@ + + + diff --git a/EClass/EClass/MainPage.storyboard b/EClass/EClass/MainPage.storyboard index ff57938..fed2530 100644 --- a/EClass/EClass/MainPage.storyboard +++ b/EClass/EClass/MainPage.storyboard @@ -52,7 +52,7 @@ - + @@ -115,7 +115,7 @@ - + @@ -140,7 +140,7 @@ - + - + @@ -197,10 +197,10 @@ - + - + @@ -253,6 +253,32 @@ + + + + + + + + + + @@ -266,15 +292,27 @@ + + + + + + + + + + + + @@ -301,27 +339,20 @@ - + - - + + + + @@ -334,6 +365,17 @@ + + + + + + + + + + + @@ -373,7 +415,7 @@ - + @@ -415,7 +457,7 @@ - +