Commit 0563bb90 cgx

对接APP更新接口

1 个父辈 a99aaf7b
......@@ -156,6 +156,7 @@
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */; };
D0BB9AA728164DFB00DB209E /* NickNameController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA628164DFB00DB209E /* NickNameController.m */; };
D0BDDFFC28618123006558D4 /* DisableAllTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BDDFFB28618123006558D4 /* DisableAllTextView.m */; };
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; };
D0BE32E9281551EB006539BE /* ShareAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E8281551EB006539BE /* ShareAlertView.m */; };
D0BE536E2845A7AF007F15B3 /* SignModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE536D2845A7AF007F15B3 /* SignModel.m */; };
......@@ -531,6 +532,8 @@
D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExceptionDefaultView.m; sourceTree = "<group>"; };
D0BB9AA528164DFB00DB209E /* NickNameController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NickNameController.h; sourceTree = "<group>"; };
D0BB9AA628164DFB00DB209E /* NickNameController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NickNameController.m; sourceTree = "<group>"; };
D0BDDFFA28618123006558D4 /* DisableAllTextView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisableAllTextView.h; sourceTree = "<group>"; };
D0BDDFFB28618123006558D4 /* DisableAllTextView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DisableAllTextView.m; sourceTree = "<group>"; };
D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; };
D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; };
D0BE32E7281551EB006539BE /* ShareAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareAlertView.h; sourceTree = "<group>"; };
......@@ -856,6 +859,8 @@
D043DD54285B11860043A4CE /* VersionUpdateBox.m */,
D043DD56285B25EE0043A4CE /* VersionRequestModel.h */,
D043DD57285B25EE0043A4CE /* VersionRequestModel.m */,
D0BDDFFA28618123006558D4 /* DisableAllTextView.h */,
D0BDDFFB28618123006558D4 /* DisableAllTextView.m */,
);
path = AppUpdate;
sourceTree = "<group>";
......@@ -1998,6 +2003,7 @@
D0D4107C2844B8DB00009638 /* DailyTaskController.m in Sources */,
D0E6600828080F97006562F2 /* SystemSetController.m in Sources */,
D0D96FE52848698F00461839 /* SomeProxy.m in Sources */,
D0BDDFFC28618123006558D4 /* DisableAllTextView.m in Sources */,
D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */,
D08F79E1281A1838000D99DD /* TZLocationManager.m in Sources */,
D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */,
......
......@@ -18,7 +18,7 @@
@implementation SetModel
+ (NSArray *)getAllSetDatas {
NSArray *titles = @[@"当前小梦睡眠版本", @"用户协议", @"隐私政策", @"清除缓存"];
NSString *version = [NSString stringWithFormat:@"V %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
NSString *version = [NSString stringWithFormat:@"V %@", DSAppVersion];
NSString *cacheSize = [DsCacheUtils getCacheSize];
NSArray *details = @[version, @"", @"", cacheSize];
NSMutableArray *tmpArr = [NSMutableArray array];
......
//
// DisableAllTextView.h
// DreamSleep
//
// Created by peter on 2022/6/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface DisableAllTextView : UITextView
@end
NS_ASSUME_NONNULL_END
//
// DisableAllTextView.m
// DreamSleep
//
// Created by peter on 2022/6/21.
//
#import "DisableAllTextView.h"
@implementation DisableAllTextView
//- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// return NO;
//}
// 禁用文字选择
- (BOOL)canBecomeFirstResponder {
return NO;
}
@end
......@@ -13,6 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 0:强制更新 1:用户选择更新
@property (nonatomic, assign) int update_Way;
/// 服务器记录的最新APP版本号
@property (nonatomic, copy) NSString *version_Num;
/// 版本更新内容
@property (nonatomic, copy) NSString *version_Content;
+ (NSURLSessionDataTask *)queryAppVersionRequestWithCompletion:(void (^)(VersionRequestModel *requestModel))completion;
......
......@@ -12,12 +12,14 @@
+ (NSURLSessionDataTask *)queryAppVersionRequestWithCompletion:(void (^)(VersionRequestModel *requestModel))completion {
VersionRequestModel * requestModel = [[VersionRequestModel alloc] init];
NSString *api = @"query_app_version";
NSString *argStr = [NSString stringWithFormat:@"query{%@(sys_code:\"IOS\",version_code:\"stable\")}", api];
NSString *argStr = [NSString stringWithFormat:@"query{%@(sys_code:\"IOS\",version_code:\"stable\",version_num:\"%@\")}", api, DSAppVersion];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"App版本升级接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
requestModel.update_Way = [resultDic[@"Update_Way"] intValue];
requestModel.version_Num = resultDic[@"Version_Num"];
requestModel.version_Content = resultDic[@"Version_Content"];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
......
......@@ -13,9 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
@interface VersionUpdateBox : UIView
/// 显示版本更新弹框
/// @param isForce 是否强制更新
- (void)showVersionUpdate:(BOOL)isForce;
/// @param versionNum 最新版本号
/// @param content 更新内容
/// @param isForce 是否强制更新:YES强制,NO:选择更新
- (void)showWithVersionNum:(NSString *)versionNum content:(NSString *)content isForce:(BOOL)isForce;
@end
NS_ASSUME_NONNULL_END
......@@ -6,10 +6,13 @@
//
#import "VersionUpdateBox.h"
#import "DisableAllTextView.h"
@interface VersionUpdateBox ()
@property (nonatomic, strong) UIImageView *updateBox;
@property (nonatomic, strong) UIButton *closeBtn;
@property (nonatomic, strong) UILabel *versionLab;
@property (nonatomic, strong) DisableAllTextView *updateContentTV;
@end
@implementation VersionUpdateBox
......@@ -29,10 +32,24 @@
}
#pragma mark - public
- (void)showVersionUpdate:(BOOL)isForce {
- (void)showWithVersionNum:(NSString *)versionNum content:(NSString *)content isForce:(BOOL)isForce {
[DSKeyWindow addSubview:self];
self.closeBtn.hidden = isForce;
self.versionLab.text = [NSString stringWithFormat:@"V%@", versionNum];
[self.versionLab sizeToFit];
[self.versionLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_updateBox).offset(94);
make.left.equalTo(_updateBox).offset(112);
make.size.mas_equalTo(CGSizeMake(self.versionLab.width + 8, self.versionLab.height + 4));
}];
NSString *dealContent = @"";
if (content && [content isKindOfClass:[NSString class]]) {
dealContent = [[NSString stringWithFormat:@"%@", content] stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"];
}
self.updateContentTV.text = dealContent;
}
- (void)dismiss {
......@@ -59,19 +76,15 @@
[_updateBox addSubview:self.closeBtn];
UILabel *versionLab = [UILabel labWithText:[NSString stringWithFormat:@"V%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] font:SysFont(10.0) fit:YES];
UILabel *versionLab = [UILabel labWithText:@"" font:SysFont(10.0) fit:YES];
versionLab.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, ColorFromHex(0xAEB1BA), DSWhite);
versionLab.dk_textColorPicker = DKColorPickerWithColors(BrandColor, ColorFromHex(0x47899E), DSWhite);
versionLab.textAlignment = NSTextAlignmentCenter;
[versionLab cornerRadius:7.0];
self.versionLab = versionLab;
[_updateBox addSubview:versionLab];
UILabel *lab1 = [UILabel labWithText:@"1.全新设计,全新体验;" textColor:SubTitleColor font:SysFont(14.0)];
[_updateBox addSubview:lab1];
UILabel *lab2 = [UILabel labWithText:@"2.人机交互哄睡,助你快速入睡;" textColor:SubTitleColor font:SysFont(14.0)];
[_updateBox addSubview:lab2];
UILabel *lab3 = [UILabel labWithText:@"3.提升系统稳定性;" textColor:SubTitleColor font:SysFont(14.0)];
[_updateBox addSubview:lab3];
[_updateBox addSubview:self.updateContentTV];
UIButton *updateBtn = [UIButton btnWithTitle:@"立即升级" font:BoldFont(16.0)];
[updateBtn addTarget:self action:@selector(updateApp) forControlEvents:UIControlEventTouchUpInside];
......@@ -84,35 +97,24 @@
wifiLab.textAlignment = NSTextAlignmentCenter;
[_updateBox addSubview:wifiLab];
[versionLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_updateBox).offset(94);
make.left.equalTo(_updateBox).offset(112);
make.size.mas_equalTo(CGSizeMake(versionLab.width + 8, versionLab.height + 4));
}];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_updateBox).offset(36);
make.right.equalTo(_updateBox);
}];
[lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
[self.updateContentTV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_updateBox).offset(35);
make.right.equalTo(_updateBox).offset(-35);
make.top.equalTo(_updateBox).offset(228);
}];
[lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(lab1);
make.top.equalTo(lab1.mas_bottom).offset(6);
}];
[lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(lab1);
make.top.equalTo(lab2.mas_bottom).offset(6);
make.bottom.equalTo(updateBtn.mas_top).offset(-17);
}];
[updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_updateBox);
make.top.equalTo(lab3.mas_bottom).offset(17);
make.bottom.equalTo(wifiLab.mas_top).offset(-8);
make.size.mas_equalTo(CGSizeMake(210, 40));
}];
[wifiLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_updateBox);
make.top.equalTo(updateBtn.mas_bottom).offset(8);
make.bottom.equalTo(_updateBox).offset(-15);
}];
}
return _updateBox;
......@@ -127,4 +129,15 @@
return _closeBtn;
}
- (DisableAllTextView *)updateContentTV {
if (!_updateContentTV) {
_updateContentTV = [DisableAllTextView new];
_updateContentTV.textColor = SubTitleColor;
_updateContentTV.font = SysFont(14.0);
_updateContentTV.backgroundColor = DSClearColor;
_updateContentTV.editable = NO;
}
return _updateContentTV;
}
@end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!