DetailHeaderCell.m 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866
  1. //
  2. // DetailHeaderCell.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 14-6-5.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "DetailHeaderCell.h"
  9. #import "RANetwork.h"
  10. #import "MainViewController.h"
  11. #import "LoginViewController.h"
  12. #import "ContactListViewController.h"
  13. #import "RAUtils.h"
  14. #import "OrderListViewController.h"
  15. #import "ImageScrollerViewController.h"
  16. #import "CartUtils.h"
  17. #import "CustomIOSAlertView.h"
  18. #import "TextUtils.h"
  19. #import "ContentPreviewController.h"
  20. #import "DetailViewController.h"
  21. #import "RAPDFViewController.h"
  22. @implementation DetailHeaderCell
  23. @synthesize celldelegate;
  24. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  25. {
  26. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  27. if (self) {
  28. // Initialization code
  29. }
  30. // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
  31. // self.selector_imageView.layer.borderWidth = 1;
  32. return self;
  33. }
  34. - (void)awakeFromNib
  35. {
  36. [super awakeFromNib];
  37. #ifdef BUILD_UWAVER
  38. // self.addPortfolioBtn.title = @"Add to Hang Tag";
  39. self.btn_hangtag.hidden=false;
  40. #else
  41. self.btn_hangtag.hidden=true;
  42. #endif
  43. // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
  44. // self.selector_imageView.layer.borderWidth = 1;
  45. self.quantity_text.delegate = self;
  46. self.selector_Button.layer.borderWidth = 0.5;
  47. self.selector_Button.layer.borderColor = [[UIColor lightGrayColor] CGColor];
  48. self.selector_Button.layer.cornerRadius = 0;
  49. [self.descriptionRTLabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
  50. [self.descriptionRTLabel setTextAlignment:RTTextAlignmentCenter];
  51. [self.descriptionRTLabel setFont:[UIFont systemFontOfSize:22]];
  52. // self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  53. // self.label_net_err.layer.borderWidth = 2.0;
  54. // self.label_net_err.layer.cornerRadius=15;
  55. // self.label_net_err.layer.masksToBounds=true;
  56. // Initialization code
  57. [self addObserver:self
  58. forKeyPath:@"stack_contents"
  59. options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
  60. context:@"content changed"];
  61. }
  62. -(void) dealloc
  63. {
  64. [self removeObserver:self forKeyPath:@"stack_contents"];
  65. }
  66. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  67. {
  68. if([keyPath isEqualToString:@"stack_contents"])
  69. {
  70. [self.ytplayerView stopVideo];
  71. self.ytplayerView.hidden=true;
  72. }
  73. }
  74. - (IBAction)create_HangTag:(id)sender {
  75. // DetailViewController *vc= (DetailViewController *)[RAUtils getViewController:self];
  76. //
  77. // NSString *catelog_name = [NSString stringWithFormat:@"%@ Hang Tag",vc.groupName];
  78. //
  79. // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Processing"];
  80. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  81. //
  82. // NSDictionary* editor_json = [RANetwork request_hangTag:vc.groupName];
  83. //
  84. // dispatch_async(dispatch_get_main_queue(), ^{
  85. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  86. //
  87. //
  88. // if([[editor_json valueForKey:@"result"] intValue]==2)
  89. // {
  90. //
  91. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  92. //
  93. // NSString* url = [editor_json valueForKey:@"pdf_path"];
  94. // bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
  95. // RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  96. // ViewController.url = url;
  97. // ViewController.canSave = false;
  98. // ViewController.isLocalfile=isLocalFile;
  99. //
  100. // ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
  101. //
  102. //
  103. // NSString* company= [appDelegate.customerInfo valueForKey:@"customer_name"];
  104. //
  105. // if(company==nil)
  106. // company=@"";
  107. //
  108. // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  109. //
  110. //
  111. // NSMutableArray* send_to = [[NSMutableArray alloc]init];
  112. // if(customer_email.length>0)
  113. // {
  114. // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  115. // }
  116. // ViewController.mail_to = send_to;
  117. //
  118. // NSString* subject;
  119. //
  120. // subject =catelog_name;
  121. //
  122. // ViewController.mail_subject = subject;
  123. //
  124. // ViewController.hidenavi = false;
  125. // [vc.navigationController pushViewController:ViewController animated:YES];
  126. //
  127. // }
  128. // else
  129. // {
  130. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Hang Tag" controller:vc];
  131. // }
  132. //
  133. // });
  134. // });
  135. //
  136. //
  137. }
  138. - (IBAction)add_toPortfolio:(id)sender {
  139. // int count=[self.quantity_text.text intValue];
  140. UIApplication * app = [UIApplication sharedApplication];
  141. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  142. if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
  143. [[NSNotificationCenter defaultCenter] postNotificationName:No_Rights_Notification object:nil];
  144. return;
  145. }
  146. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  147. if(appDelegate.bLogin==false)
  148. {
  149. UIViewController *vc= [RAUtils getViewController:self];
  150. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  151. // loginvc.delegate = self;
  152. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  153. loginvc.returnValue = ^(bool blogin){
  154. // UIApplication * app = [UIApplication sharedApplication];
  155. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  156. if(blogin)
  157. {
  158. if(self.set_update_data)
  159. self.set_update_data(true);
  160. [main_vc checklogin:true];
  161. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  162. NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
  163. dispatch_async(dispatch_get_main_queue(), ^{
  164. if([[return_json valueForKey:@"result"] intValue]==2)
  165. {
  166. // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  167. #ifdef RA_NOTIFICATION
  168. [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  169. #else
  170. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  171. #endif
  172. if(self.WatchlistBlock!=nil)
  173. {
  174. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  175. CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
  176. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  177. iv.image = img;
  178. // [self.contentView addSubview:iv];
  179. self.PortfolioBlock(iv);
  180. }
  181. }
  182. else
  183. {
  184. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
  185. }
  186. });
  187. });
  188. }
  189. // self.offset = 0;
  190. // [self.content_data removeAllObjects];
  191. // [self loadpage];
  192. //
  193. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  194. };
  195. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  196. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  197. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  198. [vc presentViewController:navi animated:YES completion:^{
  199. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  200. DebugLog(@"LoginViewController present.........");
  201. // self.btop = false;
  202. // <#code#>
  203. }];
  204. }
  205. else
  206. {
  207. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  208. NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
  209. dispatch_async(dispatch_get_main_queue(), ^{
  210. if([[return_json valueForKey:@"result"] intValue]==2)
  211. {
  212. #ifdef RA_NOTIFICATION
  213. [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  214. #else
  215. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  216. #endif
  217. if(self.WatchlistBlock!=nil)
  218. {
  219. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  220. CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
  221. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  222. iv.image = img;
  223. // [self.contentView addSubview:iv];
  224. self.PortfolioBlock(iv);
  225. }
  226. }
  227. else
  228. {
  229. UIViewController *vc= [RAUtils getViewController:self];
  230. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
  231. }
  232. });
  233. });
  234. }
  235. }
  236. - (IBAction)add_toWatchList:(id)sender {
  237. // int count=[self.quantity_text.text intValue];
  238. UIApplication * app = [UIApplication sharedApplication];
  239. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  240. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  241. if(appDelegate.bLogin==false)
  242. {
  243. UIViewController *vc= [RAUtils getViewController:self];
  244. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  245. // loginvc.delegate = self;
  246. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  247. loginvc.returnValue = ^(bool blogin){
  248. // UIApplication * app = [UIApplication sharedApplication];
  249. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  250. if(blogin)
  251. {
  252. if(self.set_update_data)
  253. self.set_update_data(true);
  254. [main_vc checklogin:true];
  255. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  256. NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
  257. dispatch_async(dispatch_get_main_queue(), ^{
  258. if([[return_json valueForKey:@"result"] intValue]==2)
  259. {
  260. // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  261. #ifdef RA_NOTIFICATION
  262. [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  263. #else
  264. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  265. #endif
  266. if(self.WatchlistBlock!=nil)
  267. {
  268. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  269. CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
  270. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  271. iv.image = img;
  272. // [self.contentView addSubview:iv];
  273. self.WatchlistBlock(iv);
  274. }
  275. }
  276. else
  277. {
  278. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
  279. }
  280. });
  281. });
  282. }
  283. // self.offset = 0;
  284. // [self.content_data removeAllObjects];
  285. // [self loadpage];
  286. //
  287. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  288. };
  289. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  290. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  291. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  292. [vc presentViewController:navi animated:YES completion:^{
  293. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  294. DebugLog(@"LoginViewController present.........");
  295. // self.btop = false;
  296. // <#code#>
  297. }];
  298. }
  299. else
  300. {
  301. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  302. NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
  303. dispatch_async(dispatch_get_main_queue(), ^{
  304. if([[return_json valueForKey:@"result"] intValue]==2)
  305. {
  306. #ifdef RA_NOTIFICATION
  307. [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  308. #else
  309. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  310. #endif
  311. if(self.WatchlistBlock!=nil)
  312. {
  313. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  314. CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
  315. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  316. iv.image = img;
  317. // [self.contentView addSubview:iv];
  318. self.WatchlistBlock(iv);
  319. }
  320. }
  321. else
  322. {
  323. UIViewController *vc= [RAUtils getViewController:self];
  324. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
  325. }
  326. });
  327. });
  328. }
  329. }
  330. - (IBAction)add_toCart:(id)sender {
  331. [CartUtils add_to_cart:[RAUtils getViewController:self] selectorholder:self selector:@selector(addtocart)];
  332. return;
  333. //
  334. //
  335. // int count=[self.quantity_text.text intValue];
  336. //
  337. // UIApplication * app = [UIApplication sharedApplication];
  338. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  339. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  340. // if(appDelegate.bLogin==false)
  341. // {
  342. // UIViewController *vc= [RAUtils getViewController:self];
  343. // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  344. // // loginvc.delegate = self;
  345. // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  346. //
  347. // loginvc.returnValue = ^(bool blogin){
  348. //
  349. //
  350. // // UIApplication * app = [UIApplication sharedApplication];
  351. // // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  352. //
  353. //
  354. //
  355. //
  356. // if(blogin)
  357. // {
  358. // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
  359. // {
  360. // if(self.set_update_data)
  361. // self.set_update_data(true);
  362. // [main_vc checklogin:false];
  363. //
  364. //
  365. // 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];
  366. //
  367. //
  368. //
  369. // // alert.
  370. // [alert show];
  371. // }
  372. // else
  373. // {
  374. // [main_vc checklogin:true];
  375. //
  376. // int c=[self.count_Label.text intValue];
  377. // DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  378. //
  379. // NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  380. //
  381. //
  382. //
  383. // if(!appDelegate.can_create_backorder && c<count)
  384. // {
  385. //
  386. // NSString *msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
  387. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
  388. //
  389. // // alert.
  390. //
  391. // alert.tag = 1234;
  392. // [alert show];
  393. // }
  394. // else
  395. // {
  396. // if(appDelegate.order_code==nil)
  397. // [ self neworder];
  398. // else
  399. // [self addtocart:count];
  400. // }
  401. //
  402. //
  403. // }
  404. // }
  405. //
  406. // // self.offset = 0;
  407. // // [self.content_data removeAllObjects];
  408. // // [self loadpage];
  409. // //
  410. // // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  411. //
  412. // };
  413. //
  414. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  415. //
  416. //
  417. //
  418. //
  419. //
  420. // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  421. //
  422. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  423. // [vc presentViewController:navi animated:YES completion:^{
  424. //
  425. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  426. //
  427. // DebugLog(@"LoginViewController present.........");
  428. //
  429. // // self.btop = false;
  430. // // <#code#>
  431. // }];
  432. // }
  433. // else
  434. // {
  435. //
  436. //// if(appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&appDelegate.order_code==nil)
  437. // if(appDelegate.order_code==nil)
  438. // {
  439. // [main_vc checklogin:false];
  440. //
  441. // if(appDelegate.can_create_order)
  442. // {
  443. // NSString* msg =@"";
  444. // if(appDelegate.contact_id.length>0)
  445. // {
  446. // msg = [msg stringByAppendingString:@"\n\nCustomer:"];
  447. // msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  448. //
  449. // }
  450. // 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];
  451. //
  452. // // alert.
  453. // [alert show];
  454. // }
  455. // else
  456. // {
  457. // 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];
  458. //
  459. // // alert.
  460. // [alert show];
  461. // }
  462. // }
  463. // else
  464. // {
  465. //
  466. //// if ([self.priceLabel.text isEqualToString:@"No Price."])
  467. //// {
  468. ////// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Model No Price" message:@"Cannot add model without price." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  469. //////
  470. //////
  471. //////
  472. ////// [alert show];
  473. ////
  474. ////
  475. ////
  476. //// [RAUtils alert_view:@"Cannot add model without price." title:@"Model No Price."];
  477. //// }
  478. //// else
  479. // {
  480. //
  481. // int c=[self.count_Label.text intValue];
  482. // DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  483. //
  484. // NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  485. //
  486. //
  487. //
  488. // if(c<count)
  489. // {
  490. //
  491. // 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];
  492. //
  493. // // alert.
  494. //
  495. // alert.tag = 1234;
  496. // [alert show];
  497. // }
  498. // else
  499. // {
  500. // if(appDelegate.order_code==nil)
  501. // [ self neworder];
  502. // else
  503. // [self addtocart:count];
  504. // }
  505. // }
  506. //
  507. // }
  508. // }
  509. //
  510. //
  511. //
  512. //
  513. //
  514. //
  515. //
  516. //
  517. }
  518. -(void) addtocart
  519. {
  520. int count=[self.quantity_text.text intValue];
  521. #ifdef MPACK
  522. if (count % self.step != 0) {
  523. UIViewController *vc= [RAUtils getViewController:self];
  524. [RAUtils message_alert:[NSString stringWithFormat:@"Sold in quantities of %d",(int)(self.stepper.stepValue)] title:@"Add to cart" controller:vc];
  525. return;
  526. }
  527. #endif
  528. int c=[self.count_Label.text intValue];
  529. DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  530. NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  531. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  532. if(/*c<count*/!appDelegate.can_create_backorder && c == 0)
  533. {
  534. NSString *msg = nil;
  535. BOOL continueAdd = YES;
  536. // #if defined(BUILD_NPD) || defined(BUILD_USAI)
  537. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  538. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  539. if ([Singleton sharedInstance].currentOrderIsMerged) { // Purchase Order不允许购买数量大于库存
  540. msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.",COMPANY_SHORT_NAME];
  541. continueAdd = NO;
  542. } else { // Shop Order购买数量大于库存需要确认
  543. msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
  544. continueAdd = YES;
  545. }
  546. }
  547. if (appDelegate.user_type == USER_ROLE_EMPLOYEE) { // Employee不允许购买数量大于库存
  548. msg = @"Item is OUT OF STOCK and not available to order.";
  549. continueAdd = NO;
  550. }
  551. // #endif
  552. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:msg preferredStyle:UIAlertControllerStyleAlert];
  553. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  554. if (continueAdd) {
  555. [self addtocart:count];
  556. }
  557. }];
  558. [alertControl addAction:alertthree];
  559. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  560. }];
  561. if (continueAdd) {
  562. [alertControl addAction:alertcancel];
  563. }
  564. UIViewController *vc= [RAUtils getViewController:self];
  565. [vc presentViewController:alertControl animated:YES completion:nil];
  566. }
  567. else
  568. {
  569. [self addtocart:count];
  570. }
  571. }
  572. -(void)Hide_selector:(bool) bhide
  573. {
  574. self.selector_Button.hidden=bhide;
  575. self.selector_dorpdown.hidden=bhide;
  576. self.selector_imageView.hidden=bhide;
  577. }
  578. -(void) addtocart:(int) count
  579. {
  580. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  581. if(self.cqty>0)
  582. {
  583. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"QTY: %d of this model already in cart. Continue ?",self.cqty] message:nil preferredStyle:UIAlertControllerStyleAlert];
  584. //block代码块取代了delegate
  585. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  586. int c=self.cqty+count;
  587. int m=c%self.step;
  588. if(m!=0&&appDelegate.alert_sold_in_quantities)
  589. {
  590. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert];
  591. //block代码块取代了delegate
  592. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  593. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  594. NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
  595. dispatch_async(dispatch_get_main_queue(), ^{
  596. if([[return_json valueForKey:@"result"] intValue]==2)
  597. {
  598. // NSString* order_code = [return_json valueForKey:@"order_code"];
  599. #ifdef RA_NOTIFICATION
  600. [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  601. #else
  602. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  603. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  604. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  605. #endif
  606. if(self.shopCartBlock!=nil)
  607. {
  608. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  609. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  610. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  611. iv.image = img;
  612. // [self.contentView addSubview:iv];
  613. self.shopCartBlock(iv);
  614. self.cqty +=count;
  615. if(self.set_cqty)
  616. self.set_cqty(self.cqty);
  617. }
  618. }
  619. else
  620. {
  621. UIViewController *vc= [RAUtils getViewController:self];
  622. NSString *msg = [return_json valueForKey:@"err_msg"];
  623. NSString *title = @"Add To Cart";
  624. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  625. title = @"Add To Cart: Out of Stock";
  626. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  627. self.btnNotifyMe.enabled = YES;
  628. self.btnaddCart.enabled = NO;
  629. }
  630. [RAUtils message_alert:msg title:title controller:vc] ;
  631. }
  632. });
  633. });
  634. }];
  635. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  636. DebugLog(@"No");
  637. }];
  638. [alertControl addAction:actionOne];
  639. [alertControl addAction:alertthree];
  640. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  641. UIViewController *vc= [RAUtils getViewController:self];
  642. [vc presentViewController:alertControl animated:YES completion:nil];
  643. }
  644. else
  645. {
  646. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  647. NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
  648. dispatch_async(dispatch_get_main_queue(), ^{
  649. if([[return_json valueForKey:@"result"] intValue]==2)
  650. {
  651. // NSString* order_code = [return_json valueForKey:@"order_code"];
  652. #ifdef RA_NOTIFICATION
  653. [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  654. #else
  655. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  656. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  657. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  658. #endif
  659. if(self.shopCartBlock!=nil)
  660. {
  661. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  662. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  663. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  664. iv.image = img;
  665. // [self.contentView addSubview:iv];
  666. self.shopCartBlock(iv);
  667. self.cqty +=count;
  668. if(self.set_cqty)
  669. self.set_cqty(self.cqty);
  670. }
  671. }
  672. else
  673. {
  674. UIViewController *vc= [RAUtils getViewController:self];
  675. NSString *msg = [return_json valueForKey:@"err_msg"];
  676. NSString *title = @"Add To Cart";
  677. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  678. title = @"Add To Cart: Out of Stock";
  679. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  680. self.btnNotifyMe.enabled = YES;
  681. self.btnaddCart.enabled = NO;
  682. }
  683. [RAUtils message_alert:msg title:title controller:vc] ;
  684. }
  685. });
  686. });
  687. }
  688. //
  689. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  690. //
  691. // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  692. //
  693. // dispatch_async(dispatch_get_main_queue(), ^{
  694. //
  695. //
  696. //
  697. // if([[return_json valueForKey:@"result"] intValue]==2)
  698. // {
  699. //
  700. // // NSString* order_code = [return_json valueForKey:@"order_code"];
  701. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  702. //// appDelegate.order_code = order_code;
  703. ////
  704. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  705. //// appDelegate.order_code = order_code;
  706. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  707. //
  708. //
  709. // if(self.shopCartBlock!=nil)
  710. // {
  711. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  712. //
  713. //
  714. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  715. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  716. // iv.image = img;
  717. // // [self.contentView addSubview:iv];
  718. // self.shopCartBlock(iv);
  719. //
  720. // self.cqty +=count;
  721. // if(self.set_cqty)
  722. // self.set_cqty(self.cqty);
  723. //
  724. // }
  725. //
  726. //
  727. // }
  728. // else
  729. // {
  730. // UIViewController *vc= [RAUtils getViewController:self];
  731. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
  732. // }
  733. //
  734. //
  735. //
  736. //
  737. // });
  738. // });
  739. //
  740. }];
  741. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  742. DebugLog(@"No");
  743. }];
  744. [alertControl addAction:actionOne];
  745. [alertControl addAction:alertthree];
  746. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  747. UIViewController *vc= [RAUtils getViewController:self];
  748. [vc presentViewController:alertControl animated:YES completion:nil];
  749. }
  750. else
  751. {
  752. int c=self.cqty+count;
  753. int m=c%self.step;
  754. if(m!=0&&appDelegate.alert_sold_in_quantities)
  755. {
  756. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert];
  757. //block代码块取代了delegate
  758. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  759. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  760. NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
  761. dispatch_async(dispatch_get_main_queue(), ^{
  762. if([[return_json valueForKey:@"result"] intValue]==2)
  763. {
  764. #ifdef RA_NOTIFICATION
  765. [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  766. #else
  767. // NSString* order_code = [return_json valueForKey:@"order_code"];
  768. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  769. // appDelegate.order_code = order_code;
  770. //
  771. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  772. // appDelegate.order_code = order_code;
  773. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  774. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  775. #endif
  776. if(self.shopCartBlock!=nil)
  777. {
  778. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  779. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  780. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  781. iv.image = img;
  782. // [self.contentView addSubview:iv];
  783. self.shopCartBlock(iv);
  784. self.cqty +=count;
  785. if(self.set_cqty)
  786. self.set_cqty(self.cqty);
  787. }
  788. }
  789. else
  790. {
  791. UIViewController *vc= [RAUtils getViewController:self];
  792. NSString *msg = [return_json valueForKey:@"err_msg"];
  793. NSString *title = @"Add To Cart";
  794. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  795. title = @"Add To Cart: Out of Stock";
  796. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  797. self.btnNotifyMe.enabled = YES;
  798. self.btnaddCart.enabled = NO;
  799. }
  800. [RAUtils message_alert:msg title:title controller:vc] ;
  801. }
  802. });
  803. });
  804. }];
  805. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  806. DebugLog(@"No");
  807. }];
  808. [alertControl addAction:actionOne];
  809. [alertControl addAction:alertthree];
  810. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  811. UIViewController *vc= [RAUtils getViewController:self];
  812. [vc presentViewController:alertControl animated:YES completion:nil];
  813. }
  814. else
  815. {
  816. NSString* model_name=self.model_label.text;
  817. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  818. NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:model_name];
  819. dispatch_async(dispatch_get_main_queue(), ^{
  820. if([[return_json valueForKey:@"result"] intValue]==2)
  821. {
  822. #ifdef RA_NOTIFICATION
  823. [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  824. #else
  825. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  826. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  827. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  828. #endif
  829. if(self.shopCartBlock!=nil)
  830. {
  831. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  832. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  833. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  834. iv.image = img;
  835. // [self.contentView addSubview:iv];
  836. self.shopCartBlock(iv);
  837. self.cqty +=count;
  838. if(self.set_cqty)
  839. self.set_cqty(self.cqty);
  840. }
  841. }
  842. else
  843. {
  844. UIViewController *vc= [RAUtils getViewController:self];
  845. NSString *msg = [return_json valueForKey:@"err_msg"];
  846. NSString *title = @"Add To Cart";
  847. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  848. title = @"Add To Cart: Out of Stock";
  849. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  850. self.btnNotifyMe.enabled = YES;
  851. self.btnaddCart.enabled = NO;
  852. }
  853. [RAUtils message_alert:msg title:title controller:vc] ;
  854. }
  855. });
  856. });
  857. }
  858. //
  859. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  860. //
  861. // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  862. //
  863. // dispatch_async(dispatch_get_main_queue(), ^{
  864. //
  865. //
  866. //
  867. // if([[return_json valueForKey:@"result"] intValue]==2)
  868. // {
  869. //
  870. // // NSString* order_code = [return_json valueForKey:@"order_code"];
  871. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  872. //// appDelegate.order_code = order_code;
  873. ////
  874. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  875. //// appDelegate.order_code = order_code;
  876. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  877. //
  878. //
  879. // if(self.shopCartBlock!=nil)
  880. // {
  881. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  882. //
  883. //
  884. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  885. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  886. // iv.image = img;
  887. // // [self.contentView addSubview:iv];
  888. // self.shopCartBlock(iv);
  889. //
  890. // self.cqty +=count;
  891. // if(self.set_cqty)
  892. // self.set_cqty(self.cqty);
  893. //
  894. // }
  895. //
  896. //
  897. // }
  898. // else
  899. // {
  900. // UIViewController *vc= [RAUtils getViewController:self];
  901. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
  902. // }
  903. //
  904. //
  905. //
  906. //
  907. // });
  908. // });
  909. //
  910. }
  911. }
  912. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  913. {
  914. [super setSelected:selected animated:animated];
  915. // Configure the view for the selected state
  916. }
  917. - (IBAction)selectorOnClick:(id)sender {
  918. DebugLog(@"select click");
  919. [celldelegate SelectorClicked:(UIButton*) sender];
  920. // [self performSegueWithIdentifier:@"selector_popover" sender:self];
  921. }
  922. #pragma mark -
  923. #pragma mark Deck DataSource Protocol Methods
  924. -(NSUInteger)numberOfPhotosInPhotoStackView:(PhotoStackView *)photoStack {
  925. return [self.photos count];
  926. }
  927. -(UIImage *)photoStackView:(PhotoStackView *)photoStack photoForIndex:(NSUInteger)index {
  928. if(self.photos.count==0)
  929. return nil;
  930. return [self.photos objectAtIndex:index];
  931. }
  932. #pragma mark -
  933. #pragma mark Deck Delegate Protocol Methods
  934. -(void)photoStackView:(PhotoStackView *)photoStackView willStartMovingPhotoAtIndex:(NSUInteger)index {
  935. // User started moving a photo
  936. }
  937. -(void)photoStackView:(PhotoStackView *)photoStackView willFlickAwayPhotoFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex {
  938. // User flicked the photo away, revealing the next one in the stack
  939. }
  940. -(void)photoStackView:(PhotoStackView *)photoStackView didRevealPhotoAtIndex:(NSUInteger)index {
  941. self.pageControl.currentPage = index;
  942. }
  943. - (UIView *)createVideoView:(NSString*) videoID
  944. {
  945. UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 640, 360)];
  946. // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
  947. // [imageView setImage:[UIImage imageNamed:@"demo"]];
  948. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 620, 10)];
  949. titleLabel.font = [UIFont boldSystemFontOfSize:20];
  950. titleLabel.text=@"a separated player will show here:";
  951. titleLabel.numberOfLines = 0;
  952. titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
  953. // titleLabel.textAlignment = NSTextAlignmentRight;
  954. titleLabel.textAlignment = NSTextAlignmentCenter;
  955. CGSize constraintkey = CGSizeMake(620, 20000.0f);//key label width is 40% cell width;
  956. CGSize sizetitle = [@"a separated player will show here:" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  957. //[titleLabel sizeToFit];
  958. // titleLabel.center.x = demoView.center.x;
  959. titleLabel.frame = CGRectMake(10, 10, 620, sizetitle.height);
  960. [demoView addSubview:titleLabel];
  961. UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 610, 10)];
  962. lineLabel.font = [UIFont boldSystemFontOfSize:17];
  963. lineLabel.text=videoID;
  964. lineLabel.numberOfLines = 0;
  965. lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
  966. CGSize sizemsg = [videoID sizeWithFont:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  967. lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 630, sizemsg.height);
  968. //[lineLabel sizeToFit];
  969. [demoView addSubview:lineLabel];
  970. demoView.frame = CGRectMake(0, 0, 640, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
  971. return demoView;
  972. }
  973. -(void)photoStackView:(PhotoStackView *)photoStackView didSelectPhotoAtIndex:(NSUInteger)index {
  974. DebugLog(@"selected %lu", (unsigned long)index);
  975. NSDictionary* item= self.stack_contents[[NSString stringWithFormat:@"item_%ld",index]];
  976. if([item[@"type"] isEqualToString:@"video"])
  977. {
  978. NSString* video_code=item[@"code"];
  979. // [TextUtils expression_varable:video regex:<#(NSString *)#>]
  980. // video_code=@"hqNcj6_lYg0";
  981. // NSString* video_id=[self.playerView Embed2VID:video_code];
  982. //
  983. // NSDictionary *playerVars = @{
  984. // @"playsinline" : @1,
  985. // @"autoplay" : @(1),
  986. // @"rel":@0,
  987. // @"showinfo": @0,
  988. // @"modestbranding":@0,
  989. // @"enablejsapi":@1
  990. // };
  991. //
  992. // [self.playerView loadWithVideoId:video_id playerVars:playerVars];
  993. [self.ytplayerView LoadWithVid:video_code];
  994. for(UIView *v in self.ytplayerView.subviews)
  995. {
  996. if([v isKindOfClass:[UIButton class] ])
  997. [self.ytplayerView bringSubviewToFront:v];
  998. }
  999. self.ytplayerView.hidden=false;
  1000. return;
  1001. } else {
  1002. if ([[self.stack_contents objectForKey:@"count"] integerValue] == 0) {
  1003. return;
  1004. }
  1005. ContentPreviewController *preVC = [[UIStoryboard storyboardWithName:@"PhotoList" bundle:nil] instantiateViewControllerWithIdentifier:@"ContentPreviewController"];
  1006. preVC.content = self.stack_contents;
  1007. // preVC.currentIndex = index;
  1008. [preVC setOffset:index];
  1009. UIViewController *superVC= [RAUtils getViewController:self];
  1010. [superVC.navigationController pushViewController:preVC animated:true];
  1011. return;
  1012. }
  1013. // NSMutableArray *imgList = [NSMutableArray arrayWithCapacity:_data.count];
  1014. // for (int i = 0; i < _data.count; i++) {
  1015. // UIImage *imgMod = _data[i];
  1016. // [imgList addObject:imgMod];
  1017. // }
  1018. // 调用展示窗口
  1019. // ImageScrollerViewController *imgShow = [[ImageScrollerViewController alloc] initWithSourceData:[self.photos mutableCopy] withIndex:index];
  1020. //
  1021. // UIViewController *vc= [RAUtils getViewController:self];
  1022. // [vc.navigationController pushViewController:imgShow animated:true];
  1023. // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:imgShow];
  1024. // [self presentViewController:nav animated:YES completion:nil];
  1025. // UIDocumentInteractionController
  1026. // UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
  1027. // preview.delegate = self;
  1028. // [preview presentPreviewAnimated:YES];
  1029. }
  1030. -(void) neworder
  1031. {
  1032. UIAlertController * waitalert = [RAUtils waiting_alert:[RAUtils getViewController:self] title:@"Create Order"];
  1033. [RANetwork request_create_order:^(NSMutableDictionary *result) {
  1034. NSMutableDictionary* return_json = result;
  1035. [waitalert dismissViewControllerAnimated:YES completion:nil];
  1036. if([[return_json valueForKey:@"result"] intValue]==2)
  1037. {
  1038. int result=[[return_json valueForKey:@"result"] intValue];
  1039. if(result==2)
  1040. {
  1041. //successed.
  1042. NSString* order_code = [return_json valueForKey:@"orderCode"];
  1043. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  1044. appDelegate.order_code = order_code;
  1045. int count=[self.quantity_text.text intValue];
  1046. [self addtocart:count];
  1047. // [self ReloadData];
  1048. // if(self.shopCartBlock!=nil)
  1049. // {
  1050. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  1051. //
  1052. //
  1053. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  1054. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  1055. // iv.image = img;
  1056. // // [self.contentView addSubview:iv];
  1057. // self.shopCartBlock(iv);
  1058. //
  1059. // }
  1060. }
  1061. }
  1062. else
  1063. {
  1064. UIViewController *vc= [RAUtils getViewController:self];
  1065. NSString *msg = [return_json valueForKey:@"err_msg"];
  1066. NSString *title = @"Add To Cart";
  1067. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  1068. title = @"Add To Cart: Out of Stock";
  1069. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  1070. self.btnNotifyMe.enabled = YES;
  1071. self.btnaddCart.enabled = NO;
  1072. }
  1073. [RAUtils message_alert:msg title:title controller:vc] ;
  1074. }
  1075. }];
  1076. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1077. //
  1078. // NSDictionary* return_json = [RANetwork new_Order];
  1079. //
  1080. // dispatch_async(dispatch_get_main_queue(), ^{
  1081. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  1082. //
  1083. //
  1084. // if([[return_json valueForKey:@"result"] intValue]==2)
  1085. // {
  1086. // int result=[[return_json valueForKey:@"result"] intValue];
  1087. // if(result==2)
  1088. // {
  1089. // //successed.
  1090. //
  1091. // NSString* order_code = [return_json valueForKey:@"orderCode"];
  1092. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  1093. // appDelegate.order_code = order_code;
  1094. //
  1095. // int count=[self.quantity_text.text intValue];
  1096. // [self addtocart:count];
  1097. //
  1098. //
  1099. // // [self ReloadData];
  1100. //
  1101. //
  1102. // // if(self.shopCartBlock!=nil)
  1103. // // {
  1104. // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  1105. // //
  1106. // //
  1107. // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  1108. // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  1109. // // iv.image = img;
  1110. // // // [self.contentView addSubview:iv];
  1111. // // self.shopCartBlock(iv);
  1112. // //
  1113. // // }
  1114. //
  1115. // }
  1116. // }
  1117. // else
  1118. // {
  1119. // UIViewController *vc= [RAUtils getViewController:self];
  1120. // NSString *msg = [return_json valueForKey:@"err_msg"];
  1121. // NSString *title = @"Add To Cart";
  1122. // if ([msg hasPrefix:@"Out of Stock.\n"]) {
  1123. // title = @"Add To Cart: Out of Stock";
  1124. // msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  1125. // self.btnNotifyMe.enabled = YES;
  1126. // self.btnaddCart.enabled = NO;
  1127. // }
  1128. //
  1129. // [RAUtils message_alert:msg title:title controller:vc] ;
  1130. // }
  1131. //
  1132. //
  1133. //
  1134. //
  1135. // });
  1136. // });
  1137. }
  1138. //#pragma mark - UIAlertViewDelegate
  1139. //// Called when a button is clicked. The view will be automatically dismissed after this call returns
  1140. //- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  1141. //{
  1142. // UIApplication * app = [UIApplication sharedApplication];
  1143. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1144. // if(alertView.tag==1234)//库存小于0
  1145. // {
  1146. //
  1147. // // availability warring;
  1148. //
  1149. // int count=[self.quantity_text.text intValue];
  1150. // if(buttonIndex!=alertView.cancelButtonIndex)
  1151. // {
  1152. // if(appDelegate.order_code==nil)
  1153. // {
  1154. // [self neworder];
  1155. // }
  1156. // else
  1157. // {
  1158. // [self addtocart:count];
  1159. // }
  1160. // }
  1161. // return;
  1162. // }
  1163. // // int count=[self.quantity_text.text intValue];
  1164. //
  1165. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  1166. // if(buttonIndex==alertView.cancelButtonIndex)
  1167. // {
  1168. //
  1169. //
  1170. //
  1171. // }
  1172. // else if(buttonIndex==1)
  1173. // {
  1174. // //open exist
  1175. // UIViewController *vc= [RAUtils getViewController:self];
  1176. // OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  1177. // ovc.showNavibar = true;
  1178. // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  1179. // if(appDelegate.order_code==nil)
  1180. // {
  1181. // [self neworder];
  1182. // }
  1183. // else
  1184. // {
  1185. // if(self.set_update_data)
  1186. // self.set_update_data(true);
  1187. //
  1188. // int model_count = [[order_detail valueForKey:@"model_count"] intValue];
  1189. // for(int i=0;i<model_count;i++)
  1190. // {
  1191. // NSDictionary* item = [order_detail objectForKey:[NSString stringWithFormat:@"item_%d",i]];
  1192. // NSString* product_id = [item valueForKey:@"product_id"];
  1193. // if([product_id isEqualToString:self.product_id])
  1194. // {
  1195. // self.cqty = [[item valueForKey:@"QTY"]intValue];
  1196. // if(self.set_cqty)
  1197. // self.set_cqty(self.cqty);
  1198. // break;
  1199. // }
  1200. //
  1201. // }
  1202. // int count=[self.quantity_text.text intValue];
  1203. // [self addtocart:count];
  1204. // [main_vc checklogin:true];
  1205. //
  1206. //
  1207. // }
  1208. //
  1209. // };
  1210. // ovc.init_style = OL_OPEN;
  1211. // ovc.onCancel = ^(){
  1212. //
  1213. // [main_vc checklogin:true];
  1214. //
  1215. // };
  1216. //
  1217. // [vc.navigationController pushViewController:ovc animated:true];
  1218. // }
  1219. // else
  1220. // {
  1221. // //create new;
  1222. // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  1223. // {
  1224. // UIViewController *vc= [RAUtils getViewController:self];
  1225. //
  1226. //
  1227. // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  1228. //
  1229. // cvc.showNavibar = true;
  1230. // cvc.contact_type = @"Sales_Order_Customer";
  1231. // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  1232. //
  1233. // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  1234. // appDelegate.customerInfo = value;
  1235. //
  1236. //
  1237. // if(appDelegate.order_code==nil)
  1238. // [self neworder];
  1239. //
  1240. // [main_vc checklogin:true];
  1241. // // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  1242. //
  1243. // //
  1244. // // if(self.returnValue)
  1245. // // self.returnValue(value);
  1246. // };
  1247. //
  1248. // cvc.onCancel = ^(){
  1249. //
  1250. // UIViewController *vc= [RAUtils getViewController:self];
  1251. // [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order" controller:vc];
  1252. //
  1253. // };
  1254. // cvc.onReset = ^(){
  1255. // [main_vc checklogin:true];
  1256. // };
  1257. //
  1258. // [vc.navigationController pushViewController:cvc animated:true];
  1259. // }
  1260. // else
  1261. // {
  1262. // [self neworder];
  1263. // }
  1264. //
  1265. //
  1266. // }
  1267. //}
  1268. - (void)valueChanged:(UIStepper *)sender {
  1269. self.quantity_text.text = [NSString stringWithFormat:@"%d",(int)sender.value ];
  1270. [celldelegate stepClicked:(int)sender.value];
  1271. // -(void) stepClicked:(int) value;
  1272. // 检查缺货
  1273. // NSString *cartQtyString = nil;
  1274. // if (self.cqyt_label.text) {
  1275. // cartQtyString = [self.cqyt_label.text substringFromIndex:[@"Model QTY in Cart:" length]];
  1276. // }
  1277. //
  1278. // int availability = [self.count_Label.text intValue];
  1279. // int buyQTY = [self.quantity_text.text intValue];
  1280. // int cartQTY = [cartQtyString intValue];
  1281. //
  1282. // [self checkAvailability:availability buyQTY:buyQTY cartQTY:cartQTY];
  1283. }
  1284. #pragma mark -
  1285. #pragma mark Actions
  1286. -(void)ClearPhotos
  1287. {
  1288. NSMutableArray *photosMutable = [self.photos mutableCopy];
  1289. [photosMutable removeAllObjects];
  1290. self.photos = photosMutable;
  1291. [self.photoStack reloadData];
  1292. }
  1293. - (void)AddPhoto :(UIImage*)photo {
  1294. NSMutableArray *photosMutable = [self.photos mutableCopy];
  1295. [photosMutable addObject:photo];
  1296. self.photos = photosMutable;
  1297. [self.photoStack reloadData];
  1298. self.pageControl.numberOfPages = [self.photos count];
  1299. if(self.photos.count<2-1)//1 for qrcode;
  1300. self.photoStack.showBorder=false;
  1301. else
  1302. self.photoStack.showBorder=true;
  1303. }
  1304. #pragma mark -
  1305. #pragma mark Setup
  1306. -(void)setup {
  1307. // int availability = [self.count_Label.text intValue];
  1308. self.stepper.minimumValue= self.step;
  1309. self.stepper.maximumValue = INTMAX_MAX;
  1310. self.stepper.stepValue= self.step;
  1311. self.stepper.value= self.quantity;
  1312. [self.stepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
  1313. if(true)//(self.photos==nil)
  1314. {
  1315. self.photos = [NSArray array];
  1316. }
  1317. if(true)//(self.photoStack==nil)
  1318. {
  1319. // if(self.photoStack!=nil)
  1320. // [self.photoStack removeFromSuperview];
  1321. // self.photoStack = [[PhotoStackView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
  1322. // self.photoStack.backgroundColor =[UIColor redColor];
  1323. // self.photoStack.center = CGPointMake(self.center.x, 220);
  1324. self.photoStack.dataSource = self;
  1325. self.photoStack.delegate = self;
  1326. // [self addSubview:self.photoStack];
  1327. self.pageControl.numberOfPages = [self.photos count];
  1328. }
  1329. }
  1330. - (IBAction)notifyMeButtonClicked:(UIButton *)sender {
  1331. if (self.notifyMeBlock) {
  1332. self.notifyMeBlock();
  1333. }
  1334. }
  1335. #pragma mark - TextField Delegate
  1336. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  1337. NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
  1338. // NSString *cartQtyString = nil;
  1339. // if (self.cqyt_label.text) {
  1340. // cartQtyString = [self.cqyt_label.text substringFromIndex:[@"Model QTY in Cart:" length]];
  1341. // }
  1342. // int availability = [self.count_Label.text intValue];
  1343. int buyQTY = [newString intValue];
  1344. // int cartQTY = [cartQtyString intValue];
  1345. // [self checkAvailability:availability buyQTY:buyQTY cartQTY:cartQTY];
  1346. self.stepper.value = buyQTY;
  1347. return YES;
  1348. }
  1349. #pragma mark - Private
  1350. /**检查是否缺货*/
  1351. - (void)checkAvailability:(int)availability buyQTY:(int)buyQty cartQTY:(int)cartQty { // availability不可以通过textField.text取得
  1352. //#if defined(BUILD_NPD) || defined(BUILD_USAI)
  1353. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  1354. if (!appDelegate.bLogin || buyQty < 1) {
  1355. return;
  1356. }
  1357. #ifdef OFFLINE_MODE
  1358. if (appDelegate.offline_mode) {
  1359. return;
  1360. }
  1361. #endif
  1362. if (appDelegate.user_type == USER_ROLE_CUSTOMER) { // customer
  1363. if (!appDelegate.order_code) { // 未打开订单状态
  1364. if ((buyQty + cartQty) > availability) {
  1365. self.btnaddCart.enabled = NO;
  1366. self.btnNotifyMe.enabled = YES;
  1367. } else {
  1368. self.btnaddCart.enabled = YES;
  1369. self.btnNotifyMe.enabled = NO;
  1370. }
  1371. } else {
  1372. // 打开订单状态
  1373. if (![Singleton sharedInstance].currentOrderIsMerged) {
  1374. // Shop Order
  1375. self.btnaddCart.enabled = YES;
  1376. // 默认未缺货
  1377. self.btnNotifyMe.enabled = NO;
  1378. if ((buyQty + cartQty) > availability) { // 缺货
  1379. self.btnNotifyMe.enabled = YES;
  1380. }
  1381. } else {
  1382. // Purchase Order
  1383. if ((buyQty + cartQty) > availability) { // 缺货
  1384. self.btnaddCart.enabled = NO;
  1385. self.btnNotifyMe.enabled = YES;
  1386. } else { // 未缺货
  1387. self.btnNotifyMe.enabled = NO;
  1388. self.btnaddCart.enabled = YES;
  1389. }
  1390. }
  1391. }
  1392. } else { // empoyee
  1393. if ((buyQty + cartQty) > availability) { // 缺货
  1394. self.btnaddCart.enabled = NO;
  1395. self.btnNotifyMe.enabled = YES;
  1396. } else { // 未缺货
  1397. self.btnNotifyMe.enabled = NO;
  1398. self.btnaddCart.enabled = YES;
  1399. }
  1400. }
  1401. //#endif
  1402. }
  1403. - (IBAction)introduceBtnClick:(UIButton *)sender {
  1404. if (self.introduceBlock) {
  1405. self.introduceBlock(sender);
  1406. }
  1407. }
  1408. - (IBAction)descriptionBtnClick:(UIButton *)sender {
  1409. if (self.descriptionBlock) {
  1410. self.descriptionBlock(sender);
  1411. }
  1412. }
  1413. - (IBAction)OnClosePlayer:(id)sender {
  1414. [self.ytplayerView stopVideo];
  1415. self.ytplayerView.hidden=true;
  1416. }
  1417. - (IBAction)noLoginBtnClick:(UIButton *)sender {
  1418. UIApplication * app = [UIApplication sharedApplication];
  1419. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1420. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  1421. if(appDelegate.bLogin==false) {
  1422. DetailViewController *vc= (DetailViewController *)[RAUtils getViewController:self];
  1423. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  1424. loginvc.returnValue = ^(bool blogin){
  1425. if(blogin) {
  1426. [vc reload];
  1427. [main_vc checklogin:true];
  1428. }
  1429. };
  1430. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  1431. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  1432. [vc presentViewController:navi animated:YES completion:^{
  1433. }];
  1434. }
  1435. }
  1436. @end