Explorar el Código

版本更新完成

南鑫林 hace 5 años
padre
commit
897318cc23

+ 8 - 6
RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate+Window.swift

@@ -56,13 +56,15 @@ extension AppDelegate {
         /// 引导页
         setGuidePageView()
         /// 版本更新
-//        setconfigUpGrade()
+        setconfigUpGrade()
         
     }
     
     /// 设置Tabbar
     func setTabbarController() {
-        self.window?.rootViewController = BaseTabbarViewController.shared
+        let tabbarViewController = BaseTabbarViewController.shared
+        self.window?.rootViewController = tabbarViewController
+        tabbarViewController.addBadge()
     }
 
     /// 设置Login
@@ -111,9 +113,9 @@ extension AppDelegate {
         
     }
     
-//    //版本更新
-//    func setconfigUpGrade() {
-//        _ = VersionManager.shared
-//    }
+    //版本更新
+    func setconfigUpGrade() {
+        _ = UpdateVersionManager.shared
+    }
     
 }

+ 27 - 12
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -27,24 +27,21 @@ class BaseTabbarViewController: UITabBarController {
         super.viewDidLoad()
         self.tabBar.shadowImage = UIImage(named: "tab_top_line")
         self.delegate = self
-        
+        setViewControllers()
+        setTag()
+    }
+    
+    func setViewControllers() {
         tabBarItemStyle(vc: v1, normalImg: "tabbar_home", selectorImg: "tabbar_home_pre", title: "社区")
-        v1.tabBarItem.tag = 0
-
+        
         tabBarItemStyle(vc: v2, normalImg: "tabbar_shopping", selectorImg: "tabbar_shopping_pre", title: "商城")
-        v2.tabBarItem.tag = 1
-
+        
         tabBarItemStyle(vc: v3, normalImg: "tabbar_publish", selectorImg: "tabbar_publish", title: "")
-        v3.tabBarItem.tag = 2
         v3.tabBarItem.imageInsets =  UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0);
-
+        
         tabBarItemStyle(vc: v4, normalImg: "tabbar_massage", selectorImg: "tabbar_massage_pre", title: "消息")
-        v4.tabBarItem.tag = 3
-
+        
         tabBarItemStyle(vc: v5, normalImg: "tabbar_my", selectorImg: "tabbar_my_pre", title: "我的")
-        v5.tabBarItem.tag = 4
-
-        // Do any additional setup after loading the view.
     }
     
     func tabBarItemStyle(vc : BaseViewController, normalImg : String, selectorImg : String, title : String){
@@ -56,6 +53,24 @@ class BaseTabbarViewController: UITabBarController {
         vc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:k666666Color], for: UIControl.State.normal)
         self.addChild(BaseNavigationViewController.init(rootViewController: vc))
     }
+    
+    func setTag() {
+        v1.tabBarItem.tag = 0
+        v2.tabBarItem.tag = 1
+        v3.tabBarItem.tag = 2
+        v4.tabBarItem.tag = 3
+        v5.tabBarItem.tag = 4
+    }
+    
+    func addBadge() {
+        if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+            v5.tabBarItem.pp.moveBadge(x: -1, y: 3)
+            v5.tabBarItem.pp.addDot(color: kFE352BColor)
+        }else {
+            v5.tabBarItem.pp.hiddenBadge()
+        }
+        
+    }
 
 }
 

+ 1 - 8
RainbowPlanet/RainbowPlanet/Manager/UpdateVersionManager/Model/UpdateVersionModel.swift

@@ -26,13 +26,7 @@ class UpdateVersionModel : NSObject, Mappable{
     }
     var upGradeModelType : UpGradeModelType = .ignore
 	var url : String = ""
-    var version : String = AppInfo.clientVersion {
-        didSet {
-            isUpdate = UpdateVersionManager.shared.systemVersion(over: version)
-        }
-    }
-    var isUpdate: Bool = false
-
+    var version : String = AppInfo.clientVersion
 
 	class func newInstance(map: Map) -> Mappable?{
 		return UpdateVersionModel()
@@ -47,7 +41,6 @@ class UpdateVersionModel : NSObject, Mappable{
 		upgrade <- map["upgrade"]
 		url <- map["url"]
 		version <- map["version"]
-        isUpdate <- map["isUpdate"]
         upGradeModelType <- map["upGradeModelType"]
 		
 	}

+ 26 - 11
RainbowPlanet/RainbowPlanet/Manager/UpdateVersionManager/View/UpdateVersionView.swift

@@ -13,6 +13,9 @@ import RxSwift
 class UpdateVersionView: FWPopupView {
     
     let disposeBag = DisposeBag()
+    let titleStr = UpdateVersionModel.shared.object()?.title
+    let contentStr = UpdateVersionModel.shared.object()?.content
+
     
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -32,6 +35,7 @@ class UpdateVersionView: FWPopupView {
         addSubview(titleLabel)
         addSubview(detailTitleLabel)
         addSubview(scrollView)
+        scrollView.addSubview(titleContentLabel)
         scrollView.addSubview(contentLabel)
         addSubview(lineLabel)
         addSubview(v_lineLabel)
@@ -56,9 +60,14 @@ class UpdateVersionView: FWPopupView {
             make.left.equalTo(20)
             make.height.equalTo(132)
         }
-        contentLabel.snp.makeConstraints { (make) in
+        titleContentLabel.snp.makeConstraints { (make) in
             make.top.left.width.equalToSuperview()
-            make.height.equalTo(str.heightForComment(font: kRegularFont14!, width: 302 - 40))
+            make.height.equalTo((titleStr?.heightForComment(font: kRegularFont14!, width: 302 - 40) ?? 0))
+        }
+        contentLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(titleContentLabel.snp.bottom)
+            make.left.width.equalToSuperview()
+            make.height.equalTo(contentStr?.heightForComment(font: kRegularFont14!, width: 302 - 40) ?? 0)
         }
         
         lineLabel.snp.makeConstraints { (make) in
@@ -109,15 +118,25 @@ class UpdateVersionView: FWPopupView {
     
     lazy var scrollView: UIScrollView = {
         let scrollView = UIScrollView()
-        scrollView.contentSize = CGSize(width: 302-40, height: str.heightForComment(font: kRegularFont14!, width: 302 - 40))
+        scrollView.contentSize = CGSize(width: 302-40, height: (contentStr?.heightForComment(font: kRegularFont14!, width: 302 - 40) ?? 0) + (titleStr?.heightForComment(font: kRegularFont14!, width: 302 - 40) ?? 0))
         return scrollView
     }()
     
-    let str = "升级功能:\n1、全新首页为你改变,资产事项一目了然。\n2、全新兑换专区,淘U票好物,享生活优惠。\n3、关注名家专栏,发现更多你感兴趣的内容。"
+    
+    
+    lazy var titleContentLabel: UILabel = {
+        let titleContentLabel = UILabel()
+        titleContentLabel.text = titleStr
+        titleContentLabel.textColor = k666666Color
+        titleContentLabel.font = kRegularFont14
+        titleContentLabel.numberOfLines = 0
+        return titleContentLabel
+    }()
+    
     
     lazy var contentLabel: UILabel = {
         let contentLabel = UILabel()
-        contentLabel.text = str
+        contentLabel.text = contentStr
         contentLabel.textColor = k666666Color
         contentLabel.font = kRegularFont14
         contentLabel.numberOfLines = 0
@@ -152,11 +171,7 @@ class UpdateVersionView: FWPopupView {
         return v_lineLabel
     }()
     
-    /// 隐藏View
-    class func dismissView() {
-        
-    }
-    
+    /// 初始化View
     class func updateVersionView() -> UpdateVersionView {
         let view = UpdateVersionView()
         let vProperty = FWPopupViewProperty()
@@ -164,7 +179,7 @@ class UpdateVersionView: FWPopupView {
         vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
         vProperty.popupAnimationType = .scale
         vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
-        vProperty.touchWildToHide = "1"
+        vProperty.touchWildToHide = "0"
         view.vProperty = vProperty
         view.show()
         view.leftButton.rx.tap.subscribe(onNext: { (data) in

+ 21 - 2
RainbowPlanet/RainbowPlanet/Manager/UpdateVersionManager/ViewModel/UpdateVersionManager.swift

@@ -23,16 +23,32 @@ class UpdateVersionManager: NSObject {
 
     override init() {
         super.init()
-        observe = NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: OperationQueue.main, using: {
+        //启动程序
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.didFinishLaunchingNotification, object: nil, queue: OperationQueue.main, using: {
             [weak self] (notification) in
             self?.configUpGrade()
         })
+        //程序进入后台
         observe = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main, using: {
             [weak self] (notification) in
             if self?.updateVersionView != nil {
                 self?.updateVersionView?.hide()
             }
         })
+        //将要进入前台的时候
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+
+            self?.configUpGrade()
+        })
+        //程序即将退出
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.willTerminateNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            if self?.updateVersionView != nil {
+                self?.updateVersionView?.hide()
+            }
+        })
+
     }
     // 用于判断当前系统版本是否低于指定版本
     func systemVersion(below aVersionString: String) -> Bool
@@ -56,7 +72,10 @@ class UpdateVersionManager: NSObject {
     func configUpGrade() {
         SwiftMoyaNetWorkServiceConfig.shared().configUpGradeApi {
             [weak self] (data) -> (Void) in
-            if UpdateVersionModel.shared.object()?.isUpdate ?? false {
+            if UpdateVersionModel.shared.object()?.upGradeModelType == .update || UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+                if self?.updateVersionView != nil {
+                    self?.updateVersionView?.hide()
+                }
                 self?.updateVersionView = UpdateVersionView.updateVersionView()
             }
         }

+ 20 - 1
RainbowPlanet/RainbowPlanet/Modules/MineModule/PersonalCenter/UserPersonalCenter/ViewController/UserPersonalCenterViewController.swift

@@ -109,9 +109,28 @@ class UserPersonalCenterViewController: BaseViewController {
             [weak self] (notification) in
             self?.userMemberDetailApi()
         }
-        
+
+        setBadge()
+        //将要进入前台的时候
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            self?.setBadge()
+        })
+  
     }
     
+    // 设置Badge
+    func setBadge() {
+        if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+            self.setButton.pp.moveBadge(x: -8, y: 8)
+            self.setButton.pp.addDot(color: kFE352BColor)
+            self.tabBarItem.pp.moveBadge(x: -1, y: 3)
+            self.tabBarItem.pp.addDot(color: kFE352BColor)
+        }else {
+            self.setButton.pp.hiddenBadge()
+            self.tabBarItem.pp.hiddenBadge()
+        }
+    }
     
     /// 刷新页面
     func reloadData() {

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/MineModule/Set/View/SetLogoutTableViewCell.swift

@@ -52,9 +52,9 @@ class SetLogoutTableViewCell: UITableViewCell {
         return titleLabel
     }()
     
-    var titles : [String]? {
+    var title : String? {
         didSet {
-            titleLabel.text = titles?[(indexPath?.row)!]
+            titleLabel.text = title
         }
     }
 

+ 37 - 3
RainbowPlanet/RainbowPlanet/Modules/MineModule/Set/View/SetTableViewCell.swift

@@ -35,8 +35,8 @@ class SetTableViewCell: UITableViewCell {
     //MRAK: - 设置View
     private func setupViews() {
         self.selectionStyle = .none
-        accessoryType = .disclosureIndicator
         addSubview(titleLabel)
+        addSubview(detaileTitleLabel)
         addSubview(lineLabel)
     }
     
@@ -59,15 +59,49 @@ class SetTableViewCell: UITableViewCell {
         return titleLabel
     }()
     
+    lazy var detaileTitleLabel: UILabel = {
+        let detaileTitleLabel = UILabel()
+        detaileTitleLabel.textColor = k999999Color
+        detaileTitleLabel.font = kRegularFont16
+        return detaileTitleLabel
+    }()
+    
     private lazy var lineLabel: UILabel = {
         let lineLabel = UILabel()
         lineLabel.backgroundColor = kf5f5f5Color
         return lineLabel
     }()
     
-    var titles : [String]? {
+    var title : String? {
         didSet {
-            titleLabel.text = titles?[(indexPath?.row)!]
+            titleLabel.text = title
+            if indexPath?.section == 1 && indexPath?.row == 4 {
+                accessoryType = .none
+                detaileTitleLabel.isHidden = false
+                if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+                    detaileTitleLabel.text = "可更新至v\((UpdateVersionModel.shared.object()?.version)!)"
+                    detaileTitleLabel.snp.remakeConstraints { (make) in
+                        make.centerY.equalToSuperview()
+                        make.right.equalToSuperview().offset(-31)
+                        make.height.equalTo(23)
+                    }
+                    detaileTitleLabel.pp.moveBadge(x: 12.5, y: 11.5)
+                    detaileTitleLabel.pp.addDot(color: kFE352BColor)
+
+                }else {
+                    detaileTitleLabel.text = "v\(AppInfo.clientVersion)"
+                    detaileTitleLabel.snp.remakeConstraints { (make) in
+                        make.centerY.equalToSuperview()
+                        make.right.equalToSuperview().offset(-14)
+                        make.height.equalTo(23)
+                    }
+                    detaileTitleLabel.pp.hiddenBadge()
+                }
+
+            }else {
+                detaileTitleLabel.isHidden = true
+                accessoryType = .disclosureIndicator
+            }
         }
     }
     

+ 15 - 3
RainbowPlanet/RainbowPlanet/Modules/MineModule/Set/View/SetView.swift

@@ -10,15 +10,27 @@ import UIKit
 
 class SetView: BaseView {
     
+    deinit {
+        if observe != nil {
+            NotificationCenter.default.removeObserver(observe!)
+        }
+    }
+    weak var observe : NSObjectProtocol?
+    
     typealias DidSelectRowClosure = (_ indexPath: IndexPath) -> Void
     var didSelectRowClosure : DidSelectRowClosure?
     
     let sections = [["账号与绑定","推送通知设置"],
-                    ["用户协议","为彩虹星球评分","投诉与建议","分享彩虹星球APP"],
+                    ["用户协议","为彩虹星球评分","投诉与建议","分享彩虹星球APP","版本号"],
                     ["退出登录"]]
     
     override func setupViews() {
         addSubview(tableView)
+        //将要进入前台的时候
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            self?.tableView.reloadData()
+        })
     }
     
     override func setupLayouts() {
@@ -53,11 +65,11 @@ extension SetView: UITableViewDelegate,UITableViewDataSource {
         switch indexPath.section {
         case 2:
             let cell = SetLogoutTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.titles = sections[indexPath.section]
+            cell.title = sections[indexPath.section][indexPath.row]
             return cell
         default:
             let cell = SetTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.titles = sections[indexPath.section]
+            cell.title = sections[indexPath.section][indexPath.row]
             return cell
         }
        

+ 3 - 0
RainbowPlanet/RainbowPlanet/Modules/MineModule/Set/ViewController/SetViewController.swift

@@ -62,6 +62,9 @@ class SetViewController: BaseViewController {
                 // 分享彩虹星球app
                 case 3:
                     ShareCommunityView.inviteGoodFriends()
+                // 更新App
+                case 4:
+                    UpdateVersionManager.shared.configUpGrade()
                     break
                 default:
                     showSwiftProgressHUDInfo()

+ 1 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaNetWorkServiceConfig.swift

@@ -169,7 +169,7 @@ class SwiftMoyaNetWorkServiceConfig: NSObject {
         var parameters = Dictionary<String,Any>()
         parameters.updateValue("ios", forKey: "os")
         parameters.updateValue(AppInfo.clientBuildVersion, forKey: "version_code")
-        SwiftMoyaNetWorkManager.shared.requestObject(UpdateVersionModel.self,target: MultiTarget(SwiftMoyaServiceConfigApi.configUpgrade(parameters: parameters))) { (updateVersionModel) in
+        SwiftMoyaNetWorkManager.shared.requestObject(UpdateVersionModel.self,target: MultiTarget(SwiftMoyaServiceConfigApi.configUpgrade(parameters: parameters))) { (updateVersionModel) in            
             UpdateVersionModel.shared.saveObject(model: updateVersionModel as? UpdateVersionModel ?? UpdateVersionModel())
             completion(updateVersionModel)
         }

+ 2 - 2
RainbowPlanet/RainbowPlanet/Supporting Files/Info.plist

@@ -20,7 +20,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>0.2.3</string>
+	<string>1.0.0</string>
 	<key>CFBundleURLTypes</key>
 	<array>
 		<dict>
@@ -75,7 +75,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>0</string>
+	<string>1</string>
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 		<string>wechat</string>