Explorar o código

登录页新增版本检测按钮

Steven hai 1 ano
pai
achega
dc0a2633ac

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/xcshareddata/xcschemes/KulexiuForTeacher.xcscheme

@@ -52,7 +52,7 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "Release"
+      buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"

+ 3 - 0
KulexiuForTeacher/KulexiuForTeacher/AppDelegate.h

@@ -32,6 +32,7 @@
 
 @property (nonatomic, strong) NSString *serverPort;
 
+@property (nonatomic, strong) NSMutableDictionary *messageDict;
 
 
 - (void)initTableBar;
@@ -44,5 +45,7 @@
 
 - (void)displayUnreadMessageCount;
 
+- (void)showMemoAlert;
+
 @end
 

+ 7 - 0
KulexiuForTeacher/KulexiuForTeacher/AppDelegate.m

@@ -1021,4 +1021,11 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
     }
 }
 
+
+- (void)showMemoAlert {
+    if (self.messageDict != nil) {
+        [self showAlertWithMemo:[self.messageDict ks_stringValueForKey:@"memo"] descMessage:[self.messageDict ks_stringValueForKey:@"descMessage"] isforce:[self.messageDict ks_boolValueForKey:@"isforce"] openUrl:[self.messageDict ks_stringValueForKey:@"openUrl"]];
+    }
+}
+
 @end

+ 48 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Login/Controller/LoginViewController.m

@@ -10,6 +10,8 @@
 #import "VefiCodeLoginController.h"
 #import "PasswordLoginController.h"
 #import "KSBaseWKWebViewController.h"
+#import "UserInfoManager.h"
+#import "AppDelegate+AppService.h"
 
 @interface LoginViewController ()
 
@@ -80,11 +82,57 @@
             [self.navigationController pushViewController:webCtrl animated:YES];
         }
             break;
+        case LOGINACTION_VERSIONCHECK:
+        {
+            [self versionCheck];
+        }
+            break;
         default:
             break;
     }
 }
 
+- (void)versionCheck {
+    NSString *currentVersion = [USER_MANAGER getCurrentVersion];
+    NSString *storeUrl = @"https://apps.apple.com/cn/app/%E9%85%B7%E4%B9%90%E7%A7%80%E5%AD%A6%E9%99%A2/id1626971149?uo=4";
+    [KSNetworkingManager appVersionInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
+        if ([dic ks_integerValueForKey:@"code"] == 200) {
+
+            NSString *serviceVersion = [[dic ks_dictionaryValueForKey:@"data"] ks_stringValueForKey:@"version"];
+            if ([currentVersion isEqualToString:serviceVersion]) {
+                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"当前是最新版本"];
+            }
+            else if ([USER_MANAGER isLowerVersionCompareLocalVersion:currentVersion serviceVersion:serviceVersion]) {
+                // desc
+                NSString *descMessage = [[dic ks_dictionaryValueForKey:@"data"] ks_stringValueForKey:@"description"];
+                if ([NSString isEmptyString:descMessage]) {
+                    descMessage = @"";
+                }
+                // 判断
+                NSMutableDictionary *parm = [NSMutableDictionary dictionary];
+                [parm setValue:serviceVersion forKey:@"memo"];
+                [parm setValue:descMessage forKey:@"descMessage"];
+                [parm setValue:storeUrl forKey:@"openUrl"];
+
+                if ([[dic ks_dictionaryValueForKey:@"data"] ks_boolValueForKey:@"isForceUpdate"]) {
+
+                    [parm setValue:@(YES) forKey:@"isforce"];
+                }
+                else {
+                    [parm setValue:@(NO) forKey:@"isforce"];
+                }
+                
+                [AppDelegate shareAppDelegate].messageDict = parm;
+                [[AppDelegate shareAppDelegate] showMemoAlert];
+            }
+            else {
+                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"当前是最新版本"];
+            }
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"当前是最新版本"];
+    }];
+}
 /*
 #pragma mark - Navigation
 

+ 1 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Login/Model/UserInfoManager.h

@@ -52,6 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)sendUMEvent:(NSString *)eventId;
 
+- (BOOL)isLowerVersionCompareLocalVersion:(NSString *)localVersion serviceVersion:(NSString *)version;
 @end
 
 NS_ASSUME_NONNULL_END

+ 1 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Login/View/LoginBodyView.h

@@ -14,6 +14,7 @@ typedef NS_ENUM(NSInteger, LOGINACTION) {
     LOGINACTION_PASSWORD,       // 密码登录
     LOGINACTION_REGPROTOCAL,    // 注册协议
     LOGINACTION_PRIVACY,        // 隐私协议
+    LOGINACTION_VERSIONCHECK,   // version
 };
 
 typedef void(^LoginAction)(LOGINACTION action, NSString *phoneNo);

+ 13 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Login/View/LoginBodyView.m

@@ -25,6 +25,8 @@
 
 @property (nonatomic, assign) NSInteger clickCount;
 
+@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
+
 @end
 
 @implementation LoginBodyView
@@ -49,6 +51,10 @@
     NSMutableAttributedString *privacyAttr = [[NSMutableAttributedString alloc] initWithString:@"和《隐私政策》" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f], NSForegroundColorAttributeName:HexRGB(0x999999)}];
     [privacyAttr addAttributes:@{NSForegroundColorAttributeName:THEMECOLOR} range:NSMakeRange(1, 6)];
     [self.privacyLabel setAttributedText:privacyAttr];
+    
+    NSString *currentVersion = [NSString stringWithFormat:@"版本号 %@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
+    NSMutableAttributedString *versionAttr = [[NSMutableAttributedString alloc] initWithString:currentVersion attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f weight:UIFontWeightRegular], NSForegroundColorAttributeName:HexRGB(0xB2B2B2), NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle), NSUnderlineColorAttributeName:HexRGB(0xB2B2B2)}];
+    self.versionLabel.attributedText = versionAttr;
 }
 
 + (instancetype)shareInstance {
@@ -108,6 +114,13 @@
     }
 }
 
+- (IBAction)versionCheck:(id)sender {
+    [self endEditing:YES];
+    if (self.callback) {
+        self.callback(LOGINACTION_VERSIONCHECK, @"");
+    }
+}
+
 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
     if ([string isEqualToString:@"\n"]) {
         [self endEditing:YES];

+ 32 - 10
KulexiuForTeacher/KulexiuForTeacher/Module/Login/View/LoginBodyView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -19,7 +19,7 @@
                         <constraint firstAttribute="width" secondItem="A5r-6M-UYx" secondAttribute="height" multiplier="375:305" id="Bga-5e-9Uv"/>
                     </constraints>
                 </imageView>
-                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="欢迎使用酷乐秀学院" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CQJ-Py-qwY">
+                <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="欢迎使用酷乐秀学院" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CQJ-Py-qwY">
                     <rect key="frame" x="25" y="137" width="237.5" height="37"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="37" id="tvg-Qn-oM2"/>
@@ -39,7 +39,7 @@
                     </connections>
                 </imageView>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="您好," textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WqI-Rf-kUe">
-                    <rect key="frame" x="25" y="100" width="80" height="37"/>
+                    <rect key="frame" x="25" y="100" width="66.5" height="37"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="37" id="6ar-bg-MCI"/>
                     </constraints>
@@ -140,13 +140,13 @@
                     </connections>
                 </button>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="我已阅读并同意《用户注册协议》" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="enh-Ce-PS7">
-                    <rect key="frame" x="74" y="536" width="184" height="15"/>
+                    <rect key="frame" x="74" y="536" width="176.5" height="15"/>
                     <fontDescription key="fontDescription" type="system" pointSize="12"/>
                     <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ylm-Ib-zPa">
-                    <rect key="frame" x="148" y="528.5" width="110" height="30"/>
+                    <rect key="frame" x="148" y="528.5" width="102.5" height="30"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="30" id="u4J-po-0Tc"/>
                     </constraints>
@@ -156,13 +156,13 @@
                     </connections>
                 </button>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="和《隐私政策》" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Enc-9D-ZIb">
-                    <rect key="frame" x="259" y="536" width="86" height="15"/>
+                    <rect key="frame" x="251.5" y="536" width="78.5" height="15"/>
                     <fontDescription key="fontDescription" type="system" pointSize="12"/>
                     <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ko7-Ny-Rff">
-                    <rect key="frame" x="259" y="528.5" width="86" height="30"/>
+                    <rect key="frame" x="251.5" y="528.5" width="78.5" height="30"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="30" id="1nd-po-JrO"/>
                     </constraints>
@@ -172,7 +172,7 @@
                     </connections>
                 </button>
                 <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zK8-8r-GjY">
-                    <rect key="frame" x="12" y="722.5" width="390" height="20"/>
+                    <rect key="frame" x="12" y="596.5" width="390" height="20"/>
                     <gestureRecognizers/>
                     <constraints>
                         <constraint firstAttribute="height" constant="20" id="GIW-Fp-zE3"/>
@@ -184,6 +184,19 @@
                         <outletCollection property="gestureRecognizers" destination="PFX-Mf-Vhy" appends="YES" id="tUF-XA-hVw"/>
                     </connections>
                 </label>
+                <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="N3F-Yy-9eF">
+                    <rect key="frame" x="12" y="569.5" width="390" height="17"/>
+                    <gestureRecognizers/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="17" id="u2R-xo-pD8"/>
+                    </constraints>
+                    <fontDescription key="fontDescription" type="system" pointSize="12"/>
+                    <color key="textColor" red="0.69803921570000005" green="0.69803921570000005" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
+                    <nil key="highlightedColor"/>
+                    <connections>
+                        <outletCollection property="gestureRecognizers" destination="ihO-9N-7O3" appends="YES" id="fmn-SD-IOk"/>
+                    </connections>
+                </label>
             </subviews>
             <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
@@ -194,9 +207,11 @@
                 <constraint firstItem="ko7-Ny-Rff" firstAttribute="trailing" secondItem="Enc-9D-ZIb" secondAttribute="trailing" id="7R7-UL-yeh"/>
                 <constraint firstItem="FGc-X7-gKF" firstAttribute="leading" secondItem="3Vc-PU-5ec" secondAttribute="leading" id="92F-v1-QX7"/>
                 <constraint firstItem="WqI-Rf-kUe" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="25" id="9GS-oA-unV"/>
+                <constraint firstItem="N3F-Yy-9eF" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="12" id="9m0-O6-gJh"/>
                 <constraint firstItem="zK8-8r-GjY" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="12" id="A2j-fF-mWC"/>
                 <constraint firstAttribute="trailing" secondItem="A5r-6M-UYx" secondAttribute="trailing" id="D7M-2f-1sc"/>
                 <constraint firstItem="enh-Ce-PS7" firstAttribute="leading" secondItem="vXW-ev-ENf" secondAttribute="trailing" id="HwD-2q-1qI"/>
+                <constraint firstAttribute="trailing" secondItem="N3F-Yy-9eF" secondAttribute="trailing" constant="12" id="IfR-c7-i0n"/>
                 <constraint firstItem="FGc-X7-gKF" firstAttribute="trailing" secondItem="3Vc-PU-5ec" secondAttribute="trailing" id="JBf-Su-sHW"/>
                 <constraint firstItem="vXW-ev-ENf" firstAttribute="leading" secondItem="FGc-X7-gKF" secondAttribute="leading" constant="10" id="Jpn-K5-aQF"/>
                 <constraint firstItem="CQJ-Py-qwY" firstAttribute="top" secondItem="WqI-Rf-kUe" secondAttribute="bottom" id="LMh-sH-8am"/>
@@ -204,12 +219,13 @@
                 <constraint firstItem="Enc-9D-ZIb" firstAttribute="leading" secondItem="enh-Ce-PS7" secondAttribute="trailing" constant="1" id="OuG-yk-mkh"/>
                 <constraint firstItem="A5r-6M-UYx" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="Plu-en-nQW"/>
                 <constraint firstItem="3Vc-PU-5ec" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="34" id="Sf6-0A-GFM"/>
+                <constraint firstItem="zK8-8r-GjY" firstAttribute="top" secondItem="N3F-Yy-9eF" secondAttribute="bottom" constant="10" id="UFd-pU-dbU"/>
                 <constraint firstItem="ylm-Ib-zPa" firstAttribute="leading" secondItem="enh-Ce-PS7" secondAttribute="leading" multiplier="2" id="X3a-au-JmM"/>
+                <constraint firstItem="N3F-Yy-9eF" firstAttribute="top" secondItem="ylm-Ib-zPa" secondAttribute="bottom" constant="11" id="XVn-Jn-ET9"/>
                 <constraint firstItem="Enc-9D-ZIb" firstAttribute="centerY" secondItem="enh-Ce-PS7" secondAttribute="centerY" id="ZC5-br-Lnl"/>
                 <constraint firstAttribute="bottom" secondItem="0q4-1w-tla" secondAttribute="bottom" id="an5-yy-Ltq"/>
                 <constraint firstItem="ylm-Ib-zPa" firstAttribute="centerY" secondItem="enh-Ce-PS7" secondAttribute="centerY" id="eZv-hd-Mxi"/>
                 <constraint firstItem="A5r-6M-UYx" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="epe-Tm-dNT"/>
-                <constraint firstItem="0q4-1w-tla" firstAttribute="top" secondItem="zK8-8r-GjY" secondAttribute="bottom" constant="10" id="gwS-3O-d6p"/>
                 <constraint firstItem="CQJ-Py-qwY" firstAttribute="leading" secondItem="WqI-Rf-kUe" secondAttribute="leading" id="hAc-vT-7xN"/>
                 <constraint firstItem="ylm-Ib-zPa" firstAttribute="trailing" secondItem="enh-Ce-PS7" secondAttribute="trailing" id="i8W-J1-WOR"/>
                 <constraint firstItem="3Vc-PU-5ec" firstAttribute="top" secondItem="pce-OW-Xhb" secondAttribute="bottom" constant="45" id="k0L-0k-KJm"/>
@@ -234,6 +250,7 @@
                 <outlet property="privacyLabel" destination="Enc-9D-ZIb" id="32W-zA-OtE"/>
                 <outlet property="registerProtocalLabel" destination="enh-Ce-PS7" id="dMA-8Y-Kxm"/>
                 <outlet property="sureButton" destination="vXW-ev-ENf" id="XAS-m1-bSV"/>
+                <outlet property="versionLabel" destination="N3F-Yy-9eF" id="V4l-eq-5ef"/>
             </connections>
             <point key="canvasLocation" x="131.8840579710145" y="95.758928571428569"/>
         </view>
@@ -247,6 +264,11 @@
                 <action selector="copyAction:" destination="iN0-l3-epB" id="Ohi-Fv-hmL"/>
             </connections>
         </tapGestureRecognizer>
+        <tapGestureRecognizer id="ihO-9N-7O3">
+            <connections>
+                <action selector="versionCheck:" destination="iN0-l3-epB" id="oho-sV-gca"/>
+            </connections>
+        </tapGestureRecognizer>
     </objects>
     <resources>
         <image name="login_bottom" width="375" height="130"/>