Commit b6cd9f3c cgx

微信跳转弹框

1 个父辈 d8ad9052
......@@ -43,6 +43,7 @@
D0930F1A2801874B006B497A /* UIViewController+Swizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = D0930F152801874B006B497A /* UIViewController+Swizzling.m */; };
D0930F1B2801874B006B497A /* UINavigationController+Pop.m in Sources */ = {isa = PBXBuildFile; fileRef = D0930F182801874B006B497A /* UINavigationController+Pop.m */; };
D09D0E96280D3FE9008DEDAB /* NSDate+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D09D0E95280D3FE9008DEDAB /* NSDate+Extras.m */; };
D09D0E9A280D507F008DEDAB /* ProfileAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D09D0E99280D507F008DEDAB /* ProfileAlertView.m */; };
D0B5ECA627F2D9DE003EDFE3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECA527F2D9DE003EDFE3 /* AppDelegate.m */; };
D0B5ECAF27F2D9DE003EDFE3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D0B5ECAD27F2D9DE003EDFE3 /* Main.storyboard */; };
D0B5ECB127F2D9E0003EDFE3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D0B5ECB027F2D9E0003EDFE3 /* Assets.xcassets */; };
......@@ -154,6 +155,8 @@
D0930F192801874B006B497A /* NaviBarHandlerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NaviBarHandlerProtocol.h; sourceTree = "<group>"; };
D09D0E94280D3FE9008DEDAB /* NSDate+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDate+Extras.h"; sourceTree = "<group>"; };
D09D0E95280D3FE9008DEDAB /* NSDate+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDate+Extras.m"; sourceTree = "<group>"; };
D09D0E98280D507F008DEDAB /* ProfileAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProfileAlertView.h; sourceTree = "<group>"; };
D09D0E99280D507F008DEDAB /* ProfileAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfileAlertView.m; sourceTree = "<group>"; };
D0B5ECA127F2D9DE003EDFE3 /* DreamSleepDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DreamSleepDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
D0B5ECA427F2D9DE003EDFE3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
D0B5ECA527F2D9DE003EDFE3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
......@@ -382,6 +385,8 @@
D04B3DBF27F6F82D0022F8DF /* ProfileController.m */,
D0E660032807D02C006562F2 /* UserRequestModel.h */,
D0E660042807D02C006562F2 /* UserRequestModel.m */,
D09D0E98280D507F008DEDAB /* ProfileAlertView.h */,
D09D0E99280D507F008DEDAB /* ProfileAlertView.m */,
);
path = Profile;
sourceTree = "<group>";
......@@ -764,6 +769,7 @@
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */,
D01814D127FFCBAF00583D4E /* CWCarousel.m in Sources */,
D0B5ECB727F2D9E0003EDFE3 /* main.m in Sources */,
D09D0E9A280D507F008DEDAB /* ProfileAlertView.m in Sources */,
D0506B0C280503A800229278 /* UIButton+Extras.m in Sources */,
D0C50B3F27FD381000DC68F0 /* UIView+Extras.m in Sources */,
D0E65FFF2807AC5E006562F2 /* DSProgressHUD.m in Sources */,
......
......@@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN
/// @param font 字体
+ (instancetype)dkBtnWithSubTitle:(NSString *)subTitle imgName:(NSString *)imgName font:(UIFont *)font;
+ (instancetype)dkBtnTitle:(NSString *)title imgName:(NSString *)imgName font:(UIFont *)font;
/**
* 按钮中图片和标题布局方式(上下及左右)
*
......
......@@ -27,6 +27,15 @@
return btn;
}
+ (instancetype)dkBtnTitle:(NSString *)title imgName:(NSString *)imgName font:(UIFont *)font {
UIButton *btn = [UIButton new];
[btn setTitle:title forState:UIControlStateNormal];
[btn dk_setTitleColorPicker:DKColorPickerWithKey(TEXT) forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
[btn.titleLabel setFont:font];
return btn;
}
- (void)adjustLayoutWithType:(UIButtonLayoutType)type midSpace:(CGFloat)midSpace sizeToFit:(BOOL)sizeToFit
{
if (sizeToFit) {
......
//
// ProfileAlertView.h
// DreamSleep
//
// Created by peter on 2022/4/18.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ProfileAlertView : UIView
- (instancetype)initWithIndexPath:(NSIndexPath *)indexPath;
- (void)showAlertView;
@end
NS_ASSUME_NONNULL_END
//
// ProfileAlertView.m
// DreamSleep
//
// Created by peter on 2022/4/18.
//
#import "ProfileAlertView.h"
#import "WXApi.h"
@interface ProfileAlertView ()
@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, strong) UIView *alertView;
@property (nonatomic, strong) UIButton *closeBtn;
@property (nonatomic, strong) UILabel *alertLab;
@property (nonatomic, strong) UIButton *copySuccessBtn;
@property (nonatomic, strong) UIButton *goBtn;
@end
@implementation ProfileAlertView
- (instancetype)initWithIndexPath:(NSIndexPath *)indexPath {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
self.indexPath = indexPath;
self.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0x6F7587), DSClearColor, DSWhite);
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
[self addSubview:self.alertView];
[self.alertView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.equalTo(@280);
make.height.equalTo(@236);
}];
}
return self;
}
- (void)showAlertView {
self.alertLab.text = self.indexPath.row == 5 ? @"即将前往小梦睡眠微信小程序" : @"请前往微信粘贴搜索";
[self.alertLab sizeToFit];
[self.alertLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.alertView);
make.top.equalTo(self.alertView).offset(97);
}];
if (self.indexPath.row != 5) {
// 关注公众号和添加客服微信
[self.alertView addSubview:self.copySuccessBtn];
[self.copySuccessBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.alertView);
make.width.equalTo(@100);
make.bottom.equalTo(self.alertLab.mas_top).offset(-12);
}];
}
[DSKeyWindow addSubview:self];
}
- (UIView *)alertView {
if (!_alertView) {
_alertView = [UIView new];
[_alertView cornerRadius:20.0];
_alertView.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, AlertDarkColor, DSWhite);
[_alertView addSubview:self.closeBtn];
[_alertView addSubview:self.alertLab];
[_alertView addSubview:self.goBtn];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_alertView).offset(15);
make.right.equalTo(_alertView).offset(-15);
}];
[self.goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_alertView);
make.width.equalTo(@155);
make.height.equalTo(@40);
make.bottom.equalTo(_alertView).offset(-24);
}];
}
return _alertView;
}
- (UIButton *)closeBtn {
if (!_closeBtn) {
_closeBtn = [UIButton new];
[_closeBtn dk_setImage:DKImagePickerWithNames(@"ic_pop_del_normal", @"ic_pop_del_normal", @"ic_pop_del_normal") forState:UIControlStateNormal];
[_closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
}
return _closeBtn;
}
- (UILabel *)alertLab {
if (!_alertLab) {
_alertLab = [UILabel dkLabWithFont:BoldFont(16.0)];
}
return _alertLab;
}
- (UIButton *)goBtn {
if (!_goBtn) {
_goBtn = [UIButton btnWithTitle:@"立即前往" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
[_goBtn addTarget:self action:@selector(goAction) forControlEvents:UIControlEventTouchUpInside];
[_goBtn cornerRadius:20];
}
return _goBtn;
}
- (UIButton *)copySuccessBtn {
if (!_copySuccessBtn) {
_copySuccessBtn = [UIButton dkBtnTitle:@"复制成功" imgName:@"ic_xm_done" font:BoldFont(16)];
_copySuccessBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
}
return _copySuccessBtn;
}
- (void)closeAction {
[self removeFromSuperview];
}
- (void)goAction {
[self closeAction];
switch (self.indexPath.row) {
case 5: // 前往小程序
{
WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
launchMiniProgramReq.userName = @"小梦睡眠";
launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease;
[WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
}];
}
break;
case 6: // 关注公众号
{
WXOpenBusinessViewReq *req = [WXOpenBusinessViewReq object];
[WXApi sendReq:req completion:^(BOOL success) {
}];
}
break;
case 7: // 添加客服微信
{
WXOpenCustomerServiceReq *req = [[WXOpenCustomerServiceReq alloc] init];
req.corpid = @""; // 企业ID
req.url = @""; // 客服URL
[WXApi sendReq:req completion:^(BOOL success) {
}];
}
break;
default:
break;
}
}
@end
......@@ -9,6 +9,7 @@
#import "SystemSetController.h"
#import "LoginController.h"
#import "PrivacyViewController.h"
#import "ProfileAlertView.h"
@interface ProfileController ()
@property (nonatomic, strong) NSArray *tmpDatas;
......@@ -68,6 +69,24 @@
{
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"关于我们" link:[NSURL URLWithString:PrivacyPolicy] isDetail:YES] animated:YES];
}
break;;
case 5: // 前往小程序
{
[[[ProfileAlertView alloc] initWithIndexPath:indexPath] showAlertView];
}
break;
case 6: // 关注公众号
{
[UIPasteboard generalPasteboard].string = @"公众号名称";
[[[ProfileAlertView alloc] initWithIndexPath:indexPath] showAlertView];
}
break;
case 7: // 添加客服微信
{
[UIPasteboard generalPasteboard].string = @"客服微信";
[[[ProfileAlertView alloc] initWithIndexPath:indexPath] showAlertView];
}
break;
default:
break;
}
......
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_pop_del_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_pop_del_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_pop_del_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_xm_done.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_xm_done@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_xm_done@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -47,6 +47,8 @@
#define DSRed [UIColor redColor]
// 白色
#define DSWhite [UIColor whiteColor]
// 黑色
#define DSBlack [UIColor blackColor]
// clearColor
#define DSClearColor [UIColor clearColor]
......@@ -60,6 +62,8 @@
#define DarkColor ColorFromHex(0x161E38)
/** 背景色 */
#define BGColor ColorFromHex(0xF5F7FA)
// 弹框背景黑夜深色
#define AlertDarkColor ColorFromHex(0x131724)
/** 副文案颜色 */
#define SubTextColor [UIColor colorWithHexString:@"#A0A0A0"]
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!