liuzhenxing1118 2 жил өмнө
parent
commit
9860ebd1fe

+ 1 - 1
ChineseMedicine/Controller/BaseViewController.h

@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 //报告view
 - (void)pushReportPageViewController:(NSString*)reportId isPopViewController:(BOOL)isPopViewController isFromHistory:(BOOL)isFromHistory;
-- (void)showVipPayViewController:(void(^)(BOOL ispay))callback;
+- (void)showVipPayViewController:(void(^)(BOOL isOK))callback;
 - (void)showDebugViewController;
 
 - (void)makeToast:(NSString*)content;

+ 3 - 3
ChineseMedicine/Controller/BaseViewController.m

@@ -68,7 +68,7 @@
     if (model.isTryout) {
         [self pushViewController:@"UnlockVC"];
     } else if (model.isExpired && model.count <= 0) {
-        [self showVipPayViewController:^(BOOL ispay) {
+        [self showVipPayViewController:^(BOOL isOK) {
         }];
     } else if (model.isExpired && model.count > 0) {
         [self showVipInfoAlert];
@@ -78,7 +78,7 @@
 }
 
 - (IBAction)clickVippayButton:(id)sender {
-    [self showVipPayViewController:^(BOOL ispay) {
+    [self showVipPayViewController:^(BOOL isOK) {
     }];
 }
 
@@ -110,7 +110,7 @@
     NSString* secondString = SK_NSLOCALIZED_STRING(@"vip_btn_know", nil);
     __weak __typeof(self) weak_self = self;
     [self showAlert:nil content:content firstString:firstString secondString:secondString firstAction:^{
-        [weak_self showVipPayViewController:^(BOOL ispay) {
+        [weak_self showVipPayViewController:^(BOOL isOK) {
         }];
     } secondAction:^{
         [weak_self pushViewController:@"DetectionVC"];

+ 20 - 19
ChineseMedicine/Manager/ChineseMedicineManager.m

@@ -60,7 +60,6 @@
         if ([ERequest isSuccessWithResult:result]) {
             weak_self.mUserModel.isOK = YES;
             weak_self.mUserModel.token = result[KEY_DATA][@"token"];
-            weak_self.mUserModel.isPay = [result[KEY_DATA][@"isPay"] boolValue];
             callback(YES);
         } else {
             callback(NO);
@@ -199,8 +198,6 @@
     
     self.mUserModel.mac = [TestDataManager getMacAddress];
     
-    self.mUserModel.isPay = NO;
-    
     self.mUserModel.part = @"左手";
     self.mUserModel.deviceName = DEVICE_MODEL;
 #endif
@@ -223,30 +220,34 @@
 }
 
 - (BOOL)isLock {
-    if (self.mPayInfoModel.isOK) {
-        //有试用,说明未付款
-        if (self.mPayInfoModel.isTryout)
-            return YES;
-        else {
-            BOOL isOK1 = self.mPayInfoModel.isExpired;
-            BOOL isOK2 = self.mPayInfoModel.count <= 0;
-            return isOK1 && isOK2;
-        }
-    }
-    return YES;
+    if (!self.mPayInfoModel.isOK)
+        return YES;
+    
+    //有试用,说明未付款
+    if (self.mPayInfoModel.isTryout)
+        return YES;
+    
+    BOOL isOK1 = self.mPayInfoModel.isExpired;
+    BOOL isOK2 = self.mPayInfoModel.count <= 0;
+    return isOK1 && isOK2;
 }
 
 - (NSString *)getMacAddress {
     NSString* mac = self.mUserModel.mac;
-    if (!mac || [mac isEqualToString:@""])
-        mac = [TestDataManager getMacAddress];
+    if (!mac)
+        return @"";
     return [mac stringByReplacingOccurrencesOfString:@":" withString:@""];
 }
 
 - (void)setMacAddress:(NSString*)mac {
-    if (mac) {
-        self.mUserModel.mac = mac;
-    }
+    if (!mac || [mac isEqualToString:@""])
+        return;
+    
+    if ([mac isEqualToString:self.mUserModel.mac])
+        return;
+    
+    self.mUserModel.mac = mac;
+    self.mPayInfoModel.isOK = NO; //更新新mac,重新获取payinfo
 }
 
 - (void)reduceDetectionCount {

+ 0 - 1
ChineseMedicine/Model/UserModel.h

@@ -21,7 +21,6 @@ NS_ASSUME_NONNULL_BEGIN
 @property(nonatomic, strong) NSString* mac;
 
 @property(nonatomic, strong) NSString* token;
-@property(nonatomic, assign) BOOL isPay;
 
 @property(nonatomic, assign) BOOL isOK; //判断是否网络获取过数据
 @end

+ 1 - 1
ChineseMedicine/ViewController.m

@@ -47,7 +47,7 @@
         }
     }
     
-
+    [[ChineseMedicineManager shared] setMacAddress:[TestDataManager getMacAddress]];
     [[ChineseMedicineManager shared] setUserInfo:@"M" height:@"" weight:@"" birthday:@"2000-11-18" part:@"12" deviceName:@""];
     [[ChineseMedicineManager shared] requestInfo:^(BOOL isOK) {
         [[ChineseMedicineManager shared] getLaestDetection:^(NSDictionary * _Nonnull result) {