| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250 |
- //
- // 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];
- 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
- {
-
- 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
- {
- 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 cursomer 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
|