123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652 |
- //
- // ZBGoodDetailVC.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/27.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBGoodDetailVC.h"
- #import "ZBGoodDetailHeadView.h"
- #import <WebKit/WebKit.h>
- #import <WebKit/WebKit.h>
- #define collectHeight 631
- @interface ZBGoodDetailVC ()<UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,WKNavigationDelegate>
- @property(nonatomic,strong)UIScrollView *scrollViews;
- @property(nonatomic,strong)UICollectionView *collectionV;
- @property(nonatomic,strong)WKWebView *detailWebV;
- @property(nonatomic,strong)UIButton *collectionBtn;
- @property(nonatomic,strong)UIButton *buyBtn;
- @property(nonatomic,strong)UIButton *goTBBtn;
- @property(nonatomic,strong)ZBPidView *pidView;
- @property(nonatomic,strong)ZBTBShareView *shareView;
- @property(nonatomic,strong)NSMutableArray *bannerImgArray;
- @end
- @implementation ZBGoodDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initwithNav];
- [self getDetail];
-
- }
- #pragma mark---详情
- -(void)getDetail
- {
- if (![AccountTool isLogin]) {
- return;
- }
- if (self.model.goods_id.length <=0 ) {
- return;
- }
- self.detailModel = self.model;
- NSDictionary *dic =@{@"goods_id":self.model.goods_id};
- if (self.model.img.length!=0) {
- [self.bannerImgArray addObject:self.model.img];
- }
- [ZBHTTP post:getGoodDetailURL params:dic success:^(id _Nonnull json) {
- self.detailModel =[ZBGoodModel yy_modelWithJSON:json[@"data"]];
- self.detailModel.shop=[ZBShopModel yy_modelWithJSON:json[@"data"][@"shop"]];
- //浏览记录
- [self addHistoryLIstWithDic:self.detailModel];
- //是否收藏
- [self iscollect];
-
-
- [self.collectionV reloadData];
-
- [self.bannerImgArray addObjectsFromArray:self.detailModel.small_img];
- if (self.detailModel.detail_url.length != 0) {
- CGFloat bottomHeight=collectHeight;
-
- if (self.detailModel.goods_point.length>0) {
- CGSize size =[PublicFunction sizeWithString:self.detailModel.goods_point font:[UIFont systemFontOfSize:13] maxSize:CGSizeMake(SCREEN_WIDTH-30, MAXFLOAT)];
- bottomHeight=bottomHeight+size.height+40;
- [self.collectionV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(bottomHeight);
- }];
- }
-
- if ([self.detailModel.shop isKindOfClass:[NSNull class]] || self.detailModel.shop == nil) {
- [self.collectionV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(collectHeight-70);
- }];
- bottomHeight = bottomHeight -70;
- }
- self.detailWebV.frame=CGRectMake(0, bottomHeight, SCREEN_WIDTH, 0);
- [self.scrollViews addSubview:self.detailWebV];
- [self loadUrlDetail];
- }
-
- } failure:^(NSError * _Nonnull error) {
- // [MBProgressHUD hideHUDForView:self.view];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- -(void)loadUrlDetail
- {
- NSURL *urls =[NSURL URLWithString:self.detailModel.detail_url];
- NSURLRequest *request=[NSURLRequest requestWithURL:urls];
- [self.detailWebV loadRequest:request];
-
- [self.collectionV reloadData];
- }
- -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
- {
- if ([keyPath isEqualToString:@"scrollView.contentSize"]) {
- id height =[change valueForKey:NSKeyValueChangeNewKey];
- CGSize size;
- [(NSValue *)height getValue:&size];
- self.detailWebV.height=size.height;
- self.scrollViews.contentSize=CGSizeMake(0, size.height+collectHeight);
- }
- }
- #pragma mark----collectionView||delegate&Datasource
- -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.section == 0) {
- ZBGoodDetailViewCell *goodC =[collectionView dequeueReusableCellWithReuseIdentifier:@"detail" forIndexPath:indexPath];
- if (self.detailModel != nil) {
- goodC.model=self.detailModel;
-
- }
- goodC.bannerArry = self.bannerImgArray;
- return goodC;
- }
- ZBGoodDetailShopViewCell *shopC =[collectionView dequeueReusableCellWithReuseIdentifier:@"shop" forIndexPath:indexPath];
- shopC.model=self.detailModel.shop;
- return shopC;
-
- }
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.section ==0) {
- if (self.detailModel.goods_point.length>0) {//商品有卖点的时候
- CGSize size =[PublicFunction sizeWithString:self.detailModel.goods_point font:[UIFont systemFontOfSize:13] maxSize:CGSizeMake(SCREEN_WIDTH-30, MAXFLOAT)];
- return CGSizeMake(SCREEN_WIDTH, 555+size.height);
-
- }
- return CGSizeMake(SCREEN_WIDTH, 510);
- }
-
- return CGSizeMake(SCREEN_WIDTH, 69);
- }
- -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
- {
- if (kind == UICollectionElementKindSectionFooter ) {
- ZBGoodDetailHeadView *head=[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"foot" forIndexPath:indexPath];
- if (indexPath.section == 1) {
- head.titleLabel.text=@"———— 商品详情 ————";
- }
- return head;
- }
- return nil;
- }
- -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- if (section == 1 && self.detailModel.shop == nil) {
- return 0;
- }
- return 1;
- }
- -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- {
- return 2;
- }
- -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
- {
- if (section == 1) {
- return CGSizeMake(SCREEN_WIDTH, 40);
- }
- return CGSizeMake(0,0);
- }
- -(void)initwithNav
- {
- self.view.backgroundColor=[UIColor whiteColor];
-
- [self.view addSubview:self.scrollViews];
-
- self.automaticallyAdjustsScrollViewInsets = NO;
- if (@available(iOS 11.0, *)) {
-
- self.scrollViews.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
-
- } else {
-
- self.automaticallyAdjustsScrollViewInsets = NO;
-
- }
- [self.scrollViews addSubview:self.collectionV];
- [self.scrollViews mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(SCREEN_HEIGHT-TabbarHeight);
- make.top.mas_equalTo(0);
-
- }];
- [self.scrollViews addSubview:self.collectionV];
- [self.collectionV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(collectHeight);
- make.top.left.mas_equalTo(0);
- }];
-
- [self addBtns];
-
-
- [self addBottomView];
-
- [self.view addSubview:self.pidView];
- [self.pidView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(SCREEN_HEIGHT);
- make.right.left.top.bottom.mas_equalTo(0);
- }];
- self.pidView.hidden=YES;
- [self.view addSubview:self.shareView];
- [self.shareView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(SCREEN_HEIGHT);
- make.right.left.top.bottom.mas_equalTo(0);
- }];
- self.detailWebV=[[WKWebView alloc]initWithFrame:CGRectMake(0, self.collectionV.bottom, SCREEN_WIDTH, 0)];
- self.detailWebV.navigationDelegate=self;
- self.detailWebV.scrollView.scrollEnabled=NO;
- @try {
- [self.detailWebV removeObserver:self forKeyPath:@"scrollView.contentSize"];
- } @catch (NSException *exception) {
-
- }
-
- [_detailWebV addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navBar.hidden=YES;
- self.backView.hidden=YES;
- [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault;
-
- }
- - (void)dealloc {
- @try{
- [self.detailWebV removeObserver:self forKeyPath:@"scrollView.contentSize"];
- }@catch (NSException *exception) {
-
- }
- NSLog(@"释放了------------");
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }
- -(UIScrollView *)scrollViews
- {
- if (!_scrollViews) {
- _scrollViews=[[UIScrollView alloc]init];
- _scrollViews.delegate=self;
- _scrollViews.showsHorizontalScrollIndicator=NO;
- _scrollViews.backgroundColor=[UIColor whiteColor];
- _scrollViews.showsVerticalScrollIndicator=NO;
- }
- return _scrollViews;
- }
- -(UICollectionView *)collectionV
- {
- if (!_collectionV) {
- UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
- layout.minimumInteritemSpacing=5;
- layout.sectionInset=UIEdgeInsetsMake(0, 0, 5, 0);
- _collectionV =[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:layout];
- _collectionV.showsHorizontalScrollIndicator=NO;
- _collectionV.showsVerticalScrollIndicator=NO;
- _collectionV.delegate=self;
- _collectionV.dataSource=self;
- _collectionV.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- _collectionV.scrollEnabled=NO;
- [_collectionV registerClass:[ZBGoodDetailViewCell class] forCellWithReuseIdentifier:@"detail"];
- [_collectionV registerClass:[ZBGoodDetailShopViewCell class] forCellWithReuseIdentifier:@"shop"];
- [_collectionV registerClass:[ZBGoodDetailHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"foot"];
- }
- return _collectionV;
- }
- -(void)returnClickbtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(UIButton *)collectionBtn
- {
- if (!_collectionBtn) {
- _collectionBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 86, TabbarHeight-SafeBottomHeight-5)];
- [_collectionBtn setImage:[UIImage imageNamed:@"collection_un"] forState:UIControlStateNormal];
- [_collectionBtn setImage:[UIImage imageNamed:@"collection_select"] forState:UIControlStateSelected];
- [_collectionBtn setTitle:@"收藏" forState:UIControlStateNormal];
- _collectionBtn.titleLabel.font=[UIFont systemFontOfSize:10];
- [_collectionBtn setTitleColor:[UIColor YHColorWithHex:0x828282] forState:UIControlStateNormal];
- [_collectionBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:3];
- [_collectionBtn addTarget:self action:@selector(collectionGood) forControlEvents:UIControlEventTouchUpInside];
-
- }
- return _collectionBtn;
- }
- -(UIButton *)buyBtn
- {
- if (!_buyBtn) {
- _buyBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH-96)/2, 39)];
-
- _buyBtn.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF8300] toColor:[UIColor YHColorWithHex:0xFF5200] withWidth:SCREEN_WIDTH-130];
- [_buyBtn setTitle:@"推广到快手" forState:UIControlStateNormal];
-
- _buyBtn.titleLabel.font=[UIFont systemFontOfSize:15];
-
- [_buyBtn addTarget:self action:@selector(clickCopyCode) forControlEvents:UIControlEventTouchUpInside];
- _buyBtn.adjustsImageWhenHighlighted=NO;
- //
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyBtn.bounds byRoundingCorners:UIRectCornerTopRight| UIRectCornerBottomRight cornerRadii:CGSizeMake(19.5, 19.5)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.buyBtn.bounds;
- maskLayer.path = maskPath.CGPath;
- self.buyBtn.layer.mask = maskLayer;
- }
- return _buyBtn;
- }
- -(NSMutableArray *)bannerImgArray
- {
- if (!_bannerImgArray) {
- _bannerImgArray=[NSMutableArray array];
- }
- return _bannerImgArray;
- }
- -(UIButton *)goTBBtn
- {
- if (!_goTBBtn) {
- _goTBBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH-96)/2, 39)];
- //过审没有按照快手隐藏
- if (![PublicFunction canOpenURL:kwaiUrl] ) {
- _goTBBtn.frame=CGRectMake(0, 0, SCREEN_WIDTH-96, 39);
- _goTBBtn.layer.cornerRadius=19.5;
- _goTBBtn.layer.masksToBounds=YES;
- }else{
- UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.goTBBtn.bounds byRoundingCorners:UIRectCornerTopLeft| UIRectCornerBottomLeft cornerRadii:CGSizeMake(19.5, 19.5)];
- CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
- maskLayer1.frame = self.goTBBtn.bounds;
- maskLayer1.path = maskPath1.CGPath;
- self.goTBBtn.layer.mask = maskLayer1;
- }
- _goTBBtn.backgroundColor=[UIColor YHColorWithHex:0xFCA51C];
- [_goTBBtn setTitle:@"购买样品" forState:UIControlStateNormal];
- _goTBBtn.titleLabel.font =[UIFont systemFontOfSize:16];
- [_goTBBtn addTarget:self action:@selector(gotbClick) forControlEvents:UIControlEventTouchUpInside];
-
-
-
- }
- return _goTBBtn;
- }
- -(void)getBottom
- {
- if (![AccountTool isLogin] || self.detailModel.goods_id.length<=0) {
- return;
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:[NSString stringWithFormat:@"%@api/goods/shareCommonGoods",BASEURL] params:@{@"goods_id":self.detailModel.goods_id} success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSDictionary *dic =(NSDictionary *)json;
- if ([dic.allKeys containsObject:@"alert_info"]) {//需要有提示
- [UIView animateWithDuration:1 animations:^{
- self.pidView.hidden=NO;
- self.pidView.alertDic=json[@"alert_info"];
- }];
- }else{
- [PublicFunction jumpKuaishouWithstr:json[@"data"][@"kwai_url_prime"]];
-
- }
- /**
- 弹框状态 1:用户没有快手Pid
- 2:用户有Pid,首次提示
- 3:用户有Pid,二次提示
- */
-
- NSLog(@"%@",json);
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- #pragma mark--复制淘口令
- -(void)clickCopyCode
- {
- [self getBottom];
-
-
- }
- #pragma mark---购买使用-打开淘宝
- -(void)gotbClick
- {
- if (![AccountTool isLogin] || self.detailModel.goods_id.length<=0) {
- return;
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:[NSString stringWithFormat:@"%@api/goods/shareCommonGoods",BASEURL] params:@{@"goods_id":self.detailModel.goods_id} success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSDictionary *dic =(NSDictionary *)json;
- UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
- pastboard.string=dic[@"data"][@"tkl"];
- //过审没有按照快手隐藏
- if (![PublicFunction canOpenURL:kwaiUrl]) {
- if (![PublicFunction isInstallTaobaoAPP]) {//没有安装淘宝
- [ self gotyBuy:dic[@"data"][@"url"]];
- }else{
- [self openTaobao:@"taobao://"];
- }
-
-
- }else{
- self.shareView.alertDic=dic[@"data"];
- self.shareView.hidden=NO;
- }
-
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
-
- }
- -(void)openTaobao:(NSString *)taobao
- {
- UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero];
- [[UIApplication sharedApplication].keyWindow addSubview:webview];
- NSURL*url = [NSURL URLWithString:taobao];
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
- [webview loadRequest:request];
- }
- -(void)gotyBuy:(NSString *)url
- {
- id<AlibcTradePage> page =[AlibcTradePageFactory page:url];
- //打开方式
- AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
- showParam.openType = AlibcOpenTypeNative;
- [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
-
- } tradeProcessFailedCallback:^(NSError * _Nullable error) {
-
- }];
- }
- -(void) jumpKuaishouWithstr:(NSString *)str{
-
-
-
- NSString *encodedString = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
- NSString *encodeUrl = (NSString *)[encodedString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet lowercaseLetterCharacterSet]];
-
- NSString *schemeUrlString = [NSString stringWithFormat:@"%@%@", @"kwai://webview?url=", encodeUrl];
- NSURL *schemeUrl = [NSURL URLWithString:schemeUrlString];
- if ([PublicFunction canOpenURL:schemeUrlString]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [[UIApplication sharedApplication] openURL:schemeUrl];
- });
- }else{
- [MBProgressHUD showTip:KWaiTipe];
- }
-
-
-
- }
- #pragma mark----收藏商品
- -(void)collectionGood
- {
- NSString *url =[NSString stringWithFormat:@"%@api/goods_collect/handelCollection",BASEURL];
- NSString *collect=self.detailModel.is_collect;
- if (collect.integerValue == 0) {//收藏
- collect=@"1";
- }else{
- collect=@"0";
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:url params:@{@"goods_id":self.detailModel.goods_id,@"is_add":collect} success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSLog(@"%@",json);
- self.detailModel.is_collect = collect;
- if ([json[@"flag"] integerValue] == 1) {
- [MBProgressHUD showTip:@"收藏成功"];
- }
- [self iscollect];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(ZBPidView *)pidView
- {
- if (!_pidView) {
- _pidView =[[ZBPidView alloc]init];
-
- }
- return _pidView;
- }
- -(ZBTBShareView *)shareView
- {
- if (!_shareView) {
- _shareView =[[ZBTBShareView alloc]init];
- _shareView.hidden=YES;
- }
- return _shareView;
- }
- -(void)addBottomView
- {
- UIView *bottomView=[[UIView alloc]init];
-
- [self.view addSubview:bottomView];
- [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.view.mas_bottom);
- make.left.right.mas_equalTo(0);
- make.height.mas_equalTo(TabbarHeight);
- }];
-
- [bottomView addSubview:self.collectionBtn];
- [self.collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.mas_equalTo(0);
- make.width.mas_equalTo(86);
- make.bottom.mas_equalTo(-5-SafeBottomHeight);
- }];
-
-
- [bottomView addSubview:self.goTBBtn];
-
- //过审没有按照快手隐藏
- if (![PublicFunction canOpenURL:kwaiUrl] ) {
-
- self.goTBBtn.frame=CGRectMake(86, 5, SCREEN_WIDTH-96, 39);
- [self.goTBBtn setTitle:@"立即领券" forState:UIControlStateNormal];
-
- }else{
- [self.goTBBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.collectionBtn.mas_right);
- make.height.mas_equalTo(39);
- make.top.mas_equalTo(5);
- make.width.mas_equalTo((SCREEN_WIDTH-96)/2);
-
- }];
- [bottomView addSubview:self.buyBtn];
- [self.buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(5);
- make.height.mas_equalTo(39);
- make.left.mas_equalTo(self.goTBBtn.mas_right);
- make.right.mas_equalTo(-10);
-
- }];
- }
-
- }
- #pragma mark---是否收藏
- -(void)iscollect
- {
- if (self.detailModel.is_collect.integerValue ==1) {
- self.collectionBtn.selected=YES;
- }else{
- self.collectionBtn.selected=NO;
- }
- }
- -(void)addBtns
- {
- UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(15, KStatusBarHeight+15, 30,30)];
- returnBtn.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
- returnBtn.layer.cornerRadius=15;
- returnBtn.layer.masksToBounds=YES;
- returnBtn.adjustsImageWhenHighlighted=NO;
- [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
- [returnBtn addTarget:self action:@selector(returnClickbtn) forControlEvents:UIControlEventTouchUpInside];
-
- [self.view addSubview:returnBtn];
-
-
- UIButton *collectBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-50, KStatusBarHeight+15, 30, 30)];
- [collectBtn setImage:[UIImage imageNamed:@"detail_collection"] forState:UIControlStateNormal];
- [self.view addSubview:collectBtn];
- collectBtn.adjustsImageWhenHighlighted=NO;
- [collectBtn addTarget:self action:@selector(collecClickBtn) forControlEvents:UIControlEventTouchUpInside];
- }
- #pragma mark---收藏跳转
- -(void)collecClickBtn
- {
- ZBCollectionVC *collV =[[ZBCollectionVC alloc]init];
- [self.navigationController pushViewController:collV animated:YES];
- }
- #pragma mark---添加历史浏览记录
- -(void)addHistoryLIstWithDic:(ZBGoodModel *)model
- {
- NSString *img=@"";
- if (model.img.length>0) {
- img =model.img;
- }
- NSString *goods_id=@"";
- if (model.goods_id.length>0) {
- goods_id= model.goods_id;
- }
- NSString *title=@"";
- if (model.title.length>0) {
- title = model.title;
- }
- NSString *price=@"";
- if (model.price.length>0) {
- price = model.price;
- }
- NSString *live_price=@"";
- if (model.discount_price.length>0) {
- live_price = model.discount_price;
- }
- NSString *shop_title=@"";
- if (model.shop.title.length>0) {
- shop_title = model.shop.title;
- }
- NSString *shop_type=@"";
- if (model.shop_type.length>0) {
- shop_type= model.shop_type;
- }
- NSString *volume=@"";
- if (model.volume.length>0) {
- volume = model.volume;
- }
- NSString *commission_price=@"";
- if (model.commission_price.length>0) {
- commission_price = model.commission_price;
- }
- NSString *commission_rate=@"";
- if (model.commission_rate.length>0) {
- commission_rate = model.commission_rate;
- }
- 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};
-
- NSString *url =[NSString stringWithFormat:@"%@api/brower/record",BASEURL];
- [ZBHTTP post:url params:dic success:^(id _Nonnull json) {
- NSLog(@"%@",json);
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- @end
|