DetailHeaderCell.m 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  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 "iSalesNetwork.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. @implementation DetailHeaderCell
  18. @synthesize celldelegate;
  19. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self) {
  23. // Initialization code
  24. }
  25. // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
  26. // self.selector_imageView.layer.borderWidth = 1;
  27. return self;
  28. }
  29. - (void)awakeFromNib
  30. {
  31. // self.selector_imageView.layer.borderColor = [UIColorFromRGB(0x996633) CGColor];
  32. // self.selector_imageView.layer.borderWidth = 1;
  33. self.selector_Button.layer.borderWidth = 0.5;
  34. self.selector_Button.layer.borderColor = [[UIColor lightGrayColor] CGColor];
  35. self.selector_Button.layer.cornerRadius = 0;
  36. [self.descriptionRTLabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
  37. [self.descriptionRTLabel setTextAlignment:RTTextAlignmentCenter];
  38. [self.descriptionRTLabel setFont:[UIFont systemFontOfSize:22]];
  39. // self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  40. // self.label_net_err.layer.borderWidth = 2.0;
  41. // self.label_net_err.layer.cornerRadius=15;
  42. // self.label_net_err.layer.masksToBounds=true;
  43. // Initialization code
  44. }
  45. - (IBAction)add_toPortfolio:(id)sender {
  46. // int count=[self.quantity_text.text intValue];
  47. UIApplication * app = [UIApplication sharedApplication];
  48. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  49. if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
  50. [[NSNotificationCenter defaultCenter] postNotificationName:No_Rights_Notification object:nil];
  51. return;
  52. }
  53. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  54. if(appDelegate.bLogin==false)
  55. {
  56. UIViewController *vc= [RAUtils getViewController:self];
  57. LoginViewController * loginvc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
  58. // loginvc.delegate = self;
  59. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  60. loginvc.returnValue = ^(bool blogin){
  61. // UIApplication * app = [UIApplication sharedApplication];
  62. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  63. if(blogin)
  64. {
  65. if(self.set_update_data)
  66. self.set_update_data(true);
  67. [main_vc checklogin:true];
  68. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  69. NSDictionary* return_json = [iSalesNetwork add_toPortfolio:self.product_id ];
  70. dispatch_async(dispatch_get_main_queue(), ^{
  71. if([[return_json valueForKey:@"result"] intValue]==2)
  72. {
  73. // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  74. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  75. if(self.WatchlistBlock!=nil)
  76. {
  77. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  78. CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
  79. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  80. iv.image = img;
  81. // [self.contentView addSubview:iv];
  82. self.PortfolioBlock(iv);
  83. }
  84. }
  85. else
  86. {
  87. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
  88. }
  89. });
  90. });
  91. }
  92. // self.offset = 0;
  93. // [self.content_data removeAllObjects];
  94. // [self loadpage];
  95. //
  96. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  97. };
  98. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  99. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  100. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  101. [vc presentViewController:navi animated:YES completion:^{
  102. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  103. DebugLog(@"LoginViewController present.........");
  104. // self.btop = false;
  105. // <#code#>
  106. }];
  107. }
  108. else
  109. {
  110. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  111. NSDictionary* return_json = [iSalesNetwork add_toPortfolio:self.product_id ];
  112. dispatch_async(dispatch_get_main_queue(), ^{
  113. if([[return_json valueForKey:@"result"] intValue]==2)
  114. {
  115. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  116. if(self.WatchlistBlock!=nil)
  117. {
  118. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  119. CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
  120. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  121. iv.image = img;
  122. // [self.contentView addSubview:iv];
  123. self.PortfolioBlock(iv);
  124. }
  125. }
  126. else
  127. {
  128. UIViewController *vc= [RAUtils getViewController:self];
  129. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
  130. }
  131. });
  132. });
  133. }
  134. }
  135. - (IBAction)add_toWatchList:(id)sender {
  136. // int count=[self.quantity_text.text intValue];
  137. UIApplication * app = [UIApplication sharedApplication];
  138. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  139. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  140. if(appDelegate.bLogin==false)
  141. {
  142. UIViewController *vc= [RAUtils getViewController:self];
  143. LoginViewController * loginvc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
  144. // loginvc.delegate = self;
  145. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  146. loginvc.returnValue = ^(bool blogin){
  147. // UIApplication * app = [UIApplication sharedApplication];
  148. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  149. if(blogin)
  150. {
  151. if(self.set_update_data)
  152. self.set_update_data(true);
  153. [main_vc checklogin:true];
  154. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  155. NSDictionary* return_json = [iSalesNetwork add_toWatchList:self.product_id ];
  156. dispatch_async(dispatch_get_main_queue(), ^{
  157. if([[return_json valueForKey:@"result"] intValue]==2)
  158. {
  159. // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  160. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  161. if(self.WatchlistBlock!=nil)
  162. {
  163. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  164. CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
  165. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  166. iv.image = img;
  167. // [self.contentView addSubview:iv];
  168. self.WatchlistBlock(iv);
  169. }
  170. }
  171. else
  172. {
  173. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
  174. }
  175. });
  176. });
  177. }
  178. // self.offset = 0;
  179. // [self.content_data removeAllObjects];
  180. // [self loadpage];
  181. //
  182. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  183. };
  184. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  185. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  186. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  187. [vc presentViewController:navi animated:YES completion:^{
  188. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  189. DebugLog(@"LoginViewController present.........");
  190. // self.btop = false;
  191. // <#code#>
  192. }];
  193. }
  194. else
  195. {
  196. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  197. NSDictionary* return_json = [iSalesNetwork add_toWatchList:self.product_id ];
  198. dispatch_async(dispatch_get_main_queue(), ^{
  199. if([[return_json valueForKey:@"result"] intValue]==2)
  200. {
  201. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  202. if(self.WatchlistBlock!=nil)
  203. {
  204. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  205. CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
  206. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  207. iv.image = img;
  208. // [self.contentView addSubview:iv];
  209. self.WatchlistBlock(iv);
  210. }
  211. }
  212. else
  213. {
  214. UIViewController *vc= [RAUtils getViewController:self];
  215. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
  216. }
  217. });
  218. });
  219. }
  220. }
  221. - (IBAction)add_toCart:(id)sender {
  222. UIViewController *vc= [RAUtils getViewController:self];
  223. [CartUtils add_to_cart:vc selectorholder:self selector:@selector(addtocart)];
  224. return;
  225. int count=[self.quantity_text.text intValue];
  226. UIApplication * app = [UIApplication sharedApplication];
  227. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  228. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  229. if(appDelegate.bLogin==false)
  230. {
  231. UIViewController *vc= [RAUtils getViewController:self];
  232. LoginViewController * loginvc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
  233. // loginvc.delegate = self;
  234. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  235. loginvc.returnValue = ^(bool blogin){
  236. // UIApplication * app = [UIApplication sharedApplication];
  237. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  238. if(blogin)
  239. {
  240. if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
  241. {
  242. if(self.set_update_data)
  243. self.set_update_data(true);
  244. [main_vc checklogin:false];
  245. 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];
  246. // alert.
  247. [alert show];
  248. }
  249. else
  250. {
  251. [main_vc checklogin:true];
  252. int c=[self.count_Label.text intValue];
  253. DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  254. NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  255. if(c<count)
  256. {
  257. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Item is OUT OF STOCK and not available to order from NPD.\nAdd to cart anyway?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
  258. // alert.
  259. alert.tag = 1234;
  260. [alert show];
  261. }
  262. else
  263. {
  264. if(appDelegate.order_code==nil)
  265. [ self neworder];
  266. else
  267. [self addtocart:count];
  268. }
  269. }
  270. }
  271. // self.offset = 0;
  272. // [self.content_data removeAllObjects];
  273. // [self loadpage];
  274. //
  275. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  276. };
  277. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  278. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  279. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  280. [vc presentViewController:navi animated:YES completion:^{
  281. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  282. DebugLog(@"LoginViewController present.........");
  283. // self.btop = false;
  284. // <#code#>
  285. }];
  286. }
  287. else
  288. {
  289. if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
  290. {
  291. [main_vc checklogin:false];
  292. if(appDelegate.can_create_order)
  293. {
  294. NSString* msg =@"";
  295. if(appDelegate.contact_id.length>0)
  296. {
  297. msg = [msg stringByAppendingString:@"\n\nCustomer:"];
  298. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  299. }
  300. 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];
  301. // alert.
  302. [alert show];
  303. }
  304. else
  305. {
  306. 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];
  307. // alert.
  308. [alert show];
  309. }
  310. }
  311. else
  312. {
  313. // if ([self.priceLabel.text isEqualToString:@"No Price."])
  314. // {
  315. //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Model No Price" message:@"Cannot add model without price." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  316. ////
  317. ////
  318. ////
  319. //// [alert show];
  320. //
  321. //
  322. //
  323. // [RAUtils alert_view:@"Cannot add model without price." title:@"Model No Price."];
  324. // }
  325. // else
  326. {
  327. int c=[self.count_Label.text intValue];
  328. DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  329. NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  330. if(c<count)
  331. {
  332. 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];
  333. // alert.
  334. alert.tag = 1234;
  335. [alert show];
  336. }
  337. else
  338. {
  339. if(appDelegate.order_code==nil)
  340. [ self neworder];
  341. else
  342. [self addtocart:count];
  343. }
  344. }
  345. }
  346. }
  347. }
  348. -(void) addtocart
  349. {
  350. int count=[self.quantity_text.text intValue];
  351. int c=[self.count_Label.text intValue];
  352. DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
  353. NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  354. if(/*c<count*/c == 0)
  355. {
  356. NSString *msg = nil;
  357. BOOL continueAdd = YES;
  358. #ifdef BUILD_NPD
  359. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  360. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  361. if ([Singleton sharedInstance].currentOrderIsMerged) { // Purchase Order不允许购买数量大于库存
  362. msg = @"Item is OUT OF STOCK and not available to order from NPD.";
  363. continueAdd = NO;
  364. } else { // Shop Order购买数量大于库存需要确认
  365. msg = @"Item is OUT OF STOCK and not available to order from NPD.\nAdd to cart anyway?";
  366. continueAdd = YES;
  367. }
  368. }
  369. if (appDelegate.user_type == USER_ROLE_EMPLOYEE) { // Employee不允许购买数量大于库存
  370. msg = @"Item is OUT OF STOCK and not available to order.";
  371. continueAdd = NO;
  372. }
  373. #endif
  374. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:msg preferredStyle:UIAlertControllerStyleAlert];
  375. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  376. if (continueAdd) {
  377. [self addtocart:count];
  378. }
  379. }];
  380. [alertControl addAction:alertthree];
  381. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  382. }];
  383. if (continueAdd) {
  384. [alertControl addAction:alertcancel];
  385. }
  386. UIViewController *vc= [RAUtils getViewController:self];
  387. [vc presentViewController:alertControl animated:YES completion:nil];
  388. }
  389. else
  390. {
  391. [self addtocart:count];
  392. }
  393. }
  394. -(void)Hide_selector:(bool) bhide
  395. {
  396. self.selector_Button.hidden=bhide;
  397. self.selector_dorpdown.hidden=bhide;
  398. self.selector_imageView.hidden=bhide;
  399. }
  400. -(void) addtocart:(int) count
  401. {
  402. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  403. if(self.cqty>0)
  404. {
  405. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"QTY: %d of this model already in cart. Continue ?",self.cqty] message:nil preferredStyle:UIAlertControllerStyleAlert];
  406. //block代码块取代了delegate
  407. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  408. int c=self.cqty+count;
  409. int m=c%self.step;
  410. if(m!=0&&appDelegate.alert_sold_in_quantities)
  411. {
  412. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert];
  413. //block代码块取代了delegate
  414. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  415. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  416. NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  417. dispatch_async(dispatch_get_main_queue(), ^{
  418. if([[return_json valueForKey:@"result"] intValue]==2)
  419. {
  420. // NSString* order_code = [return_json valueForKey:@"order_code"];
  421. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  422. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  423. if(self.shopCartBlock!=nil)
  424. {
  425. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  426. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  427. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  428. iv.image = img;
  429. // [self.contentView addSubview:iv];
  430. self.shopCartBlock(iv);
  431. self.cqty +=count;
  432. if(self.set_cqty)
  433. self.set_cqty(self.cqty);
  434. }
  435. }
  436. else
  437. {
  438. UIViewController *vc= [RAUtils getViewController:self];
  439. NSString *msg = [return_json valueForKey:@"err_msg"];
  440. NSString *title = @"Add To Cart";
  441. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  442. title = @"Add To Cart: Out of Stock";
  443. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  444. }
  445. [RAUtils message_alert:msg title:title controller:vc] ;
  446. }
  447. });
  448. });
  449. }];
  450. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  451. DebugLog(@"No");
  452. }];
  453. [alertControl addAction:actionOne];
  454. [alertControl addAction:alertthree];
  455. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  456. UIViewController *vc= [RAUtils getViewController:self];
  457. [vc presentViewController:alertControl animated:YES completion:nil];
  458. }
  459. else
  460. {
  461. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  462. NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  463. dispatch_async(dispatch_get_main_queue(), ^{
  464. if([[return_json valueForKey:@"result"] intValue]==2)
  465. {
  466. // NSString* order_code = [return_json valueForKey:@"order_code"];
  467. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  468. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  469. if(self.shopCartBlock!=nil)
  470. {
  471. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  472. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  473. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  474. iv.image = img;
  475. // [self.contentView addSubview:iv];
  476. self.shopCartBlock(iv);
  477. self.cqty +=count;
  478. if(self.set_cqty)
  479. self.set_cqty(self.cqty);
  480. }
  481. }
  482. else
  483. {
  484. UIViewController *vc= [RAUtils getViewController:self];
  485. NSString *msg = [return_json valueForKey:@"err_msg"];
  486. NSString *title = @"Add To Cart";
  487. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  488. title = @"Add To Cart: Out of Stock";
  489. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  490. }
  491. [RAUtils message_alert:msg title:title controller:vc] ;
  492. }
  493. });
  494. });
  495. }
  496. //
  497. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  498. //
  499. // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  500. //
  501. // dispatch_async(dispatch_get_main_queue(), ^{
  502. //
  503. //
  504. //
  505. // if([[return_json valueForKey:@"result"] intValue]==2)
  506. // {
  507. //
  508. // // NSString* order_code = [return_json valueForKey:@"order_code"];
  509. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  510. //// appDelegate.order_code = order_code;
  511. ////
  512. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  513. //// appDelegate.order_code = order_code;
  514. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  515. //
  516. //
  517. // if(self.shopCartBlock!=nil)
  518. // {
  519. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  520. //
  521. //
  522. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  523. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  524. // iv.image = img;
  525. // // [self.contentView addSubview:iv];
  526. // self.shopCartBlock(iv);
  527. //
  528. // self.cqty +=count;
  529. // if(self.set_cqty)
  530. // self.set_cqty(self.cqty);
  531. //
  532. // }
  533. //
  534. //
  535. // }
  536. // else
  537. // {
  538. // UIViewController *vc= [RAUtils getViewController:self];
  539. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
  540. // }
  541. //
  542. //
  543. //
  544. //
  545. // });
  546. // });
  547. //
  548. }];
  549. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  550. DebugLog(@"No");
  551. }];
  552. [alertControl addAction:actionOne];
  553. [alertControl addAction:alertthree];
  554. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  555. UIViewController *vc= [RAUtils getViewController:self];
  556. [vc presentViewController:alertControl animated:YES completion:nil];
  557. }
  558. else
  559. {
  560. int c=self.cqty+count;
  561. int m=c%self.step;
  562. if(m!=0&&appDelegate.alert_sold_in_quantities)
  563. {
  564. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",self.step] message:nil preferredStyle:UIAlertControllerStyleAlert];
  565. //block代码块取代了delegate
  566. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  567. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  568. NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  569. dispatch_async(dispatch_get_main_queue(), ^{
  570. if([[return_json valueForKey:@"result"] intValue]==2)
  571. {
  572. // NSString* order_code = [return_json valueForKey:@"order_code"];
  573. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  574. // appDelegate.order_code = order_code;
  575. //
  576. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  577. // appDelegate.order_code = order_code;
  578. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  579. if(self.shopCartBlock!=nil)
  580. {
  581. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  582. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  583. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  584. iv.image = img;
  585. // [self.contentView addSubview:iv];
  586. self.shopCartBlock(iv);
  587. self.cqty +=count;
  588. if(self.set_cqty)
  589. self.set_cqty(self.cqty);
  590. }
  591. }
  592. else
  593. {
  594. UIViewController *vc= [RAUtils getViewController:self];
  595. NSString *msg = [return_json valueForKey:@"err_msg"];
  596. NSString *title = @"Add To Cart";
  597. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  598. title = @"Add To Cart: Out of Stock";
  599. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  600. }
  601. [RAUtils message_alert:msg title:title controller:vc] ;
  602. }
  603. });
  604. });
  605. }];
  606. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  607. DebugLog(@"No");
  608. }];
  609. [alertControl addAction:actionOne];
  610. [alertControl addAction:alertthree];
  611. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  612. UIViewController *vc= [RAUtils getViewController:self];
  613. [vc presentViewController:alertControl animated:YES completion:nil];
  614. }
  615. else
  616. {
  617. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  618. NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  619. dispatch_async(dispatch_get_main_queue(), ^{
  620. if([[return_json valueForKey:@"result"] intValue]==2)
  621. {
  622. // NSString* order_code = [return_json valueForKey:@"order_code"];
  623. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  624. // appDelegate.order_code = order_code;
  625. //
  626. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  627. // appDelegate.order_code = order_code;
  628. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  629. if(self.shopCartBlock!=nil)
  630. {
  631. UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  632. CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  633. UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  634. iv.image = img;
  635. // [self.contentView addSubview:iv];
  636. self.shopCartBlock(iv);
  637. self.cqty +=count;
  638. if(self.set_cqty)
  639. self.set_cqty(self.cqty);
  640. }
  641. }
  642. else
  643. {
  644. UIViewController *vc= [RAUtils getViewController:self];
  645. NSString *msg = [return_json valueForKey:@"err_msg"];
  646. NSString *title = @"Add To Cart";
  647. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  648. title = @"Add To Cart: Out of Stock";
  649. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  650. }
  651. [RAUtils message_alert:msg title:title controller:vc] ;
  652. }
  653. });
  654. });
  655. }
  656. //
  657. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  658. //
  659. // NSDictionary* return_json = [iSalesNetwork add_toCart:self.product_id count:count];
  660. //
  661. // dispatch_async(dispatch_get_main_queue(), ^{
  662. //
  663. //
  664. //
  665. // if([[return_json valueForKey:@"result"] intValue]==2)
  666. // {
  667. //
  668. // // NSString* order_code = [return_json valueForKey:@"order_code"];
  669. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  670. //// appDelegate.order_code = order_code;
  671. ////
  672. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  673. //// appDelegate.order_code = order_code;
  674. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  675. //
  676. //
  677. // if(self.shopCartBlock!=nil)
  678. // {
  679. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  680. //
  681. //
  682. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  683. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  684. // iv.image = img;
  685. // // [self.contentView addSubview:iv];
  686. // self.shopCartBlock(iv);
  687. //
  688. // self.cqty +=count;
  689. // if(self.set_cqty)
  690. // self.set_cqty(self.cqty);
  691. //
  692. // }
  693. //
  694. //
  695. // }
  696. // else
  697. // {
  698. // UIViewController *vc= [RAUtils getViewController:self];
  699. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
  700. // }
  701. //
  702. //
  703. //
  704. //
  705. // });
  706. // });
  707. //
  708. }
  709. }
  710. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  711. {
  712. [super setSelected:selected animated:animated];
  713. // Configure the view for the selected state
  714. }
  715. - (IBAction)selectorOnClick:(id)sender {
  716. DebugLog(@"select click");
  717. [celldelegate SelectorClicked:(UIButton*) sender];
  718. // [self performSegueWithIdentifier:@"selector_popover" sender:self];
  719. }
  720. #pragma mark -
  721. #pragma mark Deck DataSource Protocol Methods
  722. -(NSUInteger)numberOfPhotosInPhotoStackView:(PhotoStackView *)photoStack {
  723. return [self.photos count];
  724. }
  725. -(UIImage *)photoStackView:(PhotoStackView *)photoStack photoForIndex:(NSUInteger)index {
  726. if(self.photos.count==0)
  727. return nil;
  728. return [self.photos objectAtIndex:index];
  729. }
  730. #pragma mark -
  731. #pragma mark Deck Delegate Protocol Methods
  732. -(void)photoStackView:(PhotoStackView *)photoStackView willStartMovingPhotoAtIndex:(NSUInteger)index {
  733. // User started moving a photo
  734. }
  735. -(void)photoStackView:(PhotoStackView *)photoStackView willFlickAwayPhotoFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex {
  736. // User flicked the photo away, revealing the next one in the stack
  737. }
  738. -(void)photoStackView:(PhotoStackView *)photoStackView didRevealPhotoAtIndex:(NSUInteger)index {
  739. self.pageControl.currentPage = index;
  740. }
  741. -(void)photoStackView:(PhotoStackView *)photoStackView didSelectPhotoAtIndex:(NSUInteger)index {
  742. DebugLog(@"selected %lu", (unsigned long)index);
  743. // NSMutableArray *imgList = [NSMutableArray arrayWithCapacity:_data.count];
  744. // for (int i = 0; i < _data.count; i++) {
  745. // UIImage *imgMod = _data[i];
  746. // [imgList addObject:imgMod];
  747. // }
  748. // 调用展示窗口
  749. ImageScrollerViewController *imgShow = [[ImageScrollerViewController alloc] initWithSourceData:[self.photos mutableCopy] withIndex:index];
  750. UIViewController *vc= [RAUtils getViewController:self];
  751. [vc.navigationController pushViewController:imgShow animated:true];
  752. // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:imgShow];
  753. // [self presentViewController:nav animated:YES completion:nil];
  754. // UIDocumentInteractionController
  755. // UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
  756. // preview.delegate = self;
  757. // [preview presentPreviewAnimated:YES];
  758. }
  759. -(void) neworder
  760. {
  761. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
  762. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  763. NSDictionary* return_json = [iSalesNetwork new_Order];
  764. dispatch_async(dispatch_get_main_queue(), ^{
  765. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  766. if([[return_json valueForKey:@"result"] intValue]==2)
  767. {
  768. int result=[[return_json valueForKey:@"result"] intValue];
  769. if(result==2)
  770. {
  771. //successed.
  772. NSString* order_code = [return_json valueForKey:@"orderCode"];
  773. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  774. appDelegate.order_code = order_code;
  775. int count=[self.quantity_text.text intValue];
  776. [self addtocart:count];
  777. // [self ReloadData];
  778. // if(self.shopCartBlock!=nil)
  779. // {
  780. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  781. //
  782. //
  783. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  784. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  785. // iv.image = img;
  786. // // [self.contentView addSubview:iv];
  787. // self.shopCartBlock(iv);
  788. //
  789. // }
  790. }
  791. }
  792. else
  793. {
  794. UIViewController *vc= [RAUtils getViewController:self];
  795. NSString *msg = [return_json valueForKey:@"err_msg"];
  796. NSString *title = @"Add To Cart";
  797. if ([msg hasPrefix:@"Out of Stock.\n"]) {
  798. title = @"Add To Cart: Out of Stock";
  799. msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
  800. }
  801. [RAUtils message_alert:msg title:title controller:vc] ;
  802. }
  803. });
  804. });
  805. }
  806. #pragma mark - UIAlertViewDelegate
  807. // Called when a button is clicked. The view will be automatically dismissed after this call returns
  808. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  809. {
  810. UIApplication * app = [UIApplication sharedApplication];
  811. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  812. if(alertView.tag==1234)//库存小于0
  813. {
  814. // availability warring;
  815. int count=[self.quantity_text.text intValue];
  816. if(buttonIndex!=alertView.cancelButtonIndex)
  817. {
  818. if(appDelegate.order_code==nil)
  819. {
  820. [self neworder];
  821. }
  822. else
  823. {
  824. [self addtocart:count];
  825. }
  826. }
  827. return;
  828. }
  829. // int count=[self.quantity_text.text intValue];
  830. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  831. if(buttonIndex==alertView.cancelButtonIndex)
  832. {
  833. }
  834. else if(buttonIndex==1)
  835. {
  836. //open exist
  837. UIViewController *vc= [RAUtils getViewController:self];
  838. OrderListViewController* ovc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  839. ovc.showNavibar = true;
  840. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  841. if(appDelegate.order_code==nil)
  842. {
  843. [self neworder];
  844. }
  845. else
  846. {
  847. if(self.set_update_data)
  848. self.set_update_data(true);
  849. int model_count = [[order_detail valueForKey:@"model_count"] intValue];
  850. for(int i=0;i<model_count;i++)
  851. {
  852. NSDictionary* item = [order_detail objectForKey:[NSString stringWithFormat:@"item_%d",i]];
  853. NSString* product_id = [item valueForKey:@"product_id"];
  854. if([product_id isEqualToString:self.product_id])
  855. {
  856. self.cqty = [[item valueForKey:@"QTY"]intValue];
  857. if(self.set_cqty)
  858. self.set_cqty(self.cqty);
  859. break;
  860. }
  861. }
  862. int count=[self.quantity_text.text intValue];
  863. [self addtocart:count];
  864. [main_vc checklogin:true];
  865. }
  866. };
  867. ovc.init_style = OL_OPEN;
  868. ovc.onCancel = ^(){
  869. [main_vc checklogin:true];
  870. };
  871. [vc.navigationController pushViewController:ovc animated:true];
  872. }
  873. else
  874. {
  875. //create new;
  876. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  877. {
  878. UIViewController *vc= [RAUtils getViewController:self];
  879. ContactListViewController* cvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  880. cvc.showNavibar = true;
  881. cvc.contact_type = @"Sales_Order_Customer";
  882. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  883. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  884. appDelegate.customerInfo = value;
  885. if(appDelegate.order_code==nil)
  886. [self neworder];
  887. [main_vc checklogin:true];
  888. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  889. //
  890. // if(self.returnValue)
  891. // self.returnValue(value);
  892. };
  893. cvc.onCancel = ^(){
  894. UIViewController *vc= [RAUtils getViewController:self];
  895. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order" controller:vc];
  896. };
  897. cvc.onReset = ^(){
  898. [main_vc checklogin:true];
  899. };
  900. [vc.navigationController pushViewController:cvc animated:true];
  901. }
  902. else
  903. {
  904. [self neworder];
  905. }
  906. }
  907. }
  908. - (void)valueChanged:(UIStepper *)sender {
  909. self.quantity_text.text = [NSString stringWithFormat:@"%d",(int)sender.value ];
  910. [celldelegate stepClicked:(int)sender.value];
  911. // -(void) stepClicked:(int) value;
  912. }
  913. #pragma mark -
  914. #pragma mark Actions
  915. -(void)ClearPhotos
  916. {
  917. NSMutableArray *photosMutable = [self.photos mutableCopy];
  918. [photosMutable removeAllObjects];
  919. self.photos = photosMutable;
  920. [self.photoStack reloadData];
  921. }
  922. - (void)AddPhoto :(UIImage*)photo {
  923. NSMutableArray *photosMutable = [self.photos mutableCopy];
  924. [photosMutable addObject:photo];
  925. self.photos = photosMutable;
  926. [self.photoStack reloadData];
  927. self.pageControl.numberOfPages = [self.photos count];
  928. if(self.photos.count<2-1)//1 for qrcode;
  929. self.photoStack.showBorder=false;
  930. else
  931. self.photoStack.showBorder=true;
  932. }
  933. #pragma mark -
  934. #pragma mark Setup
  935. -(void)setup {
  936. self.stepper.minimumValue= self.step;
  937. self.stepper.stepValue= self.step;
  938. self.stepper.value= self.quantity;
  939. [self.stepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
  940. if(true)//(self.photos==nil)
  941. {
  942. self.photos = [NSArray arrayWithObjects:
  943. nil];
  944. }
  945. if(true)//(self.photoStack==nil)
  946. {
  947. // if(self.photoStack!=nil)
  948. // [self.photoStack removeFromSuperview];
  949. // self.photoStack = [[PhotoStackView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
  950. // self.photoStack.backgroundColor =[UIColor redColor];
  951. // self.photoStack.center = CGPointMake(self.center.x, 220);
  952. self.photoStack.dataSource = self;
  953. self.photoStack.delegate = self;
  954. // [self addSubview:self.photoStack];
  955. self.pageControl.numberOfPages = [self.photos count];
  956. }
  957. }
  958. - (IBAction)notifyMeButtonClicked:(UIButton *)sender {
  959. if (self.notifyMeBlock) {
  960. self.notifyMeBlock();
  961. }
  962. }
  963. @end