dkahgld

ZBGoodDetailVC.m 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. //
  2. // ZBGoodDetailVC.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/3/27.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBGoodDetailVC.h"
  9. #import "ZBGoodDetailHeadView.h"
  10. #import <WebKit/WebKit.h>
  11. #import <WebKit/WebKit.h>
  12. #define collectHeight 631
  13. @interface ZBGoodDetailVC ()<UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,WKNavigationDelegate>
  14. @property(nonatomic,strong)UIScrollView *scrollViews;
  15. @property(nonatomic,strong)UICollectionView *collectionV;
  16. @property(nonatomic,strong)WKWebView *detailWebV;
  17. @property(nonatomic,strong)UIButton *collectionBtn;
  18. @property(nonatomic,strong)UIButton *buyBtn;
  19. @property(nonatomic,strong)UIButton *goTBBtn;
  20. @property(nonatomic,strong)ZBPidView *pidView;
  21. @property(nonatomic,strong)ZBTBShareView *shareView;
  22. @property(nonatomic,strong)NSMutableArray *bannerImgArray;
  23. @end
  24. @implementation ZBGoodDetailVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. [self initwithNav];
  28. [self getDetail];
  29. }
  30. #pragma mark---详情
  31. -(void)getDetail
  32. {
  33. if (![AccountTool isLogin]) {
  34. return;
  35. }
  36. if (self.model.goods_id.length <=0 ) {
  37. return;
  38. }
  39. self.detailModel = self.model;
  40. NSDictionary *dic =@{@"goods_id":self.model.goods_id};
  41. if (self.model.img.length!=0) {
  42. [self.bannerImgArray addObject:self.model.img];
  43. }
  44. [ZBHTTP post:getGoodDetailURL params:dic success:^(id _Nonnull json) {
  45. self.detailModel =[ZBGoodModel yy_modelWithJSON:json[@"data"]];
  46. self.detailModel.shop=[ZBShopModel yy_modelWithJSON:json[@"data"][@"shop"]];
  47. //浏览记录
  48. [self addHistoryLIstWithDic:self.detailModel];
  49. //是否收藏
  50. [self iscollect];
  51. [self.collectionV reloadData];
  52. [self.bannerImgArray addObjectsFromArray:self.detailModel.small_img];
  53. if (self.detailModel.detail_url.length != 0) {
  54. CGFloat bottomHeight=collectHeight;
  55. if (self.detailModel.goods_point.length>0) {
  56. CGSize size =[PublicFunction sizeWithString:self.detailModel.goods_point font:[UIFont systemFontOfSize:13] maxSize:CGSizeMake(SCREEN_WIDTH-30, MAXFLOAT)];
  57. bottomHeight=bottomHeight+size.height+40;
  58. [self.collectionV mas_updateConstraints:^(MASConstraintMaker *make) {
  59. make.height.mas_equalTo(bottomHeight);
  60. }];
  61. }
  62. if ([self.detailModel.shop isKindOfClass:[NSNull class]] || self.detailModel.shop == nil) {
  63. [self.collectionV mas_updateConstraints:^(MASConstraintMaker *make) {
  64. make.height.mas_equalTo(collectHeight-70);
  65. }];
  66. bottomHeight = bottomHeight -70;
  67. }
  68. self.detailWebV.frame=CGRectMake(0, bottomHeight, SCREEN_WIDTH, 0);
  69. [self.scrollViews addSubview:self.detailWebV];
  70. [self loadUrlDetail];
  71. }
  72. } failure:^(NSError * _Nonnull error) {
  73. // [MBProgressHUD hideHUDForView:self.view];
  74. // [MBProgressHUD showMessage:@"网络错误"];
  75. }];
  76. }
  77. -(void)loadUrlDetail
  78. {
  79. NSURL *urls =[NSURL URLWithString:self.detailModel.detail_url];
  80. NSURLRequest *request=[NSURLRequest requestWithURL:urls];
  81. [self.detailWebV loadRequest:request];
  82. [self.collectionV reloadData];
  83. }
  84. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
  85. {
  86. if ([keyPath isEqualToString:@"scrollView.contentSize"]) {
  87. id height =[change valueForKey:NSKeyValueChangeNewKey];
  88. CGSize size;
  89. [(NSValue *)height getValue:&size];
  90. self.detailWebV.height=size.height;
  91. self.scrollViews.contentSize=CGSizeMake(0, size.height+collectHeight);
  92. }
  93. }
  94. #pragma mark----collectionView||delegate&Datasource
  95. -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  96. {
  97. if (indexPath.section == 0) {
  98. ZBGoodDetailViewCell *goodC =[collectionView dequeueReusableCellWithReuseIdentifier:@"detail" forIndexPath:indexPath];
  99. if (self.detailModel != nil) {
  100. goodC.model=self.detailModel;
  101. }
  102. goodC.bannerArry = self.bannerImgArray;
  103. return goodC;
  104. }
  105. ZBGoodDetailShopViewCell *shopC =[collectionView dequeueReusableCellWithReuseIdentifier:@"shop" forIndexPath:indexPath];
  106. shopC.model=self.detailModel.shop;
  107. return shopC;
  108. }
  109. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  110. {
  111. }
  112. -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  113. {
  114. if (indexPath.section ==0) {
  115. if (self.detailModel.goods_point.length>0) {//商品有卖点的时候
  116. CGSize size =[PublicFunction sizeWithString:self.detailModel.goods_point font:[UIFont systemFontOfSize:13] maxSize:CGSizeMake(SCREEN_WIDTH-30, MAXFLOAT)];
  117. return CGSizeMake(SCREEN_WIDTH, 555+size.height);
  118. }
  119. return CGSizeMake(SCREEN_WIDTH, 510);
  120. }
  121. return CGSizeMake(SCREEN_WIDTH, 69);
  122. }
  123. -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
  124. {
  125. if (kind == UICollectionElementKindSectionFooter ) {
  126. ZBGoodDetailHeadView *head=[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"foot" forIndexPath:indexPath];
  127. if (indexPath.section == 1) {
  128. head.titleLabel.text=@"———— 商品详情 ————";
  129. }
  130. return head;
  131. }
  132. return nil;
  133. }
  134. -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  135. {
  136. if (section == 1 && self.detailModel.shop == nil) {
  137. return 0;
  138. }
  139. return 1;
  140. }
  141. -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  142. {
  143. return 2;
  144. }
  145. -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  146. {
  147. if (section == 1) {
  148. return CGSizeMake(SCREEN_WIDTH, 40);
  149. }
  150. return CGSizeMake(0,0);
  151. }
  152. -(void)initwithNav
  153. {
  154. self.view.backgroundColor=[UIColor whiteColor];
  155. [self.view addSubview:self.scrollViews];
  156. self.automaticallyAdjustsScrollViewInsets = NO;
  157. if (@available(iOS 11.0, *)) {
  158. self.scrollViews.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  159. } else {
  160. self.automaticallyAdjustsScrollViewInsets = NO;
  161. }
  162. [self.scrollViews addSubview:self.collectionV];
  163. [self.scrollViews mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.width.mas_equalTo(SCREEN_WIDTH);
  165. make.height.mas_equalTo(SCREEN_HEIGHT-TabbarHeight);
  166. make.top.mas_equalTo(0);
  167. }];
  168. [self.scrollViews addSubview:self.collectionV];
  169. [self.collectionV mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.width.mas_equalTo(SCREEN_WIDTH);
  171. make.height.mas_equalTo(collectHeight);
  172. make.top.left.mas_equalTo(0);
  173. }];
  174. [self addBtns];
  175. [self addBottomView];
  176. [self.view addSubview:self.pidView];
  177. [self.pidView mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.width.mas_equalTo(SCREEN_WIDTH);
  179. make.height.mas_equalTo(SCREEN_HEIGHT);
  180. make.right.left.top.bottom.mas_equalTo(0);
  181. }];
  182. self.pidView.hidden=YES;
  183. [self.view addSubview:self.shareView];
  184. [self.shareView mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.width.mas_equalTo(SCREEN_WIDTH);
  186. make.height.mas_equalTo(SCREEN_HEIGHT);
  187. make.right.left.top.bottom.mas_equalTo(0);
  188. }];
  189. self.detailWebV=[[WKWebView alloc]initWithFrame:CGRectMake(0, self.collectionV.bottom, SCREEN_WIDTH, 0)];
  190. self.detailWebV.navigationDelegate=self;
  191. self.detailWebV.scrollView.scrollEnabled=NO;
  192. @try {
  193. [self.detailWebV removeObserver:self forKeyPath:@"scrollView.contentSize"];
  194. } @catch (NSException *exception) {
  195. }
  196. [_detailWebV addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
  197. }
  198. -(void)viewWillAppear:(BOOL)animated
  199. {
  200. [super viewWillAppear:animated];
  201. self.navBar.hidden=YES;
  202. self.backView.hidden=YES;
  203. [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault;
  204. }
  205. - (void)dealloc {
  206. @try{
  207. [self.detailWebV removeObserver:self forKeyPath:@"scrollView.contentSize"];
  208. }@catch (NSException *exception) {
  209. }
  210. NSLog(@"释放了------------");
  211. }
  212. -(void)viewWillDisappear:(BOOL)animated
  213. {
  214. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  215. }
  216. -(UIScrollView *)scrollViews
  217. {
  218. if (!_scrollViews) {
  219. _scrollViews=[[UIScrollView alloc]init];
  220. _scrollViews.delegate=self;
  221. _scrollViews.showsHorizontalScrollIndicator=NO;
  222. _scrollViews.backgroundColor=[UIColor whiteColor];
  223. _scrollViews.showsVerticalScrollIndicator=NO;
  224. }
  225. return _scrollViews;
  226. }
  227. -(UICollectionView *)collectionV
  228. {
  229. if (!_collectionV) {
  230. UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
  231. layout.minimumInteritemSpacing=5;
  232. layout.sectionInset=UIEdgeInsetsMake(0, 0, 5, 0);
  233. _collectionV =[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:layout];
  234. _collectionV.showsHorizontalScrollIndicator=NO;
  235. _collectionV.showsVerticalScrollIndicator=NO;
  236. _collectionV.delegate=self;
  237. _collectionV.dataSource=self;
  238. _collectionV.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  239. _collectionV.scrollEnabled=NO;
  240. [_collectionV registerClass:[ZBGoodDetailViewCell class] forCellWithReuseIdentifier:@"detail"];
  241. [_collectionV registerClass:[ZBGoodDetailShopViewCell class] forCellWithReuseIdentifier:@"shop"];
  242. [_collectionV registerClass:[ZBGoodDetailHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"foot"];
  243. }
  244. return _collectionV;
  245. }
  246. -(void)returnClickbtn
  247. {
  248. [self.navigationController popViewControllerAnimated:YES];
  249. }
  250. -(UIButton *)collectionBtn
  251. {
  252. if (!_collectionBtn) {
  253. _collectionBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 86, TabbarHeight-SafeBottomHeight-5)];
  254. [_collectionBtn setImage:[UIImage imageNamed:@"collection_un"] forState:UIControlStateNormal];
  255. [_collectionBtn setImage:[UIImage imageNamed:@"collection_select"] forState:UIControlStateSelected];
  256. [_collectionBtn setTitle:@"收藏" forState:UIControlStateNormal];
  257. _collectionBtn.titleLabel.font=[UIFont systemFontOfSize:10];
  258. [_collectionBtn setTitleColor:[UIColor YHColorWithHex:0x828282] forState:UIControlStateNormal];
  259. [_collectionBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:3];
  260. [_collectionBtn addTarget:self action:@selector(collectionGood) forControlEvents:UIControlEventTouchUpInside];
  261. }
  262. return _collectionBtn;
  263. }
  264. -(UIButton *)buyBtn
  265. {
  266. if (!_buyBtn) {
  267. _buyBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH-96)/2, 39)];
  268. _buyBtn.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF8300] toColor:[UIColor YHColorWithHex:0xFF5200] withWidth:SCREEN_WIDTH-130];
  269. [_buyBtn setTitle:@"推广到快手" forState:UIControlStateNormal];
  270. _buyBtn.titleLabel.font=[UIFont systemFontOfSize:15];
  271. [_buyBtn addTarget:self action:@selector(clickCopyCode) forControlEvents:UIControlEventTouchUpInside];
  272. _buyBtn.adjustsImageWhenHighlighted=NO;
  273. //
  274. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyBtn.bounds byRoundingCorners:UIRectCornerTopRight| UIRectCornerBottomRight cornerRadii:CGSizeMake(19.5, 19.5)];
  275. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  276. maskLayer.frame = self.buyBtn.bounds;
  277. maskLayer.path = maskPath.CGPath;
  278. self.buyBtn.layer.mask = maskLayer;
  279. }
  280. return _buyBtn;
  281. }
  282. -(NSMutableArray *)bannerImgArray
  283. {
  284. if (!_bannerImgArray) {
  285. _bannerImgArray=[NSMutableArray array];
  286. }
  287. return _bannerImgArray;
  288. }
  289. -(UIButton *)goTBBtn
  290. {
  291. if (!_goTBBtn) {
  292. _goTBBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH-96)/2, 39)];
  293. //过审没有按照快手隐藏
  294. if (![PublicFunction canOpenURL:kwaiUrl] ) {
  295. _goTBBtn.frame=CGRectMake(0, 0, SCREEN_WIDTH-96, 39);
  296. _goTBBtn.layer.cornerRadius=19.5;
  297. _goTBBtn.layer.masksToBounds=YES;
  298. }else{
  299. UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.goTBBtn.bounds byRoundingCorners:UIRectCornerTopLeft| UIRectCornerBottomLeft cornerRadii:CGSizeMake(19.5, 19.5)];
  300. CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
  301. maskLayer1.frame = self.goTBBtn.bounds;
  302. maskLayer1.path = maskPath1.CGPath;
  303. self.goTBBtn.layer.mask = maskLayer1;
  304. }
  305. _goTBBtn.backgroundColor=[UIColor YHColorWithHex:0xFCA51C];
  306. [_goTBBtn setTitle:@"购买样品" forState:UIControlStateNormal];
  307. _goTBBtn.titleLabel.font =[UIFont systemFontOfSize:16];
  308. [_goTBBtn addTarget:self action:@selector(gotbClick) forControlEvents:UIControlEventTouchUpInside];
  309. }
  310. return _goTBBtn;
  311. }
  312. -(void)getBottom
  313. {
  314. if (![AccountTool isLogin] || self.detailModel.goods_id.length<=0) {
  315. return;
  316. }
  317. [LoadingView showInView:self.view];
  318. [ZBHTTP post:[NSString stringWithFormat:@"%@api/goods/shareCommonGoods",BASEURL] params:@{@"goods_id":self.detailModel.goods_id} success:^(id _Nonnull json) {
  319. [LoadingView dismiss];
  320. NSDictionary *dic =(NSDictionary *)json;
  321. if ([dic.allKeys containsObject:@"alert_info"]) {//需要有提示
  322. [UIView animateWithDuration:1 animations:^{
  323. self.pidView.hidden=NO;
  324. self.pidView.alertDic=json[@"alert_info"];
  325. }];
  326. }else{
  327. [PublicFunction jumpKuaishouWithstr:json[@"data"][@"kwai_url_prime"]];
  328. }
  329. /**
  330. 弹框状态 1:用户没有快手Pid
  331. 2:用户有Pid,首次提示
  332. 3:用户有Pid,二次提示
  333. */
  334. NSLog(@"%@",json);
  335. } failure:^(NSError * _Nonnull error) {
  336. [LoadingView dismiss];
  337. // [MBProgressHUD showMessage:@"网络错误"];
  338. }];
  339. }
  340. #pragma mark--复制淘口令
  341. -(void)clickCopyCode
  342. {
  343. [self getBottom];
  344. }
  345. #pragma mark---购买使用-打开淘宝
  346. -(void)gotbClick
  347. {
  348. if (![AccountTool isLogin] || self.detailModel.goods_id.length<=0) {
  349. return;
  350. }
  351. [LoadingView showInView:self.view];
  352. [ZBHTTP post:[NSString stringWithFormat:@"%@api/goods/shareCommonGoods",BASEURL] params:@{@"goods_id":self.detailModel.goods_id} success:^(id _Nonnull json) {
  353. [LoadingView dismiss];
  354. NSDictionary *dic =(NSDictionary *)json;
  355. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  356. pastboard.string=dic[@"data"][@"tkl"];
  357. //过审没有按照快手隐藏
  358. if (![PublicFunction canOpenURL:kwaiUrl]) {
  359. if (![PublicFunction isInstallTaobaoAPP]) {//没有安装淘宝
  360. [ self gotyBuy:dic[@"data"][@"url"]];
  361. }else{
  362. [self openTaobao:@"taobao://"];
  363. }
  364. }else{
  365. self.shareView.alertDic=dic[@"data"];
  366. self.shareView.hidden=NO;
  367. }
  368. } failure:^(NSError * _Nonnull error) {
  369. [LoadingView dismiss];
  370. // [MBProgressHUD showMessage:@"网络错误"];
  371. }];
  372. }
  373. -(void)openTaobao:(NSString *)taobao
  374. {
  375. UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero];
  376. [[UIApplication sharedApplication].keyWindow addSubview:webview];
  377. NSURL*url = [NSURL URLWithString:taobao];
  378. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  379. [webview loadRequest:request];
  380. }
  381. -(void)gotyBuy:(NSString *)url
  382. {
  383. id<AlibcTradePage> page =[AlibcTradePageFactory page:url];
  384. //打开方式
  385. AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
  386. showParam.openType = AlibcOpenTypeNative;
  387. [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
  388. } tradeProcessFailedCallback:^(NSError * _Nullable error) {
  389. }];
  390. }
  391. -(void) jumpKuaishouWithstr:(NSString *)str{
  392. NSString *encodedString = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  393. NSString *encodeUrl = (NSString *)[encodedString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet lowercaseLetterCharacterSet]];
  394. NSString *schemeUrlString = [NSString stringWithFormat:@"%@%@", @"kwai://webview?url=", encodeUrl];
  395. NSURL *schemeUrl = [NSURL URLWithString:schemeUrlString];
  396. if ([PublicFunction canOpenURL:schemeUrlString]) {
  397. dispatch_async(dispatch_get_main_queue(), ^{
  398. [[UIApplication sharedApplication] openURL:schemeUrl];
  399. });
  400. }else{
  401. [MBProgressHUD showTip:KWaiTipe];
  402. }
  403. }
  404. #pragma mark----收藏商品
  405. -(void)collectionGood
  406. {
  407. NSString *url =[NSString stringWithFormat:@"%@api/goods_collect/handelCollection",BASEURL];
  408. NSString *collect=self.detailModel.is_collect;
  409. if (collect.integerValue == 0) {//收藏
  410. collect=@"1";
  411. }else{
  412. collect=@"0";
  413. }
  414. [LoadingView showInView:self.view];
  415. [ZBHTTP post:url params:@{@"goods_id":self.detailModel.goods_id,@"is_add":collect} success:^(id _Nonnull json) {
  416. [LoadingView dismiss];
  417. NSLog(@"%@",json);
  418. self.detailModel.is_collect = collect;
  419. if ([json[@"flag"] integerValue] == 1) {
  420. [MBProgressHUD showTip:@"收藏成功"];
  421. }
  422. [self iscollect];
  423. } failure:^(NSError * _Nonnull error) {
  424. [LoadingView dismiss];
  425. }];
  426. }
  427. -(ZBPidView *)pidView
  428. {
  429. if (!_pidView) {
  430. _pidView =[[ZBPidView alloc]init];
  431. }
  432. return _pidView;
  433. }
  434. -(ZBTBShareView *)shareView
  435. {
  436. if (!_shareView) {
  437. _shareView =[[ZBTBShareView alloc]init];
  438. _shareView.hidden=YES;
  439. }
  440. return _shareView;
  441. }
  442. -(void)addBottomView
  443. {
  444. UIView *bottomView=[[UIView alloc]init];
  445. [self.view addSubview:bottomView];
  446. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  447. make.bottom.mas_equalTo(self.view.mas_bottom);
  448. make.left.right.mas_equalTo(0);
  449. make.height.mas_equalTo(TabbarHeight);
  450. }];
  451. [bottomView addSubview:self.collectionBtn];
  452. [self.collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  453. make.left.top.mas_equalTo(0);
  454. make.width.mas_equalTo(86);
  455. make.bottom.mas_equalTo(-5-SafeBottomHeight);
  456. }];
  457. [bottomView addSubview:self.goTBBtn];
  458. //过审没有按照快手隐藏
  459. if (![PublicFunction canOpenURL:kwaiUrl] ) {
  460. self.goTBBtn.frame=CGRectMake(86, 5, SCREEN_WIDTH-96, 39);
  461. [self.goTBBtn setTitle:@"立即领券" forState:UIControlStateNormal];
  462. }else{
  463. [self.goTBBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  464. make.left.mas_equalTo(self.collectionBtn.mas_right);
  465. make.height.mas_equalTo(39);
  466. make.top.mas_equalTo(5);
  467. make.width.mas_equalTo((SCREEN_WIDTH-96)/2);
  468. }];
  469. [bottomView addSubview:self.buyBtn];
  470. [self.buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  471. make.top.mas_equalTo(5);
  472. make.height.mas_equalTo(39);
  473. make.left.mas_equalTo(self.goTBBtn.mas_right);
  474. make.right.mas_equalTo(-10);
  475. }];
  476. }
  477. }
  478. #pragma mark---是否收藏
  479. -(void)iscollect
  480. {
  481. if (self.detailModel.is_collect.integerValue ==1) {
  482. self.collectionBtn.selected=YES;
  483. }else{
  484. self.collectionBtn.selected=NO;
  485. }
  486. }
  487. -(void)addBtns
  488. {
  489. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(15, KStatusBarHeight+15, 30,30)];
  490. returnBtn.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
  491. returnBtn.layer.cornerRadius=15;
  492. returnBtn.layer.masksToBounds=YES;
  493. returnBtn.adjustsImageWhenHighlighted=NO;
  494. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  495. [returnBtn addTarget:self action:@selector(returnClickbtn) forControlEvents:UIControlEventTouchUpInside];
  496. [self.view addSubview:returnBtn];
  497. UIButton *collectBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-50, KStatusBarHeight+15, 30, 30)];
  498. [collectBtn setImage:[UIImage imageNamed:@"detail_collection"] forState:UIControlStateNormal];
  499. [self.view addSubview:collectBtn];
  500. collectBtn.adjustsImageWhenHighlighted=NO;
  501. [collectBtn addTarget:self action:@selector(collecClickBtn) forControlEvents:UIControlEventTouchUpInside];
  502. }
  503. #pragma mark---收藏跳转
  504. -(void)collecClickBtn
  505. {
  506. ZBCollectionVC *collV =[[ZBCollectionVC alloc]init];
  507. [self.navigationController pushViewController:collV animated:YES];
  508. }
  509. #pragma mark---添加历史浏览记录
  510. -(void)addHistoryLIstWithDic:(ZBGoodModel *)model
  511. {
  512. NSString *img=@"";
  513. if (model.img.length>0) {
  514. img =model.img;
  515. }
  516. NSString *goods_id=@"";
  517. if (model.goods_id.length>0) {
  518. goods_id= model.goods_id;
  519. }
  520. NSString *title=@"";
  521. if (model.title.length>0) {
  522. title = model.title;
  523. }
  524. NSString *price=@"";
  525. if (model.price.length>0) {
  526. price = model.price;
  527. }
  528. NSString *live_price=@"";
  529. if (model.discount_price.length>0) {
  530. live_price = model.discount_price;
  531. }
  532. NSString *shop_title=@"";
  533. if (model.shop.title.length>0) {
  534. shop_title = model.shop.title;
  535. }
  536. NSString *shop_type=@"";
  537. if (model.shop_type.length>0) {
  538. shop_type= model.shop_type;
  539. }
  540. NSString *volume=@"";
  541. if (model.volume.length>0) {
  542. volume = model.volume;
  543. }
  544. NSString *commission_price=@"";
  545. if (model.commission_price.length>0) {
  546. commission_price = model.commission_price;
  547. }
  548. NSString *commission_rate=@"";
  549. if (model.commission_rate.length>0) {
  550. commission_rate = model.commission_rate;
  551. }
  552. NSDictionary *dic =@{@"goods_id":goods_id,@"title":title,@"img":img,@"volume":volume,@"shop_type":shop_type,@"shop_title":shop_title,@"price":price,@"discount_price":live_price,@"commission_rate":commission_rate,@"commission_price":commission_price};
  553. NSString *url =[NSString stringWithFormat:@"%@api/brower/record",BASEURL];
  554. [ZBHTTP post:url params:dic success:^(id _Nonnull json) {
  555. NSLog(@"%@",json);
  556. } failure:^(NSError * _Nonnull error) {
  557. }];
  558. }
  559. @end