123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- //
- // activityDetailVController.m
- // ZhongJingLianMeng
- //
- // Created by youke on 2018/12/6.
- // Copyright © 2018 youke. All rights reserved.
- //
- #import "activityDetailVController.h"
- #import "UIAlertController+LY.h"
- #import <JavaScriptCore/JavaScriptCore.h>
- #import <ShareSDK/ShareSDK.h>
- #import <ShareSDKUI/ShareSDK+SSUI.h>
- #import "ZLCWebView.h"
- #import<ShareSDKUI/SSUIShareActionSheetStyle.h>//设置简单分享菜单样式
- #import "logInViewController.h"
- #import "UserInfoModel.h"
- #import "eventActivityVController.h"
- #import "OrderAirportPayCancelView.h"
- //#import "joinAllianceVController.h"
- //#import "VIPXuFeiController.h"
- //#import "applyForDirectorController.h"
- @interface activityDetailVController ()<ZLCWebViewDelegate>
- @property (nonatomic, strong) ZLCWebView *webView;
- @property(nonatomic,strong) JSContext *jsContext;
- @property(nonatomic,strong)UIButton *collectionBtn;
- @property(nonatomic,strong)UIButton *sendBtn;
- @property (strong, nonatomic) HttpRequestManger *sessionManager;
- @property(nonatomic,strong)NSString *collectionStaus;
- @property(nonatomic,strong)InfoModel *userInfoModel;
- @property (strong, nonatomic) OrderAirportPayCancelView *cancelView;
- @property (strong, nonatomic) OrderAirportPayCancelView *vipContinueView;
- @end
- @implementation activityDetailVController
- - (HttpRequestManger*) sessionManager{
- if (!_sessionManager) {
- _sessionManager = [[HttpRequestManger alloc]init];
- }
- return _sessionManager;
- }
- -(void)viewWillAppear:(BOOL)animated{
-
- [super viewWillAppear:YES];
-
- [self loadSelectActivityStatus];
- [self loadIsCollection];
-
- }
- -(void)loadSelectActivityStatus{
-
- kWeakSelf(self);
-
- NSMutableDictionary *parma = [NSMutableDictionary dictionary];
- parma[@"id"] = weakself.newsId;
- self.sessionManager = [[HttpRequestManger alloc]init];
- [self.sessionManager sendPostHttpRequestWithUrl:selectActivityStatus params:parma bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- NSLog(@"%@",response);
- weakself.activityStatus =[NSString stringWithFormat:@"%@", response[@"activityStatus"]];
- if ([weakself.activityStatus isEqualToString:@"0"]) {
- [weakself.sendBtn setTitle:@"活动报名" forState:UIControlStateNormal];
- weakself.sendBtn.userInteractionEnabled = YES;
- }else{
- [weakself.sendBtn setTitle:@"活动已结束" forState:UIControlStateNormal];
- weakself.sendBtn.userInteractionEnabled = NO;
- }
- } failure:^(NSError *error) {
- NSLog(@"%@",error);
- }];
-
-
- }
- -(void)loadIsCollection{
-
- // kWeakSelf(self);
- //
- // NSMutableDictionary *parma = [NSMutableDictionary dictionary];
- //
- // parma[@"id"] = weakself.newsId;
- // parma[@"type"] = @"1";
- // self.sessionManager = [[HttpRequestManger alloc]init];
-
- // [self.sessionManager sendPostHttpRequestWithUrl:isCollection params:parma bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- //
- // weakself.collectionStaus = response[@"isCollected"];
- //
- // if ([weakself.collectionStaus isEqualToString:@"1"]) {
- //
- // [weakself.collectionBtn setImage:[UIImage imageNamed:@"collectionIng"] forState:UIControlStateNormal];
- //
- // [_collectionBtn setTitle:@"取消收藏" forState:UIControlStateNormal];
- //
- // }else{
- //
- // [weakself.collectionBtn setImage:[UIImage imageNamed:@"collectionNo"] forState:UIControlStateNormal];
- //
- // [_collectionBtn setTitle:@"收藏" forState:UIControlStateNormal];
- //
- // }
- // } failure:^(NSError *error) {
- //
- // NSLog(@"%@",error);
- // }];
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.navigationView removeAllLeftButton];
-
- self.navigationView.titleLabel.text = self.titleStr;
-
- self.navigationView.titleLabel.textColor = [UIColor blackColor];
-
- self.view.backgroundColor = [UIColor whiteColor];
-
- kWeakSelf(self);
-
- [self.navigationView addLeftButtonWithImage:[UIImage imageNamed:@"btn_back"] clickCallBack:^(UIView *view) {
- [weakself.navigationController popViewControllerAnimated:YES];
- }];
- [self.navigationView addRightButtonWithImage:[UIImage imageNamed:@"share"] clickCallBack:^(UIView *view) {
-
- [weakself showShareView];
-
- }];
-
- UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, kGScreenHeight -50, kGScreenWidth, 50)];
-
- bottomView.backgroundColor = [UIColor whiteColor];
-
- [self.view addSubview:bottomView];
-
- // UIView *btnView = [[UIView alloc]init];
- // btnView.backgroundColor = [UIColor whiteColor];
- // [bottomView addSubview:btnView];
- // [btnView mas_makeConstraints:^(MASConstraintMaker *make) {
- //
- // make.size.mas_equalTo(CGSizeMake(kGScreenWidth -264, 50));
- //
- // make.left.equalTo(bottomView.mas_left).offset(0);
- //
- // make.top.equalTo(bottomView.mas_top).offset(0);
- // }];
-
-
- // _collectionBtn =[UIButton buttonWithType:UIButtonTypeCustom];
- //
- // [_collectionBtn setImage:[UIImage imageNamed:@"collectionNo"] forState:UIControlStateNormal];
- //
- // [_collectionBtn setTitle:@"收藏" forState:UIControlStateNormal];
- //
- // _collectionBtn.titleLabel.size = CGSizeMake(30, 15);
- //
- // _collectionBtn.titleLabel.font = TextFont(12);
- //
- // [_collectionBtn setTitleColor:[UIColor colorWithHexValue:0x333333] forState:UIControlStateNormal];
- //
- // [_collectionBtn setImageEdgeInsets:UIEdgeInsetsMake(-10, 10, 0, 0)];
- //
- // [_collectionBtn setTitleEdgeInsets:UIEdgeInsetsMake(_collectionBtn.currentImage.size.height + 10, -_collectionBtn.currentImage.size.width, 0, 0)];
- //
- // [_collectionBtn addTarget:self action:@selector(collectionClick:) forControlEvents:UIControlEventTouchUpInside];
- //
- // [btnView addSubview:_collectionBtn];
- //
- // [_collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- //
- // make.size.mas_equalTo(CGSizeMake(50, 50));
- //
- // make.centerX.mas_equalTo(btnView.mas_centerX).offset(0);
- //
- // make.centerY.mas_equalTo(btnView.mas_centerY).offset(0);
- //
- // }];
- //
- _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-
- // if ([self.activityStatus isEqualToString:@"0"]) {
- //
- // [_sendBtn setTitle:@"活动报名" forState:UIControlStateNormal];
- // _sendBtn.userInteractionEnabled = YES;
- // }else{
- //
- // [_sendBtn setTitle:@"活动已结束" forState:UIControlStateNormal];
- //
- // _sendBtn.userInteractionEnabled = NO;
- // }
- _sendBtn.titleLabel.size = CGSizeMake(30, 15);
-
- _sendBtn.titleLabel.font = TextFont(15);
-
- [_sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- _sendBtn.backgroundColor = AllMainColor;
- [_sendBtn addTarget:self action:@selector(OrderToClick:) forControlEvents:UIControlEventTouchUpInside];
- [bottomView addSubview:_sendBtn];
- [_sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
- make.left.equalTo(bottomView.mas_left).offset(0);
- make.right.equalTo(bottomView.mas_right).offset(0);
- make.top.equalTo(bottomView.mas_top).offset(0);
- }];
- self.webView = [[ZLCWebView alloc] initWithFrame:CGRectMake(0,isFullScreen?35:20, kGScreenWidth,isFullScreen?kGScreenHeight -35 -90: kGScreenHeight-20 -70)];
- if (@available(iOS 11.0, *)) {
-
- self.webView.wkWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }else {
-
- self.automaticallyAdjustsScrollViewInsets = NO;
-
- }
- self.webView.delegate = self;
-
- [self.view addSubview:self.webView];
-
- [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]]];
-
- self.webView.wkWebView.scrollView.backgroundColor = [UIColor whiteColor];
- self.webView.wkWebView.scrollView.showsVerticalScrollIndicator = NO;
- // self.webView.wkWebView.scrollView.showsHorizontalScrollIndicator = NO;
- _webView.wkWebView.scrollView.bounces = NO;
- // Do any additional setup after loading the view.
- }
- -(void)collectionClick:(UIButton *)sender{
-
- // if (!IsStrEmpty([DKGlobal sharedInstance].token)) {
- //
- // kWeakSelf(self);
- //
- // if (![weakself.collectionStaus isEqualToString:@"0"]) {
- //
- // NSMutableDictionary *parma = [NSMutableDictionary dictionary];
- //
- // parma[@"id"] = weakself.newsId;
- //
- // parma[@"collectType"] = @"1";
- //
- // self.sessionManager = [[HttpRequestManger alloc]init];
- //
- // [self.sessionManager sendPostHttpRequestWithUrl:cancelCollection params:parma bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- //
- // [MBProgressHUD showSuccess:@"取消收藏"];
- //
- // weakself.collectionStaus = @"0";
- //
- // [weakself.collectionBtn setImage:[UIImage imageNamed:@"collectionNo"] forState:UIControlStateNormal];
- //
- // [_collectionBtn setTitle:@"收藏" forState:UIControlStateNormal];
- // } failure:^(NSError *error) {
- //
- // NSLog(@"%@",error);
- // }];
- // }else{
- // kWeakSelf(self);
- // NSMutableDictionary *parma = [NSMutableDictionary dictionary];
- //
- // parma[@"id"] = weakself.newsId;
- //
- // parma[@"type"] = @"1";
- //
- // self.sessionManager = [[HttpRequestManger alloc]init];
- //
- // [self.sessionManager sendPostHttpRequestWithUrl:collectionNews params:parma bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- // [MBProgressHUD showSuccess:@"收藏成功"];
- //
- // weakself.collectionStaus = @"1";
- //
- // [weakself.collectionBtn setImage:[UIImage imageNamed:@"collectionIng"] forState:UIControlStateNormal];
- //
- // [_collectionBtn setTitle:@"取消收藏" forState:UIControlStateNormal];
- //
- //
- // } failure:^(NSError *error) {
- // NSLog(@"%@",error);
- // }];
- // }
- // }else{
- // [MBProgressHUD showError:@"请先登录"];
- // logInViewController *loginVC = [[logInViewController alloc]init];
- // [self.navigationController pushViewController:loginVC animated:YES];
- //
- // }
- //
- }
- - (void)zlcwebViewDidStartLoad:(ZLCWebView *)webview
- {
- [SVProgressHUD show];
- NSLog(@"页面开始加载");
- }
- - (void)zlcwebView:(ZLCWebView *)webview shouldStartLoadWithURL:(NSURL *)URL
- {
-
- NSLog(@"截取到URL:%@",URL);
- }
- - (void)zlcwebView:(ZLCWebView *)webview didFinishLoadingURL:(NSURL *)URL
- {
- [SVProgressHUD dismiss];
-
- NSLog(@"页面加载完成%@",URL);
- }
- - (void)zlcwebView:(ZLCWebView *)webview didFailToLoadURL:(NSURL *)URL error:(NSError *)error
- {
-
- [SVProgressHUD dismiss];
- NSLog(@"加载出现错误");
- }
- //}
- -(void)viewWillDisappear:(BOOL)animated{
-
- [super viewWillDisappear:YES];
-
- _webView = nil;
-
- [self cleanCacheAndCookie];
-
- }
- /**清除缓存和cookie*/
- - (void)cleanCacheAndCookie{
- //清除cookies
- NSHTTPCookie *cookie;
- NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
- for (cookie in [storage cookies]){
- [storage deleteCookie:cookie];
- }
- //清除UIWebView的缓存
- [[NSURLCache sharedURLCache] removeAllCachedResponses];
- NSURLCache * cache = [NSURLCache sharedURLCache];
- [cache removeAllCachedResponses];
- [cache setDiskCapacity:0];
- [cache setMemoryCapacity:0];
- }
- -(void)showShareView{
-
- NSArray *arr =@[[UIImage imageNamed:@"AppIcon"]];
- if (IsStrEmpty(_shareTitle)) {
- _shareTitle = @"";
- }
- if (arr) {
-
- NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
- [shareParams SSDKSetupShareParamsByText:@"卖铺宝"
- images:arr
- url:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_shareUrl]]
- title:_shareTitle
- type:SSDKContentTypeAuto];
- // [shareParams SSDKEnableUseClientShare];
-
-
- [ShareSDK showShareActionSheet:nil //要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view 对象,iPhone可以传nil不会影响
- items:@[@(SSDKPlatformSubTypeWechatSession),@(SSDKPlatformSubTypeWechatTimeline)]
- shareParams:shareParams
- onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
-
- switch (platformType) {
- case SSDKPlatformSubTypeWechatSession:
-
- break;
- case SSDKPlatformSubTypeWechatTimeline:
-
- break;
- default:
- break;
- }
-
- switch (state) {
- case SSDKResponseStateSuccess:
- // {
- // UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
- // message:nil
- // delegate:nil
- // cancelButtonTitle:@"确定"
- // otherButtonTitles:nil];
- // [alertView show];
- break;
- // }
- case SSDKResponseStateFail:
- // {
- // UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"分享失败"
- // message:nil
- // delegate:nil
- // cancelButtonTitle:@"OK"
- // otherButtonTitles:nil, nil];
- // [alert show];
- //
- //
- // NSLog(@"%@",error);
- break;
- // }
- default:
- break;
- }
- }
- ];
- }
-
- }
- -(void)OrderToClick:(UIButton *)sender{
-
- // if (![DKGlobal sharedInstance].token ) {
- // logInViewController *control = [[logInViewController alloc] init];
- // [self.navigationController pushViewController:control animated:YES];
- // }else{
- // [self isSpeicialStatus];
- //
- // }
- if (![DKGlobal sharedInstance].token) {
- LogInViewController *control = [[LogInViewController alloc] init];
- control.hidesBottomBarWhenPushed = YES;
- EasyNavigationController *nav = [[EasyNavigationController alloc]initWithRootViewController:control];
- [[DKGlobal sharedInstance].rootNavController presentViewController:nav animated:YES completion:nil];
- }else{
- [self loadActivityStatus];
- }
-
- }
- - (OrderAirportPayCancelView*)cancelView{
- WS(weakSelf);
- if (!_cancelView) {
- _cancelView = [[NSBundle mainBundle]loadNibNamed:@"OrderAirportPayCancelView" owner:self options:nil].firstObject;
- _cancelView.frame = self.view.bounds;
- // _cancelView.isFromOrder = self.isFromOrder;
- _cancelView.tipLabel.hidden = YES;
- _cancelView.contentLabel.hidden = YES;
- _cancelView.titleLabel.text = @"您还未加入会员";
- _cancelView.titleLabelTop.constant = 35;
- [_cancelView.rightBtn setBackgroundColor:[UIColor colorWithHexValue:0x3C915C]];
- [_cancelView.leftBtn setTitle:@"继续报名" forState:UIControlStateNormal];
- [_cancelView.rightBtn setTitle:@"加入会员" forState:UIControlStateNormal];
-
- _cancelView.leftBtnCallback = ^{
- eventActivityVController *control = [[eventActivityVController alloc] init];
- control.activityId = weakSelf.newsId;
- [weakSelf.navigationController pushViewController:control animated:YES];
- // [weakSelf.cancelView removeFromSuperview];
- };
- // _cancelView.rightBtnCallback = ^{
- // joinAllianceVController *joinVC = [[joinAllianceVController alloc]init];
- // joinVC.phone = weakSelf.userInfoModel.phone;
- // joinVC.model = weakSelf.userInfoModel;
- // [weakSelf.navigationController pushViewController:joinVC animated:YES];
- //
- // };
- }
- return _cancelView;
- }
- - (OrderAirportPayCancelView*)vipContinueView{
- WS(weakSelf);
- if (!_vipContinueView) {
- _vipContinueView = [[NSBundle mainBundle]loadNibNamed:@"OrderAirportPayCancelView" owner:self options:nil].firstObject;
- _vipContinueView.frame = self.view.bounds;
- // _cancelView.isFromOrder = self.isFromOrder;
- _vipContinueView.tipLabel.hidden = YES;
- _vipContinueView.contentLabel.hidden = YES;
- _vipContinueView.titleLabel.text = @"您的会员已经到期";
- _vipContinueView.titleLabelTop.constant = 35;
- [_vipContinueView.rightBtn setBackgroundColor:[UIColor colorWithHexValue:0x3C915C]];
- [_vipContinueView.leftBtn setTitle:@"待会再说" forState:UIControlStateNormal];
- [_vipContinueView.rightBtn setTitle:@"申请续费" forState:UIControlStateNormal];
-
- _vipContinueView.leftBtnCallback = ^{
- [weakSelf.cancelView removeFromSuperview];
- };
- // _vipContinueView.rightBtnCallback = ^{
- // if ([weakSelf.userInfoModel.level isEqualToString:@"3"]){
- // applyForDirectorController *applyFor = [[applyForDirectorController alloc]init];
- // applyFor.model = self.userInfoModel;
- // [self.navigationController pushViewController:applyFor animated:YES];
- // }else{
- // VIPXuFeiController *control = [[VIPXuFeiController alloc] init];
- // [weakSelf.navigationController pushViewController:control animated:YES];
- // }
- // };
- }
- return _vipContinueView;
- }
- -(void)isSpeicialStatus{
- // kWeakSelf(self);
- //
- // [ProgressHUD show];
- //
- // _sessionManager =[[HttpRequestManger alloc]init];
- //
- // [_sessionManager sendPostHttpRequestWithUrl:getMemberInfo params:nil bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- //
- // [ProgressHUD hide];
- //
- // NSLog(@"%@",response);
- //
- // NSDictionary *dic = [response objectForKeySafely:@"memberInfo"];
- //
- // weakself.userInfoModel = [UserInfoModel mj_objectWithKeyValues:dic];
- // //判断是否会员到期
- // if ([weakself.userInfoModel.term isEqualToString:@"2"]){
- //
- // UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
- //
- // [window addSubview: weakself.vipContinueView];
- // }else{
- // if ([weakself.userInfoModel.level isEqualToString:@"1"]||[weakself.userInfoModel.level isEqualToString:@"2"]||[weakself.userInfoModel.level isEqualToString:@"3"]){
- //
- // //是会员的话 走 loadActivityStatus 方法
- // [self loadActivityStatus];
- //
- // }else{
- // //弹窗
- // UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
- //
- // [window addSubview: weakself.cancelView];
- // }
- // }
- //
- //
- // } failure:^(NSError *error) {
- // NSLog(@"%@",error);
- // [ProgressHUD hide];
- // }];
- }
- -(void)loadActivityStatus{
-
- WS(weakSelf)
- [ProgressHUD show];
- _sessionManager = [[HttpRequestManger alloc] init];
- NSMutableDictionary *parma = [NSMutableDictionary dictionary];
- parma[@"id"] = weakSelf.newsId;
-
- [self.sessionManager sendPostHttpRequestWithUrl:isSignUp params:parma bodyBlock:nil progress:nil success:^(NSDictionary *response) {
- [ProgressHUD hide];
- NSLog(@"%@",response);
- NSString *flag = [NSString stringWithFormat:@"%@",response[@"flag"]];
- if ([flag isEqualToString:@"0"]) {
- eventActivityVController *control = [[eventActivityVController alloc] init];
- control.activityId = weakSelf.newsId;
- [self.navigationController pushViewController:control animated:YES];
- }else{
- [ToastView showToast:@"已报名该活动,不能重复报名"];
- }
- // }else{
- //
- // [ToastView showToast:@"请不要重复报名"];
- // }
-
- } failure:^(NSError *error) {
- [ProgressHUD hide];
- NSLog(@"%@",error);
- }];
-
- }
- - (void)dealloc {
- if (_sessionManager) {
- [_sessionManager cancelAllTask];
- }
- DebugLog(@"%@没有造成循环引用", [self class]);
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|