shopDetailVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. //
  2. // shopDetailVC.m
  3. // YBVideo
  4. //
  5. // Created by IOS1 on 2019/7/5.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "shopDetailVC.h"
  9. #import "shopCell.h"
  10. #import "AddGoodsVC.h"
  11. #import "GoodsDetailViewController.h"
  12. #import "CommodityDetailVC.h"
  13. #import "StoreInfoView.h"
  14. #import "ShopInfoVC.h"
  15. #import "JCHATConversationViewController.h"
  16. #import "OutsideGoodsDetailVC.h"
  17. #import "PlatformCell.h"
  18. @interface shopDetailVC ()<UICollectionViewDelegate,UICollectionViewDataSource>{
  19. int page;
  20. NSMutableArray *infoArray;
  21. UIImageView *bigImgView;
  22. UIImageView *iconImgV;
  23. UILabel *nameL;
  24. UILabel *contentL;
  25. UILabel *numL;
  26. UILabel *platformNumL;
  27. UIView *headerView;
  28. UIButton *saleBtn;
  29. UIButton *platfromBtn;
  30. UIButton *allreturnBtn;
  31. NSDictionary *shopInfo;
  32. NSString *numsStr;
  33. StoreInfoView *_infoView;
  34. UIButton *customerBtn;
  35. NSArray *titleArr;
  36. UILabel *lineLb;
  37. BOOL isPlatform;
  38. UIView *noDataView;
  39. }
  40. @property (nonatomic,strong) UICollectionView *shopCollectView;
  41. @end
  42. @implementation shopDetailVC
  43. - (UIStatusBarStyle)preferredStatusBarStyle {
  44. if (@available(iOS 13.0,*)) {
  45. return UIStatusBarStyleDarkContent;
  46. }
  47. return UIStatusBarStyleDefault;
  48. }
  49. - (void)addBtnClick{
  50. AddGoodsVC *vc = [[AddGoodsVC alloc]init];
  51. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  52. }
  53. - (void)viewDidLoad {
  54. [super viewDidLoad];
  55. self.subNavi.backgroundColor = UIColor.whiteColor;
  56. self.titleL.textColor = UIColor.blackColor;
  57. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  58. self.naviLine.hidden = NO;
  59. self.naviLine.backgroundColor = RGB(245, 245, 245);
  60. self.titleL.text = [common shop_system_name];
  61. infoArray = [NSMutableArray array];
  62. page = 1;
  63. [self creatUI];
  64. // [self requestData];
  65. if (titleArr.count > 1) {
  66. [self requestData];
  67. }else{
  68. [self getPlatformGoods];
  69. }
  70. [self createNoDataView];
  71. }
  72. - (void)creatUI{
  73. headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 180)];
  74. headerView.backgroundColor = [UIColor whiteColor];
  75. iconImgV = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 50, 50)];
  76. iconImgV.layer.cornerRadius = 25;
  77. iconImgV.layer.masksToBounds = YES;
  78. iconImgV.contentMode = UIViewContentModeScaleAspectFill;
  79. iconImgV.clipsToBounds = YES;
  80. iconImgV.backgroundColor = Normal_Color;
  81. [headerView addSubview:iconImgV];
  82. nameL = [[UILabel alloc]init];
  83. nameL.textColor = [UIColor blackColor];
  84. nameL.font = [UIFont boldSystemFontOfSize:14];
  85. [headerView addSubview:nameL];
  86. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(iconImgV).offset(10);
  88. make.left.equalTo(iconImgV.mas_right).offset(15);
  89. }];
  90. UIButton *shopTap = [UIButton buttonWithType:0];
  91. [shopTap addTarget:self action:@selector(shopTapClick) forControlEvents:UIControlEventTouchUpInside];
  92. [headerView addSubview:shopTap];
  93. [shopTap mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.right.top.bottom.equalTo(nameL);
  95. }];
  96. UIImageView *rightImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"shop_right"]];
  97. [headerView addSubview:rightImg];
  98. [rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.equalTo(nameL.mas_right).offset(5);
  100. make.height.width.mas_equalTo(16);
  101. make.centerY.equalTo(nameL.mas_centerY);
  102. }];
  103. customerBtn = [UIButton buttonWithType:0];
  104. [customerBtn setImage:[UIImage imageNamed:@"shophome_客服"] forState:0];
  105. [customerBtn addTarget:self action:@selector(customerBtnClick) forControlEvents:UIControlEventTouchUpInside];
  106. [headerView addSubview:customerBtn];
  107. [customerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.right.equalTo(headerView.mas_right).offset(-15);
  109. make.height.width.mas_equalTo(20);
  110. make.centerY.equalTo(nameL.mas_centerY);
  111. }];
  112. if ([[Config getOwnID] isEqual:_toUserID]) {
  113. customerBtn.hidden = YES;
  114. }
  115. _infoView = [[StoreInfoView alloc]initWithFrame:CGRectMake(15, iconImgV.bottom +10, _window_width-30, 64)];
  116. _infoView.layer.cornerRadius = 5;
  117. _infoView.layer.masksToBounds = YES;
  118. [headerView addSubview:_infoView];
  119. UIView *numView = [[UIView alloc]init];
  120. numView.backgroundColor =RGB_COLOR(@"#f5f5f5", 1);
  121. numView.frame = CGRectMake(0, headerView.height-30, _window_width, 30);
  122. [headerView addSubview:numView];
  123. if ([_toUserID isEqual:@"1"]) {
  124. titleArr = @[YZMsg(@"平台自营")];
  125. }else{
  126. titleArr = @[YZMsg(@"在售商品"),YZMsg(@"平台自营")];
  127. }
  128. for (int i = 0; i < titleArr.count; i ++) {
  129. UIButton *btn = [UIButton buttonWithType:0];
  130. btn.frame = CGRectMake(iconImgV.left +60*i+40*i, numView.height/2-10, 60, 20);
  131. if (![lagType isEqual:ZH_CN]) {
  132. if (i==1) {
  133. btn.frame = CGRectMake(iconImgV.left +140*i+40*i, numView.height/2-10, 70, 20);
  134. }else {
  135. btn.frame = CGRectMake(iconImgV.left +120*i+40*i, numView.height/2-10, 120, 20);
  136. }
  137. }
  138. [btn setTitle:titleArr[i] forState:0];
  139. btn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  140. [btn setTitleColor:RGB_COLOR(@"#969696", 1) forState:0];
  141. [btn setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
  142. [btn addTarget:self action:@selector(goodsListBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  143. btn.tag = 20000+i;
  144. [numView addSubview:btn];
  145. UILabel *lb = [[UILabel alloc]init];
  146. lb.frame = CGRectMake(btn.right, btn.top, 30, 20);
  147. lb.textColor = RGB_COLOR(@"#969696", 1);
  148. lb.font = [UIFont systemFontOfSize:12];
  149. [numView addSubview:lb];
  150. if (![lagType isEqual:ZH_CN]) {
  151. lb.frame = CGRectMake(btn.right, btn.top, 60, 20);
  152. }
  153. btn.titleLabel.adjustsFontSizeToFitWidth = YES;
  154. lb.adjustsFontSizeToFitWidth = YES;
  155. if (titleArr.count > 1) {
  156. if ( i == 0) {
  157. saleBtn = btn;
  158. numL = lb;
  159. saleBtn.selected = YES;
  160. }else{
  161. platfromBtn =btn;
  162. platformNumL = lb;
  163. }
  164. }else{
  165. platfromBtn =btn;
  166. platformNumL = lb;
  167. platfromBtn.selected = YES;
  168. }
  169. }
  170. lineLb = [[UILabel alloc]init];
  171. if (titleArr.count > 1) {
  172. lineLb.frame = CGRectMake(0, saleBtn.bottom, 20, 2);
  173. lineLb.centerX = saleBtn.centerX;
  174. }else{
  175. lineLb.frame = CGRectMake(0, platfromBtn.bottom, 20, 2);
  176. lineLb.centerX = platfromBtn.centerX;
  177. }
  178. lineLb.backgroundColor = Pink_Cor;
  179. lineLb.layer.cornerRadius = 1;
  180. lineLb.layer.masksToBounds = YES;
  181. [numView addSubview:lineLb];
  182. [self.view addSubview:self.shopCollectView];
  183. [self.view sendSubviewToBack:_shopCollectView];
  184. }
  185. -(void)goodsListBtnClick:(UIButton *)sender
  186. {
  187. if (titleArr.count > 1) {
  188. page = 1;
  189. if (sender.tag == 20000) {
  190. //在售商品
  191. saleBtn.selected = YES;
  192. platfromBtn.selected = NO;
  193. lineLb.centerX = saleBtn.centerX;
  194. isPlatform = NO;
  195. [self requestData];
  196. }else{
  197. //平台自营
  198. saleBtn.selected = NO;
  199. platfromBtn.selected = YES;
  200. lineLb.centerX = platfromBtn.centerX;
  201. isPlatform = YES;
  202. [self getPlatformGoods];
  203. }
  204. }else{
  205. page = 1;
  206. platfromBtn.selected = YES;
  207. lineLb.centerX = platfromBtn.centerX;
  208. isPlatform = YES;
  209. [self getPlatformGoods];
  210. }
  211. }
  212. -(void)customerBtnClick{
  213. if ([_toUserID isEqual:@"1"]) {
  214. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:nil message:YZMsg(@"请到个性设置-关于我们中联系客服") preferredStyle:UIAlertControllerStyleAlert];
  215. UIAlertAction *sureAction = [UIAlertAction actionWithTitle:YZMsg(@"确定") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  216. }];
  217. [sureAction setValue:Normal_Color forKey:@"_titleTextColor"];
  218. [alertControl addAction:sureAction];
  219. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:alertControl animated:YES completion:nil];
  220. }else{
  221. NSDictionary *userDic = @{
  222. @"id":strFormat([shopInfo valueForKey:@"uid"]),
  223. @"user_nickname":strFormat([shopInfo valueForKey:@"user_nickname"]),
  224. @"avatar":strFormat([shopInfo valueForKey:@"avatar"]),
  225. };
  226. [[YBMessageManager shareManager] chatWithUser:userDic];
  227. }
  228. }
  229. -(void)shopTapClick{
  230. ShopInfoVC *shop = [[ShopInfoVC alloc]init];
  231. shop.shopInfoDic =shopInfo;
  232. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:shop animated:YES];
  233. }
  234. -(void)createNoDataView{
  235. noDataView = [[UIView alloc]initWithFrame:CGRectMake(0, 200, _window_width, 150)];
  236. noDataView.hidden = YES;
  237. noDataView.backgroundColor = [UIColor clearColor];
  238. [_shopCollectView addSubview:noDataView];
  239. UIImageView *noImg = [[UIImageView alloc]init];
  240. noImg.frame = CGRectMake(_window_width/2-40, 10, 81, 51);
  241. noImg.image = [UIImage imageNamed:@"shop_无数据"];
  242. [noDataView addSubview:noImg];
  243. UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0, noImg.bottom+10, _window_width, 20)];
  244. label2.font = [UIFont systemFontOfSize:13];
  245. label2.text = YZMsg(@"你还没有相关商品");
  246. label2.textAlignment = NSTextAlignmentCenter;
  247. label2.textColor = RGB_COLOR(@"#969696", 1);
  248. [noDataView addSubview:label2];
  249. noDataView.hidden = YES;
  250. }
  251. - (UICollectionView *)shopCollectView{
  252. if (!_shopCollectView) {
  253. UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
  254. flow.scrollDirection = UICollectionViewScrollDirectionVertical;
  255. flow.itemSize = CGSizeMake((_window_width-21)/2, (_window_width-21)/2 + 75);
  256. flow.minimumLineSpacing = 7;
  257. flow.minimumInteritemSpacing = 7;
  258. flow.sectionInset = UIEdgeInsetsMake(7, 7, 7, 7);
  259. flow.headerReferenceSize = CGSizeMake(_window_width, 180);
  260. _shopCollectView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height-64-statusbarHeight) collectionViewLayout:flow];
  261. [_shopCollectView registerNib:[UINib nibWithNibName:@"shopCell" bundle:nil] forCellWithReuseIdentifier:@"shopCELL"];
  262. [_shopCollectView registerNib:[UINib nibWithNibName:@"PlatformCell" bundle:nil] forCellWithReuseIdentifier:@"PlatformCELL"];
  263. [_shopCollectView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"storeHeaderV"];
  264. _shopCollectView.delegate =self;
  265. _shopCollectView.dataSource = self;
  266. _shopCollectView.backgroundColor = RGB_COLOR(@"#f5f5f5", 1);
  267. _shopCollectView.mj_footer = [MJRefreshBackFooter footerWithRefreshingBlock:^{
  268. page ++;
  269. // [self requestData];
  270. if (titleArr.count > 1) {
  271. if (saleBtn.selected == YES) {
  272. [self requestData];
  273. }else{
  274. [self getPlatformGoods];
  275. }
  276. }else{
  277. [self getPlatformGoods];
  278. }
  279. }];
  280. _shopCollectView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  281. page = 1;
  282. if (titleArr.count > 1) {
  283. if (saleBtn.selected == YES) {
  284. [self requestData];
  285. }else{
  286. [self getPlatformGoods];
  287. }
  288. }else{
  289. [self getPlatformGoods];
  290. }
  291. // [self requestData];
  292. }];
  293. _shopCollectView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  294. }
  295. return _shopCollectView;
  296. }
  297. -(void)getPlatformGoods{
  298. [YBNetworking postWithUrl:@"Shop.getOnsalePlatformGoods" Dic:@{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"p":@(page),@"touid":_toUserID} Suc:^(int code, id info, NSString *msg) {
  299. [_shopCollectView.mj_header endRefreshing];
  300. [_shopCollectView.mj_footer endRefreshing];
  301. if (code ==0) {
  302. NSDictionary *dic = [info firstObject];
  303. NSArray *list = [dic valueForKey:@"list"];
  304. shopInfo = [dic valueForKey:@"shop_info"];
  305. numsStr = minstr([shopInfo valueForKey:@"goods_nums"]);
  306. numL.text = [NSString stringWithFormat:YZMsg(@"%@件"),numsStr];
  307. CommodityDetailModel *model = [[CommodityDetailModel alloc]init];
  308. model.shop_sale_nums = minstr([shopInfo valueForKey:@"sale_nums"]);
  309. model.quality_points =minstr([shopInfo valueForKey:@"quality_points"]);
  310. model.service_points =minstr([shopInfo valueForKey:@"service_points"]);
  311. model.express_points =minstr([shopInfo valueForKey:@"express_points"]);
  312. model.other_sale_nums = minstr([shopInfo valueForKey:@"platform_goods_nums"]);
  313. platformNumL.text =[NSString stringWithFormat:YZMsg(@"%@件"),model.other_sale_nums];
  314. [_infoView setStoreModels:model];
  315. if (!iconImgV.image) {
  316. [iconImgV sd_setImageWithURL:[NSURL URLWithString:minstr([shopInfo valueForKey:@"avatar"])]];
  317. nameL.text = minstr([shopInfo valueForKey:@"name"]);
  318. }
  319. if (page == 1) {
  320. [infoArray removeAllObjects];
  321. }
  322. [infoArray addObjectsFromArray:list];
  323. if (infoArray.count < 1) {
  324. noDataView.hidden = NO;
  325. // [PublicView showImgNoData:_shopCollectView name:@"shop_无数据" text:YZMsg(@"没有相关商品")];
  326. [self.shopCollectView reloadData];
  327. return ;
  328. }else{
  329. noDataView.hidden = YES;
  330. // [PublicView hiddenImgNoData:_shopCollectView];
  331. }
  332. }
  333. [_shopCollectView reloadData];
  334. } Fail:^(id fail) {
  335. [_shopCollectView.mj_header endRefreshing];
  336. [_shopCollectView.mj_footer endRefreshing];
  337. }];
  338. }
  339. - (void)requestData{
  340. NSString *url = [purl stringByAppendingFormat:@"?service=Shop.GetShop"];
  341. [YBNetworking postWithUrl:@"Shop.GetShop" Dic:@{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"p":@(page),@"touid":_toUserID} Suc:^(int code, id info, NSString *msg) {
  342. [_shopCollectView.mj_header endRefreshing];
  343. [_shopCollectView.mj_footer endRefreshing];
  344. if (code ==0) {
  345. NSDictionary *dic = [info firstObject];
  346. NSArray *list = [dic valueForKey:@"list"];
  347. shopInfo = [dic valueForKey:@"shop_info"];
  348. numsStr = minstr([shopInfo valueForKey:@"goods_nums"]);
  349. numL.text = [NSString stringWithFormat:YZMsg(@"%@件"),numsStr];
  350. CommodityDetailModel *model = [[CommodityDetailModel alloc]init];
  351. model.shop_sale_nums = minstr([shopInfo valueForKey:@"sale_nums"]);
  352. model.quality_points =minstr([shopInfo valueForKey:@"quality_points"]);
  353. model.service_points =minstr([shopInfo valueForKey:@"service_points"]);
  354. model.express_points =minstr([shopInfo valueForKey:@"express_points"]);
  355. model.other_sale_nums = minstr([shopInfo valueForKey:@"platform_goods_nums"]);
  356. platformNumL.text =[NSString stringWithFormat:YZMsg(@"%@件"),model.other_sale_nums];
  357. [_infoView setStoreModels:model];
  358. if (!iconImgV.image) {
  359. [iconImgV sd_setImageWithURL:[NSURL URLWithString:minstr([shopInfo valueForKey:@"avatar"])]];
  360. nameL.text = minstr([shopInfo valueForKey:@"name"]);
  361. }
  362. if (page == 1) {
  363. [infoArray removeAllObjects];
  364. }
  365. [infoArray addObjectsFromArray:list];
  366. if (infoArray.count < 1) {
  367. noDataView.hidden = NO;
  368. // [PublicView showImgNoData:_shopCollectView name:@"shop_无数据" text:YZMsg(@"没有相关商品")];
  369. [self.shopCollectView reloadData];
  370. return ;
  371. }else{
  372. noDataView.hidden = YES;
  373. // [PublicView hiddenImgNoData:_shopCollectView];
  374. }
  375. }
  376. [_shopCollectView reloadData];
  377. } Fail:^(id fail) {
  378. [_shopCollectView.mj_header endRefreshing];
  379. [_shopCollectView.mj_footer endRefreshing];
  380. }];
  381. }
  382. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  383. return infoArray.count;
  384. }
  385. -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  386. if (isPlatform && [_toUserID isEqual:[Config getOwnID]]) {
  387. PlatformCell *cell = (PlatformCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"PlatformCELL" forIndexPath:indexPath];
  388. NSDictionary *subDic = infoArray[indexPath.row];
  389. [cell.thumbImgV sd_setImageWithURL:[NSURL URLWithString:minstr([subDic valueForKey:@"thumb"])]];
  390. cell.titleL.text = minstr([subDic valueForKey:@"name"]);
  391. cell.priceL.text = [NSString stringWithFormat:@"¥%@",minstr([subDic valueForKey:@"price"])];
  392. cell.commissionLb.text = [NSString stringWithFormat:YZMsg(@"佣 ¥%@"),minstr([subDic valueForKey:@"commission"])];
  393. //type 商品类型 0 站内商品 1 外链商品
  394. if ([minstr([subDic valueForKey:@"type"]) isEqual:@"1"]) {
  395. cell.lineLb.hidden = NO;
  396. cell.sellCountLb.text = [NSString stringWithFormat:@"¥%@",minstr([subDic valueForKey:@"original_price"])];
  397. }else{
  398. cell.lineLb.hidden = YES;
  399. cell.sellCountLb.text =[NSString stringWithFormat:YZMsg(@"已售%@件"),minstr([subDic valueForKey:@"sale_nums"])];
  400. }
  401. return cell;
  402. }else{
  403. shopCell *cell = (shopCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"shopCELL" forIndexPath:indexPath];
  404. NSDictionary *subDic = infoArray[indexPath.row];
  405. [cell.thumbImgV sd_setImageWithURL:[NSURL URLWithString:minstr([subDic valueForKey:@"thumb"])]];
  406. cell.titleL.text = minstr([subDic valueForKey:@"name"]);
  407. cell.priceL.text = [NSString stringWithFormat:@"¥%@",minstr([subDic valueForKey:@"price"])];
  408. //type 商品类型 0 站内商品 1 外链商品
  409. if ([minstr([subDic valueForKey:@"type"]) isEqual:@"1"]) {
  410. cell.lineLb.hidden = NO;
  411. cell.sellCountLb.text = [NSString stringWithFormat:@"¥%@",minstr([subDic valueForKey:@"original_price"])];
  412. }else{
  413. cell.lineLb.hidden = YES;
  414. cell.sellCountLb.text =[NSString stringWithFormat:YZMsg(@"已售%@件"),minstr([subDic valueForKey:@"sale_nums"])];
  415. }
  416. return cell;
  417. }
  418. }
  419. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  420. if (isPlatform && ![_toUserID isEqual:@"1"]) {
  421. return CGSizeMake((_window_width-21)/2, (_window_width-21)/2 + 75+30);
  422. }else{
  423. return CGSizeMake((_window_width-21)/2, (_window_width-21)/2 + 75);
  424. }
  425. }
  426. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  427. if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
  428. UICollectionReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"storeHeaderV" forIndexPath:indexPath];
  429. header.backgroundColor = [UIColor whiteColor];
  430. [header addSubview:headerView];
  431. return header;
  432. }else{
  433. return nil;
  434. }
  435. }
  436. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  437. NSDictionary *subDic = infoArray[indexPath.row];
  438. [PublicObj checkGoodsExistenceWithID:minstr([subDic valueForKey:@"id"]) Existence:^(int code, NSString *msg) {
  439. if (code ==0) {
  440. if ([minstr([subDic valueForKey:@"type"]) isEqual:@"1"]) {
  441. OutsideGoodsDetailVC *detail = [[OutsideGoodsDetailVC alloc]init];
  442. detail.goodsID = minstr([subDic valueForKey:@"id"]);
  443. detail.liveUid= _toUserID;
  444. if ([[Config getOwnID] isEqual:_toUserID] && !isPlatform) {
  445. detail.fromWhere = @"seller";
  446. }
  447. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  448. }else{
  449. CommodityDetailVC *detail = [[CommodityDetailVC alloc]init];
  450. detail.goodsID = minstr([subDic valueForKey:@"id"]);
  451. detail.backTags = @"shop";
  452. detail.liveUid= _toUserID;
  453. if ([[Config getOwnID] isEqual:_toUserID] && !isPlatform) {
  454. detail.fromWhere = @"seller";
  455. }
  456. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  457. }
  458. }else{
  459. [MBProgressHUD showError:msg];
  460. }
  461. }];
  462. }
  463. @end