Просмотр исходного кода

Merge branch 'develop' into feature/dev_Chris

Chris лет назад: 5
Родитель
Сommit
9ded9ad5de
24 измененных файлов с 623 добавлено и 99 удалено
  1. 16 2
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 26 12
      RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate+Window.swift
  3. 9 7
      RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h
  4. 1 1
      RainbowPlanet/RainbowPlanet/Manager/MapManager/BaiduMapManager/BaiduMapManager.swift
  5. 56 8
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/BindPhoneNumber/View/BindPhoneNumberView.swift
  6. 9 23
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/BindPhoneNumber/ViewController/BindPhoneNumberViewController.swift
  7. 16 9
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/GenderSelection/ViewController/GenderSelectionViewController.swift
  8. 55 6
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/MobileLogin/View/MobileLoginView.swift
  9. 10 4
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/MobileLogin/ViewController/MobileLoginViewController.swift
  10. 2 4
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/View/PasswordLoginView.swift
  11. 8 1
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/ViewController/PasswordLoginViewController.swift
  12. 5 10
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/RegisterLogin/ViewController/RegisterLoginViewController.swift
  13. 1 0
      RainbowPlanet/RainbowPlanet/Service/Model/UserModel/UserModel.swift
  14. 29 4
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift
  15. 16 5
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaServiceUserApi.swift
  16. 22 0
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/Contents.json
  17. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/login_sex_female@2x.png
  18. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/login_sex_female@3x.png
  19. 22 0
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/Contents.json
  20. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/login_sex_male@2x.png
  21. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/login_sex_male@3x.png
  22. 46 3
      RainbowPlanet/RainbowPlanet/Tools/Extension/Extension+String.swift
  23. 49 0
      RainbowPlanet/RainbowPlanet/Tools/WaterFallLayout/WaterFallLayout.h
  24. 225 0
      RainbowPlanet/RainbowPlanet/Tools/WaterFallLayout/WaterFallLayout.m

+ 16 - 2
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -345,6 +345,7 @@
 		A7D5F23322BB9BE600F8E9AF /* H5CommonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D5F23222BB9BE600F8E9AF /* H5CommonViewController.swift */; };
 		A7D5F24D22BC720000F8E9AF /* WVJBModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D5F24C22BC720000F8E9AF /* WVJBModel.swift */; };
 		A7D5F25022BC7B3700F8E9AF /* WebViewJavascriptBridgeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D5F24F22BC7B3700F8E9AF /* WebViewJavascriptBridgeManager.swift */; };
+		A7D5F25522BF8E6B00F8E9AF /* WaterFallLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D5F25422BF8E6A00F8E9AF /* WaterFallLayout.m */; };
 		A7DC467F22783A47001F3EFC /* EditExpressAddressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DC467E22783A47001F3EFC /* EditExpressAddressTableViewCell.swift */; };
 		A7DF50D622A4E8B400998908 /* OrderDetailProductTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50D522A4E8B400998908 /* OrderDetailProductTableViewCell.swift */; };
 		A7DF50D822A4FAFC00998908 /* ProductDetailEvaluationImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50D722A4FAFC00998908 /* ProductDetailEvaluationImageCollectionViewCell.swift */; };
@@ -912,6 +913,8 @@
 		A7D5F23222BB9BE600F8E9AF /* H5CommonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = H5CommonViewController.swift; sourceTree = "<group>"; };
 		A7D5F24C22BC720000F8E9AF /* WVJBModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WVJBModel.swift; sourceTree = "<group>"; };
 		A7D5F24F22BC7B3700F8E9AF /* WebViewJavascriptBridgeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewJavascriptBridgeManager.swift; sourceTree = "<group>"; };
+		A7D5F25322BF8E6A00F8E9AF /* WaterFallLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaterFallLayout.h; sourceTree = "<group>"; };
+		A7D5F25422BF8E6A00F8E9AF /* WaterFallLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WaterFallLayout.m; sourceTree = "<group>"; };
 		A7DC467E22783A47001F3EFC /* EditExpressAddressTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditExpressAddressTableViewCell.swift; sourceTree = "<group>"; };
 		A7DF50D522A4E8B400998908 /* OrderDetailProductTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailProductTableViewCell.swift; sourceTree = "<group>"; };
 		A7DF50D722A4FAFC00998908 /* ProductDetailEvaluationImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailEvaluationImageCollectionViewCell.swift; sourceTree = "<group>"; };
@@ -2585,10 +2588,10 @@
 		A77F2CAE2232010F001BD3F6 /* RegisterLoginModule */ = {
 			isa = PBXGroup;
 			children = (
-				A7931E0922AF86D900297D0A /* GenderSelection */,
-				A7931E0E22AF929B00297D0A /* TopicSelection */,
 				A7778CAC2244BC2600C7C47A /* RegisterLogin */,
 				A7778CB52244E93E00C7C47A /* BindPhoneNumber */,
+				A7931E0922AF86D900297D0A /* GenderSelection */,
+				A7931E0E22AF929B00297D0A /* TopicSelection */,
 				A75414F9224B5EFC002480B5 /* MobileLogin */,
 				A729B5B122672401004AE098 /* PasswordLogin */,
 				A7778CC32246030200C7C47A /* PhoneCountryArea */,
@@ -2633,6 +2636,7 @@
 		A77F2CBC2232022A001BD3F6 /* Tools */ = {
 			isa = PBXGroup;
 			children = (
+				A7D5F25222BF8E6A00F8E9AF /* WaterFallLayout */,
 				A7DF50D922A556C300998908 /* BrowsePictures */,
 				A790706222B9DF81008CE279 /* TextLimitTool */,
 				A743229922B8C1440017C367 /* AppStoreReview */,
@@ -3492,6 +3496,15 @@
 			path = H5Modules;
 			sourceTree = "<group>";
 		};
+		A7D5F25222BF8E6A00F8E9AF /* WaterFallLayout */ = {
+			isa = PBXGroup;
+			children = (
+				A7D5F25322BF8E6A00F8E9AF /* WaterFallLayout.h */,
+				A7D5F25422BF8E6A00F8E9AF /* WaterFallLayout.m */,
+			);
+			path = WaterFallLayout;
+			sourceTree = "<group>";
+		};
 		A7DF50D922A556C300998908 /* BrowsePictures */ = {
 			isa = PBXGroup;
 			children = (
@@ -4727,6 +4740,7 @@
 				BDF47D7E22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift in Sources */,
 				BD108C9522A60C2100837DAB /* HGImageCollectionViewCell.swift in Sources */,
 				A7FF1589228C854900A85748 /* OrderDetailBottomView.swift in Sources */,
+				A7D5F25522BF8E6B00F8E9AF /* WaterFallLayout.m in Sources */,
 				BD1FC1A722B1075F00D55081 /* UIColor+Expanded.m in Sources */,
 				A7D5F22B22BB687100F8E9AF /* BaseJSWebViewController.swift in Sources */,
 				BD12203122AF4A010051C7C2 /* MessageMainItemView.swift in Sources */,

+ 26 - 12
RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate+Window.swift

@@ -23,17 +23,25 @@ extension AppDelegate {
             /// 设置全局的navigation
             self?.setNavBarAppearence()
         }
-        if (UserModel.shared().getModel()?.token) != nil && (DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType) != nil {
-            /// 设置Tabbar
-            /// 刷新token
-            setTabbarController()
+        
+        /// 设置默认为快递
+        let deliveryMethodTypeModel = DeliveryMethodTypeModel.shared()
+        deliveryMethodTypeModel.deliveryMethodType = "2"
+        DeliveryMethodTypeModel.shared().setModel(model: deliveryMethodTypeModel)
+        
+        /// 判断初始化页面
+        if (UserModel.shared().getModel()?.token) != nil && ( UserModel.shared().getModel()?.gender != nil || UserModel.shared().getModel()?.gender == 0) {//设置性别话题
+            setSexViewController()
             SwiftMoyaNetWorkServiceUser.shared().userRefreshApi { _ in }
-        } else if (UserModel.shared().getModel()?.token) != nil && (DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType) == nil {
-            /// 设置Tabbar
-            setLocationViewController()
+        }else if (UserModel.shared().getModel()?.token) != nil && ( UserModel.shared().getModel()?.gender != nil || UserModel.shared().getModel()?.gender == 1 || UserModel.shared().getModel()?.gender == 2) { //设置首页
+            setTabbarController()
             SwiftMoyaNetWorkServiceUser.shared().userRefreshApi { _ in }
-        }else {
-            /// 设置登录
+        }
+//        else if (UserModel.shared().getModel()?.token) != nil && ( UserModel.shared().getModel()?.isFollow == nil || UserModel.shared().getModel()?.isFollow == 0) { //设置关注话题
+//            setTopicViewController()
+//            SwiftMoyaNetWorkServiceUser.shared().userRefreshApi { _ in }
+//        }
+        else {// 设置登录
             setLoginController()
         }
 
@@ -53,10 +61,16 @@ extension AppDelegate {
         self.window?.rootViewController = BaseNavigationViewController.init(rootViewController: RegisterLoginViewController())
     }
     
-    /// 设置定位页面
-    func setLocationViewController() {
+    /// 设置性别页面
+    func setSexViewController() {
+        
+        self.window?.rootViewController = BaseNavigationViewController.init(rootViewController: GenderSelectionViewController())
+    }
+    
+    /// 设置话题页面
+    func setTopicViewController() {
         
-        self.window?.rootViewController = BaseNavigationViewController.init(rootViewController: LocationViewController())
+        self.window?.rootViewController = BaseNavigationViewController.init(rootViewController: TopicSelectionViewController())
     }
 
      /// 设置全局的navigation

+ 9 - 7
RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h

@@ -16,16 +16,22 @@
 //微信支付
 #import "WXApi.h"
 
+// mj刷新封装
 #import "UIScrollView+MJRefreshEX.h"
-
+// 限制字符
 #import "TextLimitTool.h"
-
+//瀑布流
+#import "WaterFallLayout.h"
 //空白页面占位图
 #import <LYEmptyView/LYEmptyViewHeader.h>
-
+//sku
 #import "ORSKUDataFilter.h"
+//靠左
 #import "UICollectionViewLeftAlignedLayout.h"
 
+// FIXME: 自定义键盘--待转swift
+#import "LXKeyBoard.h"
+
 #import "FMDB.h"
 
 //友盟
@@ -53,10 +59,6 @@
 #import <BaiduMapAPI_Map/BMKMapView.h>
 
 
-// FIXME: 自定义键盘--待转swift
-#import "LXKeyBoard.h"
-
-
 //  KSMediaPicker所依靠的OC文件
 #import "KSMediaPickerCollectionView.h"
 #import "KSVideoPlayerBaseView.h"

+ 1 - 1
RainbowPlanet/RainbowPlanet/Manager/MapManager/BaiduMapManager/BaiduMapManager.swift

@@ -33,6 +33,7 @@ public class BaiduMapManager: NSObject {
     public func initBaiduMap() -> Void {
         BMKLocationAuth.sharedInstance()?.checkPermision(withKey: kBaiduMapAppKey, authDelegate: self)
         BMKMapManager().start(kBaiduMapAppKey, generalDelegate: self)
+        startLocation()
     }
     
 // ====================================定位========================================
@@ -205,7 +206,6 @@ extension BaiduMapManager:BMKLocationManagerDelegate {
     ///  当定位发生错误时,会调用代理的此方法。
     public func bmkLocationManager(_ manager: BMKLocationManager, didFailWithError error: Error?) {
         NXLLog("定位错误");
-        
     }
     
     /// 定位权限状态改变时回调函数

+ 56 - 8
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/BindPhoneNumber/View/BindPhoneNumberView.swift

@@ -17,11 +17,14 @@ class BindPhoneNumberView: BaseView {
 
     /// 验证码
     var sms : String = ""
+    
+    /// 邀请码
+    var invitationCode : String = ""
 
     typealias SendSmSBlock = (_ smsButton: CountdownButton,_ phoneNumber : String) -> Void
     var sendSmSBlock : SendSmSBlock?
 
-    typealias LoginBlock = (_ phoneNumber : String ,_ sms : String) -> Void
+    typealias LoginBlock = (_ phoneNumber : String ,_ sms : String,_ invitationCode : String) -> Void
     var loginBlock : LoginBlock?
 
     override func setupViews() {
@@ -37,6 +40,10 @@ class BindPhoneNumberView: BaseView {
         smsBgView.addSubview(linesmsLabel)
         smsBgView.addSubview(smsButton)
         smsBgView.addSubview(smsTextField)
+        
+        addSubview(invitationCodeBgView)
+        invitationCodeBgView.addSubview(lineInvitationCodeLabel)
+        invitationCodeBgView.addSubview(invitationCodeTextField)
 
         addSubview(loginButton)
     }
@@ -92,9 +99,23 @@ class BindPhoneNumberView: BaseView {
             make.left.equalTo(phoneAreaCodeLabel)
             make.width.equalTo(kScreenWidth - kScaleValue(value: 76 + 30 + smsButton.width))
         }
+        
+        invitationCodeBgView.snp.makeConstraints { (make) in
+            make.top.equalTo(smsBgView.snp.bottom)
+            make.left.right.height.equalTo(phoneNumberBgView)
+        }
+        lineInvitationCodeLabel.snp.makeConstraints { (make) in
+            make.left.right.bottom.equalToSuperview()
+            make.height.equalTo(0.5)
+        }
+        invitationCodeTextField.snp.makeConstraints { (make) in
+            make.left.right.equalToSuperview()
+            make.top.equalToSuperview().offset(kScaleValue(value: 6))
+            make.height.equalTo(phoneAreaCodeLabel)
+        }
 
         loginButton.snp.makeConstraints { (make) in
-            make.top.equalTo(smsBgView.snp.bottom).offset(kScaleValue(value: 35))
+            make.top.equalTo(invitationCodeBgView.snp.bottom).offset(kScaleValue(value: 35))
             make.height.equalTo(kScaleValue(value:44))
             make.left.equalToSuperview().offset(kScaleValue(value: 38))
             make.right.equalToSuperview().offset(kScaleValue(value: -38))
@@ -146,7 +167,7 @@ class BindPhoneNumberView: BaseView {
         phoneNumberTextField.clearButtonMode = .whileEditing
         phoneNumberTextField.sizeToFit()
         phoneNumberTextField.keyboardType = .numberPad
-        phoneNumberTextField.tintColor = kFFA42FColor
+        phoneNumberTextField.tintColor = kThemeColor
 
         phoneNumberTextField.rx.text.changed.subscribe(onNext: { [weak self] (text) in
             self?.phoneNumberTextField.text = String(text?.prefix(11) ?? "") as String
@@ -173,12 +194,12 @@ class BindPhoneNumberView: BaseView {
         smsButton.disabledText = "  seconds后重新获取  "
         smsButton.setTitle(smsButton.normalText, for: UIControl.State.normal)
         smsButton.setTitle(smsButton.disabledText, for: UIControl.State.disabled)
-        smsButton.setTitleColor(kFFA42FColor, for: UIControl.State.normal)
+        smsButton.setTitleColor(kThemeColor, for: UIControl.State.normal)
         smsButton.setTitleColor(k333333Color, for: UIControl.State.disabled)
         smsButton.titleLabel?.font = kScaleRegularFont12
         smsButton.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.center
         smsButton.sizeToFit()
-        smsButton.normalBorderColor = kFFA42FColor
+        smsButton.normalBorderColor = kThemeColor
         smsButton.normalBorderWidth = 0.5
         smsButton.normalCornerRadius = kScaleValue(value: 15)
         smsButton.normalBackgroundColor = UIColor.white
@@ -209,7 +230,7 @@ class BindPhoneNumberView: BaseView {
         smsTextField.font = kScaleRegularFont16
         smsTextField.sizeToFit()
         smsTextField.keyboardType = .numberPad
-        smsTextField.tintColor = kFFA42FColor
+        smsTextField.tintColor = kThemeColor
         smsTextField.rx.text.changed.subscribe(onNext: { [weak self] (text) in
             self?.smsTextField.text = String(text?.prefix(6) ?? "") as String
             self?.sms = self?.smsTextField.text ?? ""
@@ -218,6 +239,33 @@ class BindPhoneNumberView: BaseView {
 
         return smsTextField
     }()
+    
+    private lazy var invitationCodeBgView: UIView = {
+        let invitationCodeBgView = UIView()
+        return invitationCodeBgView
+    }()
+    
+    private lazy var lineInvitationCodeLabel: UILabel = {
+        let lineInvitationCodeLabel = UILabel()
+        lineInvitationCodeLabel.backgroundColor = ke6e6e6Color
+        return lineInvitationCodeLabel
+    }()
+    
+    private lazy var invitationCodeTextField : UITextField = {
+        let invitationCodeTextField = UITextField()
+        invitationCodeTextField.placeholder = "请输入邀请码(选填)"
+        invitationCodeTextField.borderStyle = .none
+        invitationCodeTextField.textColor = k666666Color
+        invitationCodeTextField.font = kScaleRegularFont16
+        invitationCodeTextField.clearButtonMode = .whileEditing
+        invitationCodeTextField.sizeToFit()
+        invitationCodeTextField.keyboardType = .numberPad
+        invitationCodeTextField.tintColor = kThemeColor
+        invitationCodeTextField.rx.text.orEmpty.changed.subscribe(onNext: { [weak self] (text) in
+            self?.invitationCode = self?.invitationCodeTextField.text ?? ""
+        }).disposed(by: disposeBag)
+        return invitationCodeTextField
+    }()
 
     private lazy var loginButton: UIButton = {
         let loginButton = UIButton(type: UIButton.ButtonType.custom)
@@ -233,7 +281,7 @@ class BindPhoneNumberView: BaseView {
         loginButton.rx.tap.subscribe(onNext: { [weak self] (data) in
 
             if let loginBlock = self?.loginBlock {
-                loginBlock((self?.phoneNumber)!,(self?.sms)!)
+                loginBlock((self?.phoneNumber)!,(self?.sms)!,(self?.invitationCode)!)
             }
 
         }).disposed(by: disposeBag)
@@ -249,7 +297,7 @@ class BindPhoneNumberView: BaseView {
             }.subscribe(onNext: {
                 [weak self] isEmpty in
                 self?.loginButton.isEnabled = isEmpty
-            }).disposed(by: self.disposeBag)
+        }).disposed(by: self.disposeBag)
     }
 
 }

+ 9 - 23
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/BindPhoneNumber/ViewController/BindPhoneNumberViewController.swift

@@ -30,22 +30,6 @@ class BindPhoneNumberViewController: BaseViewController {
     }
 
     override  func setupViews() {
-        if bindPhoneNumberVCType == .weixinlogin {
-            navigationBar.wr_setLeftButton(image: UIImage())
-            navigationBar.wr_setRightButton(title: "跳过", titleColor: k333333Color)
-            navigationBar.onClickLeftButton = nil
-            navigationBar.onClickRightButton = {
-                [weak self] in
-                let vc = LocationViewController()
-                let nav = BaseNavigationViewController.init(rootViewController: vc)
-                self?.present(nav, animated: true, completion: {
-                    
-                })
-            }
-        }else if bindPhoneNumberVCType == .accountSecuritySet  {
-            
-        }
-       
         view.addSubview(bindPhoneNumberView)
     }
 
@@ -65,15 +49,17 @@ class BindPhoneNumberViewController: BaseViewController {
             })
         }
         bindPhoneNumberView.loginBlock = {
-            [weak self] (phoneNumber,sms) in
-            SwiftMoyaNetWorkServiceUser.shared().userBindMobileApi(mobile: phoneNumber, smsCode: sms, unionId: UserModel.shared().getModel()?.unionId ?? "", openId: UserModel.shared().getModel()?.openId ?? "", completion: { [weak self] (data) -> (Void) in
-                if self?.bindPhoneNumberVCType == .weixinlogin {
-                    self?.navigationController?.pushViewController(LocationViewController(), animated: true)
-
-                }else if self?.bindPhoneNumberVCType == .accountSecuritySet  {
+            [weak self] (phoneNumber,sms,invitationCode) in
+            SwiftMoyaNetWorkServiceUser.shared().userBindMobileApi(mobile: phoneNumber, smsCode: sms, unionId: UserModel.shared().getModel()?.unionId ?? "", openId: UserModel.shared().getModel()?.openId ?? "", invitationCode: invitationCode, completion: { [weak self] (data) -> (Void) in
+                if self?.bindPhoneNumberVCType == .weixinlogin { //跳转性别
+                   
+                    self?.present(GenderSelectionViewController(), animated: true, completion: {
+                        
+                    })
+                }else if self?.bindPhoneNumberVCType == .accountSecuritySet  { //设置密码
                         let vc = SetPasswordViewController()
                         self?.navigationController?.pushViewController(vc, animated: true)
-                }else if self?.bindPhoneNumberVCType == .accountSecurityBindMobile  {
+                }else if self?.bindPhoneNumberVCType == .accountSecurityBindMobile  { //绑定手机
                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "AccountSecurity"), object: nil)
                     self?.navigationController?.popViewController(animated: true)
                 }

+ 16 - 9
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/GenderSelection/ViewController/GenderSelectionViewController.swift

@@ -80,12 +80,12 @@ class GenderSelectionViewController: BaseViewController {
         let maleButton = UIButton(type: UIButton.ButtonType.custom)
         maleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFF9F0Color), for: UIControl.State.normal)
         maleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFEDD3Color), for: UIControl.State.highlighted)
-        maleButton.setImage(kImage(name: "pic_preload"), for: UIControl.State.normal)
+        maleButton.setImage(kImage(name: "login_sex_male"), for: UIControl.State.normal)
         maleButton.cornerRadius = 10
         maleButton.masksToBounds = true
         maleButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.presentVC()
+            self?.userGenderApi(gender:1)
         }).disposed(by: disposeBag)
         return maleButton
     }()
@@ -94,12 +94,12 @@ class GenderSelectionViewController: BaseViewController {
         let femaleButton = UIButton(type: UIButton.ButtonType.custom)
         femaleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFF9F0Color), for: UIControl.State.normal)
         femaleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFEDD3Color), for: UIControl.State.highlighted)
-        femaleButton.setImage(kImage(name: "pic_preload"), for: UIControl.State.normal)
+        femaleButton.setImage(kImage(name: "login_sex_female"), for: UIControl.State.normal)
         femaleButton.cornerRadius = 10
         femaleButton.masksToBounds = true
         femaleButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.presentVC()
+            self?.userGenderApi(gender:2)
         }).disposed(by: disposeBag)
         return femaleButton
     }()
@@ -111,7 +111,7 @@ class GenderSelectionViewController: BaseViewController {
         maleTitleButton.titleLabel?.font = kScaleRegularFont16
         maleTitleButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.presentVC()
+            self?.userGenderApi(gender:1)
         }).disposed(by: disposeBag)
         return maleTitleButton
     }()
@@ -123,15 +123,22 @@ class GenderSelectionViewController: BaseViewController {
         femaleTitleButton.titleLabel?.font = kScaleRegularFont16
         femaleTitleButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.presentVC()
+            self?.userGenderApi(gender:2)
         }).disposed(by: disposeBag)
         return femaleTitleButton
     }()
 }
 
 extension GenderSelectionViewController {
-    func presentVC() {
-        let vc = TopicSelectionViewController()
-        self.present(vc, animated: true, completion: nil)
+    
+    
+    /// 设置性别
+    ///
+    /// - Parameter gender: 性别
+    func userGenderApi(gender:Int) {
+        SwiftMoyaNetWorkServiceUser.shared().userGenderApi(gender: gender) { (data) -> (Void) in
+            let vc = TopicSelectionViewController()
+            self.present(vc, animated: true, completion: nil)
+        }
     }
 }

+ 55 - 6
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/MobileLogin/View/MobileLoginView.swift

@@ -17,11 +17,14 @@ class MobileLoginView: BaseView {
 
     /// 验证码
     var sms : String = ""
+    
+    /// 邀请码
+    var invitationCode : String = ""
 
     typealias SendSmSBlock = (_ smsButton: CountdownButton,_ phoneNumber : String) -> Void
     var sendSmSBlock : SendSmSBlock?
 
-    typealias LoginBlock = (_ phoneNumber : String ,_ sms : String) -> Void
+    typealias LoginBlock = (_ phoneNumber : String ,_ sms : String,_ invitationCode : String) -> Void
     var loginBlock : LoginBlock?
 
     typealias PasswordLoginBlock = () -> Void
@@ -39,6 +42,10 @@ class MobileLoginView: BaseView {
         smsBgView.addSubview(linesmsLabel)
         smsBgView.addSubview(smsButton)
         smsBgView.addSubview(smsTextField)
+        
+        addSubview(invitationCodeBgView)
+        invitationCodeBgView.addSubview(lineInvitationCodeLabel)
+        invitationCodeBgView.addSubview(invitationCodeTextField)
 
         addSubview(loginButton)
         addSubview(passwordLoginButton)
@@ -92,9 +99,23 @@ class MobileLoginView: BaseView {
             make.left.equalTo(phoneAreaCodeLabel)
             make.width.equalTo(kScreenWidth - kScaleValue(value: 76 + 30 + smsButton.width))
         }
+        
+        invitationCodeBgView.snp.makeConstraints { (make) in
+            make.top.equalTo(smsBgView.snp.bottom)
+            make.left.right.height.equalTo(phoneNumberBgView)
+        }
+        lineInvitationCodeLabel.snp.makeConstraints { (make) in
+            make.left.right.bottom.equalToSuperview()
+            make.height.equalTo(0.5)
+        }
+        invitationCodeTextField.snp.makeConstraints { (make) in
+            make.left.right.equalToSuperview()
+            make.top.equalToSuperview().offset(kScaleValue(value: 6))
+            make.height.equalTo(phoneAreaCodeLabel)
+        }
 
         loginButton.snp.makeConstraints { (make) in
-            make.top.equalTo(smsBgView.snp.bottom).offset(kScaleValue(value: 35))
+            make.top.equalTo(invitationCodeBgView.snp.bottom).offset(kScaleValue(value: 35))
             make.height.equalTo(kScaleValue(value:44))
             make.left.equalToSuperview().offset(kScaleValue(value: 38))
             make.right.equalToSuperview().offset(kScaleValue(value: -38))
@@ -171,12 +192,12 @@ class MobileLoginView: BaseView {
         smsButton.disabledText = "  seconds后重新获取  "
         smsButton.setTitle(smsButton.normalText, for: UIControl.State.normal)
         smsButton.setTitle(smsButton.disabledText, for: UIControl.State.disabled)
-        smsButton.setTitleColor(kFFA42FColor, for: UIControl.State.normal)
+        smsButton.setTitleColor(kThemeColor, for: UIControl.State.normal)
         smsButton.setTitleColor(k333333Color, for: UIControl.State.disabled)
         smsButton.titleLabel?.font = kRegularFont12
         smsButton.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.center
         smsButton.sizeToFit()
-        smsButton.normalBorderColor = kFFA42FColor
+        smsButton.normalBorderColor = kThemeColor
         smsButton.normalBorderWidth = 0.5
         smsButton.normalCornerRadius = kScaleValue(value: 15)
         smsButton.normalBackgroundColor = UIColor.white
@@ -207,7 +228,7 @@ class MobileLoginView: BaseView {
         smsTextField.font = kScaleRegularFont16
         smsTextField.sizeToFit()
         smsTextField.keyboardType = .numberPad
-        smsTextField.tintColor = kFFA42FColor
+        smsTextField.tintColor = kThemeColor
 
         smsTextField.rx.text.changed.subscribe(onNext: { [weak self] (text) in
             self?.smsTextField.text = String(text?.prefix(6) ?? "") as String
@@ -217,6 +238,33 @@ class MobileLoginView: BaseView {
 
         return smsTextField
     }()
+    
+    private lazy var invitationCodeBgView: UIView = {
+        let invitationCodeBgView = UIView()
+        return invitationCodeBgView
+    }()
+    
+    private lazy var lineInvitationCodeLabel: UILabel = {
+        let lineInvitationCodeLabel = UILabel()
+        lineInvitationCodeLabel.backgroundColor = ke6e6e6Color
+        return lineInvitationCodeLabel
+    }()
+    
+    private lazy var invitationCodeTextField : UITextField = {
+        let invitationCodeTextField = UITextField()
+        invitationCodeTextField.placeholder = "请输入邀请码(选填)"
+        invitationCodeTextField.borderStyle = .none
+        invitationCodeTextField.textColor = k666666Color
+        invitationCodeTextField.font = kScaleRegularFont16
+        invitationCodeTextField.clearButtonMode = .whileEditing
+        invitationCodeTextField.sizeToFit()
+        invitationCodeTextField.keyboardType = .numberPad
+        invitationCodeTextField.tintColor = kThemeColor
+        invitationCodeTextField.rx.text.orEmpty.changed.subscribe(onNext: { [weak self] (text) in
+            self?.invitationCode = self?.invitationCodeTextField.text ?? ""
+        }).disposed(by: disposeBag)
+        return invitationCodeTextField
+    }()
 
     private lazy var loginButton: UIButton = {
         let loginButton = UIButton(type: UIButton.ButtonType.custom)
@@ -232,7 +280,7 @@ class MobileLoginView: BaseView {
         loginButton.rx.tap.subscribe(onNext: { [weak self] (data) in
 
             if let loginBlock = self?.loginBlock {
-                loginBlock((self?.phoneNumber)!,(self?.sms)!)
+                loginBlock((self?.phoneNumber)!,(self?.sms)!, (self?.invitationCode)!)
             }
 
         }).disposed(by: disposeBag)
@@ -266,5 +314,6 @@ class MobileLoginView: BaseView {
             }).disposed(by: self.disposeBag)
     }
 
+
 }
 

+ 10 - 4
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/MobileLogin/ViewController/MobileLoginViewController.swift

@@ -40,10 +40,16 @@ class MobileLoginViewController: BaseViewController {
         }
         // 登录
         mobileLoginView.loginBlock = {
-            (phoneNumber,sms) in
-            SwiftMoyaNetWorkServiceUser.shared().userMobileRegisterApi(mobile: phoneNumber, sms_code: sms, completion: { [weak self] (data) -> (Void) in
-                self?.navigationController?.pushViewController(LocationViewController(), animated: true)
-
+            (phoneNumber,sms,invitationCode) in
+            SwiftMoyaNetWorkServiceUser.shared().userMobileRegisterApi(mobile: phoneNumber, sms_code: sms,invitationCode:invitationCode, completion: { [weak self] (data) -> (Void) in
+                if(UserModel.shared().getModel()?.gender == nil || UserModel.shared().getModel()?.gender == 0) {//设置性别话题
+                    self?.present(GenderSelectionViewController(), animated: true, completion: {
+                        
+                    })
+                }else {// 设置首页
+                    kAppDelegate.setTabbarController()
+                    self?.navigationController?.popToRootViewController(animated: false)
+                }
             })
             
         }

+ 2 - 4
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/View/PasswordLoginView.swift

@@ -141,7 +141,7 @@ class PasswordLoginView: BaseView {
         phoneNumberTextField.clearButtonMode = .whileEditing
         phoneNumberTextField.sizeToFit()
         phoneNumberTextField.keyboardType = .numberPad
-        phoneNumberTextField.tintColor = kFFA42FColor
+        phoneNumberTextField.tintColor = kThemeColor
         phoneNumberTextField.rx.text.changed.subscribe(onNext: { [weak self] (text) in
             self?.phoneNumberTextField.text = String(text?.prefix(11) ?? "") as String
             self?.phoneNumber = self?.phoneNumberTextField.text ?? ""
@@ -181,7 +181,7 @@ class PasswordLoginView: BaseView {
         passwordTextField.sizeToFit()
         passwordTextField.isSecureTextEntry = false
         passwordTextField.clearButtonMode = .whileEditing
-        passwordTextField.tintColor = kFFA42FColor
+        passwordTextField.tintColor = kThemeColor
 
         passwordTextField.rx.text.changed.subscribe(onNext: { [weak self] (text) in
             self?.passwordTextField.text = String(text?.prefix(16) ?? "") as String
@@ -226,8 +226,6 @@ class PasswordLoginView: BaseView {
         return forgetPasswordButton
     }()
 
-
-
     func observableString() {
         Observable.combineLatest(Observable.just(phoneNumber), Observable.just(password)) { (textValue1, textValue2) -> Bool in
             let textValue1 = String(textValue1.prefix(11)) as String

+ 8 - 1
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/ViewController/PasswordLoginViewController.swift

@@ -32,7 +32,14 @@ class PasswordLoginViewController: BaseViewController {
         passwordLoginView.loginBlock = {
             [weak self] (phoneNumber,password) in
             SwiftMoyaNetWorkServiceUser.shared().userMobileLoginApi(mobile: phoneNumber, password: password, completion: { (data) -> (Void) in
-                self?.navigationController?.pushViewController(LocationViewController(), animated: true)
+                if(UserModel.shared().getModel()?.gender == nil || UserModel.shared().getModel()?.gender == 0) {//设置性别话题
+                    self?.present(GenderSelectionViewController(), animated: true, completion: {
+                        
+                    })
+                }else {// 设置首页
+                    kAppDelegate.setTabbarController()
+                    self?.navigationController?.popToRootViewController(animated: false)
+                }
 
             })
         }

+ 5 - 10
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/RegisterLogin/ViewController/RegisterLoginViewController.swift

@@ -18,8 +18,7 @@ class RegisterLoginViewController: BaseViewController {
 
     override func setupViews() {
         view.backgroundColor = UIColor.white
-        navigationBar.wr_setLeftButton(title: "", titleColor: UIColor.clear)
-        navigationBar.onClickLeftButton = nil
+        navigationBar.isHidden = true
         view.addSubview(registerLoginView)
     }
 
@@ -35,18 +34,14 @@ class RegisterLoginViewController: BaseViewController {
         registerLoginView.weiXinLoginBlock = { [weak self] in
             UMManager.shared().loginGetUserInfo(platformType: UMSocialPlatformType.wechatSession) { (UserModel) -> (Void) in
                 let wxLoginModel = UserModel
-                SwiftMoyaNetWorkServiceUser.shared().userWeiXinRegisterApi(open_id: wxLoginModel.open_id, union_id: wxLoginModel.union_id, avatar: wxLoginModel.avatar, username: wxLoginModel.username, gender: wxLoginModel.gender, completion: { (UserModel) -> (Void) in
-                    let UserModel =  UserModel as! UserModel
-                    if (UserModel.mobile != nil && UserModel.mobile != "" ) {
+                SwiftMoyaNetWorkServiceUser.shared().userWeiXinRegisterApi(open_id: wxLoginModel.open_id, union_id: wxLoginModel.union_id, avatar: wxLoginModel.avatar, username: wxLoginModel.username, gender: wxLoginModel.gender, completion: { (userModel) -> (Void) in
+                    let userModel =  userModel as! UserModel
+                    if (userModel.mobile != nil && userModel.mobile != "" ) {
                         self?.navigationController?.pushViewController(LocationViewController(), animated: true)
-
                     }else {
                         let vc = BindPhoneNumberViewController()
                         vc.bindPhoneNumberVCType = .weixinlogin
-                        let nav = BaseNavigationViewController.init(rootViewController: vc)
-                        self?.present(nav, animated: true, completion: {
-
-                        })
+                        self?.navigationController?.pushViewController(vc, animated: true)
                     }
 
                 })

+ 1 - 0
RainbowPlanet/RainbowPlanet/Service/Model/UserModel/UserModel.swift

@@ -27,6 +27,7 @@ class UserModel : NSObject, NSCoding, Mappable{
     var uid : Int?
     var unionId : String?
     var username : String?
+    var isFollow : Int?
 
 
 	class func newInstance(map: Map) -> Mappable?{

+ 29 - 4
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift

@@ -43,9 +43,12 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
         parameters.updateValue(gender, forKey: "gender")
         SwiftProgressHUD.shared().showWait()
         SwiftMoyaNetWorkManager.shared.requestObject(UserModel.self,target: MultiTarget(SwiftMoyaServiceUserApi.userWeiXinRegister(parameters: parameters))) { (userModel) in
-            UserModel.shared().setModel(model: userModel as! UserModel)
+            let userModel = userModel as! UserModel
+            if userModel.mobile != nil || userModel.mobile != "" {
+                UserModel.shared().setModel(model: userModel)
+            }
             SwiftProgressHUD.shared().hide()
-            completion(UserModel.shared().getModel() as Any)
+            completion(userModel as Any)
         }
     }
 
@@ -56,12 +59,13 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
     ///   - mobile: 手机号
     ///   - sms_code: 短信验证码
     ///   - completion: 回调
-    func userMobileRegisterApi(mobile:String,sms_code:String,completion: @escaping apiCallBack) {
+    func userMobileRegisterApi(mobile:String,sms_code:String,invitationCode:String,completion: @escaping apiCallBack) {
         
         if isMobileVerification(mobile: mobile) {
             var parameters = Dictionary<String,Any>()
             parameters.updateValue(mobile, forKey: "mobile")
             parameters.updateValue(sms_code, forKey: "sms_code")
+            parameters.updateValue(invitationCode, forKey: "invite_code")
             SwiftProgressHUD.shared().showWait()
             SwiftMoyaNetWorkManager.shared.requestObject(UserModel.self,target: MultiTarget(SwiftMoyaServiceUserApi.userMobileRegister(parameters: parameters))) { (userModel) in
                 UserModel.shared().setModel(model: userModel as! UserModel)
@@ -132,7 +136,7 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
     ///   - unionId: 微信unioId
     ///   - openId: 微信openId
     ///   - completion: 回调
-    func userBindMobileApi(mobile:String,smsCode:String,unionId:String,openId:String,completion: @escaping apiCallBack) {
+    func userBindMobileApi(mobile:String,smsCode:String,unionId:String,openId:String,invitationCode:String,completion: @escaping apiCallBack) {
         
         if isMobileVerification(mobile: mobile) {
             var parameters = Dictionary<String,Any>()
@@ -140,6 +144,7 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
             parameters.updateValue(smsCode, forKey: "sms_code")
             parameters.updateValue(unionId, forKey: "union_id")
             parameters.updateValue(openId, forKey: "open_id")
+            parameters.updateValue(invitationCode, forKey: "invite_code")
             
             SwiftProgressHUD.shared().showWait()
             SwiftMoyaNetWorkManager.shared.requestObject(UserModel.self,target: MultiTarget(SwiftMoyaServiceUserApi.userBindMobile(parameters: parameters))) { (userModel) in
@@ -524,5 +529,25 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
             }
         }
     }
+    
+    // MARK: - 修改用户性别
+    /// 修改用户性别
+    ///
+    /// - Parameters:
+    ///   - gender: 0位置 1男 2女
+    ///   - completion: 回调
+    func userGenderApi(gender:Int = 0,completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        parameters.updateValue(gender, forKey: "deliver_type")
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared.requestAny(target: MultiTarget(SwiftMoyaServiceUserApi.userSetDeliverType(parameters: parameters))) { (data) in
+            // 设置成功更新本地存储数据
+            let model = UserModel.shared().getModel()
+            model?.gender = gender
+            UserModel.shared().setModel(model: model!)
+            SwiftProgressHUD.shared().hide()
+            completion("")
+        }
+    }
 
 }

+ 16 - 5
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaServiceUserApi.swift

@@ -97,6 +97,10 @@ public let kUserAddSelfAddressApi = "/user/addSelfAddress"
 /// 设置用户配送方式
 public let kUserSetDeliverTypeApi = "/user/setDeliverType"
 
+// MARK: - 设置用户性别
+/// 设置用户性别
+public let kUserMemberUpdateGenderApi = "user/v2/member/updateGender"
+
 /// 用户
 ///
 /// - userLogout: 登出
@@ -144,6 +148,7 @@ public enum SwiftMoyaServiceUserApi {
     case userSetExpreesContactsDefault(parameters:Dictionary<String, Any>)
     case userAddSelfAddress(parameters:Dictionary<String, Any>)
     case userSetDeliverType(parameters:Dictionary<String, Any>)
+    case userMemberUpdateGender(parameters:Dictionary<String, Any>)
     
 }
 
@@ -172,7 +177,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
              .userAddSelfAddress,
-             .userSetDeliverType
+             .userSetDeliverType,
+             .userMemberUpdateGender
             :
             return URL(string: kApiDataPrefix())!
         }
@@ -222,8 +228,10 @@ extension SwiftMoyaServiceUserApi: TargetType {
             return kUserSetExpreesContactsDefaultApi
         case .userAddSelfAddress:
             return kUserAddSelfAddressApi
-        case.userSetDeliverType:
+        case .userSetDeliverType:
              return kUserSetDeliverTypeApi
+        case .userMemberUpdateGender:
+            return kUserMemberUpdateGenderApi
         }
     }
 
@@ -252,7 +260,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
         case .userSelfAddressList,
              .userExpreesContactsList,
              .userDefaultExpress,
-             .userDefaultContact
+             .userDefaultContact,
+             .userMemberUpdateGender
             :
             return .get
         case .userAddressDelete,
@@ -288,7 +297,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userDelExpreesContacts(var parameters),
              .userSetExpreesContactsDefault(var parameters),
              .userAddSelfAddress(var parameters),
-             .userSetDeliverType(var parameters)
+             .userSetDeliverType(var parameters),
+             .userMemberUpdateGender(var parameters)
             :
             let sign = SwiftSign.shared().sign(signType:.AccessToken, parameters: parameters)
             parameters.updateValue(sign, forKey: "sign")
@@ -332,7 +342,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
              .userAddSelfAddress,
-             .userSetDeliverType
+             .userSetDeliverType,
+             .userMemberUpdateGender
             :
             return (headerParameters(headerType: .tokenHeader) as! [String : String])
         case .userLogout,

+ 22 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "login_sex_female@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "login_sex_female@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/login_sex_female@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_female.imageset/login_sex_female@3x.png


+ 22 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "login_sex_male@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "login_sex_male@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/login_sex_male@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/login_sex_male.imageset/login_sex_male@3x.png


+ 46 - 3
RainbowPlanet/RainbowPlanet/Tools/Extension/Extension+String.swift

@@ -189,7 +189,12 @@ extension String {
         return jsonStr
     }
     
-    static func getArrayFromJSONString(jsonString:String) ->NSArray{
+    
+    /// json转数组
+    ///
+    /// - Parameter jsonString: jsonstring
+    /// - Returns: 数组
+    static func getArrayFromJSONString(jsonString:String) ->NSArray {
         
         let jsonData:Data = jsonString.data(using: .utf8)!
         
@@ -202,7 +207,7 @@ extension String {
     }
     
     //改变指定字符串中内容的颜色
-    func changeTextColor(rangStr : String, rangColor : UIColor) ->NSAttributedString{
+    func changeTextColor(rangStr : String, rangColor : UIColor) ->NSAttributedString {
         let strg = self
         let ranStr = rangStr
         //所有文字变为富文本
@@ -215,7 +220,7 @@ extension String {
         return attrstring
     }
     //改变指定字符串中内容的颜色
-    func changeTextColorFont(rangStr : String, rangColor : UIColor,font:UIFont) ->NSAttributedString{
+    func changeTextColorFont(rangStr : String, rangColor : UIColor,font:UIFont) ->NSAttributedString {
         let strg = self
         let ranStr = rangStr
         //所有文字变为富文本
@@ -228,9 +233,47 @@ extension String {
         return attrstring
     }
     
+    /// 富文本
+    ///
+    /// - Returns: html
     func setHTMLImgStyle() -> String {
         let str = "<head><style>img{width:\(kScreenWidth) !important;height:auto}</style></head>\(self)"
         return str
 
     }
+    
+    
+    /// 计算string 内容的宽度
+    ///
+    /// - Parameters:
+    ///   - font: 字体
+    ///   - height: 高度
+    /// - Returns: 返回宽度
+    func widthForComment(font: UIFont, height: CGFloat = 15) -> CGFloat {
+        let rect = NSString(string: self).boundingRect(with: CGSize(width: CGFloat(MAXFLOAT), height: height), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)
+        return ceil(rect.width)
+    }
+    
+    /// 计算string 内容的高度
+    ///
+    /// - Parameters:
+    ///   - font: 字体
+    ///   - width: 宽度
+    /// - Returns: 返回高度
+    func heightForComment(font: UIFont, width: CGFloat) -> CGFloat {
+        let rect = NSString(string: self).boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)
+        return ceil(rect.height)
+    }
+    
+    /// 计算string 内容的高度
+    ///
+    /// - Parameters:
+    ///   - font: 字体
+    ///   - width: 宽度
+    ///   - maxHeight: 最大高度
+    /// - Returns: 高度
+    func heightForComment(font: CGFloat, width: CGFloat, maxHeight: CGFloat) -> CGFloat {
+        let rect = NSString(string: self).boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)
+        return ceil(rect.height)>maxHeight ? maxHeight : ceil(rect.height)
+    }
 }

+ 49 - 0
RainbowPlanet/RainbowPlanet/Tools/WaterFallLayout/WaterFallLayout.h

@@ -0,0 +1,49 @@
+//
+//  WaterFallLayout.h
+//  WateFallLayoutTest
+//
+//  Created by 刘梦桦 on 2017/5/18.
+//  Copyright © 2017年 . All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class WaterFallLayout;
+
+@protocol  WaterFallLayoutDeleaget<NSObject>
+
+@required
+/**
+ * 每个item的高度
+ */
+- (CGFloat)waterFallLayout:(WaterFallLayout *)waterFallLayout heightForItemAtIndexPath:(NSUInteger)indexPath itemWidth:(CGFloat)itemWidth;
+
+@optional
+/**
+ * 有多少列
+ */
+- (NSUInteger)columnCountInWaterFallLayout:(WaterFallLayout *)waterFallLayout;
+
+/**
+ * 每列之间的间距
+ */
+- (CGFloat)columnMarginInWaterFallLayout:(WaterFallLayout *)waterFallLayout;
+
+/**
+ * 每行之间的间距
+ */
+- (CGFloat)rowMarginInWaterFallLayout:(WaterFallLayout *)waterFallLayout;
+
+/**
+ * 每个item的内边距
+ */
+- (UIEdgeInsets)edgeInsetdInWaterFallLayout:(WaterFallLayout *)waterFallLayout;
+
+
+@end
+
+@interface WaterFallLayout : UICollectionViewLayout
+/** 代理 */
+@property (nonatomic, weak) id<WaterFallLayoutDeleaget> delegate;
+
+@end

+ 225 - 0
RainbowPlanet/RainbowPlanet/Tools/WaterFallLayout/WaterFallLayout.m

@@ -0,0 +1,225 @@
+//
+//  WaterFallLayout.m
+//  WateFallLayoutTest
+//
+//  Created by 刘梦桦 on 2017/5/18.
+//  Copyright © 2017年 . All rights reserved.
+//
+
+#import "WaterFallLayout.h"
+
+/** 默认的列数    */
+static const CGFloat DefaultColunmCount = 2;
+/** 每一列之间的间距    */
+static const CGFloat DefaultColunmMargin = 10;
+
+/** 每一行之间的间距    */
+static const CGFloat DefaultRowMargin = 10;
+
+/** 内边距    */
+static const UIEdgeInsets DefaultEdgeInsets = {10,10,10,10};
+
+
+@interface WaterFallLayout()
+/** 存放所有的布局属性 */
+@property (nonatomic, strong) NSMutableArray * attrsArr;
+/** 存放所有列的当前高度 */
+@property (nonatomic, strong) NSMutableArray *columnHeights;
+/** 内容的高度 */
+@property (nonatomic, assign) CGFloat contentHeight;
+
+- (NSUInteger)colunmCount;
+- (CGFloat)columnMargin;
+- (CGFloat)rowMargin;
+- (UIEdgeInsets)edgeInsets;
+
+@end
+
+@implementation WaterFallLayout
+
+
+
+#pragma mark 懒加载
+- (NSMutableArray *)attrsArr{
+    if (!_attrsArr) {
+        _attrsArr = [NSMutableArray array];
+    }
+    
+    return _attrsArr;
+}
+
+- (NSMutableArray *)columnHeights{
+    if (!_columnHeights) {
+        _columnHeights = [NSMutableArray array];
+    }
+    
+    return _columnHeights;
+}
+
+#pragma mark - 数据处理
+/**
+ * 列数
+ */
+- (NSUInteger)colunmCount{
+    
+    if ([self.delegate respondsToSelector:@selector(columnCountInWaterFallLayout:)]) {
+        return [self.delegate columnCountInWaterFallLayout:self];
+    }else{
+        return DefaultColunmCount;
+    }
+}
+
+/**
+ * 列间距
+ */
+- (CGFloat)columnMargin{
+    if ([self.delegate respondsToSelector:@selector(columnMarginInWaterFallLayout:)]) {
+        return [self.delegate columnMarginInWaterFallLayout:self];
+    }else{
+        return DefaultColunmMargin;
+    }
+}
+
+/**
+ * 行间距
+ */
+- (CGFloat)rowMargin{
+    if ([self.delegate respondsToSelector:@selector(rowMarginInWaterFallLayout:)]) {
+        return [self.delegate rowMarginInWaterFallLayout:self];
+    }else{
+        return DefaultRowMargin;
+    }
+}
+
+/**
+ * item的内边距
+ */
+- (UIEdgeInsets)edgeInsets{
+    if ([self.delegate respondsToSelector:@selector(edgeInsetdInWaterFallLayout:)]) {
+        return [self.delegate edgeInsetdInWaterFallLayout:self];
+    }else{
+        return DefaultEdgeInsets;
+    }
+}
+
+
+
+/**
+ * 初始化
+ */
+- (void)prepareLayout{
+    
+    [super prepareLayout];
+    
+    self.contentHeight = 0;
+    
+    // 清楚之前计算的所有高度
+    [self.columnHeights removeAllObjects];
+    
+    // 设置每一列默认的高度
+    for (NSInteger i = 0; i < DefaultColunmCount ; i ++) {
+        [self.columnHeights addObject:@(DefaultEdgeInsets.top)];
+    }
+    
+    
+    // 清楚之前所有的布局属性
+    [self.attrsArr removeAllObjects];
+    
+    // 开始创建每一个cell对应的布局属性
+    NSInteger count = [self.collectionView numberOfItemsInSection:0];
+    
+    for (int i = 0; i < count; i++) {
+        
+        // 创建位置
+        NSIndexPath * indexPath = [NSIndexPath indexPathForItem:i inSection:0];
+        
+        // 获取indexPath位置上cell对应的布局属性
+        UICollectionViewLayoutAttributes * attrs = [self layoutAttributesForItemAtIndexPath:indexPath];
+        
+        [self.attrsArr addObject:attrs];
+    }
+    
+}
+
+
+/**
+ * 返回indexPath位置cell对应的布局属性
+ */
+- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath{
+    
+    // 创建布局属性
+    UICollectionViewLayoutAttributes * attrs = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
+    
+    //collectionView的宽度
+    CGFloat collectionViewW = self.collectionView.frame.size.width;
+    
+    // 设置布局属性的frame
+    
+    CGFloat cellW = (collectionViewW - self.edgeInsets.left - self.edgeInsets.right - (self.colunmCount - 1) * self.columnMargin) / self.colunmCount;
+    CGFloat cellH = [self.delegate waterFallLayout:self heightForItemAtIndexPath:indexPath.item itemWidth:cellW];
+
+    
+    // 找出最短的那一列
+    NSInteger destColumn = 0;
+    CGFloat minColumnHeight = [self.columnHeights[0] doubleValue];
+    
+    for (int i = 1; i < DefaultColunmCount; i++) {
+        
+        // 取得第i列的高度
+        CGFloat columnHeight = [self.columnHeights[i] doubleValue];
+        
+        if (minColumnHeight > columnHeight) {
+            minColumnHeight = columnHeight;
+            destColumn = i;
+        }
+    }
+    
+    CGFloat cellX = self.edgeInsets.left + destColumn * (cellW + self.columnMargin);
+    CGFloat cellY = minColumnHeight;
+    if (cellY != self.edgeInsets.top) {
+        
+        cellY += self.rowMargin;
+    }
+    
+    attrs.frame = CGRectMake(cellX, cellY, cellW, cellH);
+    
+    // 更新最短那一列的高度
+    self.columnHeights[destColumn] = @(CGRectGetMaxY(attrs.frame));
+    
+    // 记录内容的高度 - 即最长那一列的高度
+    CGFloat maxColumnHeight = [self.columnHeights[destColumn] doubleValue];
+    if (self.contentHeight < maxColumnHeight) {
+        self.contentHeight = maxColumnHeight;
+    }
+    
+    return attrs;
+}
+
+/**
+ * 决定cell的高度
+ */
+- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect{
+    
+    return self.attrsArr;
+}
+
+/**
+ * 内容的高度
+ */
+- (CGSize)collectionViewContentSize{
+ 
+//    CGFloat maxColumnHeight = [self.columnHeights[0] doubleValue];
+//    for (int i = 0; i < DefaultColunmCount; i++) {
+//        
+//        // 取得第i列的高度
+//        CGFloat columnHeight = [self.columnHeights[i] doubleValue];
+//        
+//        if (maxColumnHeight < columnHeight) {
+//            maxColumnHeight = columnHeight;
+//        }
+//
+//    }
+    
+    return CGSizeMake(0, self.contentHeight + self.edgeInsets.bottom);
+}
+@end