Commit bd3d46eb cgx

首页活动弹框及首次启动APP进入首页弹框UI

1 个父辈 c618be59
正在显示 27 个修改的文件 包含 316 行增加27 行删除
......@@ -132,6 +132,8 @@
D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; };
D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; };
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; };
D0DB33A528204E7C00E15914 /* FirstLeadAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DB33A428204E7C00E15914 /* FirstLeadAlertView.m */; };
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DB33A728224D5100E15914 /* PromotionModel.m */; };
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DF90AD2814390000FC0F64 /* BannerModel.m */; };
D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; };
D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; };
......@@ -397,6 +399,10 @@
D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; };
D0D7480328118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
D0D7480428118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
D0DB33A328204E7C00E15914 /* FirstLeadAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FirstLeadAlertView.h; sourceTree = "<group>"; };
D0DB33A428204E7C00E15914 /* FirstLeadAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FirstLeadAlertView.m; sourceTree = "<group>"; };
D0DB33A628224D5100E15914 /* PromotionModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PromotionModel.h; sourceTree = "<group>"; };
D0DB33A728224D5100E15914 /* PromotionModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PromotionModel.m; sourceTree = "<group>"; };
D0DF90AB28142F1300FC0F64 /* DreamSleepDebug.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = DreamSleepDebug.entitlements; sourceTree = "<group>"; };
D0DF90AC2814390000FC0F64 /* BannerModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BannerModel.h; sourceTree = "<group>"; };
D0DF90AD2814390000FC0F64 /* BannerModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BannerModel.m; sourceTree = "<group>"; };
......@@ -764,6 +770,8 @@
children = (
D0874BBD2816E61000CECB3C /* RescuePlanView.h */,
D0874BBE2816E61000CECB3C /* RescuePlanView.m */,
D0DB33A328204E7C00E15914 /* FirstLeadAlertView.h */,
D0DB33A428204E7C00E15914 /* FirstLeadAlertView.m */,
);
path = ActivityPopup;
sourceTree = "<group>";
......@@ -1037,6 +1045,8 @@
D0E660002807B5AE006562F2 /* SafeSleepRequestModel.m */,
D0DF90AC2814390000FC0F64 /* BannerModel.h */,
D0DF90AD2814390000FC0F64 /* BannerModel.m */,
D0DB33A628224D5100E15914 /* PromotionModel.h */,
D0DB33A728224D5100E15914 /* PromotionModel.m */,
D0BE32E42814D42B006539BE /* HomeRequestModel.h */,
D0BE32E52814D42B006539BE /* HomeRequestModel.m */,
);
......@@ -1368,6 +1378,7 @@
D08F79DE281A1838000D99DD /* TZPhotoPickerController.m in Sources */,
D04B3DC027F6F82D0022F8DF /* ProfileController.m in Sources */,
D01C9D7028168BFC00163567 /* NSDate+Extension.m in Sources */,
D0DB33A528204E7C00E15914 /* FirstLeadAlertView.m in Sources */,
D0C50B3027FD1BEB00DC68F0 /* PrivacyView.m in Sources */,
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */,
D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */,
......@@ -1438,6 +1449,7 @@
D08F79DA281A1838000D99DD /* TZPhotoPreviewController.m in Sources */,
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */,
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */,
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */,
D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */,
D07DACA92810557D0067A1BF /* UIImage+RSKImageCropper.m in Sources */,
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */,
......
//
// FirstLeadAlertView.h
// DreamSleep
//
// Created by peter on 2022/5/3.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
// 弹框点击跳转类型
typedef NS_ENUM(int, JumpType) {
JumpTypeAI,
JumpTypeSpeed
};
typedef void (^HomeJumpBlock)(JumpType type);
/// 首次启动APP进入到主页后弹框
@interface FirstLeadAlertView : UIView
@property (nonatomic, copy) HomeJumpBlock block;
- (instancetype)initWithJumpBlock:(HomeJumpBlock)block;
- (void)show;
@end
NS_ASSUME_NONNULL_END
//
// FirstLeadAlertView.m
// DreamSleep
//
// Created by peter on 2022/5/3.
//
#import "FirstLeadAlertView.h"
@interface FirstLeadAlertView ()
/// 关闭按钮
@property (nonatomic, strong) UIButton *closeBtn;
/// title
@property (nonatomic, strong) UILabel *titleLab;
/// AI
@property (nonatomic, strong) UIButton *aiBtn;
/// Speed Sleep
@property (nonatomic, strong) UIButton *ssBtn;
@end
@implementation FirstLeadAlertView
- (instancetype)initWithJumpBlock:(HomeJumpBlock)block {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_block = block;
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self addSubview:self.closeBtn];
[self addSubview:self.titleLab];
[self addSubview:self.aiBtn];
[self addSubview:self.ssBtn];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.top.equalTo(self).offset(51);
}];
[self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(35);
make.top.equalTo(self.closeBtn.mas_bottom).offset(57);
}];
CGFloat width = kScreenWidth - 28;
[self.aiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(14);
make.right.equalTo(self).offset(-14);
make.top.equalTo(self.titleLab.mas_bottom).offset(98);
make.height.equalTo(@(122*width/347));
}];
[self.ssBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.aiBtn);
make.top.equalTo(self.aiBtn.mas_bottom).offset(48);
make.size.equalTo(self.aiBtn);
}];
}
return self;
}
#pragma mark - Actions
- (void)show {
[DSKeyWindow addSubview:self];
}
- (void)dismiss {
[self removeFromSuperview];
}
- (void)buttonAction:(UIButton *)sender {
[self dismiss];
if (self.block) {
self.block(sender.tag == 1 ? JumpTypeAI : JumpTypeSpeed);
}
}
#pragma mark - lazy
- (UIButton *)closeBtn {
if (!_closeBtn) {
_closeBtn = [UIButton new];
[_closeBtn dk_setImage:DKImagePickerWithNames(@"home_close", @"dk_home_close", @"home_close") forState:UIControlStateNormal];
[_closeBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}
return _closeBtn;
}
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [UILabel labWithText:@"我现在最想:" font:BoldFont(18) fit:YES];
_titleLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite);
}
return _titleLab;
}
- (UIButton *)aiBtn {
if (!_aiBtn) {
_aiBtn = [UIButton new];
_aiBtn.tag = 1;
[_aiBtn dk_setImage:DKImagePickerWithNames(@"pic_select_weeks_normal", @"dk_pic_select_weeks_normal", @"pic_select_weeks_normal") forState:UIControlStateNormal];
[_aiBtn cornerRadius:12.0];
_aiBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
_aiBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
[_aiBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _aiBtn;
}
- (UIButton *)ssBtn {
if (!_ssBtn) {
_ssBtn = [UIButton new];
_ssBtn.tag = 2;
[_ssBtn dk_setImage:DKImagePickerWithNames(@"pic_select_sleep_normal", @"dk_pic_select_sleep_normal", @"dk_pic_select_sleep_normal") forState:UIControlStateNormal];
[_ssBtn cornerRadius:12.0];
_ssBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
_ssBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
[_ssBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _ssBtn;
}
@end
......@@ -11,12 +11,12 @@ NS_ASSUME_NONNULL_BEGIN
typedef void (^JumpBlock)(void);
/// 失眠拯救计划
/// 失眠拯救计划相关弹框
@interface RescuePlanView : UIView
@property (nonatomic, copy) JumpBlock block;
- (instancetype)initWithJumpBlock:(JumpBlock)block;
- (instancetype)initWithJumpBlock:(JumpBlock)block imageUrl:(NSString *)imageUrl;
- (void)show;
......
......@@ -16,7 +16,7 @@
@implementation RescuePlanView
- (instancetype)initWithJumpBlock:(JumpBlock)block {
- (instancetype)initWithJumpBlock:(JumpBlock)block imageUrl:(NSString *)imageUrl {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_block = block;
self.backgroundColor = DarkColor;
......@@ -27,11 +27,14 @@
[self.rescueIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.size.mas_equalTo(CGSizeMake(280, 384));
}];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.rescueIV);
make.top.equalTo(self.rescueIV).offset(24);
}];
[self.rescueIV yy_setImageWithURL:[NSURL URLWithString:imageUrl] placeholder:[UIImage imageNamed:@"bannerPlaceholder"]];
}
return self;
}
......@@ -53,8 +56,9 @@
#pragma mark - lazy
- (UIImageView *)rescueIV {
if (!_rescueIV) {
_rescueIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pic_pop_normal"]];
_rescueIV = [UIImageView new];
_rescueIV.userInteractionEnabled = YES;
_rescueIV.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
[_rescueIV addGestureRecognizer:tapGR];
}
......@@ -64,7 +68,7 @@
- (UIButton *)closeBtn {
if (!_closeBtn) {
_closeBtn = [UIButton new];
[_closeBtn setImage:[UIImage imageNamed:@"home_close"] forState:UIControlStateNormal];
[_closeBtn setImage:[UIImage imageNamed:@"dk_home_close"] forState:UIControlStateNormal];
[_closeBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}
return _closeBtn;
......
......@@ -8,7 +8,9 @@
#import "HomeViewController.h"
#import "HomeTableView.h"
#import "RescuePlanView.h"
#import "FirstLeadAlertView.h"
#import "UserRequestModel.h"
#import "HomeRequestModel.h"
@interface HomeViewController ()
@property (nonatomic, strong) HomeTableView *homeTV;
......@@ -33,14 +35,49 @@
[UserRequestModel autoLoginRequestWithCompletion:^(UserRequestModel * _Nonnull requestModel) {
}];
}
// 运营活动弹框时机(已登录还是未登录)
// [self queryPromotionImageRequest];
}
#pragma mark - APP首次启动弹框
- (void)showFirstLeadAlertView {
FirstLeadAlertView *view = [[FirstLeadAlertView alloc] initWithJumpBlock:^(JumpType type) {
if (type == JumpTypeAI) {
// 切换到AI睡眠教练标签
self.tabBarController.selectedIndex = 1;
} else {
// 进入快速入眠页面
}
}];
[view show];
}
#pragma mark - 运营活动弹窗接口
- (void)queryPromotionImageRequest {
[HomeRequestModel queryPromotionImageWithCompletion:^(HomeRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
PromotionModel *pModel = requestModel.promotionModel;
[self showRescuePlanView:pModel];
}
}];
}
#pragma mark - 显示失眠拯救计划弹框
- (void)showRescuePlanView {
- (void)showRescuePlanView:(PromotionModel *)pModel {
BOOL isNative = [pModel.page_url containsString:@"native"];
WS(weakSelf);
RescuePlanView *rescuePlanView = [[RescuePlanView alloc] initWithJumpBlock:^{
[weakSelf.navigationController pushViewController:[[DsWebController alloc] initWithTitle:@"失眠拯救计划" link:@"https://www.cbti.cn/sleep/sleep_plan"] animated:YES];
}];
// 跳转到原生页面
if (isNative) {
int type = [[[pModel.page_url componentsSeparatedByString:@"type="] lastObject] intValue];
} else {
// 跳转到H5页面
[weakSelf.navigationController pushViewController:[[DsWebController alloc] initWithTitle:pModel.title link:pModel.page_url] animated:YES];
}
} imageUrl:pModel.image_url];
[rescuePlanView show];
}
......
......@@ -6,6 +6,7 @@
//
#import "DSNetworkTool.h"
#import "PromotionModel.h"
NS_ASSUME_NONNULL_BEGIN
......@@ -14,10 +15,16 @@ NS_ASSUME_NONNULL_BEGIN
/// banner列表数据
@property (nonatomic, strong) NSArray *bannerListData;
/// 活动弹框数据
@property (nonatomic, strong) PromotionModel *promotionModel;
/// 获取banner列表数据
/// @param completion completion
+ (NSURLSessionDataTask *)queryBannerListWithCompletion:(void (^)(HomeRequestModel *requestModel))completion;
/// 运营活动弹窗接口
/// @param completion completion
+ (NSURLSessionDataTask *)queryPromotionImageWithCompletion:(void (^)(HomeRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
......@@ -32,4 +32,22 @@
}];
}
+ (NSURLSessionDataTask *)queryPromotionImageWithCompletion:(void (^)(HomeRequestModel *requestModel))completion {
HomeRequestModel * requestModel = [[HomeRequestModel alloc] init];
NSString *api = @"query_promotion_image";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"运营活动弹窗接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
PromotionModel *pModel = [PromotionModel yy_modelWithDictionary:resultDic];
requestModel.promotionModel = pModel;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end
//
// PromotionModel.h
// DreamSleep
//
// Created by peter on 2022/5/4.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 运营活动数据model
@interface PromotionModel : NSObject
// 活动标题
@property (nonatomic, copy) NSString *title;
// 弹窗图片url
@property (nonatomic, copy) NSString *image_url;
// 登录标识 0:不登录,1:登录
@property (nonatomic, assign) int login_flag;
// H5详情页面url
@property (nonatomic, copy) NSString *page_url;
@end
NS_ASSUME_NONNULL_END
//
// PromotionModel.m
// DreamSleep
//
// Created by peter on 2022/5/4.
//
#import "PromotionModel.h"
@implementation PromotionModel
@end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:ocusmp.xinstall.com.cn</string>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

350 字节 | 宽: | 高:

395 字节 | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

613 字节 | 宽: | 高:

657 字节 | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@2x.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

1.2 KB | 宽: | 高:

1.3 KB | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/dk_home_close.imageset/dk_home_close@3x.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖
{
"images" : [
{
"filename" : "dk_pic_select_sleep_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_pic_select_sleep_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_pic_select_sleep_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_pic_select_weeks_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_pic_select_weeks_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_pic_select_weeks_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

395 字节 | 宽: | 高:

350 字节 | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

657 字节 | 宽: | 高:

613 字节 | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@2x.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖

1.3 KB | 宽: | 高:

1.2 KB | 宽: | 高:

DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@3x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/Home/home_close.imageset/home_close@3x.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!