Sfoglia il codice sorgente

登录页新增版本检测按钮

Steven 11 mesi fa
parent
commit
c73b417c30

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

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

+ 3 - 0
KulexiuForStudent/KulexiuForStudent/AppDelegate.h

@@ -36,6 +36,9 @@
 
 @property (nonatomic, strong) NSString *serverPort;
 
+@property (nonatomic, strong) NSMutableDictionary *messageDict;
+
+
 - (void)showMemoAlert;
 
 - (void)initTableBar;

+ 0 - 2
KulexiuForStudent/KulexiuForStudent/AppDelegate.m

@@ -55,8 +55,6 @@
 
 @property (nonatomic, strong) KSUpdateAlert *alertView;
 
-@property (nonatomic, strong) NSMutableDictionary *messageDict;
-
 @property (nonatomic, assign) BOOL hasCheckTrackAuth;
 
 @end

+ 48 - 0
KulexiuForStudent/KulexiuForStudent/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 ()
 
@@ -90,11 +92,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/id1626971695?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
KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfoManager.h

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

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/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);

+ 14 - 0
KulexiuForStudent/KulexiuForStudent/Module/Login/View/LoginBodyView.m

@@ -24,6 +24,9 @@
 
 @property (nonatomic, assign) NSInteger clickCount;
 
+@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
+
+
 @end
 
 @implementation LoginBodyView
@@ -44,6 +47,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 {
@@ -103,6 +110,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];

+ 31 - 9
KulexiuForStudent/KulexiuForStudent/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>
@@ -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,19 +140,19 @@
                     </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>
                 <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="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>
@@ -162,14 +162,14 @@
                     </connections>
                 </button>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ko7-Ny-Rff">
-                    <rect key="frame" x="259" y="526.5" width="86" height="34"/>
+                    <rect key="frame" x="251.5" y="526.5" width="78.5" height="34"/>
                     <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                     <connections>
                         <action selector="privacyAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="2PD-CJ-1dt"/>
                     </connections>
                 </button>
                 <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o7S-X6-4Wt">
-                    <rect key="frame" x="12" y="722.5" width="390" height="20"/>
+                    <rect key="frame" x="12" y="598.5" width="390" height="20"/>
                     <gestureRecognizers/>
                     <constraints>
                         <constraint firstAttribute="height" constant="20" id="O7f-T1-6Sq"/>
@@ -181,12 +181,26 @@
                         <outletCollection property="gestureRecognizers" destination="v87-Il-G9X" appends="YES" id="x4e-b5-xOh"/>
                     </connections>
                 </label>
+                <label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kbc-cH-usY">
+                    <rect key="frame" x="12" y="571.5" width="390" height="17"/>
+                    <gestureRecognizers/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="17" id="fX4-P5-tjB"/>
+                    </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="B3f-ry-yyx" appends="YES" id="w9g-fb-dNM"/>
+                    </connections>
+                </label>
             </subviews>
             <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
+                <constraint firstItem="kbc-cH-usY" firstAttribute="top" secondItem="ko7-Ny-Rff" secondAttribute="bottom" constant="11" id="0H4-O0-CSH"/>
+                <constraint firstItem="o7S-X6-4Wt" firstAttribute="top" secondItem="kbc-cH-usY" secondAttribute="bottom" constant="10" id="0Hg-Ea-5Pd"/>
                 <constraint firstItem="vXW-ev-ENf" firstAttribute="top" secondItem="FGc-X7-gKF" secondAttribute="bottom" constant="20" id="3hl-Va-qKC"/>
                 <constraint firstAttribute="trailing" secondItem="3Vc-PU-5ec" secondAttribute="trailing" constant="34" id="5qw-B8-PuM"/>
-                <constraint firstItem="0q4-1w-tla" firstAttribute="top" secondItem="o7S-X6-4Wt" secondAttribute="bottom" constant="10" id="5sN-Ky-dcK"/>
                 <constraint firstItem="ko7-Ny-Rff" firstAttribute="centerY" secondItem="Enc-9D-ZIb" secondAttribute="centerY" id="6Ob-us-ECK"/>
                 <constraint firstItem="FGc-X7-gKF" firstAttribute="top" secondItem="3Vc-PU-5ec" secondAttribute="bottom" constant="20" id="7Hx-0J-7RR"/>
                 <constraint firstItem="FGc-X7-gKF" firstAttribute="leading" secondItem="3Vc-PU-5ec" secondAttribute="leading" id="92F-v1-QX7"/>
@@ -207,10 +221,12 @@
                 <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="ko7-Ny-Rff" firstAttribute="trailing" secondItem="Enc-9D-ZIb" secondAttribute="trailing" id="f7k-sG-caE"/>
+                <constraint firstItem="kbc-cH-usY" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="12" id="fZH-Z9-wpe"/>
                 <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"/>
                 <constraint firstAttribute="trailing" secondItem="LXC-2r-VRG" secondAttribute="trailing" id="kCk-C9-Xk8"/>
+                <constraint firstAttribute="trailing" secondItem="kbc-cH-usY" secondAttribute="trailing" constant="12" id="kbF-Sh-ZRn"/>
                 <constraint firstItem="vXW-ev-ENf" firstAttribute="leading" secondItem="FGc-X7-gKF" secondAttribute="leading" constant="10" id="lPS-HY-uAl"/>
                 <constraint firstItem="pce-OW-Xhb" firstAttribute="top" secondItem="LXC-2r-VRG" secondAttribute="bottom" constant="10" id="m2g-hY-JN5"/>
                 <constraint firstItem="Enc-9D-ZIb" firstAttribute="centerY" secondItem="enh-Ce-PS7" secondAttribute="centerY" id="pxx-eE-jU3"/>
@@ -231,6 +247,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="kbc-cH-usY" id="7hP-Sm-r2U"/>
             </connections>
             <point key="canvasLocation" x="131.8840579710145" y="95.758928571428569"/>
         </view>
@@ -244,6 +261,11 @@
                 <action selector="copyAction:" destination="iN0-l3-epB" id="8JB-i5-oOo"/>
             </connections>
         </tapGestureRecognizer>
+        <tapGestureRecognizer id="B3f-ry-yyx">
+            <connections>
+                <action selector="versionCheck:" destination="iN0-l3-epB" id="Rzv-50-SK2"/>
+            </connections>
+        </tapGestureRecognizer>
     </objects>
     <resources>
         <image name="login_bottom" width="375" height="130"/>