// // OffcialAccountSettingVC.m // tongxin // // Created by Apple on 2019/1/22. // Copyright © 2019年 xTT. All rights reserved. // #import "OffcialAccountSettingVC.h" #import "EditMeViewController.h" @interface OffcialAccountSettingVC () @end @implementation OffcialAccountSettingVC -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; WEAKSELF [cUser getGZHSwitchSuccess:^(id responseObject) { if([responseObject[@"status"] intValue] != 1){ weakSelf.GZHStatusSwitch.on = 0; }else{ weakSelf.GZHStatusSwitch.on = 1; } if(cUser.status.intValue == 2){ //未关注公众号 //首先判断是否是 微信登录 或者是 手机号登录绑定微信 if( [myHelper getNowAccoutType:cUser] == 2 || (cUser.account_status.intValue == 1 && cUser.wx_status.intValue == 1) ){ // 已经具备条件了 // 关注微信公众号,你将可以在微信收到宝贝的消息,是否前往关注? LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:@"关注微信公众号【童信汇】,你将可以在微信收到宝贝的消息,是否前往关注?" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { //去截图 跳转 微信 [weakSelf saveImageView:self.view]; } cancelHandler:nil destructiveHandler:nil]; alertView.cancelOnTouch = NO; [alertView showAnimated:YES completionHandler:nil]; }else{ // 当前账号未绑定微信,是否前往绑定? LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:@"当前账号未绑定微信,是否前往绑定?" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { //跳转用户资料页面 ---> 提示,绑定微信页面 UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; EditMeViewController *vc =[sb instantiateViewControllerWithIdentifier:@"EditMeViewController"]; vc.willLoadBlack = ^{ LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:@"请绑定微信,并关注微信公众号【童信汇】" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { } cancelHandler:nil destructiveHandler:nil]; alertView.cancelOnTouch = NO; [alertView showAnimated:YES completionHandler:nil]; }; [weakSelf.navigationController pushViewController:vc animated:YES]; } cancelHandler:^(LGAlertView *alertView) { [weakSelf.navigationController popViewControllerAnimated:YES]; } destructiveHandler:nil]; alertView.cancelOnTouch = NO; [alertView showAnimated:YES completionHandler:nil]; } } } failure:^(id faiObject) { }]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"消息提醒设置"; } - (IBAction)msgRemindSettingAction:(UISwitch *)sender { //储存之前改变前的 __block BOOL tempFlag = !sender.on; // sender.on = !sender.on; [SVProgressHUD dismiss]; [cUser setGZHSwitchStatus:@(sender.on) Success:^(id responseObject) { [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"公众号消息提醒%@",(sender.on)?@"打开":@"关闭"]]; [SVProgressHUD dismissWithDelay:1]; } failure:^(id faiObject) { sender.on = tempFlag; }]; } //截屏分享 传入想截屏的view(也可以是controller webview只能截当前屏幕-_-`,用其他的方法) -(void)saveImageView:(UIView*)view{ UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0); CGContextRef ctx = UIGraphicsGetCurrentContext(); [view.layer renderInContext:ctx]; // 这个是要分享图片的样式(自定义的) UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); //保存到本地相机 UIImageWriteToSavedPhotosAlbum(newImage,self,@selector(image:didFinishSavingWithError:contextInfo:),nil); } - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ xLog(@"截屏保存成功"); LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:@"截图保存至相册成功,微信使用\"扫一扫\",右上角相册选择截图,扫描截图并关注公众号即可开启通知" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { [self openScheme:@"weixin://"]; } cancelHandler:nil destructiveHandler:nil]; alertView.cancelOnTouch = NO; [alertView showAnimated:YES completionHandler:nil]; } - (void)openScheme:(NSString *)scheme { UIApplication *application = [UIApplication sharedApplication]; NSURL *URL = [NSURL URLWithString:scheme]; //iOS 10 以后 if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { //1 如果这个要打开的URL有效,并且在应用中配置它布尔值为true(YES)时才可以打开,否则打不开 // NSDictionary *options = @{UIApplicationOpenURLOptionUniversalLinksOnly : @YES}; //2 此时与openURL功能相似 NSDictionary *options =@{}; [application openURL:URL options:options completionHandler:^(BOOL success) { NSLog(@"Open %@: %d",scheme,success); }]; } else { if ([application canOpenURL:URL]) { BOOL success = [application openURL:URL]; NSLog(@"Open %@: %d",scheme,success); } } } @end