| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255 |
- //
- // DetailHeaderCell.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 14-6-5.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "DetailHeaderCell.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"
- #import "RAPDFViewController.h"
- @implementation DetailHeaderCell
- @synthesize celldelegate;
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- // Initialization code
- }
-
- // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
- // self.selector_imageView.layer.borderWidth = 1;
- return self;
- }
- - (void)awakeFromNib
- {
- [super awakeFromNib];
- #ifdef BUILD_UWAVER
- // self.addPortfolioBtn.title = @"Add to Hang Tag";
- self.btn_hangtag.hidden=false;
- #else
-
- self.btn_hangtag.hidden=true;
- #endif
-
-
- // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
- // self.selector_imageView.layer.borderWidth = 1;
-
- self.quantity_text.delegate = self;
-
- 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.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
- // self.label_net_err.layer.borderWidth = 2.0;
- // self.label_net_err.layer.cornerRadius=15;
- // self.label_net_err.layer.masksToBounds=true;
- // Initialization code
-
- [self addObserver:self
- forKeyPath:@"stack_contents"
- options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
- context:@"content changed"];
-
-
- }
- -(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.ytplayerView stopVideo];
-
- self.ytplayerView.hidden=true;
-
- }
- }
- - (IBAction)create_HangTag:(id)sender {
-
- // DetailViewController *vc= (DetailViewController *)[RAUtils getViewController:self];
- //
- // NSString *catelog_name = [NSString stringWithFormat:@"%@ Hang Tag",vc.groupName];
- //
- // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Processing"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork request_hangTag:vc.groupName];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // NSString* url = [editor_json valueForKey:@"pdf_path"];
- // bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
- // RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
- // ViewController.url = url;
- // ViewController.canSave = false;
- // ViewController.isLocalfile=isLocalFile;
- //
- // ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
- //
- //
- // NSString* company= [appDelegate.customerInfo valueForKey:@"customer_name"];
- //
- // if(company==nil)
- // company=@"";
- //
- // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
- //
- //
- // NSMutableArray* send_to = [[NSMutableArray alloc]init];
- // if(customer_email.length>0)
- // {
- // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- // }
- // ViewController.mail_to = send_to;
- //
- // NSString* subject;
- //
- // subject =catelog_name;
- //
- // ViewController.mail_subject = subject;
- //
- // ViewController.hidenavi = false;
- // [vc.navigationController pushViewController:ViewController animated:YES];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Hang Tag" controller:vc];
- // }
- //
- // });
- // });
- //
- //
- }
- - (IBAction)add_toPortfolio:(id)sender {
-
- // int count=[self.quantity_text.text intValue];
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- [[NSNotificationCenter defaultCenter] postNotificationName:No_Rights_Notification object:nil];
- return;
- }
-
-
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- if(appDelegate.bLogin==false)
- {
- UIViewController *vc= [RAUtils getViewController:self];
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-
- loginvc.returnValue = ^(bool blogin){
-
-
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
-
-
-
- if(blogin)
- {
-
- if(self.set_update_data)
- self.set_update_data(true);
-
- [main_vc checklogin:true];
-
- [RANetwork request_addto_portfolio:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* return_json =result;
-
-
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
- // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- #endif
-
- if(self.WatchlistBlock!=nil)
- {
- UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-
-
- CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
- UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- iv.image = img;
- // [self.contentView addSubview:iv];
- self.PortfolioBlock(iv);
-
- }
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
- }
-
-
-
-
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- //#endif
- //
- // if(self.WatchlistBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.PortfolioBlock(iv);
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
- // }
- //
- //
- //
- // });
- // });
-
-
- }
-
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- // [self loadpage];
- //
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [vc presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"LoginViewController present.........");
-
- // self.btop = false;
- // <#code#>
- }];
- }
- else
- {
- [RANetwork request_addto_portfolio:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* return_json =result;
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- #endif
- if(self.WatchlistBlock!=nil)
- {
- UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-
-
- CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
- UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- iv.image = img;
- // [self.contentView addSubview:iv];
- self.PortfolioBlock(iv);
-
- }
- }
- else
- {
- UIViewController *vc= [RAUtils getViewController:self];
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
- }
-
-
-
- }];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- //#endif
- // if(self.WatchlistBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.PortfolioBlock(iv);
- //
- // }
- // }
- // else
- // {
- // UIViewController *vc= [RAUtils getViewController:self];
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
- // }
- //
- //
- //
- // });
- // });
- }
- }
- - (IBAction)add_toWatchList:(id)sender {
-
- // int count=[self.quantity_text.text intValue];
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- if(appDelegate.bLogin==false)
- {
- UIViewController *vc= [RAUtils getViewController:self];
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-
- loginvc.returnValue = ^(bool blogin){
-
-
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
-
-
-
- if(blogin)
- {
-
- if(self.set_update_data)
- self.set_update_data(true);
-
- [main_vc checklogin:true];
-
- [RANetwork request_addto_wishlist:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* return_json =result;
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
- // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- #endif
-
- if(self.WatchlistBlock!=nil)
- {
- UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-
-
- CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
- UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- iv.image = img;
- // [self.contentView addSubview:iv];
- self.WatchlistBlock(iv);
-
- }
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
- }
-
-
-
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- //#endif
- //
- // if(self.WatchlistBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.WatchlistBlock(iv);
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
- // }
- //
- //
- //
- // });
- // });
-
-
- }
-
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- // [self loadpage];
- //
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [vc presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"LoginViewController present.........");
-
- // self.btop = false;
- // <#code#>
- }];
- }
- else
- {
- [RANetwork request_addto_wishlist:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* return_json =result;
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- #endif
-
- if(self.WatchlistBlock!=nil)
- {
- UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-
-
- CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
- UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- iv.image = img;
- // [self.contentView addSubview:iv];
- self.WatchlistBlock(iv);
-
- }
- }
- else
- {
- UIViewController *vc= [RAUtils getViewController:self];
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
- }
-
-
-
- }];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
- //#endif
- //
- // if(self.WatchlistBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.WatchlistBlock(iv);
- //
- // }
- // }
- // else
- // {
- // UIViewController *vc= [RAUtils getViewController:self];
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
- // }
- //
- //
- //
- // });
- // });
- }
- }
- - (IBAction)add_toCart:(id)sender {
-
- [CartUtils add_to_cart:[RAUtils getViewController:self] selectorholder:self selector:@selector(addtocart)];
- return;
- //
- //
- // int count=[self.quantity_text.text intValue];
- //
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // if(appDelegate.bLogin==false)
- // {
- // UIViewController *vc= [RAUtils getViewController:self];
- // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // // loginvc.delegate = self;
- // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- //
- // loginvc.returnValue = ^(bool blogin){
- //
- //
- // // UIApplication * app = [UIApplication sharedApplication];
- // // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //
- //
- //
- //
- // if(blogin)
- // {
- // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
- // {
- // if(self.set_update_data)
- // self.set_update_data(true);
- // [main_vc checklogin:false];
- //
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"Do you want to add to pending a order or a new order", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
- //
- //
- //
- // // alert.
- // [alert show];
- // }
- // else
- // {
- // [main_vc checklogin:true];
- //
- // int c=[self.count_Label.text intValue];
- // DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
- //
- // NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
- //
- //
- //
- // if(!appDelegate.can_create_backorder && c<count)
- // {
- //
- // NSString *msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
- //
- // // alert.
- //
- // alert.tag = 1234;
- // [alert show];
- // }
- // else
- // {
- // if(appDelegate.order_code==nil)
- // [ self neworder];
- // else
- // [self addtocart:count];
- // }
- //
- //
- // }
- // }
- //
- // // self.offset = 0;
- // // [self.content_data removeAllObjects];
- // // [self loadpage];
- // //
- // // [[self navigationController] setNavigationBarHidden:YES animated:NO];
- //
- // };
- //
- // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
- //
- //
- //
- //
- //
- // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
- //
- // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- // [vc presentViewController:navi animated:YES completion:^{
- //
- // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
- //
- // DebugLog(@"LoginViewController present.........");
- //
- // // self.btop = false;
- // // <#code#>
- // }];
- // }
- // else
- // {
- //
- //// if(appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&appDelegate.order_code==nil)
- // if(appDelegate.order_code==nil)
- // {
- // [main_vc checklogin:false];
- //
- // if(appDelegate.can_create_order)
- // {
- // NSString* msg =@"";
- // if(appDelegate.contact_id.length>0)
- // {
- // msg = [msg stringByAppendingString:@"\n\nCustomer:"];
- // msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
- //
- // }
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
- //
- // // alert.
- // [alert show];
- // }
- // else
- // {
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"Do you want to add to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
- //
- // // alert.
- // [alert show];
- // }
- // }
- // else
- // {
- //
- //// if ([self.priceLabel.text isEqualToString:@"No Price."])
- //// {
- ////// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Model No Price" message:@"Cannot add model without price." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //////
- //////
- //////
- ////// [alert show];
- ////
- ////
- ////
- //// [RAUtils alert_view:@"Cannot add model without price." title:@"Model No Price."];
- //// }
- //// else
- // {
- //
- // int c=[self.count_Label.text intValue];
- // DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
- //
- // NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
- //
- //
- //
- // if(c<count)
- // {
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Confirm add to cart. ", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Confirm", nil), nil];
- //
- // // alert.
- //
- // alert.tag = 1234;
- // [alert show];
- // }
- // else
- // {
- // if(appDelegate.order_code==nil)
- // [ self neworder];
- // else
- // [self addtocart:count];
- // }
- // }
- //
- // }
- // }
- //
- //
- //
- //
- //
- //
- //
- //
- }
- -(void) addtocart
- {
- int count=[self.quantity_text.text intValue];
-
- #ifdef MPACK
-
- if (count % self.step != 0) {
- UIViewController *vc= [RAUtils getViewController:self];
- [RAUtils message_alert:[NSString stringWithFormat:@"Sold in quantities of %d",(int)(self.stepper.stepValue)] title:@"Add to cart" controller:vc];
- return;
- }
-
- #endif
-
- int c=[self.count_Label.text intValue];
- DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
-
- NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
-
-
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- if(/*c<count*/!appDelegate.can_create_backorder && c == 0)
- {
-
- NSString *msg = nil;
- BOOL continueAdd = YES;
- // #if defined(BUILD_NPD) || defined(BUILD_USAI)
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
-
- if ([RASingleton sharedInstance].currentOrderIsMerged) { // Purchase Order不允许购买数量大于库存
- msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.",COMPANY_SHORT_NAME];
- continueAdd = NO;
- } else { // Shop Order购买数量大于库存需要确认
- msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
- continueAdd = YES;
- }
- }
- if (appDelegate.user_type == USER_ROLE_EMPLOYEE) { // Employee不允许购买数量大于库存
- msg = @"Item is OUT OF STOCK and not available to order.";
- continueAdd = NO;
- }
- // #endif
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:msg preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- if (continueAdd) {
- [self addtocart:count];
- }
- }];
-
- [alertControl addAction:alertthree];
-
-
- UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- }];
- if (continueAdd) {
- [alertControl addAction:alertcancel];
- }
- UIViewController *vc= [RAUtils getViewController:self];
-
-
- [vc presentViewController:alertControl animated:YES completion:nil];
- }
- else
- {
- [self addtocart:count];
- }
-
-
-
-
- }
- -(void)Hide_selector:(bool) bhide
- {
- self.selector_Button.hidden=bhide;
- self.selector_dorpdown.hidden=bhide;
- self.selector_imageView.hidden=bhide;
-
- }
- -(void) addtocart:(int) count
- {
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- #ifdef MPACK
- if(self.cqty>0)
- {
-
-
- 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) {
- [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
-
- NSDictionary* return_json = result;
-
- 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] ;
- }
-
-
-
-
- }];
-
- // 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
- {
-
- [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
-
- NSDictionary* return_json = result;
-
- 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] ;
- }
-
-
-
-
- }];
- // 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] ;
- // }
- //
- //
- //
- //
- // });
- // });
- }
-
-
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // // NSString* order_code = [return_json valueForKey:@"order_code"];
- // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- //// appDelegate.order_code = order_code;
- ////
- //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //// appDelegate.order_code = order_code;
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- //
- //
- // 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];
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" 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
- #endif
- {
-
-
-
- #ifdef MPACK
- 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) {
-
- [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* return_json =result;
-
-
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- // NSString* order_code = [return_json valueForKey:@"order_code"];
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = order_code;
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = order_code;
- [((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] ;
- }
-
-
-
-
- }];
-
- // 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)
- // {
- //
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // // NSString* order_code = [return_json valueForKey:@"order_code"];
- // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- // // appDelegate.order_code = order_code;
- // //
- // // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.order_code = order_code;
- // [((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
- #endif
- {
- NSString* model_name=self.model_label.text;
-
- [RANetwork request_addto_cart:self.product_id count:count name:model_name completionHandler:^(NSMutableDictionary *result) {
-
- NSDictionary* return_json = result;
-
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
-
- #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] ;
- }
-
-
-
-
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:model_name];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //
- //#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] ;
- // }
- //
- //
- //
- //
- // });
- // });
-
- }
-
-
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // // NSString* order_code = [return_json valueForKey:@"order_code"];
- // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- //// appDelegate.order_code = order_code;
- ////
- //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //// appDelegate.order_code = order_code;
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- //
- //
- // 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];
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" 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];
-
- CGSize sizetitle = [RAUtils sizeWithFont:@"a separated player will show here:" font:[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];
-
-
- CGSize sizemsg = [RAUtils sizeWithFont:videoID font:[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 *)#>]
- // video_code=@"hqNcj6_lYg0";
-
-
- // 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];
- [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;
- } 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;
- }
-
- // NSMutableArray *imgList = [NSMutableArray arrayWithCapacity:_data.count];
- // for (int i = 0; i < _data.count; i++) {
- // UIImage *imgMod = _data[i];
- // [imgList addObject:imgMod];
- // }
-
- // 调用展示窗口
- // ImageScrollerViewController *imgShow = [[ImageScrollerViewController alloc] initWithSourceData:[self.photos mutableCopy] withIndex:index];
- //
- // UIViewController *vc= [RAUtils getViewController:self];
- // [vc.navigationController pushViewController:imgShow animated:true];
- // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:imgShow];
-
- // [self presentViewController:nav animated:YES completion:nil];
- // UIDocumentInteractionController
- // UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
- // preview.delegate = self;
- // [preview presentPreviewAnimated:YES];
- }
- -(void) neworder
- {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:[RAUtils getViewController:self] title:@"Create Order" completion:^{
- [RANetwork request_create_order:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json = result;
-
- [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];
-
-
- // [self ReloadData];
-
-
- // 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);
- //
- // }
-
- }
- }
- 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] ;
- }
- }];
-
-
-
-
-
-
-
-
- }];
- }];
- // 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:nil];
- //
- //
- // 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];
- //
- //
- // // [self ReloadData];
- //
- //
- // // 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);
- // //
- // // }
- //
- // }
- // }
- // 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<model_count;i++)
- // {
- // NSDictionary* item = [order_detail objectForKey:[NSString stringWithFormat:@"item_%d",i]];
- // NSString* product_id = [item valueForKey:@"product_id"];
- // if([product_id isEqualToString:self.product_id])
- // {
- // self.cqty = [[item valueForKey:@"QTY"]intValue];
- // if(self.set_cqty)
- // self.set_cqty(self.cqty);
- // break;
- // }
- //
- // }
- // int count=[self.quantity_text.text intValue];
- // [self addtocart:count];
- // [main_vc checklogin:true];
- //
- //
- // }
- //
- // };
- // ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [main_vc checklogin:true];
- //
- // };
- //
- // [vc.navigationController pushViewController:ovc animated:true];
- // }
- // else
- // {
- // //create new;
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- // UIViewController *vc= [RAUtils getViewController:self];
- //
- //
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- //
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworder];
- //
- // [main_vc checklogin:true];
- // // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
- //
- // //
- // // if(self.returnValue)
- // // self.returnValue(value);
- // };
- //
- // cvc.onCancel = ^(){
- //
- // UIViewController *vc= [RAUtils getViewController:self];
- // [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"New Order" controller:vc];
- //
- // };
- // cvc.onReset = ^(){
- // [main_vc checklogin:true];
- // };
- //
- // [vc.navigationController pushViewController:cvc animated:true];
- // }
- // else
- // {
- // [self neworder];
- // }
- //
- //
- // }
- //}
- - (void)valueChanged:(UIStepper *)sender {
-
-
-
- self.quantity_text.text = [NSString stringWithFormat:@"%d",(int)sender.value ];
-
- [celldelegate stepClicked:(int)sender.value];
- // -(void) stepClicked:(int) value;
-
- // 检查缺货
- // NSString *cartQtyString = nil;
- // if (self.cqyt_label.text) {
- // cartQtyString = [self.cqyt_label.text substringFromIndex:[@"Model QTY in Cart:" length]];
- // }
- //
- // int availability = [self.count_Label.text intValue];
- // int buyQTY = [self.quantity_text.text intValue];
- // int cartQTY = [cartQtyString intValue];
- //
- // [self checkAvailability:availability buyQTY:buyQTY cartQTY:cartQTY];
- }
- #pragma mark -
- #pragma mark Actions
- -(void)ClearPhotos
- {
- NSMutableArray *photosMutable = [self.photos mutableCopy];
- [photosMutable removeAllObjects];
- self.photos = photosMutable;
- [self.photoStack reloadData];
-
- }
- - (void)AddPhoto :(UIImage*)photo {
-
- NSMutableArray *photosMutable = [self.photos mutableCopy];
- [photosMutable addObject:photo];
- self.photos = photosMutable;
- [self.photoStack reloadData];
- self.pageControl.numberOfPages = [self.photos count];
- if(self.photos.count<2-1)//1 for qrcode;
- self.photoStack.showBorder=false;
- else
- self.photoStack.showBorder=true;
-
- }
- #pragma mark -
- #pragma mark Setup
- -(void)setup {
-
-
- // int availability = [self.count_Label.text intValue];
- self.stepper.minimumValue= self.step;
- self.stepper.maximumValue = INTMAX_MAX;
-
-
- self.stepper.stepValue= self.step;
-
- self.stepper.value= self.quantity;
-
-
-
- [self.stepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-
- if(true)//(self.photos==nil)
- {
-
- self.photos = [NSArray array];
- }
- if(true)//(self.photoStack==nil)
- {
- // if(self.photoStack!=nil)
- // [self.photoStack removeFromSuperview];
- // self.photoStack = [[PhotoStackView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
- // self.photoStack.backgroundColor =[UIColor redColor];
- // self.photoStack.center = CGPointMake(self.center.x, 220);
- self.photoStack.dataSource = self;
- self.photoStack.delegate = self;
-
-
- // [self addSubview:self.photoStack];
- self.pageControl.numberOfPages = [self.photos count];
- }
- }
- - (IBAction)notifyMeButtonClicked:(UIButton *)sender {
-
- if (self.notifyMeBlock) {
- self.notifyMeBlock();
- }
-
- }
- #pragma mark - TextField Delegate
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
-
-
-
- NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
- // NSString *cartQtyString = nil;
- // if (self.cqyt_label.text) {
- // cartQtyString = [self.cqyt_label.text substringFromIndex:[@"Model QTY in Cart:" length]];
- // }
-
- // int availability = [self.count_Label.text intValue];
- int buyQTY = [newString intValue];
- // int cartQTY = [cartQtyString intValue];
-
- // [self checkAvailability:availability buyQTY:buyQTY cartQTY:cartQTY];
-
- self.stepper.value = buyQTY;
-
- return YES;
- }
- #pragma mark - Private
- /**检查是否缺货*/
- - (void)checkAvailability:(int)availability buyQTY:(int)buyQty cartQTY:(int)cartQty { // availability不可以通过textField.text取得
-
- //#if defined(BUILD_NPD) || defined(BUILD_USAI)
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- if (!appDelegate.bLogin || buyQty < 1) {
- return;
- }
-
- #ifdef OFFLINE_MODE
- if (appDelegate.offline_mode) {
- return;
- }
- #endif
-
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER) { // customer
-
- if (!appDelegate.order_code) { // 未打开订单状态
-
- if ((buyQty + cartQty) > 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.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
|