12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226 |
- //
- // LDGoodDetailViewController.m
- // YouHuiProject
- //
- // Created by xiaoxi on 2018/1/22.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDGoodDetailViewController.h"
- #import <WebKit/WebKit.h>
- #import "LDDetailLoginView.h"
- #import <AlibabaAuthSDK/ALBBSDK.h>
- #import <AlibabaAuthSDK/ALBBSession.h>
- #import "LDSearchCoupleWebViewController.h"
- #import "LDGoodDetailRequestViewModel.h"
- #import "SDCycleScrollView.h"
- #import "LDTableView.h"
- #import "LDAdWebViewController.h"
- #import "LDPrivilegeReferralViewController.h"
- #import "LDGoodDetailBottomView.h"
- #import "LDGoodDetailView.h"
- #import "LDCollectionView.h"
- #import "LDGoodCollectionCell.h"
- #import "LDShopDetailViewController.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import "LDHistoryTool.h"
- #import "LDHistoryModel.h"
- #import "LDGoodListViewController.h"
- #import "LDLoginViewController.h"
- #import "LDAdWebViewController.h"
- #import "LDEventTool.h"
- #import "LDGotoDetailView.h"
- #import "SDPhotoBrowser.h"
- #import "LDShareGoodsViewController.h"
- #import "LDWebDetailController.h"
- #import "LDLinkFansController.h"
- #import "LDPrivilegeReferralViewController.h"
- #import "LDModuleView.h"
- #import "LDDetailHeaderTitle.h"
- #import "CCAlertShowView.h"
- #import "LDShareImgPopView.h"
- #import "LDShopInfoView.h"
- #import "LDDetailGuideView.h"
- #import "PhoneLoginManager.h"
- #import "LDGoodDetailImageCell.h"
- #import "LDDetailImgModel.h"
- #import "LDShareGoodViewController.h"
- #import "LDShareRequestViewModel.h"
- #import "LDShareInfoModel.h"
- #import "LDTaobaoWebAuthorController.h"
- #import "LDSearchCoupleWebViewController.h"
- #import "LDDCCyleTipView.h"
- #define GoodSimilarViewHeight ((self.goodSimilarArr.count-1)/2+1)*FITSIZE(292)+FITSIZE(45)
- static CGFloat detailDescWebHeight = 0.1;
- static NSInteger const detailDescWebTag = 111;
- static NSString *const cellID = @"LDGoodCollectionCell";
- static NSString *const collectionViewHeader = @"collectionViewHeader";
- @interface LDGoodDetailViewController ()
- <
- SDCycleScrollViewDelegate,
- UITableViewDelegate,
- UITableViewDataSource,
- YHGoodDetailBottomViewDelegate,
- YHGoodDetailViewDelegate,
- UIWebViewDelegate,
- UICollectionViewDelegate,
- UICollectionViewDataSource,
- UICollectionViewDelegateFlowLayout,
- SGPageTitleViewDelegate,
- UIWebViewDelegate,
- WKNavigationDelegate,
- SDPhotoBrowserDelegate,
- LDDetailGuideViewDelegate
- >
- {
- NSInteger _page;
- ActivityIndicatorView *_indicatorView;
- BOOL isDealloc;
- NSString *shopjsonstr;
- LDDCCyleTipView *redTipView;//红包导图
- UIButton *redBtn;//有红包时候
- CGFloat _lastOffY;
- }
- @property (nonatomic, strong) LDGoodDetailModel *goodModel;
- @property (nonatomic, strong) LDShareInfoModel *shareModel;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) WKWebView *detailDescWebView;
- @property (nonatomic, strong) UIView *tableHeaderView;
- @property (nonatomic, strong) LDGoodDetailView *goodDetailView;
- @property (nonatomic, strong) SDCycleScrollView *cycleView;
- @property (nonatomic, strong) NSArray *goodSimilarArr;
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) UIButton *backButton;
- @property (nonatomic, strong) SGPageTitleView *topTitleView;
- @property (nonatomic, strong) YYFPSLabel *fpsLabel;
- @property (nonatomic, strong) LDGoodDetailBottomView *goodBottomView;
- @property (nonatomic, strong) NSNumber *flag;//用户等级 1 会员 2 超级会员 3 运营商
- @property (nonatomic, strong) LDModuleView *moduleView;
- @property (nonatomic, strong) LDShopInfoView *shopInfoView;
- @property (nonatomic, strong) LDGoodDetailBottomView *bottomView;
- @property (nonatomic, strong) UIView *moduleBg;
- @property (nonatomic, strong) LDDetailHeaderTitle *detailHeader;
- @property (nonatomic, strong) LDDetailGuideView *guideView;
- @property (nonatomic, strong) NSMutableArray *bannerImgArray;
- //登录引导
- @property (nonatomic, strong)LDDetailLoginView *loginView;
- @end
- @implementation LDGoodDetailViewController
- - (void)dealloc {
- @try{
- [self.detailDescWebView removeObserver:self forKeyPath:@"scrollView.contentSize"];
- }@catch (NSException *exception) {
-
- }
- NSLog(@"释放了------------");
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [LoadingView dismiss];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initNavBar];
- [self initSubviews];
- // [self initHUD];
- [self request];
- [self requestCount];
- [self loadUserInfo];
- [self inittipRedView];
-
- }
- #pragma mark----红包按钮
- -(void)inittipRedView
- {
- if (![[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {//显示手机号登陆。过审,不显示红包按钮
- redBtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-200, SCREEN_HEIGHT/2-50, 200, 71)];
- [redBtn setBackgroundImage:[UIImage imageNamed:@"detail_redtip"] forState:UIControlStateNormal];
- [self.view addSubview:redBtn];
- [redBtn addTarget:self action:@selector(clickRedView) forControlEvents:UIControlEventTouchUpInside];
- redBtn.adjustsImageWhenHighlighted=NO;
- redBtn.hidden=YES;
-
- UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(10, 10, redBtn.size.width-90, redBtn.size.height-20)];
- label.numberOfLines=2;
- label.textColor=[UIColor whiteColor];
- label.font=[UIFont systemFontOfSize:14];
- [redBtn addSubview:label];
- label.tag= 1111;
-
-
- redTipView=[[LDDCCyleTipView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- redTipView.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
- redTipView.hidden=YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)];
- [redTipView addGestureRecognizer:tap];
- redTipView.userInteractionEnabled=YES;
- [self.view addSubview:redTipView];
- self.view.userInteractionEnabled = YES;
- }
-
- }
- -(void)tapImageView
- {
- [UIView animateWithDuration:0.5 animations:^{
- redTipView.hidden=YES;
- }];
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [UIView animateWithDuration:0.5 animations:^{
- redTipView.hidden=YES;
- }];
-
- }
- #pragma mark---红包提示
- -(void)clickRedView
- {
- [UIView animateWithDuration:0.5 animations:^{
- redTipView.hidden=NO;
- }];
- }
- -(void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
-
- }
- - (void)configParam {
- _page = 1;
- }
- - (void)requestCount {
- [LDEventTool eventWithEventType:0 origin:self.eventModel.origin category_id:self.eventModel.category_id goods_id:self.requestModel.goods_id source:self.eventModel.source];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- self.navigationController.navigationBar.hidden = YES;
- self.bottomView.goodModel=self.goodModel;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- - (void)initNavBar {
- [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.0]];
-
- UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
- leftButton.frame = CGRectMake(0, 0, FITSIZE(22), FITSIZE(22));
- leftButton.backgroundColor = [UIColor clearColor];
- [leftButton setImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
- [leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- self.backButton = leftButton;
- [self.navigationBar setCustomLeftButtons:@[leftButton]];
-
- [self.navigationBar addSubview:self.topTitleView];
- }
- #pragma mark---初始化值
- -(void)initValues
- {
- LDGoodDetailModel *mndoels=[[LDGoodDetailModel alloc] init];
- [mndoels changeDetailRequestModel:_requestModel];
- self.goodDetailView.goodModel =mndoels;
- self.guideView.model = mndoels;
- LDShopModel *shopmodel =[[LDShopModel alloc]init];
- shopmodel.title= _requestModel.shop_title;
- [self.shopInfoView setShopInfo:shopmodel];
- }
- - (void)initSubviews {
-
-
- __weak typeof(self) weakSelf = self;
- //底部栏
- LDGoodDetailBottomView *bottomView = [[LDGoodDetailBottomView alloc] initWithFrame:CGRectMake(0, kScreenHeight-FITSIZE(55)-BottomMargin, kScreenWidth, FITSIZE(55))];
- bottomView.delegate = self;
- self.bottomView = bottomView;
- [self.view addSubview:bottomView];
- self.goodBottomView = bottomView;
-
- //轮播
- if (self.requestModel.img) {
- [self.bannerImgArray addObject:self.requestModel.img];
- }
- SDCycleScrollView *cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, FITSIZE(375), FITSIZE(375)) delegate:self placeholderImage:[UIImage imageNamed:@""]];
- // cycleView.pageDotImage = [UIImage imageNamed:@"page_nor"];
- cycleView.imageURLStringsGroup= self.bannerImgArray;
- self.cycleView = cycleView;
-
- //商品信息
- self.goodDetailView = [[LDGoodDetailView alloc] initWithFrame:CGRectMake(0, cycleView.height, kScreenWidth, FITSIZE(110))];
- self.goodDetailView.delegate = self;
-
- //领券模块
- LDDetailGuideView *guide = [[LDDetailGuideView alloc] initWithFrame:CGRectMake(0, self.goodDetailView.bottom, SCREEN_WIDTH, FITSIZE(120))];
- self.guideView = guide;
-
- self.guideView.delegate=self;
- guide.tapAction = ^{
- if (![AccountTool isLogin]) {
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [weakSelf presentViewController:login animated:YES completion:nil];
- return ;
- }
- LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init];
- [weakSelf.navigationController pushViewController:Privilege animated:YES];
- };
- if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
- guide.height = 0;
- }
-
- self.navigationItem.hidesBackButton = YES;
-
- //店铺信息
-
- self.shopInfoView = [[LDShopInfoView alloc] initWithFrame:CGRectMake(0, guide.bottom+5, SCREEN_WIDTH, FITSIZE(68))];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapShopInfo)];
- [self.shopInfoView addGestureRecognizer:tap];
-
-
- //推荐模块
- UIView *moduleBg = [[UIView alloc] initWithFrame:CGRectMake(0, self.shopInfoView.bottom+5, SCREEN_WIDTH, Fitsize(202))];
- self.moduleBg = moduleBg;
- LDDetailHeaderTitle *headerTitle = [[LDDetailHeaderTitle alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Fitsize(34)) title:@"相关推荐"];
- [moduleBg addSubview:headerTitle];
- self.moduleView = [[LDModuleView alloc] initWithFrame:CGRectMake(0, headerTitle.height, SCREEN_WIDTH, moduleBg.height-Fitsize(34))];
- self.moduleView.didSelectedGood = ^(LDChildGoodModel *model) {
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
- LDGoodDetailViewController *detail = [[LDGoodDetailViewController alloc] init];
- detail.requestModel = requestModel;
- LDEventModel *evevtModel = [[LDEventModel alloc] initWithOrigin:model.origin category_id:@"0" source:goodsDetailTopRecommendAction];
- detail.eventModel = evevtModel;
- [weakSelf.navigationController pushViewController:detail animated:YES];
- [MobClick event:GoodsDetailRecommend];
- };
- [moduleBg addSubview:self.moduleView];
-
- self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, moduleBg.bottom+5)];
-
- //详情webview
- LDDetailHeaderTitle *detailHeader = [[LDDetailHeaderTitle alloc] initWithFrame:CGRectMake(0, moduleBg.bottom+5, SCREEN_WIDTH, Fitsize(34)) title:@"宝贝详情"];
- self.detailHeader = detailHeader;
- _detailDescWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, detailHeader.bottom, kScreenWidth, 0)];
- _detailDescWebView.tag = detailDescWebTag;
- _detailDescWebView.navigationDelegate = self;
- _detailDescWebView.scrollView.scrollEnabled = NO;
- // _detailDescWebView.scalesPageToFit = YES;
-
-
- [self.tableHeaderView addSubview:cycleView];
- [self.tableHeaderView addSubview:self.goodDetailView];
- [self.tableHeaderView addSubview:guide];
- [self.tableHeaderView addSubview:self.shopInfoView];
- [self.tableHeaderView addSubview:moduleBg];
- [self.tableHeaderView addSubview:detailHeader];
- [self.tableHeaderView addSubview:_detailDescWebView];
- self.tableView.tableHeaderView = self.tableHeaderView;
- [self.view addSubview:self.tableView];
- [self.view bringSubviewToFront:self.navigationBar];
- //添加监听
- @try{
- [self.detailDescWebView removeObserver:self forKeyPath:@"scrollView.contentSize"];
- }@catch (NSException *exception) {
- }
- [_detailDescWebView addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
-
- [self.view bringSubviewToFront:self.navigationBar];
-
- [LDGoodDetailRequestViewModel requestGoodSimilarParamGoods_id:self.requestModel.goods_id page:@(_page) success:^(NSArray *array) {
- if (array.count > 0) {
- self.goodSimilarArr = array;
- self.tableView.tableFooterView = self.collectionView;
- }
- } failure:^(NSError *error) {
-
- }];
- [self initValues];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
- if ([keyPath isEqualToString:@"scrollView.contentSize"]) {
- if (self.goodModel.detail_pic.count > 0) {
- self.detailDescWebView.height = 0;
- return;
- }
- id height = [change valueForKey:NSKeyValueChangeNewKey];
- CGSize size;
- [(NSValue *)height getValue:&size];
-
- if (detailDescWebHeight != size.height) {
- detailDescWebHeight = size.height;
- self.detailDescWebView.height = size.height;
- self.tableHeaderView.height = self.detailDescWebView.top+size.height;
- self.tableView.tableHeaderView = self.tableHeaderView;
- }
-
- }
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark - HUD
- - (void)initHUD {
- ActivityIndicatorView *indicatorView = [ActivityIndicatorView showInView:self.view frame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- _indicatorView = indicatorView;
- [_indicatorView startAnimating];
-
- }
- #pragma mark---图片点击
- -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
- {
- SDPhotoBrowser *browser = [[SDPhotoBrowser alloc] init];
- // browser.sourceImagesContainerView = self.cycleView;
- browser.currentImageIndex = index;
- browser.delegate = self;
- browser.imageCount = self.bannerImgArray.count;
- [browser show];
- }
- #pragma mark - SDPhotoBrowserDelegate
- - (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index
- {
-
- NSString *imageName = self.bannerImgArray[index];
-
- return [NSURL URLWithString:imageName];
- }
- - (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index
- {
-
- return [UIImage imageNamed:@"placeHolder"];
- }
- #pragma mark - request
- - (void)request {
-
- [LDGoodDetailRequestViewModel requestGoodDetailParamGoods_id:self.requestModel success:^(LDGoodDetailModel *model,NSDictionary *dic) {
- if (model) {
- self.goodModel = model;
-
- [self requestUserIdentity];
- [self requestThressRecommon];
- [self saveGoodsInfoAsBrowserHistoryWith:dic];
-
- if (model.commission_price.length<= 0 && model.is_coupon.integerValue == 0 &&model.red_active_status.integerValue == 0) {//红包、券、返都没有的时候
- self.guideView.height = 0;
-
- }else{
- if (model.red_active_status.integerValue == 0 ) {//判断是否显示红包按钮
- redBtn.hidden = YES;
- }else{
- UILabel *labels =[redBtn viewWithTag:1111];
- if (model.red_active_money.floatValue != 0) {
- labels.text=[NSString stringWithFormat:@"下单后记得回来领取%@元红包哦",model.red_active_money];
- }
- redBtn.hidden=NO;
- }
- if (![AccountTool isLogin]) {//未登录,不显示返佣
- if ( model.is_coupon.integerValue ==0 && model.red_active_status.integerValue == 0) {//其中都为0的时候
- self.guideView.height =0;
- }else{
- self.guideView.height =FITSIZE(60);
- }
- }else{
- if (model.commission_price.length<=0 || model.is_coupon.integerValue ==0 || model.red_active_status.integerValue == 0) {//其中y至少有一个为0的时候
- self.guideView.height =FITSIZE(60);
- }
- }
-
- self.guideView.model=model;
- }
- //显示。过审不显示红包领券
- if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
- self.guideView.height = 0;
- }
- self.shopInfoView.frame=CGRectMake(0, self.guideView.bottom+5, SCREEN_WIDTH, Fitsize(68));
- self.moduleBg.frame=CGRectMake(0, self.shopInfoView.bottom+5, SCREEN_WIDTH, Fitsize(202));
- self.moduleView.frame=CGRectMake(0, FITSIZE(34), SCREEN_WIDTH, self.moduleBg.height-Fitsize(34));
- self.tableHeaderView.frame=CGRectMake(0, 0, SCREEN_WIDTH, self.moduleBg.bottom+5);
- self.detailHeader.frame=CGRectMake(0, self.moduleBg.bottom+5, SCREEN_WIDTH, Fitsize(34));
- self.detailDescWebView.frame=CGRectMake(0, self.detailHeader.bottom, kScreenWidth, 0);
- [self setGoodInfoForHeader];
- self.bottomView.goodModel=self.goodModel;
- }
- [_indicatorView stopAnimating];
- [self loadshopJsonStr];
- [self.tableView reloadData];
- } failure:^(NSError *error) {
- [_indicatorView stopAnimating];
- [MBProgressHUD showMessage:@"加载失败"];
- }];
-
- }
- - (void)setGoodInfoForHeader {
- self.bottomView.goodModel = self.goodModel;
- [self.bannerImgArray addObjectsFromArray:self.goodModel.small_img];
- self.cycleView.imageURLStringsGroup= self.bannerImgArray;
- self.goodDetailView.goodModel = self.goodModel;
- LDShopModel *model = self.goodModel.shop;
- CGFloat shopViewHeight = model==nil?0:Fitsize(68);
- [self.shopInfoView setShopInfo:model];
- self.shopInfoView.height = shopViewHeight;
-
- CGFloat topMargin = shopViewHeight>0?5:0;
- self.shopInfoView.y = self.guideView.bottom +topMargin;
- self.moduleBg.y = self.shopInfoView.bottom+5;
- self.detailHeader.y = self.moduleBg.bottom+5;
- _detailDescWebView.y = self.detailHeader.bottom;
-
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.goodModel.detail_url]];
- NSArray *picList = self.goodModel.detail_pic;
- if (picList.count == 0) {
- // if (@available(iOS 9.0, *)) {
- // NSArray * types=@[WKWebsiteDataTypeCookies,WKWebsiteDataTypeLocalStorage];
- //
- // NSSet *websiteDataTypes= [NSSet setWithArray:types];
- // NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
- //
- // [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
- //
- // }];
- // }
- // NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
-
- [_detailDescWebView loadRequest:request];
- }
- self.tableHeaderView.height = self.detailDescWebView.bottom;
- self.tableView.tableHeaderView = self.tableHeaderView;
- }
- /**
- 加载上部相关推荐
- */
- - (void)requestThressRecommon {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/recommendtop",BaseURL];
- NSDictionary *para = @{@"goods_id":self.requestModel.goods_id};
- [LDHttp post:url params:para success:^(id json) {
-
- NSArray *list = [NSArray yy_modelArrayWithClass:[LDChildGoodModel class] json:json[@"data"]];
- [self.moduleView setRecommonData:list];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)requestUserIdentity {
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/userIdentity",BaseURL];
- [LDHttp post:url params:nil success:^(id json) {
- if (json[@"data"]) {
-
- NSNumber *flag=json[@"data"][@"flag"];
-
- self.flag=flag;
-
- }
- } failure:^(NSError *error) {
- self.flag=0;
- }];
- }
- /**
- 保存浏览记录
- */
- - (void)saveGoodsInfoAsBrowserHistoryWith:(NSDictionary *)dic {
-
- if (![AccountTool isLogin]) {
- return;
- }
- NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/brower/record", BaseURL];
- NSDictionary *para = [self.requestModel modelToDictionary];
- [LDHttp post:urlString params:para success:^(id json) {
-
- } failure:^(NSError *error) {
-
- }];
-
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- CGFloat offsetY = scrollView.contentOffset.y;
- // CGFloat standard = FITSIZE(734)-NavBarHeight;
- CGFloat standard = self.cycleView.height-NavBarHeight;
- if (offsetY > -standard && offsetY < standard) {
- [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:offsetY/standard]];
- self.topTitleView.alpha = offsetY/standard;
- if (offsetY/standard < 0.5) {
- [self.backButton setImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
- self.backButton.alpha = 1-offsetY/standard;
- }
- else {
- [self.backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- self.backButton.alpha = offsetY/standard;
- }
- }
- else {
-
- }
- if (offsetY >= standard) {
- [self.navigationBar setShowNavigationBarBottomLine:YES];
- } else {
- [self.navigationBar setShowNavigationBarBottomLine:NO];
- }
-
-
- //设置导航栏头部seg下标
- CGFloat indexOneHeight = self.moduleView.superview.bottom+5-NavBarHeight;
- CGFloat indexTwoHeight;
- if (self.goodModel.detail_pic.count > 0) {
- //详情为图片数组时
- CGRect senctionHeight = [self.tableView rectForSection:0];
- indexTwoHeight = senctionHeight.size.height+self.tableHeaderView.height-NavBarHeight;
- }else {
- //详情为web
- indexTwoHeight = self.tableHeaderView.height-NavBarHeight;
- }
-
- if (offsetY < indexOneHeight) {
- self.topTitleView.newSelectedIndex = 0;
- }else if (offsetY>=indexOneHeight && offsetY<indexTwoHeight){
- self.topTitleView.newSelectedIndex = 1;
- }else {
- self.topTitleView.newSelectedIndex = 2;
- }
-
-
- //悬浮tip移动动画
- if (offsetY > SCREEN_WIDTH) {
- CGFloat changeValue = offsetY - _lastOffY;
- redBtn.left += changeValue*0.5;
- if (redBtn.left > SCREEN_WIDTH-10) {
- redBtn.left = SCREEN_WIDTH-10;
- }
- if (redBtn.left < SCREEN_WIDTH-200) {
- redBtn.left = SCREEN_WIDTH-200;
- }
- }
- _lastOffY = offsetY;
- }
- #pragma mark--- 特权和购买
- -(void)commisionClickPage
- {
- LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init];
- [self.navigationController pushViewController:Privilege animated:YES];
- }
- -(void)goBuyWithModel:(LDGoodDetailModel *)model
- {
- [self getTicketTaoBaoUrl];
- }
- #pragma mark-红包
- -(void)redClickPage
- {
- if (![AccountTool isLogin]) {
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:login animated:YES completion:nil];
- return;
- }
- LDAdWebViewController *web = [[LDAdWebViewController alloc] init];
- web.url = self.goodModel.red_url;
- [self.navigationController pushViewController:web animated:YES];
- }
- #pragma mark - topTitleViewDelegate
- - (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
- CGFloat indexOneHeight = self.moduleView.superview.bottom+5-NavBarHeight;
- CGFloat indexTwoHeight;
- if (self.goodModel.detail_pic.count > 0) {
- CGRect senctionHeight = [self.tableView rectForSection:0];
- indexTwoHeight = senctionHeight.size.height+self.tableHeaderView.height-NavBarHeight;
- }else {
- indexTwoHeight = self.tableHeaderView.height-NavBarHeight;
- }
- switch (selectedIndex) {
- case 0:
- [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
- break;
- case 1:
- [self.tableView setContentOffset:CGPointMake(0, indexOneHeight) animated:NO];
- break;
- case 2:
- [self.tableView setContentOffset:CGPointMake(0, indexTwoHeight) animated:NO];
- break;
- default:
- break;
- }
- }
- #pragma mark - goodDetailBottomViewDelegate
- /**
- 分享
- */
- - (void)yh_GoodDetailBottomViewClickCommissionButton {
-
- if ([AccountTool isLogin]) {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/relationAuth/isAuthOrNo",BaseURL];
- [LDHttp post:url params:nil success:^(id json) {
-
- NSNumber *flag = json[@"flag"];
- if (flag.boolValue) {
- //已授权
- LDShareGoodViewController *shareVc = [[LDShareGoodViewController alloc] init];
- [LoadingView show];
- [LDShareRequestViewModel requestGoodDetailParamGoods_id:self.requestModel success:^(LDShareInfoModel * _Nonnull model, NSDictionary * _Nonnull dic) {
- [LoadingView dismiss];
- self.shareModel = model;
- shareVc.goodModel = self.shareModel;
- [self.navigationController pushViewController:shareVc animated:YES];
-
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }else {
- //未授权 去授权
- [LDTaobaoAuthorTool taobaoAuthorManager:json[@"auth_url"] type:@"1" currentVc:self];
- }
-
-
- } failure:^(NSError *error) {
-
- }];
-
-
-
- }else{
- //没有登录。直接领取
- [self goBuy];
- }
- }
- -(void)yh_GoodDetailViewCollectButton{
- if ([AccountTool isLogin]) {
- [MobClick event:collection_count];
-
- NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_start_time : @"";
- NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_end_time : @"";
- NSNumber *is_coupon = self.goodModel.is_coupon;
- NSString *coupon_price = self.goodModel.coupon_price;
- NSString *price = self.goodModel.price;
- NSString *discount_price = self.goodModel.discount_price;
- NSString *commission_rate = self.goodModel.commission_rate;
-
- if (!coupon_start_time) coupon_start_time = @"";
- if (!coupon_end_time) coupon_end_time = @"";
- if (!is_coupon) is_coupon = @0;
- if (!coupon_price) coupon_price = @"";
- if (!price) price = @"";
- if (!discount_price) discount_price = @"";
- if (!commission_rate) commission_rate = @"";
-
- NSDictionary *para = @{@"goods_id":self.goodModel.goods_id,
- @"is_coupon":is_coupon,
- @"coupon_price":coupon_price,
- @"price":price,
- @"discount_price":discount_price,
- @"commission_rate":commission_rate,
- @"coupon_end_time":coupon_end_time,
- @"coupon_start_time":coupon_start_time
- };
- [LDGoodDetailRequestViewModel requestCollectGoodParamGoods_id:para success:^(NSString *msg) {
- [SVProgressHUD showSuccessWithStatus:msg];
- if ([msg isEqualToString:@"收藏成功"]) {
- self.goodModel.is_favorites = @1;
- {
- self.goodDetailView.collectButton.selected = YES;
- }
- }else {
- self.goodModel.is_favorites = @0;
- {self.goodDetailView.collectButton.selected = NO;
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- else {
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.loginSucc = ^{
- [self request];
- };
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.navigationController presentViewController:login animated:YES completion:nil];
- }
- }
- - (void)yh_GoodDetailBottomViewClickCollectButton {
- if ([AccountTool isLogin]) {
- [MobClick event:collection_count];
-
- NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_start_time : @"";
- NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_end_time : @"";
- NSNumber *is_coupon = self.goodModel.is_coupon;
- NSString *coupon_price = self.goodModel.coupon_price;
- NSString *price = self.goodModel.price;
- NSString *discount_price = self.goodModel.discount_price;
- NSString *commission_rate = self.goodModel.commission_rate;
-
- if (!coupon_start_time) coupon_start_time = @"";
- if (!coupon_end_time) coupon_end_time = @"";
- if (!is_coupon) is_coupon = @0;
- if (!coupon_price) coupon_price = @"";
- if (!price) price = @"";
- if (!discount_price) discount_price = @"";
- if (!commission_rate) commission_rate = @"";
-
- NSDictionary *para = @{@"goods_id":self.goodModel.goods_id,
- @"is_coupon":is_coupon,
- @"coupon_price":coupon_price,
- @"price":price,
- @"discount_price":discount_price,
- @"commission_rate":commission_rate,
- @"coupon_end_time":coupon_end_time,
- @"coupon_start_time":coupon_start_time
- };
- [LDGoodDetailRequestViewModel requestCollectGoodParamGoods_id:para success:^(NSString *msg) {
- [SVProgressHUD showSuccessWithStatus:msg];
- if ([msg isEqualToString:@"收藏成功"]) {
- self.goodModel.is_favorites = @1;
- // self.goodBottomView.collectButton.selected = YES;
- }
- else {
- self.goodModel.is_favorites = @0;
- // self.goodBottomView.collectButton.selected = NO;
- }
- } failure:^(NSError *error) {
-
- }];
- }
- else {
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.loginSucc = ^{
- [self request];
- };
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.navigationController presentViewController:login animated:YES completion:nil];
- }
- }
- /**
- 跳到淘宝领券
- */
- - (void)yh_GoodDetailBottomViewClickBuyButton {
-
- if (![AccountTool isLogin]) {
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:login animated:YES completion:nil];
- return;
- }
- [self getTicketTaoBaoUrl];
-
-
- }
- /**
- 获取商品链接
- */
- - (void)getTicketTaoBaoUrl {
-
- [MobClick event:pay_count];
- // if (![AccountTool account]) {
- // self.loginView.model=self.goodModel;
- // self.loginView.hidden=NO;
- // return;
- // }
- //
- [self goBuy];
-
-
- }
- -(void)goBuy{
- [LoadingView show];
- NSString *category_id = self.eventModel.category_id==nil?@"":self.eventModel.category_id;
- NSString *path = self.eventModel.source==nil?@"":self.eventModel.source;
- NSString *goods_id = self.requestModel.goods_id==nil?@"":self.requestModel.goods_id;
- NSString *is_coupon = self.requestModel.is_coupon==nil?@"":self.requestModel.is_coupon;
-
- NSString *coupon_id = self.requestModel.coupon_id==nil?@"":self.requestModel.coupon_id;
- NSDictionary *param = @{@"goods_id":goods_id,
- @"is_coupon":is_coupon,
- @"category_id":category_id,
- @"path":path,
- @"coupon_id":coupon_id,
- };
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/orderDown",BaseURL];
- [LDHttp post:url params:param success:^(id json) {
- NSNumber *flag = json[@"flag"];
- if ([AccountTool isLogin]) {
- if (!flag.boolValue) {
- //未授权 去授权
- [LDTaobaoAuthorTool taobaoAuthorManager:json[@"auth_url"] type:@"2" currentVc:self];
- }else {
- //已授权 直接购买
- [self jumpToTaobaoWithGoodsUrl:json[@"url"]];
- }
- }else {
- //未登录,直接购买
- [self jumpToTaobaoWithGoodsUrl:json[@"url"]];
- }
-
- [LoadingView dismiss];
- } failure:^(NSError *error) {
- [LoadingView dismiss];
- if (error) {
- [XHToast showCenterWithText:@"加载失败"];
- }
-
- }];
- }
- - (void)jumpToTaobaoWithGoodsUrl:(NSString *)url {
- [LDEventTool eventWithEventType:1 origin:self.eventModel.origin category_id:self.eventModel.category_id goods_id:self.requestModel.goods_id source:self.eventModel.source];
-
- id<AlibcTradePage> page = [AlibcTradePageFactory page:url];
- //淘客信息
- AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
- taoKeParams.pid = ALTK_PID; //
- //打开方式
- AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
- showParam.openType = AlibcOpenTypeNative;
- [[AlibcTradeSDK sharedInstance].tradeService openByUrl:url identity:@"trade" webView:nil parentController:self.navigationController showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
-
- } tradeProcessFailedCallback:^(NSError * _Nullable error) {
-
- }];
-
-
- }
- /**
- 判断是否安装淘宝app
- */
- - (BOOL)isInstallTaobaoAPP {
- if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"taobao://"]]) {
- return YES;
- }else {
- return NO;
- }
- }
- #pragma mark - goodDetailViewDelegate
- - (void)yh_GoodDetailViewTapCoupon {
- [LDGoodDetailRequestViewModel requestTicketProcessParamGoods_id:self.requestModel.goods_id coupon_price:self.goodModel.coupon_price success:^(NSString *msg) {
- [self yh_GoodDetailBottomViewClickBuyButton];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)yh_GoodDetailViewTapShop {
- LDShopDetailViewController *shopVC = [[LDShopDetailViewController alloc] init];
- shopVC.goodModel = self.goodModel;
- [self.navigationController pushViewController:shopVC animated:YES];
- }
- #pragma mark - webView
- - (void)webViewDidStartLoad:(UIWebView *)webView {
- [LoadingView dismiss];
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView {
- [LoadingView dismiss];
-
- CGSize contentSize = webView.scrollView.contentSize;
- CGSize viewSize = self.detailDescWebView.bounds.size;
-
- float rw = viewSize.width / contentSize.width;
-
- webView.scrollView.minimumZoomScale = rw;
- webView.scrollView.maximumZoomScale = rw;
- webView.scrollView.zoomScale = rw;
- }
- - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
- [LoadingView dismiss];
- }
- #pragma mark ------ wkWebView delegate ------
- // main frame的导航开始请求时调用
- - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{
-
- }
- // 当main frame开始加载数据失败时,会回调
- - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
-
- }
- //当main frame导航完成时,会回调
- - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
- // 页面加载完成之后调用
- }
- #pragma mark - tableView
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- NSArray *pics = self.goodModel.detail_pic;
- return pics.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- LDDetailImgModel *model = self.goodModel.detail_pic[indexPath.row];
- CGFloat imgScale = model.width.floatValue/model.height.floatValue;
- CGFloat imgH = SCREEN_WIDTH/imgScale;
- return imgH;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- LDGoodDetailImageCell *cell = [LDGoodDetailImageCell cellWithTableView:tableView];
- cell.model = self.goodModel.detail_pic[indexPath.row];
- return cell;
- }
- #pragma mark - collectionView
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.goodSimilarArr.count;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- LDChildGoodModel *model = self.goodSimilarArr[indexPath.row];
- CGFloat width = (SCREEN_WIDTH-5)/2;
- CGFloat height = width + 135;
- if (![AccountTool isLogin] && ![model.red_active_status boolValue]) {
- height = width +112;
- }
- return CGSizeMake(width, height);
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- LDGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
- cell.backgroundColor = [UIColor whiteColor];
- cell.backgroundView.backgroundColor = [UIColor whiteColor];
- cell.contentView.backgroundColor = [UIColor whiteColor];
- LDChildGoodModel *model = self.goodSimilarArr[indexPath.item];
- cell.model = model;
- return cell;
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
- UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader forIndexPath:indexPath];
-
- CALayer *lineGapLayer = [CALayer layer];
- lineGapLayer.frame = CGRectMake(0, 0, kScreenWidth, FITSIZE(5));
- lineGapLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor;
- [view.layer addSublayer:lineGapLayer];
-
- UILabel *lineGapLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, kScreenWidth, FITSIZE(40))];
- lineGapLabel.backgroundColor = [UIColor whiteColor];
- lineGapLabel.textColor = [UIColor YHColorWithHex:0x222222];
- lineGapLabel.font = [UIFont systemFontOfSize:FITSIZE(13)];
- lineGapLabel.text = @"相关推荐";
- lineGapLabel.textAlignment = NSTextAlignmentCenter;
- [view addSubview:lineGapLabel];
-
- return view;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
- return CGSizeMake(kScreenWidth, FITSIZE(45));
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- LDChildGoodModel *model = self.goodSimilarArr[indexPath.item];
- //详情
- LDGoodDetailViewController *detailVC = [[LDGoodDetailViewController alloc] init];
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
- detailVC.requestModel = requestModel;
-
- LDEventModel *evevtModel = [[LDEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:goodsDetailRecommendAction];
- detailVC.eventModel = evevtModel;
- [self.navigationController pushViewController:detailVC animated:YES];
-
-
- }
- #pragma mark - lazy
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[LDTableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-FITSIZE(55)-BottomMargin) style:UITableViewStylePlain];
- _tableView.rowHeight = 0.1;
- _tableView.estimatedRowHeight = 0;
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
- if (@available(iOS 11.0, *)) {
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
- }
- return _tableView;
- }
- - (UICollectionView *)collectionView {
- if (!_collectionView) {
- UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
- flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
-
- flowLayout.minimumLineSpacing = FITSIZE(5);
- flowLayout.minimumInteritemSpacing = FITSIZE(0);
-
- _collectionView = [[LDCollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, GoodSimilarViewHeight) collectionViewLayout:flowLayout];
- _collectionView.scrollEnabled = NO;
- _collectionView.bounces = NO;
- _collectionView.showsVerticalScrollIndicator = NO;
- _collectionView.delegate = self;
- _collectionView.dataSource = self;
- [_collectionView registerClass:[LDGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
- [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader];
- }
- return _collectionView;
- }
- - (SGPageTitleView *)topTitleView {
- if (!_topTitleView) {
- SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
- configure.titleFont = [UIFont systemFontOfSize:FITSIZE(14)];
- configure.titleColor = [UIColor YHColorWithHex:0x222222];
- configure.titleSelectedColor = [UIColor YHColorWithHex:0xff2420];
- configure.indicatorColor = [UIColor YHColorWithHex:0xff2420];
- configure.indicatorScrollStyle = SGIndicatorScrollStyleHalf;
-
- _topTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kScreenWidth/2-FITSIZE(100), KStatusBarHeight, FITSIZE(200), 44) delegate:self titleNames:@[@"宝贝",@"详情",@"推荐"] configure:configure];
- _topTitleView.backgroundColor = [UIColor clearColor];
- _topTitleView.alpha = 0.0;
- _topTitleView.isNeedBounces = NO;
- _topTitleView.isTitleGradientEffect = NO;
- _topTitleView.isOpenTitleTextZoom = YES;
- _topTitleView.isShowBottomSeparator = NO;
- }
- return _topTitleView;
- }
- - (NSMutableArray *)bannerImgArray {
- if (!_bannerImgArray) {
- _bannerImgArray = [NSMutableArray array];
- }
- return _bannerImgArray;
- }
- - (void)loadUserInfo {
- [LDCacheHttp post:UserInfo params:nil success:^(id json, BOOL isCache) {
- //讲将数据保存到本地单例
- [LDUserInfoManager shareManager].userInfoDic =json;
-
- } failure:^(NSError *error) {
-
- }];
- }
- -(void)loadshopJsonStr
- {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/backJsStr",BaseURL];
- [LDHttp post:url params:@{@"type":@"2"} success:^(id json) {
- NSString *jsonstr= json[@"jsStr"];
- shopjsonstr = jsonstr;
-
- } failure:^(NSError *error) {
-
- }];
- }
- #pragma mark---跳转店铺信息
- -(void)tapShopInfo
- {
-
- //点击大牌商品
- LDSearchCoupleWebViewController *searchCoupleWeb = [[LDSearchCoupleWebViewController alloc] init];
- searchCoupleWeb.url = self.goodModel.shop.shop_url;
- searchCoupleWeb.name = _goodModel.shop_title;
- if (shopjsonstr.length != 0) {
- searchCoupleWeb.jsString = shopjsonstr;
- }
- if ([[ALBBSession sharedInstance] isLogin] && [AccountTool isLogin]) {
- //进入
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
-
- }else if (![AccountTool isLogin]) {
- //未登录
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:login animated:YES completion:nil];
- }else if (![[ALBBSession sharedInstance] isLogin]) {
- //淘宝未授权
- ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
- [albbSDK setAppkey:ALBC_APP_KEY];
- [albbSDK setAuthOption:NormalAuth];
-
- [albbSDK auth:self successCallback:^(ALBBSession *session){
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
- } failureCallback:^(ALBBSession *session,NSError *error){
- NSLog(@"session == %@,error == %@",session,error);
- }];
- }
- }
- -(LDDetailLoginView *)loginView
- {
- if (!_loginView) {
- _loginView =[[LDDetailLoginView alloc]init];
- _loginView.hidden=YES;
- }
- return _loginView;
- }
- @end
|