| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- //
- // DetailViewController.m
- // iShop
- //
- // Created by Rui Zhang on 12/15/23.
- //
- #import "CatalogModelDetailViewController.h"
- #import "RANetwork.h"
- #import "RAUtils.h"
- #import "DetailSlideImageCell.h"
- #import "SliderPage.h"
- #import "RTLabel.h"
- #import "DetailKVCell.h"
- #import "LineView.h"
- #import "DetailBasicCell0.h"
- #import "FileCache.h"
- #import "ColorSelectViewController.h"
- #import "CustomPresentationController.h"
- #define RTLABEL_FONT_SIZE 15
- #define DEF_CELL_HEIGHT 44
- #define DEF_TABLE_HEIGHT 44
- #define LINE_WIDTH 10
- #define CELL_MARGIN 0
- #define LABEL_MARGIN 10
- @interface CatalogModelDetailViewController ()
- @end
- @implementation CatalogModelDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.show_navi = true;
- // Do any additional setup after loading the view.
- }
- //- (void)setDetail_data:(NSMutableDictionary *)detail_data
- //{
- // NSMutableDictionary* data = [NSMutableDictionary new];
- //
- //
- // NSMutableDictionary* img_section=detail_data[@"img_section"];
- //// NSMutableDictionary* img=detail_data[@"images"];
- //// NSMutableDictionary* video=detail_data[@"videos"];
- ////
- //// NSMutableDictionary* new_res =[NSMutableDictionary new];
- //// int new_count = 0;
- //// for(int i=0;i<video.count;i++)
- //// {
- ////
- //// NSMutableDictionary* item =[NSMutableDictionary new];
- //// item[@"code"]= video[[NSString stringWithFormat:@"video_%d",i]];
- //// item[@"type"]=@"video";
- ////
- ////
- //// new_res[[NSString stringWithFormat:@"res_%d",new_count]]=item;
- ////
- //// new_count++;
- //// }
- ////
- //
- // NSMutableDictionary* images=[img_section[@"images"] mutableCopy];
- // NSMutableDictionary* videos=[img_section[@"videos"] mutableCopy];
- //
- // NSMutableDictionary* contents = [NSMutableDictionary new];
- // int count = 0;
- //
- //
- // for(int ic=0;ic<[videos[@"count"] intValue];ic++)
- // {
- // NSString* videocode = videos[[NSString stringWithFormat:@"video_%d",ic]];
- //
- //
- //
- // NSMutableDictionary* item =[@{@"type":@"video",@"code":videocode} mutableCopy];
- //
- // contents[[NSString stringWithFormat:@"item_%d",count]]=item;
- // count++;
- // }
- //
- //
- // for(int ic=0;ic<[images[@"img_count"] intValue];ic++)
- // {
- // NSMutableDictionary* item = [images[[NSString stringWithFormat:@"img_%d",ic]] mutableCopy];
- // item[@"type"]=@"image";
- // contents[[NSString stringWithFormat:@"item_%d",count]]=item;
- // count++;
- // }
- //
- //
- //
- //
- //
- // contents[@"count"]=@(count);
- // data[@"stack_contents"]=contents;
- //}
- -(void) add_recent_model:(NSDictionary*) model
- {
- NSMutableDictionary * newdict = [[NSMutableDictionary alloc]init];
- [newdict setObject:model forKey:@"item_0"];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- int count=[appDelegate.recent_model[@"count"] intValue];
- for(int i=0;i<count;i++)
- {
- NSMutableDictionary * mitem= appDelegate.recent_model[[NSString stringWithFormat:@"item_%d",i]];
- NSString *mitemProductID = [NSString stringWithFormat:@"%@",mitem[@"product_id"]];
- NSString *modelProductID = [NSString stringWithFormat:@"%@",model[@"product_id"]];
- if([mitemProductID isEqualToString:modelProductID])
- continue;
- [newdict setObject:mitem forKey:[NSString stringWithFormat:@"item_%lu",(unsigned long)newdict.allKeys.count]];
- }
- newdict[@"count"]=[NSString stringWithFormat:@"%lu",(unsigned long)newdict.allKeys.count];
- appDelegate.recent_model = newdict;
- }
- -(void) reload
- {
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
-
-
- if(self.isrefreshing)
- return;
-
- // self.label_net_err.hidden=true;
- self.tableView.hidden = true;
- self.isrefreshing=true;
- // self.mum.center = self.view.center;
- // self.mum.hidden = false;
- // [self.mum startAnimating];
-
- //self.detailTable.hidden=true;
-
-
- [RANetwork request_modeldetail:self.product_id model_name:self.model_name upc_code:self.upc_code category_id:self.category_id use_name:self.use_model_name use_upc:self.use_upc_code groupName:self.groupName completionHandler:^(NSMutableDictionary *result) {
- NSMutableDictionary* detail_json=result;
-
- // [self.mum stopAnimating];
- self.groupName = nil;
- if([[detail_json valueForKey:@"result"] intValue]==2)
- {
-
- self.detail_data = [detail_json mutableCopy];
- self.product_id = [NSString stringWithFormat:@"%d",[[detail_json valueForKey:@"product_id"] intValue] ];
- NSMutableDictionary* imgsection = [[detail_json objectForKey:@"img_section"] mutableCopy];
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(/*appDelegate.user_type==USER_ROLE_CUSTOMER*/true)
- {
-
-
- self.quantity =[[imgsection valueForKey:@"stockUom"] intValue];
- }
- if(self.quantity==0)
- self.quantity=1;
- self.step=self.quantity;
- [self.tableView reloadData];
-
- //
- self.tableView.hidden = false;
-
- NSString* model_name = self.detail_data[@"img_section"][@"model_name"];
-
- NSString* img_url = self.detail_data[@"img_section"][@"model_s_img"];
-
- NSMutableDictionary* images=[self.detail_data[@"img_section"][@"images"] mutableCopy];
- NSMutableDictionary* videos=[self.detail_data[@"img_section"][@"videos"] mutableCopy];
-
- NSMutableDictionary* contents = [NSMutableDictionary new];
- int count = 0;
-
- {
- for(int ic=0;ic<[videos[@"count"] intValue];ic++)
- {
- NSString* videocode = videos[[NSString stringWithFormat:@"video_%d",ic]];
-
-
- // NSString* path=[[NSBundle mainBundle] pathForResource:@"play" ofType:@"jpg"];
- //
- // NSMutableDictionary* item =[@{@"type":@"video",@"is_localfile":@(true),@"l":path,@"s":path} mutableCopy];
- //
- // contents[[NSString stringWithFormat:@"item_%d",count]]=item ;
- // count++;
-
- NSMutableDictionary* item =[@{@"type":@"video",@"code":videocode} mutableCopy];
-
- contents[[NSString stringWithFormat:@"item_%d",count]]=item;
- count++;
- }
- }
-
- {
- for(int ic=0;ic<[images[@"img_count"] intValue];ic++)
- {
- NSMutableDictionary* item = [images[[NSString stringWithFormat:@"img_%d",ic]] mutableCopy];
- item[@"type"]=@"image";
- contents[[NSString stringWithFormat:@"item_%d",count]]=item;
- count++;
- }
-
- }
-
-
-
-
- contents[@"count"]=@(count);
- imgsection[@"stack_contents"]=contents;
- self.detail_data[@"img_section"]=imgsection;
- // self.detail_data[@"img_section"][@"stack_contents"]=contents;
-
- NSMutableDictionary* item = [[NSMutableDictionary alloc]init];
- [item setValue:self.product_id forKey:@"product_id"];
- [item setValue:self.category_id forKey:@"category"];
- [item setValue:model_name forKey:@"fash_name"];
- [item setValue:img_url forKey:@"picture_path"];
-
-
- [self add_recent_model:item];
-
- NSUInteger ii[2] = {0,0};
-
- [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndexes:ii length:2] atScrollPosition:UITableViewScrollPositionTop animated:YES];
-
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // int count=[appDelegate.recent_model[@"count"] intValue];
- // bool bexist = false;
- // for(int i=0;i<count;i++)
- // {
- // NSMutableDictionary * mitem= appDelegate.recent_model[[NSString stringWithFormat:@"item_%d",i]];
- // if([mitem[@"product_id"] isEqualToString:self.product_id])
- // {
- // bexist=true;
- // break;
- // }
- // }
- //
- // if(!bexist)
- // {
- // [appDelegate.recent_model setObject:item forKey:[NSString stringWithFormat:@"item_%d",count]];
- // appDelegate.recent_model[@"count"]=[NSString stringWithFormat:@"%d",count+1];
- // }
-
- self.groupName = [detail_json objectForKey:@"groupName"];
-
- }
- else
- if([[detail_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
- {
- self.tableView.hidden = true;
- // self.label_net_err.hidden=false;
- }
- else if([[detail_json valueForKey:@"result"] intValue]==RESULT_NO_MODEL)
- {
- self.tableView.hidden = true;
- [RAUtils message_box:@"Model Detail" message:[detail_json valueForKey:@"err_msg"] completion:nil] ;
-
- if(self.ispush)
- [ self.navigationController popViewControllerAnimated:true];
- }
- else
- {
- [RAUtils message_box:@"Model Detail" message:[detail_json valueForKey:@"err_msg"] completion:nil] ;
- }
-
- self.isrefreshing=false;
-
-
- }];
-
- return;
-
- });
- }
- /*
- #pragma mark - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- #pragma mark - RA_NOTIFICAITON
- -(void) refresh_ui
- {
- [self.tableView reloadData];
- }
- -(void) reload_data
- {
- [self reload];
- }
- -(void) refresh_price
- {
- [self refresh_ui];
- }
- #pragma mark - Table view data source
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- if(section==0)
- return nil;
-
- NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
- if(related_json==nil)
- {
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)(section-1)]];
- return [section_json valueForKey:@"title"] ;
- }
- else
- {
- if(section==1)
- return @"related model";
- else
- {
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)section-2]];
- return [section_json valueForKey:@"title"] ;
- }
- }
- }
- //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- //{
- // return 33;
- //}
- //-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- //
- //
- //
- // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
- //
- // if(value==nil)
- // value=@"";
- // unsigned long color = strtoul([value UTF8String],0,16);
- //
- // NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
- // if (sectionTitle == nil) {
- // return nil;
- // }
- //
- //
- // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // // myView.backgroundColor = UIColorFromRGB(0x996633);
- // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
- // myView.layer.shadowColor = [UIColor blackColor].CGColor;
- // myView.layer.shadowOffset = CGSizeMake(0, 0);
- // myView.layer.shadowOpacity = 0.5;
- // myView.layer.shadowRadius = 2.0;
- //
- // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5.5, 90, 22)];
- // titlelabel.textColor=UIColorFromRGB(color);
- // // titlelabel.backgroundColor = [UIColor clearColor];
- // titlelabel.text=sectionTitle;
- // [titlelabel sizeToFit];
- //
- //
- //
- // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)(section-1)]];
- // bool refresh= [[section_json valueForKey:@"partial_refresh"] boolValue] ;
- //
- //
- // if(refresh)
- // {
- // NSString* btntitle=@"Refresh" ;
- //
- //// NSString* value =[DefaultAppearance get_noneappearance_value:@"DetailTableHeaderView" valuename:@"refresh_button_color"];
- ////
- //// if(value==nil)
- //// value=@"";
- //// unsigned long color = strtoul([value UTF8String],0,16);
- //
- //
- //
- // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-100-15, 0, 100, 33)];
- //
- //
- // // [btn setTitleColor:UIColorFromRGB(color) forState:UIControlStateNormal];
- // btn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
- // btn.tag=section;
- // [btn addTarget:self action:@selector(RefreshSection:) forControlEvents:UIControlEventTouchUpInside];
- // [btn setTitle:btntitle forState:UIControlStateNormal];
- // [myView addSubview:btn];
- // }
- //
- // [myView addSubview:titlelabel];
- //
- //
- // return myView;
- //}
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
-
- int section_count =[[self.detail_data valueForKey:@"detail_section_count"] intValue];
- if(section_count==0)
- return section_count;
- NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
- if(related_json==nil)
- return section_count+1;
- else
- return section_count+2;
- }
- //- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- //{
- // DebugLog(@"canMoveRowAtIndexPath");
- //
- // if([tableView numberOfRowsInSection:indexPath.section]>1)
- // return true;
- // else
- // return false;
- //}
- //- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
- //{
- // NSMutableArray * from;
- // NSMutableArray * to ;
- // if(fromIndexPath.section==0)
- // from = self.displayfields;
- // else
- // from = self.hidefields;
- // if(toIndexPath.section==0)
- // to = self.displayfields;
- // else
- // to = self.hidefields;
- // id content=from[fromIndexPath.row];
- // [from removeObjectAtIndex:fromIndexPath.row];
- // [to insertObject:content atIndex:toIndexPath.row];
- //
- // [tableView reloadData];
- //
- //}
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
-
- if(section==0)
- return 2;
- NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
- if(related_json==nil)
- {
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)section-1]];
- NSString* type=[section_json valueForKey:@"type"] ;
- if([type isEqualToString:@"content"])
- return 1;
- return [[section_json valueForKey:@"count"] intValue];
- }
- else
- {
- if(section==1)
- return 1;
- else
- {
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)section-2]];
- NSString* type=[section_json valueForKey:@"type"] ;
- if([type isEqualToString:@"content"])
- return 1;
- return [[section_json valueForKey:@"count"] intValue];
- }
- }
-
-
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- if(section ==0)
- return 0;
- else
- return 33;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
-
- if(indexPath.section ==0)
-
- return 295;
-
- else if(indexPath.section==2||indexPath.section==3)
- return 270;
- NSDictionary* nsdic = self.detail_data;
- NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
- if(related_json==nil)
- {
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)indexPath.section-1]];
-
- NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
-
- NSString* type=[section_json valueForKey:@"type"] ;
-
- if([type isEqualToString:@"kv"])
- {
-
-
- float width = tableView.frame.size.width;
- width-=CELL_MARGIN*2;
- CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
- CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
-
-
-
- // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- NSString* key =[item_json valueForKey:@"key"] ;
-
- // [cell.keyLabel sizeToFit];
- NSString* val=[item_json valueForKey:@"val"] ;
-
- if([val isEqual:[NSNull null]])
- val=@"";
- if(val==nil)
- val=@"";
- if([val isEqualToString:@"null"])
- val=@"";
-
-
-
- CGRect frame;
- frame.size = constraintval;
- frame.origin.x=0;
- frame.origin.y=0;
- RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
- // rtlabel.lineSpacing = 20.0;
- [rtlabel setText: val];
-
- rtlabel.font = [UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
- CGSize sizeval=rtlabel.optimumSize;
- //
- //
- // CGSize sizeval0=[RAUtils sizeWithFont:val font:[UIFont systemFontOfSize:RTLABEL_FONT_SIZE] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- //
- // // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
- // CGSize sizekey = [RAUtils sizeWithFont:key font:[UIFont systemFontOfSize:RTLABEL_FONT_SIZE] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
-
- frame.size =constraintkey;
-
- UILabel* label = [[UILabel alloc] initWithFrame:frame];
- [label setLineBreakMode:NSLineBreakByWordWrapping];
- label.font=[UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
- label.text = key;
- CGSize sizekey =[label sizeThatFits:label.frame.size];
-
-
- // rtlabel.text = key;
- // CGSize sizekey =rtlabel.optimumSize;
-
- // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
- float height = MAX(sizekey.height,sizeval.height);
- height = MAX(height+LINE_WIDTH, DEF_CELL_HEIGHT);
-
-
- return height;
- }
- else if([type isEqualToString:@"img"])
- {
- int img_count = [[item_json valueForKey:@"count"] intValue];
- double ret = 0;
- for(int j=0;j<img_count;j++)
- {
- NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
- float width = [[img_json valueForKey:@"width"]floatValue];
- float height = [[img_json valueForKey:@"height"]floatValue];
- ret+=height*tableView.bounds.size.width / width;
- }
-
- return ret;
- }
- else if([type isEqualToString:@"content"])
- return 270;
-
- }
-
-
- return 44;
- }
- - (BOOL)isOutofStock {
- NSMutableDictionary* section_json = [[self.detail_data objectForKey:@"img_section"] mutableCopy];
- NSString *qtyStr = [section_json valueForKey:@"Availability"];
-
- // 2018-01-10 修改通过lowercase判断
- if (!qtyStr || !qtyStr.length || [qtyStr.lowercaseString isEqualToString:@"in production"] || [qtyStr isEqualToString:@"0"] || [qtyStr.lowercaseString isEqualToString:@"sold out"] || [qtyStr.lowercaseString isEqualToString:@"out of stock"]) {
- return YES;
- }
- return NO;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
-
- if(indexPath.section==0)
- if(indexPath.item ==0)
- {
-
- NSString *CellIdentifier = @"DetailImageCell";
- DetailSlideImageCell *slidecell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- [slidecell.imgScroll stopTimmer];
- [slidecell.imgScroll removeFromSuperview];
-
-
- NSMutableDictionary* view_json = [[self.detail_data objectForKey:@"img_section"] mutableCopy];
-
- //如果模版有高度就用模版设置值,没有则用默认值。
- int i_width = [[view_json valueForKey:@"width"]intValue];
- int i_height = [[view_json valueForKey:@"height"]intValue];
- if(i_width<=0||i_height<=0)
- {
- i_width=400;
- i_height=300;
- }
-
-
-
- int ui_height = (tableView.frame.size.width * i_height)/i_width;
-
-
-
- CycleScrollViewPlus *imgScroll = [[CycleScrollViewPlus alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, ui_height) animationDuration:5];
-
- imgScroll.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
- int slide_item_count = [view_json[@"stack_contents"][@"count"] intValue];
-
- //imgScroll.frame =CGRectMake(0, 5, width, 300);
- [imgScroll reset];
-
- // [imgScroll animationDuration:5];
- // imgScroll.backgroundColor = [[UIColor purpleColor] colorWithAlphaComponent:0.1];
-
- for(int i = 0;i<slide_item_count;i++)
- {
- NSDictionary * slide_itemjson =view_json[@"stack_contents"][[NSString stringWithFormat:@"item_%d",i]] ;
-
-
- SliderPage * tempview = [[SliderPage alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, ui_height)];
- tempview.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
- NSString* img_url =nil;
- if([slide_itemjson[@"type"] isEqualToString:@"image"])
- img_url=[slide_itemjson valueForKey:@"s"];
- else
- img_url=@"";
-
-
- tempview.contentMode = UIViewContentModeScaleAspectFit;
- tempview.img_url = img_url;
- // tempview.url =@"";
- // tempview.action_type = ;
- // tempview.params = ;
-
- [imgScroll addPage:tempview];
-
-
-
- }
-
-
- [imgScroll setTotalPagesCount];
- imgScroll.TapActionBlock = ^(NSInteger pageIndex){
- DebugLog(@"点击了第%ld个",(long)pageIndex);
- NSDictionary * item_json =[view_json objectForKey:[NSString stringWithFormat:@"item_%ld",pageIndex] ];
- NSString* action = [item_json valueForKeyPath:@"action"];
-
-
- };
-
- //
- slidecell.imgScroll = imgScroll;
- // return cell;
- [slidecell.contentView addSubview:imgScroll];
- return slidecell;
- }
- else
- {
-
-
- NSMutableDictionary* section_json = [[self.detail_data objectForKey:@"img_section"] mutableCopy];
- NSString *CellIdentifier = @"DetailBasicCell0";
- DetailBasicCell0 *basiccell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- basiccell.celldelegate=self;
-
-
-
-
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-
- NSMutableDictionary* dict = [[defaults dictionaryForKey:@"local_list"] mutableCopy];
-
- // NSMutableArray* arr = [[defaults arrayForKey:@"local_list_idx"] mutableCopy];
-
-
-
- if(dict[self.product_id])
- {
- UIImage* img = basiccell.btnAddList.imageView.image;
-
- UIImage* img1 = [img imageWithTintColor:UIColor.redColor];
-
- basiccell.btnAddList.imageView.image = [img imageWithTintColor:UIColor.redColor];
- // basiccell.btnAddList.imageView.tintColor= UIColor.redColor;
- [basiccell.btnAddList setTitle:@"Remove from list" forState:UIControlStateNormal];
-
- // [basiccell.btnAddList setBackgroundColor:UIColor.redColor];
- }
-
- else
- {
-
- UIImage* img =basiccell.btnAddList.imageView.image;;
-
-
-
- basiccell.btnAddList.imageView.image = [img imageWithTintColor:UIColor.blackColor];
- // basiccell.btnAddList.imageView.tintColor= UIColor.blackColor;
- [basiccell.btnAddList setTitle:@"Add to list" forState:UIControlStateNormal];
-
- // [basiccell.btnAddList setBackgroundColor:UIColor.blackColor];
- }
-
- basiccell.descriptionRTLabel.text =[NSString stringWithFormat:@"%@\n\n",[section_json valueForKey:@"model_descrition"]];
-
- basiccell.labelModel.text =[section_json valueForKey:@"model_name"];
- self.selector = [section_json objectForKey:@"selector"];
-
-
- NSString* defaultimg = nil;
-
- if(self.selector!=nil)
- {
-
-
- int selector_count = [[self.selector valueForKey:@"count"] intValue];
-
- basiccell.imageviewSelector.image = [UIImage imageNamed:@"loading_s"];
-
- for(int i=0;i<selector_count;i++)
- {
- NSDictionary* params_json=[[self.selector objectForKey:[NSString stringWithFormat:@"item_%d",i]] objectForKey:@"params"] ;
-
- if([[[[params_json objectForKey:@"param_0"] valueForKey:@"val"] stringValue] isEqualToString:self.product_id])
- {
-
- NSString* selectstr=[NSString stringWithFormat:@"%@: %@",[self.selector valueForKey:@"name"],[[self.selector objectForKey:[NSString stringWithFormat:@"item_%d",i]] valueForKey:@"title"]];
- if([[self.selector objectForKey:[NSString stringWithFormat:@"item_%d",i]] valueForKey:@"title"] ==nil)
- selectstr=[NSString stringWithFormat:@"%@:",[self.selector valueForKey:@"name"]];
- basiccell.labelSelector.text = selectstr;
-
- NSString* img_url = [[self.selector objectForKey:[NSString stringWithFormat:@"item_%d",i]] valueForKey:@"pic_url"];
-
- if(i==0)
- defaultimg = img_url;
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[FileCache load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
- dispatch_async(dispatch_get_main_queue(), ^{
- UIImage * img =[UIImage imageWithData:img_data];
- basiccell.imageviewSelector.image=img;
-
-
-
- });
- }
- else
- {
- NSData* downloadimg_data = nil;
- // BOOL offline = NO;
- //#ifdef OFFLINE_MODE
- // offline = appDelegate.offline_mode;
- //#endif
- // if (!offline) {
- downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
- // }
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- basiccell.imageviewSelector.image=img;
- }
- else
- basiccell.imageviewSelector.image = [UIImage imageNamed:@"notfound_s"];
-
- });
- }
-
- }
- }
- }
-
- NSDictionary* property_json = [section_json objectForKey:@"property"];
- // int pcount = [[property_json valueForKey:@"count"]intValue];
- basiccell.labelProperty.text=[[property_json objectForKey:@"item_0"] valueForKey:@"key"];
- basiccell.labelPropertyVal.text=[[property_json objectForKey:@"item_0"] valueForKey:@"val"];
-
-
-
- basiccell.WatchlistBlock = ^(void){
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-
- NSMutableDictionary* dict = [[defaults dictionaryForKey:@"local_list"] mutableCopy];
-
-
- NSMutableArray* arr = [[defaults arrayForKey:@"local_list_idx"] mutableCopy];
-
- if(dict ==nil)
- dict = [NSMutableDictionary new];
-
-
- if(arr ==nil)
- arr = [NSMutableArray new];
-
- if(dict[self.product_id])
- {
- [dict removeObjectForKey:self.product_id];
- [arr removeObject:self.product_id];
- }
- else
- {
- NSMutableDictionary* obj = [NSMutableDictionary new];
-
-
-
- obj[@"img_url"]=defaultimg;
- obj[@"description"]=[section_json valueForKey:@"model_descrition"];
- obj[@"model_name"]=self.model_name;
- obj[@"catalog_id"]=self.category_id;
-
-
- dict[self.product_id]= obj;
- [arr insertObject:self.product_id atIndex:0];
- }
-
-
-
-
- // [arr insertObject:obj atIndex:0];
-
- [defaults setObject:dict forKey:@"local_list"];
-
- [defaults setObject:arr forKey:@"local_list_idx"];
-
- [defaults synchronize];
-
-
-
- [self.tableView reloadData];
-
-
- [TabViewController Notify:@"LocalListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-
- // self.add_wish=true;
- // CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
- // rect.origin.y = rect.origin.y - [self.detailTable contentOffset].y;
- // CGRect headRect = imageView.frame;
- // headRect.origin.y = rect.origin.y+headRect.origin.y;
- // [self startAnimationWithRect:headRect ImageView:imageView];
- };
-
-
- return basiccell;
-
-
- }
-
- else
- {
-
-
-
-
- NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)indexPath.section-1]];
-
- NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
-
- NSString *CellIdentifier = @"DetailInfoCell";
-
- NSString* type=[section_json valueForKey:@"type"] ;
-
-
- if([type isEqualToString:@"kv"])
- {
-
-
-
-
-
- float width = tableView.frame.size.width;
-
- width-=CELL_MARGIN*2;
- CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
- CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
- // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- NSString* key =[item_json valueForKey:@"key"] ;
-
- NSString* val=[item_json valueForKey:@"val"] ;
-
-
- NSString* type=[item_json valueForKey:@"type"] ;
-
-
-
- if([val isEqual:[NSNull null]])
- val=@"";
- if(val==nil)
- val=@"";
- if([val isEqualToString:@"null"])
- val=@"";
-
-
-
-
- CGRect frame;
- frame.size = constraintval;
- frame.origin.x=0;
- frame.origin.y=0;
- RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
- rtlabel.font=[UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
- // rtlabel.lineSpacing = 20.0;
- [rtlabel setText: val];
- CGSize sizeval=rtlabel.optimumSize;
- // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
-
- frame.size =constraintkey;
-
- UILabel* label = [[UILabel alloc] initWithFrame:frame];
- [label setLineBreakMode:NSLineBreakByWordWrapping];
- label.font=[UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
- label.text = key;
- CGSize sizekey =[label sizeThatFits:label.frame.size]; // [RAUtils sizeWithFont:key font:[UIFont systemFontOfSize:RTLABEL_FONT_SIZE] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
- float height = MAX(sizekey.height,sizeval.height);
- height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
- sizekey.height = height;
- sizekey.width = constraintkey.width;
- // sizeval.height = height;
- sizeval.width =constraintval.width;
-
- // NSString *CellIdentifier = @"detail_item_kv";
- DetailKVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- if(cell==nil)
- DebugLog(@"cell is nil.........................");
-
-
- // cell.layer.bo
-
- cell.layer.borderWidth = 0.5;
- cell.layer.borderColor = [[UIColor lightGrayColor] CGColor];
- // self.btnSelector.layer.cornerRadius = 0;
-
-
- CGRect framekey = cell.keyLabel.frame;
- framekey.origin.x=CELL_MARGIN+LABEL_MARGIN;
- framekey.origin.y=LINE_WIDTH/2;
- framekey.size = sizekey;
- cell.keyLabel.frame = framekey;
- cell.keyLabel.text=key;
- cell.keyLabel.font = [UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
-
-
-
-
-
- CGRect frameval = cell.valLabel.frame;
- frameval.origin.x=constraintkey.width+CELL_MARGIN+3*LABEL_MARGIN; //2 margin for key 1 margin for value self
- frameval.origin.y=0;
- frameval.size = sizeval;
- cell.valLabel.frame = frameval;
- // [cell.valLabel setTextAlignment:RTTextAlignmentCenter];
- cell.valLabel.text= val;
- cell.valLabel.font = [UIFont systemFontOfSize:RTLABEL_FONT_SIZE];
-
- CGPoint rcenter;
- rcenter.x = width * 0.4+width * 0.6/2;
- rcenter.y = (height+LINE_WIDTH) /2;
- cell.valLabel.center=rcenter;
-
- // cell.valLabel.backgroundColor =[UIColor redColor];
-
- // cell.contentView.superview.backgroundColor = [UIColor clearColor];
- // cell.backgroundColor = [UIColor whiteColor];
- UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
-
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- // else if ([type isEqualToString:@"img"])
- // {
- // DetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailImageCell" forIndexPath:indexPath];
- //
- // int img_count = [[item_json valueForKey:@"count"] intValue];
- // double posy = 0;
- // for(int j=0;j<img_count;j++)
- // {
- // NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
- // float width = [[img_json valueForKey:@"width"]floatValue];
- // float height = [[img_json valueForKey:@"height"]floatValue];
- // //
- // UIImageView * imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, posy, tableView.bounds.size.width , height*tableView.bounds.size.width / width)];
- // imgview.contentMode = UIViewContentModeScaleAspectFit;
- //
- // NSString* img_url = [img_json valueForKey:@"img_url"];
- // posy+=height*tableView.bounds.size.width / width;
- // NSString* file_name=[img_url lastPathComponent];
- // NSData* img_data=[FileCache load_cached_img:file_name loadFrom:img_url];
- // if(img_data!=nil)
- // {
- //
- // UIImage * img =[UIImage imageWithData:img_data];
- // imgview.image = img;
- // [cell addSubview:imgview];
- // }
- // else
- // {
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSData* downloadimg_data = nil;
- //// BOOL offline = NO;
- ////#ifdef OFFLINE_MODE
- //// offline = appDelegate.offline_mode;
- ////#endif
- //// if (!offline) {
- // downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
- //// }
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if(downloadimg_data!=nil)
- // {
- //
- // [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
- //
- // UIImage * img =[UIImage imageWithData:downloadimg_data];
- // imgview.image = img;
- // [cell addSubview:imgview];
- // }
- // else
- // {
- // imgview.image = [UIImage imageNamed:@"notfound_l"];
- //
- // [cell addSubview:imgview];
- //
- // }
- // });
- // });
- //
- //
- // }
- //
- //
- // }
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- // }
- else if ([type isEqualToString:@"content"])
- {
-
- NSString *CellIdentifier = @"DetailTopicCell";
-
- NSString* data=[section_json valueForKey:@"data"] ;
- if([data isEqualToString:@"local"])
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [appDelegate.recent_model addEntriesFromDictionary:section_json];
-
- // NSDictionary* section_json = [self.detail_data objectForKey:@"related_model"];
- DetailTopicCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- cell.itemdelegate = self;
- cell.related_data = appDelegate.recent_model;
- [cell.topicCollectionView reloadData];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- }
- else
- {
-
- // NSDictionary* section_json = [self.detail_data objectForKey:@"related_model"];
- DetailTopicCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- cell.itemdelegate = self;
- cell.related_data = section_json;
- [cell.topicCollectionView reloadData];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
-
- }
- // return nil;
-
- }
-
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
-
- return cell;
- }
- //{
- // // DebugLog(@"cellForRowAtIndexPath");
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- //
- // // NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
- // // if(related_json==nil)
- // else
- // {
- //
- //
- //
- //
- // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%ld",(long)indexPath.section-1]];
- //
- // NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
- //
- // NSString *CellIdentifier = @"DetailInfoCell";
- //
- // NSString* type=[section_json valueForKey:@"type"] ;
- //
- // if([type isEqualToString:@"kv"])
- // {
- // float width = tableView.frame.size.width;
- //
- // width-=CELL_MARGIN*2;
- // CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
- // CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
- // // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
- // NSString* key =[item_json valueForKey:@"key"] ;
- //
- // NSString* val=[item_json valueForKey:@"val"] ;
- //
- //
- // NSString* type=[item_json valueForKey:@"type"] ;
- //
- // if([type isEqualToString:@"price"])
- // {
- //
- // if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- // {
- //
- // }
- // else
- // {
- // val=nil;
- // }
- // }
- //
- //
- // if([val isEqual:[NSNull null]])
- // val=@"";
- // if(val==nil)
- // val=@"";
- // if([val isEqualToString:@"null"])
- // val=@"";
- //
- //
- //
- //
- // CGRect frame;
- // frame.size = constraintval;
- // frame.origin.x=0;
- // frame.origin.y=0;
- // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
- // // rtlabel.lineSpacing = 20.0;
- // [rtlabel setText: val];
- // CGSize sizeval=rtlabel.optimumSize;
- //// CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
- //
- // CGSize sizekey = [RAUtils sizeWithFont:key font:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
- //
- // float height = MAX(sizekey.height,sizeval.height);
- // height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
- // sizekey.height = height;
- // sizekey.width = constraintkey.width;
- // // sizeval.height = height;
- // sizeval.width =constraintval.width;
- //
- // // NSString *CellIdentifier = @"detail_item_kv";
- // DetailKVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // if(cell==nil)
- // DebugLog(@"cell is nil.........................");
- //
- //
- //
- //
- // CGRect framekey = cell.keyLabel.frame;
- // framekey.origin.x=CELL_MARGIN+LABEL_MARGIN;
- // framekey.origin.y=LINE_WIDTH;
- // framekey.size = sizekey;
- // cell.keyLabel.frame = framekey;
- // cell.keyLabel.text=key;
- // CGRect frameval = cell.valLabel.frame;
- // frameval.origin.x=constraintkey.width+CELL_MARGIN+3*LABEL_MARGIN; //2 margin for key 1 margin for value self
- // frameval.origin.y=LINE_WIDTH;
- // frameval.size = sizeval;
- // cell.valLabel.frame = frameval;
- // // [cell.valLabel setTextAlignment:RTTextAlignmentCenter];
- // cell.valLabel.text= val;
- // CGPoint rcenter;
- // rcenter.x = width * 0.4+width * 0.6/2;
- // rcenter.y = height /2;
- // cell.valLabel.center=rcenter;
- // // cell.valLabel.backgroundColor =[UIColor redColor];
- //
- // // cell.contentView.superview.backgroundColor = [UIColor clearColor];
- // // cell.backgroundColor = [UIColor whiteColor];
- // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
- // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
- // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
- // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
- //
- //
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- // }
- // else if ([type isEqualToString:@"img"])
- // {
- // DetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailImageCell" forIndexPath:indexPath];
- //
- // int img_count = [[item_json valueForKey:@"count"] intValue];
- // double posy = 0;
- // for(int j=0;j<img_count;j++)
- // {
- // NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
- // float width = [[img_json valueForKey:@"width"]floatValue];
- // float height = [[img_json valueForKey:@"height"]floatValue];
- // //
- // UIImageView * imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, posy, tableView.bounds.size.width , height*tableView.bounds.size.width / width)];
- // imgview.contentMode = UIViewContentModeScaleAspectFit;
- //
- // NSString* img_url = [img_json valueForKey:@"img_url"];
- // posy+=height*tableView.bounds.size.width / width;
- // NSString* file_name=[img_url lastPathComponent];
- // NSData* img_data=[FileCache load_cached_img:file_name loadFrom:img_url];
- // if(img_data!=nil)
- // {
- //
- // UIImage * img =[UIImage imageWithData:img_data];
- // imgview.image = img;
- // [cell addSubview:imgview];
- // }
- // else
- // {
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSData* downloadimg_data = nil;
- //// BOOL offline = NO;
- ////#ifdef OFFLINE_MODE
- //// offline = appDelegate.offline_mode;
- ////#endif
- //// if (!offline) {
- // downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
- //// }
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if(downloadimg_data!=nil)
- // {
- //
- // [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
- //
- // UIImage * img =[UIImage imageWithData:downloadimg_data];
- // imgview.image = img;
- // [cell addSubview:imgview];
- // }
- // else
- // {
- // imgview.image = [UIImage imageNamed:@"notfound_l"];
- //
- // [cell addSubview:imgview];
- //
- // }
- // });
- // });
- //
- //
- // }
- //
- //
- // }
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- // }
- // else if ([type isEqualToString:@"content"])
- // {
- //
- // NSString *CellIdentifier = @"DetailTopicCell";
- //
- // NSString* data=[section_json valueForKey:@"data"] ;
- // if([data isEqualToString:@"local"])
- // {
- // [appDelegate.recent_model addEntriesFromDictionary:section_json];
- //
- // // NSDictionary* section_json = [self.detail_data objectForKey:@"related_model"];
- // DetailTopicCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // cell.itemdelegate = self;
- // cell.related_data = appDelegate.recent_model;
- // [cell.topicCollectionView reloadData];
- //
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- //
- // }
- // else
- // {
- //
- // // NSDictionary* section_json = [self.detail_data objectForKey:@"related_model"];
- // DetailTopicCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // cell.itemdelegate = self;
- // cell.related_data = section_json;
- // [cell.topicCollectionView reloadData];
- //
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- // }
- //
- // }
- // return nil;
- //
- // }
- //
- //
- //}
- - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath
- {
- if([cell isKindOfClass:[DetailSlideImageCell class]])
- {
- DetailSlideImageCell* slidecell=(DetailSlideImageCell*)cell;
- [slidecell.imgScroll stopTimmer];
- }
- }
- #pragma mark - Basic0 cell delegate
- -(void) SelectorClicked:(UIView*) trigger
- {
-
-
-
- int selector_count = [[self.selector valueForKey:@"count"] intValue];
-
-
- int current_sel = -1;
- for(int i=0;i<selector_count;i++)
- {
- NSDictionary* params_json=[[self.selector objectForKey:[NSString stringWithFormat:@"item_%d",i]] objectForKey:@"params"] ;
-
-
- if([[[[params_json objectForKey:@"param_0"] valueForKey:@"val"] stringValue] isEqualToString:self.product_id])
- {
-
- current_sel = i;
- }
- }
-
- ColorSelectViewController* colorSelectVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ColorSelectViewController"];
-
- colorSelectVC.data = self.selector;
-
- colorSelectVC.selected =current_sel;
-
-
- __block CatalogModelDetailViewController *brself= self;
-
- colorSelectVC.selectChanged =^(long index){
-
-
- NSDictionary* item = [brself.selector objectForKey:[NSString stringWithFormat:@"item_%ld",index]];
-
- NSDictionary* params = [item objectForKey:@"params"];
-
- NSString* detail_id=[[[params objectForKey:@"param_0"] valueForKey:@"val" ] stringValue];
-
-
- brself.product_id = detail_id;
- brself.use_model_name = false;
- [brself reload];
-
-
-
-
- };
-
- //
- // UIModalPresentationFullScreen = 0,
- // UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
- // UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
- // UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),
- // UIModalPresentationCustom API_AVAILABLE(ios(7.0)),
- // UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),
- // UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),
- // UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),
- // UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),
- // UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,
- // UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,
-
- CustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
-
- presentationController = [[CustomPresentationController alloc] initWithPresentedViewController:colorSelectVC presentingViewController:self];
-
- colorSelectVC.transitioningDelegate = presentationController;
-
- [self presentViewController:colorSelectVC animated:YES completion:NULL];
-
-
-
- //
- //
- // colorSelectVC.modalPresentationStyle = UIModalPresentationFormSheet;
- //
- //
- //
- //
- //// if (self = [super initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController]) {
- //// _controllerHeight = presentedViewController.controllerHeight == 0 ? [UIScreen mainScreen].bounds.size.height : presentedViewController.controllerHeight;
- //// }
- //
- // [self presentViewController:colorSelectVC animated:YES completion:^{
- //// CGRect frame = self.view.frame;
- //// colorSelectVC.view.superview.frame =CGRectMake(frame.origin.x, frame.origin.y+20, frame.size.width, frame.size.height*0.6);
- //
- // colorSelectVC.preferredContentSize = CGSizeMake(200,200);
- // }];
- //
- //
- //
- //
- //
- // if(self.dropDown == nil)
- // {
- // CGFloat height = 70*selector_count;
- // if (selector_count > 4) {
- // height = 70 * 4.5;
- // }
- // self.dropDown =[[NIDropDown alloc] showDropDown:trigger.superview based:(id)trigger height:height data:self.selector direction:@"up" current_sel:current_sel];
- //
- //
- // //Capturing strongly warring;
- // __block CatalogModelDetailViewController *brself= self;
- // self.dropDown.dropDownTouchOutsideBlk = ^{
- // [brself.dropDown hideDropDown:(id)trigger];
- // brself.dropDown= nil;
- // };
- //
- //
- // }
- // else {
- // [self.dropDown hideDropDown:(id)trigger];
- // self.dropDown= nil;
- // }
-
- return;
-
-
- }
- #pragma mark - Topic cell delegate
- -(void) TopicItemClicked:(NSString*) product_id category:(NSString*) category
- {
- if(true)
- {
- CatalogModelDetailViewController* dvc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CatalogModelDetailViewController" ];
-
- // dvc.OnBack=^(bool add_cart,bool add_wish,bool update_data)
- // {
- //
- //
- // NSMutableDictionary* items =[[self.category_data objectForKey:@"items"] mutableCopy];
- //
- // NSMutableDictionary* item = [[items objectForKey:[NSString stringWithFormat:@"item_%ld",index]] mutableCopy];
- // if(add_cart)
- // item[@"cart_exists"]=@"true";
- // if(add_wish)
- // item[@"wish_exists"]=@"true";
- // items[[NSString stringWithFormat:@"item_%ld",index]] = item;
- // self.category_data[@"items"]=items;
- //
- // [self.collectionview reloadData];
- // };
- dvc.product_id = product_id;
- dvc.category_id=category;
- dvc.ispush = true;
- // dvc.model_name = name;
-
- [dvc reload];
- [self.navigationController pushViewController:dvc animated:true];
- return;
-
-
-
- }
- else
- {
- // self.model_name = value;
- self.product_id = product_id;
- self.category_id=category;
- [self reload];
- DebugLog(@"color selected");
- }
- }
- @end
|