This commit is contained in:
lianxiang
2018-09-27 00:20:01 +08:00
parent d0230f55ed
commit cb0accdb66
60 changed files with 1063 additions and 290 deletions
@@ -9,5 +9,6 @@
#import "GiGaBaseViewController.h"
@interface GIGaMaskShareViewController : GiGaBaseViewController
@property(nonatomic,copy) NSString *maskTimeId;
@end
@@ -14,8 +14,11 @@
#import "MaskTimeShareActionSheet.h"
#import "GIGaUserFileHelper.h"
#import <AVFoundation/AVFoundation.h>
#import "GiGaBaseAPiRequest.h"
#import "GiGaShareModel.h"
#import "UIImageView+WebCache.h"
@interface GIGaMaskShareViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong) GiGaShareModel *model;
@end
@implementation GIGaMaskShareViewController
@@ -33,7 +36,9 @@
self.tableView.estimatedSectionHeaderHeight = 0;
//self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, 30)];
self.tableView.frame = CGRectMake(0,0,KMainW, self.view.frame.size.height);
// Do any additional setup after loading the view.
[self requestshareInfo];
}
- (void)didReceiveMemoryWarning {
@@ -56,13 +61,29 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskTimeEndViewImgaeCell" owner:self options:nil] lastObject];
}
if (self.model) {
cell.minuteLab.text = [NSString stringWithFormat:@"%@min",self.model.minute];
cell.timeLable.text = [NSString stringWithFormat:@"这是您敷面膜的第:%@张",self.model.monthMaskNum];
}
return cell;
}else if (indexPath.section == 1){
MaskTimeTimeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MaskTimeTimeViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskTimeTimeViewCell" owner:self options:nil] lastObject];
}
if (self.model) {
cell.timeLabe.text = self.model.minute;
CGFloat percent = [self.model.exquisite floatValue];
int perrr = percent * 100;
NSString *per = [NSString stringWithFormat:@"%d",perrr];
cell.percentLabe.text = per;
cell.totalTime.text = self.model.totalMaskNum;
NSURL *url = [NSURL URLWithString:self.model.headImgUrl];
[cell.useravator sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"nav_circle_avatar"]];
}
return cell;
}else if (indexPath.section == 2){
@@ -86,7 +107,7 @@
return 205;
}
return 90;
return 120;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
@@ -101,7 +122,7 @@
#pragma mark changeBackBtnAction
-(void)changeBackBtnAction{
MaskTimeShareActionSheet * sheet = [[MaskTimeShareActionSheet alloc] initWithFrame:CGRectMake(0, 0, KMainW, KMainH)];
MaskTimeShareActionSheet * sheet = [MaskTimeShareActionSheet showAtView:self];
[sheet show:^(NSUInteger index) {
switch (index) {
case 0:
@@ -114,6 +135,7 @@
//系统
[GIGaUserFileHelper delectShareImage:kUSERSHAREA_IMAGENAME];
ShareViewController *share = [[ShareViewController alloc] init];
share.model = self.model;
[self presentViewController:share animated:NO completion:nil];
}
@@ -129,15 +151,15 @@
}
}];
[self.view addSubview:sheet];
}
#pragma mark share
-(void)shareBtnAction{
ShareViewController *share = [[ShareViewController alloc] init];
[self presentViewController:share animated:NO completion:nil];
share.model = self.model;
[self presentViewController:share animated:YES completion:nil];
}
@@ -220,6 +242,7 @@
[GIGaUserFileHelper savaShareImange:kUSERSHAREA_IMAGENAME image:small];
ShareViewController *share = [[ShareViewController alloc] init];
share.model = self.model;
[self presentViewController:share animated:NO completion:nil];
}
@@ -227,5 +250,23 @@
[picker dismissViewControllerAnimated:YES completion:nil];
}
-(void)requestshareInfo{
if (self.maskTimeId == nil) {
return;
}
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiShareAction method:RequestPostMethod parms:@{@"id":self.maskTimeId}];
[api requstDataWithResult:^(GiGaAPIResult *result){
if (result.success) {
NSDictionary *dic = result.dic;
GiGaShareModel *model = [[GiGaShareModel alloc] initWithDictionary:dic error:nil];
self.model = model;
[self.tableView reloadData];
}
}];
}
@end
@@ -46,8 +46,11 @@
}
return _danmuSwitch;
}
- (GiGaFlyingCommitInputView *)commitInputView{
if (!_commitInputView) {
@@ -139,10 +142,10 @@
_manager = manager;
_client = manager.defaultSocket;
[self.manager connect];
weakify(self);
[self.client on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
GIGA_WIndowTost(@"客户端上线");
//GIGA_WIndowTost(@"客户端上线");
NSLog(@"*************\n\niOS客户端上线\n\n*************");
}];
@@ -154,9 +157,11 @@
[self.client on:@"onTalk" callback:^(NSArray * _Nonnull data, SocketAckEmitter * _Nonnull ack) {
NSString *json =data[0];
NSLog(@"callback json***:%@",json);
NSDictionary *dic = [GiGaHelper dictionaryWithJsonString:json];
//NSString *json =data[0];
//NSDictionary *dic = [GiGaHelper dictionaryWithJsonString:json];
NSDictionary *dic = data[0];
NSLog(@"callback json***:%@",dic);
if (dic == nil) {
NSLog(@"解析失败");
@@ -176,15 +181,8 @@
[self.client on:@"error" callback:^(NSArray * _Nonnull event, SocketAckEmitter * _Nonnull ack) {
[GIGAMBHUDHelper messageAddto:self.view title:@"连接弹幕"];
// NSString *htmlString =event[0];
// htmlString = [self htmlEntityDecode:htmlString];
//
// UIWebView * webView = [[UIWebView alloc]initWithFrame:CGRectMake(20, 300, self.view.frame.size.width - 40, 400)];
// [webView loadHTMLString:htmlString baseURL:nil];
// [self.view addSubview:webView];
//
// NSLog(@"*************\n\n%@\n\n*************",event?event[0]:@"");
[GIGAMBHUDHelper messageAddto:self.view title:@"连接弹幕中..."];
GILog(@"请求超时");
}];
@@ -33,9 +33,11 @@
#import "GiGaBaseAPiRequest.h"
#import "MaskTestResultVC.h"
#import "GIGaMaskShareViewController.h"
#import "MaskHistryRecord.h"
#import "MaskTimeTopAnimationView.h"
@interface GiGaMaskTaskViewController ()<MaskCirCularProGressViewDelegate>
@interface GiGaMaskTaskViewController ()<MaskCirCularProGressViewDelegate,MaskTimeTextViewDelegate>
{
AVAudioPlayer *_musicPalyer;
}
@@ -53,13 +55,28 @@
@property(nonatomic,strong) UIButton *startTestButton;
//开启弹幕按钮
@property(nonatomic,strong) UIButton *openDanmuButton;
//记录当前面试时间 记录开id
@property(nonatomic,copy) NSString *currentMaskId;
@property(nonatomic,strong) MaskTimeTopAnimationView *animLabeview;
@end
@implementation GiGaMaskTaskViewController
#pragma mark - property
- (MaskTimeTopAnimationView *)animLabeview{
if (!_animLabeview) {
_animLabeview = [[MaskTimeTopAnimationView alloc] initWithFrame:CGRectMake(0,20+ PhoneX_TopMargin,KMainW - 40 * 2, 44)];
NSString *text = @"长时间的使用面膜可能会对您的皮肤造成伤害";
[_animLabeview animationWithTexts:[NSArray arrayWithObjects:text,@"面膜时间",text, nil]];
//_animLabeview.backgroundColor = [UIColor blueColor];
}
return _animLabeview;
}
- (UIButton *)openDanmuButton{
if (!_openDanmuButton) {
_openDanmuButton = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -177,7 +194,7 @@
#pragma mark 弹幕
-(void)createInputView{
self.openDanmuButton.hidden = YES;
GiGaFlingCommitVC* GiGaFlingVC = [[GiGaFlingCommitVC alloc] init];
if (ISIOS8) {
GiGaFlingVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
@@ -228,13 +245,13 @@
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpNav];
[self initUI];
[self addNotify];
[self creatBackGroundMusic];
}
#pragma mark - 响应事件
@@ -345,18 +362,18 @@
#pragma mark 布局
-(void)initUI{
self.view.backgroundColor = GIGA_MAIN_BGCOLOR;
[self.view addSubview:self.openDanmuButton];
[self.view addSubview:self.faceView];
[self.view addSubview:self.maskImageView];
[self.view addSubview:self.hairImageView];
//[self.view bringSubviewToFront:self.maskImageView];
[self.view addSubview:self.swipeGaurdimagView];
[self.view addSubview:self.startMaskButton];
[self.view addSubview:self.startTestButton];
[self.view addSubview:self.cicleProgressView];
//face
[self.faceView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(124 + PhoneX_TopMargin);
@@ -442,7 +459,8 @@
#pragma mark 开始面膜时间
-(void)startMaskTime{
//记录
[self sendBengainMaskTime];
[self createInputView]; //出现弹幕
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
if (delegate.isMasking) {
@@ -450,17 +468,18 @@
}
delegate.isMasking = YES;
[_musicPalyer play];
[self setBackGroundPlayingInfo];//锁屏音频信息
//[self setBackGroundPlayingInfo];//锁屏音频信息
//总时间隔 s
NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime];
//NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime];
NSTimeInterval timeInterVal = 6;
[self.cicleProgressView startWith:timeInterVal];
//底部弹窗
[self showWaringView];
//app 前台时收到本地通知showAlert 后台时通知提醒
[[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"本地推送" fireTimeInterval:timeInterVal alertAction:@"测试面膜时间" withIdentifier:kLOCALNotifiID_MASKETIMEEND];
// [[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"本地推送" fireTimeInterval:timeInterVal alertAction:@"测试面膜时间" withIdentifier:kLOCALNotifiID_MASKETIMEEND];
}
@@ -506,8 +525,8 @@
#pragma mark 面膜时间结束
-(void)maskTimeEnd{
[self sendEndMaskTime];
NC_POST_NAME_OBJECT(kUserNoti_MASKEND, nil);
//面膜时间结束时设置 全局变量 不再发送本地通知 提醒
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
delegate.isMasking = NO;
@@ -579,6 +598,7 @@
}
-(void)dealloc{
NC_REMOVE_NAME(self, USER_GUARD_DISSMISS, nil);
NC_REMOVE_NAME(self, APP_GUARD_DISSMISS, nil);
NC_REMOVE_NAME(self, APP_PUSHTO_DETAILVIEW, nil);
@@ -586,7 +606,6 @@
NC_REMOVE_NAME(self, kUserLogOutNotify, nil);
NC_REMOVE_NAME(self, kUserLoginSuccessNoti, nil);
NC_REMOVE_NAME(self, @"UserCloseChatRoomAction", nil);
}
#pragma mark 新手引导
@@ -612,12 +631,12 @@
#pragma mark - 导航按钮
-(void)setUpNav{
//leftItem
// UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
// leftBtn.frame = CGRectMake(0, 0, 40, 40);
// leftBtn.backgroundColor = [UIColor redColor];
// [leftBtn setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal];
// [leftBtn addTarget:self action:@selector(leftBtnAction) forControlEvents:UIControlEventTouchUpInside];
// self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
leftBtn.frame = CGRectMake(0, 0, 40, 40);
//leftBtn.backgroundColor = [UIColor redColor];
//[leftBtn setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal];
//[leftBtn addTarget:self action:@selector(leftBtnAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
//rightItem
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -647,6 +666,8 @@
}
}
}
self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
}
#pragma mark 用户头像更新
@@ -746,23 +767,30 @@
-(void)showAlertGoShareMaskTime{
[self jxt_showAlertWithTitle:@"面膜时间" message:@"去分享我的面膜时间" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"下次");
alertMaker.addActionDefaultTitle(@"去分享");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (self.currentMaskId == nil) {
return;
}
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
//游客不分享
[self jxt_showAlertWithTitle:@"面膜时间" message:@"去分享我的面膜时间" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"下次");
alertMaker.addActionDefaultTitle(@"去分享");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
GIGaMaskShareViewController *shareVC = [[GIGaMaskShareViewController alloc] init];
shareVC.maskTimeId = self.currentMaskId;
[self.navigationController pushViewController:shareVC animated:YES];
}
}];
if (buttonIndex == 1) {
GIGaMaskShareViewController *shareVC = [[GIGaMaskShareViewController alloc] init];
[self.navigationController pushViewController:shareVC animated:YES];;
}
}];
}
}
#pragma mark - 开启弹幕按钮事件
-(void)openDanmuButtonAction{
self.openDanmuButton.hidden = YES;
[self createInputView];
}
//通知用户挂断弹幕
@@ -770,4 +798,43 @@
self.openDanmuButton.hidden = NO;
}
#pragma mark 开始敷面膜 APi
-(void)sendBengainMaskTime{
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime];
NSString *minute = [NSString stringWithFormat:@"%.f",timeInterVal /60];
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:KApiBeginMaskTime method:RequestPostMethod parms:@{@"minute":minute}];
[api requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
NSDictionary *maskDic = result.dic[@"maskUseLog"];
self.currentMaskId = maskDic[@"id"];
}
}];
}
}
#pragma mark 结束敷面膜 APi
-(void)sendEndMaskTime{
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
if (self.currentMaskId) {
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiEndMaskTime method:RequestPostMethod parms:@{@"id":self.currentMaskId}];
[api requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GILog(@"%@",@"面膜时间APi结束");
}
}];
}
}
}
-(void)addNavTitile:(NSString *)title{
self.navigationItem.titleView = self.animLabeview;
}
@end
@@ -7,7 +7,9 @@
//
#import "GiGaBaseViewController.h"
#import "GiGaShareModel.h"
@interface ShareViewController : GiGaBaseViewController
@property(nonatomic,strong) GiGaShareModel *model;
@end
@@ -18,6 +18,8 @@
#import <WXApiObject.h>
#import <WXApi.h>
#import "UIImage+ShotImage.h"
#import "GiGaBaseAPiRequest.h"
#import "UIImageView+WebCache.h"
@interface ShareViewController ()<UITableViewDelegate,UITableViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong) UITableView *tab;
@@ -37,7 +39,7 @@
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(20,44, 40, 40);
backBtn.frame = CGRectMake(20,20 +PhoneX_TopMargin, 40, 40);
[backBtn setImage:[UIImage imageNamed:@"btn_moment_back"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
@@ -46,6 +48,12 @@
[self creatBtns];
NC_ADD_TARGET_NAME_OBJECT(self, @selector(usershareSuccessNoti), NC_UseShareSuccessNoti, nil);
}
-(void)dealloc{
NC_REMOVE_NAME(self, NC_UseShareSuccessNoti, nil);
}
-(void)creatTabUI{
@@ -84,12 +92,23 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskTimeShareViewCell" owner:self options:nil] lastObject];
}
return cell;
}else if (indexPath.row == 1){
MaskShareTimeMidViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MaskShareTimeMidViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskShareTimeMidViewCell" owner:self options:nil] lastObject];
if (self.model) {
cell.timeLabe.text = self.model.minute;
CGFloat percent = [self.model.exquisite floatValue];
int perrr = percent * 100;
NSString *per = [NSString stringWithFormat:@"%d",perrr];
cell.percetLabe.text = per;
cell.totalLabe.text = self.model.totalMaskNum;
NSURL *url = [NSURL URLWithString:self.model.headImgUrl];
[cell.userAvtoar sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"nav_circle_avatar"]];
}
}
return cell;
}
@@ -161,7 +180,8 @@
//更换背景
-(void)changeAction{
MaskTimeShareActionSheet * sheet = [[MaskTimeShareActionSheet alloc] initWithFrame:CGRectMake(0, 0, KMainW, KMainH)];
MaskTimeShareActionSheet * sheet = [MaskTimeShareActionSheet showAtView:self];
[sheet show:^(NSUInteger index) {
switch (index) {
case 0:
@@ -176,10 +196,24 @@
if (self->_curentImageIndex == 4) {
self->_curentImageIndex = 0;
}
NSArray *images = @[@"sharebg_2",@"sharebg_3",@"sharebg_4",@"sharebg_5",@"sharebg_1"];
NSArray *images = @[@"sharebg_1",@"sharebg_2",@"sharebg_3",@"sharebg_4",@"sharebg_5"];
[self.backimageview setImage:[UIImage imageNamed: images[self->_curentImageIndex]]];
MaskTimeShareViewCell *cell = [self.tab cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
if (self.curentImageIndex==0) {
cell.shareLabe.image = [UIImage imageNamed:@"share_oneblack"];
cell.doinglabel.textColor = [UIColor blackColor];
}
if (self.curentImageIndex == 1) {
cell.shareLabe.image = [UIImage imageNamed:@"share_one"];
cell.doinglabel.textColor = GIGARGB(170, 170, 170, 1);
}
}
break;
case 2:
@@ -193,9 +227,7 @@
}
}];
[self.view addSubview:sheet];
}
#pragma mark 相册
@@ -307,6 +339,7 @@
// 朋友圈
[self shareImagToWX:image scene:WXSceneTimeline];
}
}];
}
@@ -330,4 +363,10 @@
[WXApi sendReq:req];
}
//分享成功
-(void)usershareSuccessNoti{
}
@end