// // HomerModelDetailHeaderCell.m // iSales-HOMER // // Created by Jack on 2017/10/25. // Copyright © 2017年 United Software Applications, Inc. All rights reserved. // #import "HomerModelDetailHeaderCell.h" #import "RANetwork.h" #import "MainViewController.h" #import "LoginViewController.h" #import "ContactListViewController.h" #import "RAUtils.h" #import "OrderListViewController.h" #import "ImageScrollerViewController.h" #import "CartUtils.h" #import "CustomIOSAlertView.h" #import "TextUtils.h" #import "ContentPreviewController.h" #import "DetailViewController.h" @implementation HomerModelDetailHeaderCell @synthesize celldelegate; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void)awakeFromNib { [super awakeFromNib]; self.quantity_text.delegate = self; // MDHTMLLabelVerticalAlignmentCenter = 0, // MDHTMLLabelVerticalAlignmentTop = 1, self.informationLabel.numberOfLines = 0; // self.informationLabel.verticalAlignment=MDHTMLLabelVerticalAlignmentTop; // self.informationLabel.backgroundColor = [UIColor yellowColor]; // self.selector_Button.layer.borderWidth = 0.5; // self.selector_Button.layer.borderColor = [[UIColor lightGrayColor] CGColor]; // self.selector_Button.layer.cornerRadius = 0; [self.descriptionRTLabel setLineBreakMode: RTTextLineBreakModeWordWrapping]; [self.descriptionRTLabel setTextAlignment:RTTextAlignmentCenter]; [self.descriptionRTLabel setFont:[UIFont systemFontOfSize:22]]; [self addObserver:self forKeyPath:@"stack_contents" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:@"content changed"]; self.inforframe=self.informationLabel.frame.size; // [self generate_information]; } -(void) dealloc { [self removeObserver:self forKeyPath:@"stack_contents"]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { // if([keyPath isEqualToString:@"stack_contents"]) // { // [self.playerView stopVideo]; // // self.playerView.hidden=true; // // } if([keyPath isEqualToString:@"stack_contents"]) { [self.ytplayerView stopVideo]; self.ytplayerView.hidden=true; } } - (void)layoutSubviews { [super layoutSubviews]; // [self generate_information]; } -(void) generate_information { NSMutableArray* arr_addr = [[NSMutableArray alloc] init]; [arr_addr addObject:[NSString stringWithFormat:@"Availability: %@",self.count_Label.text]]; if(self.incomingcount_Label.text.length>0) [arr_addr addObject:[NSString stringWithFormat:@" Incoming stock: %@",self.incomingcount_Label.text]]; if(self.etaval_label.text.length>0) [arr_addr addObject:[NSString stringWithFormat:@" Arrival Date: %@",self.etaval_label.text]]; [arr_addr addObject:[NSString stringWithFormat:@"Availability in 7-10 days: %@",self.hmlg_stock_count_lb.text]]; if(self.cqyt_label.text.length>0) [arr_addr addObject:[NSString stringWithFormat:@"%@",self.cqyt_label.text]]; NSString * information_str = [RAConvertor arr2string:arr_addr separator:@"
" trim:true]; // UIFont *font=[UIFont systemFontOfSize:14]; //// label.font=font; NSDictionary *optoins=@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType}; NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[information_str dataUsingEncoding:NSUnicodeStringEncoding] options:optoins documentAttributes:nil error:nil]; // self.informationLabel.numberOfLines // self.informationLabel.lineBreakMode // // self.informationLabel.adjustsFontSizeToFitWidth = YES; // self.informationLabel.minimumFontSize = 0.5; self.informationLabel.attributedText=attrStr; // self.informationLabel.text = @"文字在语言学中指书面语的视觉形式,古代把独体字叫做“文”,把合体字叫做“字”,如今联合起来叫做“文字”,文字的基本个体叫做“字”。在日常生活中,"; // [self.informationLabel sizeToFit]; // CGSize inforsize=[self.informationLabel sizeThatFits:self.informationLabel.frame.size]; // CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrStr); // //计算文本绘制size ,这里300是文字宽度,你可以自己更改为247,但是要记得,在height 方法里的这个位置,也改为247 // CGSize tmpSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0,0), NULL, CGSizeMake(self.informationLabel.frame.size.width, MAXFLOAT), NULL); // // // // CFRelease(framesetter); // CGSize lblSize = [self.informationLabel.text boundingRectWithSize:self.informationLabel.frame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size; // self.informationLabel.frame = CGRectMake(self.informationLabel.frame.origin.x, self.informationLabel.frame.origin.y, tmpSize.width, tmpSize.height); // [self.informationLabel sizeToFit]; UILabel* textLabel = [UILabel new]; textLabel.attributedText = attrStr; textLabel.numberOfLines = 0; textLabel.lineBreakMode = NSLineBreakByWordWrapping; // [textLabel sizeToFit]; CGSize newsize = [textLabel sizeThatFits:self.inforframe]; float new_height=newsize.height0) { UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"QTY: %d of this model already in cart. Continue ?",self.cqty] message:nil preferredStyle:UIAlertControllerStyleAlert]; //block代码块取代了delegate UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { int c=self.cqty+count; int m=c%self.step; if(m!=0&&appDelegate.alert_sold_in_quantities) { UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert]; //block代码块取代了delegate UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text]; dispatch_async(dispatch_get_main_queue(), ^{ if([[return_json valueForKey:@"result"] intValue]==2) { // NSString* order_code = [return_json valueForKey:@"order_code"]; #ifdef RA_NOTIFICATION [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA]; #else AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false]; [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false]; #endif if(self.shopCartBlock!=nil) { UIImage* img=[self photoStackView:self.photoStack photoForIndex:0]; CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100); UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect]; iv.image = img; // [self.contentView addSubview:iv]; self.shopCartBlock(iv); self.cqty +=count; if(self.set_cqty) self.set_cqty(self.cqty); } } else { UIViewController *vc= [RAUtils getViewController:self]; NSString *msg = [return_json valueForKey:@"err_msg"]; NSString *title = @"Add To Cart"; if ([msg hasPrefix:@"Out of Stock.\n"]) { title = @"Add To Cart: Out of Stock"; msg = [msg substringFromIndex:[@"Out of Stock.\n" length]]; self.btnNotifyMe.enabled = YES; self.btnaddCart.enabled = NO; } [RAUtils message_alert:msg title:title controller:vc] ; } }); }); }]; UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { DebugLog(@"No"); }]; [alertControl addAction:actionOne]; [alertControl addAction:alertthree]; //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField) UIViewController *vc= [RAUtils getViewController:self]; [vc presentViewController:alertControl animated:YES completion:nil]; } else { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text]; dispatch_async(dispatch_get_main_queue(), ^{ if([[return_json valueForKey:@"result"] intValue]==2) { // NSString* order_code = [return_json valueForKey:@"order_code"]; #ifdef RA_NOTIFICATION [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA]; #else AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false]; [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false]; #endif if(self.shopCartBlock!=nil) { UIImage* img=[self photoStackView:self.photoStack photoForIndex:0]; CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100); UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect]; iv.image = img; // [self.contentView addSubview:iv]; self.shopCartBlock(iv); self.cqty +=count; if(self.set_cqty) self.set_cqty(self.cqty); } } else { UIViewController *vc= [RAUtils getViewController:self]; NSString *msg = [return_json valueForKey:@"err_msg"]; NSString *title = @"Add To Cart"; if ([msg hasPrefix:@"Out of Stock.\n"]) { title = @"Add To Cart: Out of Stock"; msg = [msg substringFromIndex:[@"Out of Stock.\n" length]]; self.btnNotifyMe.enabled = YES; self.btnaddCart.enabled = NO; } [RAUtils message_alert:msg title:title controller:vc] ; } }); }); } }]; UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { DebugLog(@"No"); }]; [alertControl addAction:actionOne]; [alertControl addAction:alertthree]; //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField) UIViewController *vc= [RAUtils getViewController:self]; [vc presentViewController:alertControl animated:YES completion:nil]; } else { int c=self.cqty+count; int m=c%self.step; if(m!=0&&appDelegate.alert_sold_in_quantities) { UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert]; //block代码块取代了delegate UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text]; dispatch_async(dispatch_get_main_queue(), ^{ if([[return_json valueForKey:@"result"] intValue]==2) { // NSString* order_code = [return_json valueForKey:@"order_code"]; #ifdef RA_NOTIFICATION [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA]; #else AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false]; [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false]; #endif if(self.shopCartBlock!=nil) { UIImage* img=[self photoStackView:self.photoStack photoForIndex:0]; CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100); UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect]; iv.image = img; // [self.contentView addSubview:iv]; self.shopCartBlock(iv); self.cqty +=count; if(self.set_cqty) self.set_cqty(self.cqty); } } else { UIViewController *vc= [RAUtils getViewController:self]; NSString *msg = [return_json valueForKey:@"err_msg"]; NSString *title = @"Add To Cart"; if ([msg hasPrefix:@"Out of Stock.\n"]) { title = @"Add To Cart: Out of Stock"; msg = [msg substringFromIndex:[@"Out of Stock.\n" length]]; self.btnNotifyMe.enabled = YES; self.btnaddCart.enabled = NO; } [RAUtils message_alert:msg title:title controller:vc] ; } }); }); }]; UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { DebugLog(@"No"); }]; [alertControl addAction:actionOne]; [alertControl addAction:alertthree]; //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField) UIViewController *vc= [RAUtils getViewController:self]; [vc presentViewController:alertControl animated:YES completion:nil]; } else { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text]; dispatch_async(dispatch_get_main_queue(), ^{ if([[return_json valueForKey:@"result"] intValue]==2) { // NSString* order_code = [return_json valueForKey:@"order_code"]; #ifdef RA_NOTIFICATION [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA]; #else AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false]; [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false]; #endif if(self.shopCartBlock!=nil) { UIImage* img=[self photoStackView:self.photoStack photoForIndex:0]; CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100); UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect]; iv.image = img; // [self.contentView addSubview:iv]; self.shopCartBlock(iv); self.cqty +=count; if(self.set_cqty) self.set_cqty(self.cqty); } } else { UIViewController *vc= [RAUtils getViewController:self]; NSString *msg = [return_json valueForKey:@"err_msg"]; NSString *title = @"Add To Cart"; if ([msg hasPrefix:@"Out of Stock.\n"]) { title = @"Add To Cart: Out of Stock"; msg = [msg substringFromIndex:[@"Out of Stock.\n" length]]; self.btnNotifyMe.enabled = YES; self.btnaddCart.enabled = NO; } [RAUtils message_alert:msg title:title controller:vc] ; } }); }); } } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (IBAction)selectorOnClick:(id)sender { DebugLog(@"select click"); [celldelegate SelectorClicked:(UIButton*) sender]; // [self performSegueWithIdentifier:@"selector_popover" sender:self]; } #pragma mark - #pragma mark Deck DataSource Protocol Methods -(NSUInteger)numberOfPhotosInPhotoStackView:(PhotoStackView *)photoStack { return [self.photos count]; } -(UIImage *)photoStackView:(PhotoStackView *)photoStack photoForIndex:(NSUInteger)index { if(self.photos.count==0) return nil; return [self.photos objectAtIndex:index]; } #pragma mark - #pragma mark Deck Delegate Protocol Methods -(void)photoStackView:(PhotoStackView *)photoStackView willStartMovingPhotoAtIndex:(NSUInteger)index { // User started moving a photo } -(void)photoStackView:(PhotoStackView *)photoStackView willFlickAwayPhotoFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex { // User flicked the photo away, revealing the next one in the stack } -(void)photoStackView:(PhotoStackView *)photoStackView didRevealPhotoAtIndex:(NSUInteger)index { self.pageControl.currentPage = index; } - (UIView *)createVideoView:(NSString*) videoID { UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 640, 360)]; // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)]; // [imageView setImage:[UIImage imageNamed:@"demo"]]; UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 620, 10)]; titleLabel.font = [UIFont boldSystemFontOfSize:20]; titleLabel.text=@"a separated player will show here:"; titleLabel.numberOfLines = 0; titleLabel.lineBreakMode =NSLineBreakByWordWrapping; // titleLabel.textAlignment = NSTextAlignmentRight; titleLabel.textAlignment = NSTextAlignmentCenter; CGSize constraintkey = CGSizeMake(620, 20000.0f);//key label width is 40% cell width; CGSize sizetitle = [@"a separated player will show here:" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping]; //[titleLabel sizeToFit]; // titleLabel.center.x = demoView.center.x; titleLabel.frame = CGRectMake(10, 10, 620, sizetitle.height); [demoView addSubview:titleLabel]; UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 610, 10)]; lineLabel.font = [UIFont boldSystemFontOfSize:17]; lineLabel.text=videoID; lineLabel.numberOfLines = 0; lineLabel.lineBreakMode =NSLineBreakByWordWrapping; CGSize sizemsg = [videoID sizeWithFont:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping]; lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 630, sizemsg.height); //[lineLabel sizeToFit]; [demoView addSubview:lineLabel]; demoView.frame = CGRectMake(0, 0, 640, lineLabel.frame.origin.y+lineLabel.frame.size.height+25); return demoView; } -(void)photoStackView:(PhotoStackView *)photoStackView didSelectPhotoAtIndex:(NSUInteger)index { DebugLog(@"selected %lu", (unsigned long)index); NSDictionary* item= self.stack_contents[[NSString stringWithFormat:@"item_%ld",index]]; if([item[@"type"] isEqualToString:@"video"]) { NSString* video_code=item[@"code"]; // [TextUtils expression_varable:video regex:<#(NSString *)#>] // // NSString* video_id=[self.playerView Embed2VID:video_code]; // // NSDictionary *playerVars = @{ // @"playsinline" : @1, // @"autoplay" : @(1), // @"rel":@0, // @"showinfo": @0, // @"modestbranding":@0, // @"enablejsapi":@1 // }; // [self.playerView loadWithVideoId:video_id playerVars:playerVars]; // for(UIView *v in self.playerView.subviews) // { // if([v isKindOfClass:[UIButton class] ]) // [self.playerView bringSubviewToFront:v]; // } // self.playerView.webView.allowsPictureInPictureMediaPlayback=false; // self.playerView.hidden=false; [self.ytplayerView LoadWithVid:video_code]; for(UIView *v in self.ytplayerView.subviews) { if([v isKindOfClass:[UIButton class] ]) [self.ytplayerView bringSubviewToFront:v]; } self.ytplayerView.hidden=false; return; return; } else { if ([[self.stack_contents objectForKey:@"count"] integerValue] == 0) { return; } ContentPreviewController *preVC = [[UIStoryboard storyboardWithName:@"PhotoList" bundle:nil] instantiateViewControllerWithIdentifier:@"ContentPreviewController"]; preVC.content = self.stack_contents; // preVC.currentIndex = index; [preVC setOffset:index]; UIViewController *superVC= [RAUtils getViewController:self]; [superVC.navigationController pushViewController:preVC animated:true]; return; } // } // 调用展示窗口 ImageScrollerViewController *imgShow = [[ImageScrollerViewController alloc] initWithSourceData:[self.photos mutableCopy] withIndex:index]; UIViewController *vc= [RAUtils getViewController:self]; [vc.navigationController pushViewController:imgShow animated:true]; } -(void) neworder { UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order"]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSDictionary* return_json = [RANetwork new_Order]; dispatch_async(dispatch_get_main_queue(), ^{ [waitalert dismissViewControllerAnimated:YES completion:^{ if([[return_json valueForKey:@"result"] intValue]==2) { int result=[[return_json valueForKey:@"result"] intValue]; if(result==2) { //successed. NSString* order_code = [return_json valueForKey:@"orderCode"]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.order_code = order_code; int count=[self.quantity_text.text intValue]; [self addtocart:count]; } } else { UIViewController *vc= [RAUtils getViewController:self]; NSString *msg = [return_json valueForKey:@"err_msg"]; NSString *title = @"Add To Cart"; if ([msg hasPrefix:@"Out of Stock.\n"]) { title = @"Add To Cart: Out of Stock"; msg = [msg substringFromIndex:[@"Out of Stock.\n" length]]; self.btnNotifyMe.enabled = YES; self.btnaddCart.enabled = NO; } [RAUtils message_alert:msg title:title controller:vc] ; } }]; }); }); } #pragma mark - UIAlertViewDelegate // Called when a button is clicked. The view will be automatically dismissed after this call returns - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; if(alertView.tag==1234)//库存小于0 { // availability warring; int count=[self.quantity_text.text intValue]; if(buttonIndex!=alertView.cancelButtonIndex) { if(appDelegate.order_code==nil) { [self neworder]; } else { [self addtocart:count]; } } return; } // int count=[self.quantity_text.text intValue]; MainViewController* main_vc=(MainViewController*)appDelegate.main_vc; if(buttonIndex==alertView.cancelButtonIndex) { } else if(buttonIndex==1) { //open exist UIViewController *vc= [RAUtils getViewController:self]; OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"]; ovc.showNavibar = true; ovc.selectOrder = ^(NSMutableDictionary* order_detail){ if(appDelegate.order_code==nil) { [self neworder]; } else { if(self.set_update_data) self.set_update_data(true); int model_count = [[order_detail valueForKey:@"model_count"] intValue]; for(int i=0;i availability) { self.btnaddCart.enabled = NO; self.btnNotifyMe.enabled = YES; } else { self.btnaddCart.enabled = YES; self.btnNotifyMe.enabled = NO; } } else { // 打开订单状态 if (![RASingleton sharedInstance].currentOrderIsMerged) { // Shop Order self.btnaddCart.enabled = YES; // 默认未缺货 self.btnNotifyMe.enabled = NO; if ((buyQty + cartQty) > availability) { // 缺货 self.btnNotifyMe.enabled = YES; } } else { // Purchase Order if ((buyQty + cartQty) > availability) { // 缺货 self.btnaddCart.enabled = NO; self.btnNotifyMe.enabled = YES; } else { // 未缺货 self.btnNotifyMe.enabled = NO; self.btnaddCart.enabled = YES; } } } } else { // empoyee if ((buyQty + cartQty) > availability) { // 缺货 self.btnaddCart.enabled = NO; self.btnNotifyMe.enabled = YES; } else { // 未缺货 self.btnNotifyMe.enabled = NO; self.btnaddCart.enabled = YES; } } //#endif } - (IBAction)introduceBtnClick:(UIButton *)sender { if (self.introduceBlock) { self.introduceBlock(sender); } } - (IBAction)descriptionBtnClick:(UIButton *)sender { if (self.descriptionBlock) { self.descriptionBlock(sender); } } - (IBAction)OnClosePlayer:(id)sender { // [self.playerView stopVideo]; // // self.playerView.hidden=true; [self.ytplayerView stopVideo]; self.ytplayerView.hidden=true; } - (IBAction)noLoginBtnClick:(UIButton *)sender { UIApplication * app = [UIApplication sharedApplication]; AppDelegate *appDelegate = (AppDelegate *)[app delegate]; MainViewController* main_vc=(MainViewController*)appDelegate.main_vc; if(appDelegate.bLogin==false) { DetailViewController *vc= (DetailViewController *)[RAUtils getViewController:self]; LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"]; loginvc.returnValue = ^(bool blogin){ if(blogin) { [vc reload]; [main_vc checklogin:true]; } }; UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ; navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种 [vc presentViewController:navi animated:YES completion:^{ }]; } } @end