123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374 |
- //
- // FKProDetailController.m
- // FirstLink
- //
- // Created by jack on 16/8/11.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProDetailController.h"
- #import "FKPullPageTopView.h"
- #import "FKPullPageBottomView.h"
- #import "FKLadderTableView.h"
- #import "FKProSegmentView.h"
- #import "FKProServeDetailView.h"
- #import "FKProBottomView.h"
- #import "FKProHeaderView.h"
- #import "FKProductNavigationBar.h"
- #import "FKProductSelectSpecView.h"
- #import "GuideView.h"
- #import "XHImageViewer.h"
- #import "FKShareView.h"
- #import "FLShareHelper.h"
- #import "FLImageHelper.h"
- #import "FKAddBasketAnimTool.h"
- #import "FKCollectAnimationTool.h"
- #import "FKProDetailViewModel.h"
- #import "FKProDetailRequest.h"
- #import "FKProductDetailReform.h"
- #import "FKSubmitOrderController.h"
- #import "WebViewController.h"
- #import "FLControllerHelper.h"
- #import "ChatViewController.h"
- #import "FKProductAdviseController.h"
- #import "FKBasketController.h"
- #import "FKExploreListController.h"
- #import "FKPriceWarnEditController.h"
- #import "SchemaManager.h"
- #import "SDWebImageDownloader.h"
- #define CONTENT_OFFSET_KEYPATH @"contentOffset"
- typedef NS_ENUM(NSUInteger, kSpecActionTag) {
- kSpecActionTagBuy = 0,
- kSpecActionTagAddBasket,
- kSpecActionTagSelect,
- };
- static NSString *PRODUCT_HAS_SHOW_GUIDE_KEY = @"PRODUCT_HAS_SHOW_GUIDE_KEY";
- @interface FKProDetailController ()
- <UITableViewDataSource,
- UITableViewDelegate,
- RefreshControlDelegate,
- FLNetworkDelegate,
- FKCollectAnimationToolDelegate,
- PdProductShowCellDelegate,
- FKProductSelectSpecViewDelegate,
- FKProRecommendListCellDelegate>
-
- @property (nonatomic, strong) FKLadderTableView *ladderView;
- @property (nonatomic, strong) FKProSegmentView *segmentView;
- @property (nonatomic, strong) FKProServeDetailView *featureView;
- @property (nonatomic, strong) FKProBottomView *bottomView;
- @property (nonatomic, strong) FKProductNavigationBar *navBar;
- @property (nonatomic, strong) FKProductSelectSpecView *buySpecView;
- @property (nonatomic, strong) FKProductSelectSpecView *priceWarnSpecView;
- @property (nonatomic, strong) XHImageViewer *imageBrowser; // 图片查看器
- @property (nonatomic, strong) FKAddBasketAnimTool *addBasketAnimTool;
- @property (nonatomic, strong) FKCollectAnimationTool *collectAnimTool; // 收藏动画管理
- @property (nonatomic, strong) UITableView *upTableView;
- @property (nonatomic, strong) UITableView *downTableView;
- @property (nonatomic, strong) FKProDetailViewModel *viewModel;
- @end
- @implementation FKProDetailController
- - (instancetype)initWithProductID:(NSString *)productID{
- return [self initWithProductID:productID selectSpecId:nil];
- }
- - (instancetype)initWithProductID:(NSString *)productID selectSpecId:(NSString *)selectSpecId; {
- self = [super init];
- if (self) {
- self.viewModel.productID = productID;
- self.viewModel.selectSpecId = selectSpecId;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.edgesForExtendedLayout = UIRectEdgeAll;
- self.automaticallyAdjustsScrollViewInsets = NO;
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(timeCountZeroCallback)
- name:PRODUCT_DETAIL_COUNT_TIME_ZERO
- object:nil];
-
- if (self.openURLPara) {
- self.viewModel.productID = self.openURLPara[@"id"];
- self.viewModel.refer = self.openURLPara[REFER_KEY];
-
- [self savePageRefer:self.openURLPara];
- }
-
- [self addAllSubviews];
- [self reqAllLookList];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- [UIApplication sharedApplication].statusBarHidden = NO;
- [self.navigationController setNavigationBarHidden:YES animated:YES];
-
- [self reqAllWithHud:YES];
-
- if (!self.viewModel.relativeProArray.count){
- [self requestForRelativeProduct];
- }
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- [self.tabBarController.tabBar setHidden:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
- [self.navigationController.view bringSubviewToFront:self.navigationController.navigationBar];
- [self hiddenSpecView];
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
-
- [self.viewModel setNotShowWeightDetailDefault];
- }
- - (void)addAllSubviews{
-
- [self.view addSubview:self.ladderView];
- [self.view addSubview:self.bottomView];
- [self.view addSubview:self.navBar];
-
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.equalTo(self.view);
- make.height.mas_equalTo(IS_IPHONE_X ? 90 : 56);
- }];
-
- [self.ladderView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.equalTo(self.view);
- make.bottom.equalTo(self.bottomView.mas_top);
- }];
-
- [self.navBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.equalTo(self.view);
- make.height.equalTo(IS_IPHONE_X ? @88 : @64);
- }];
- }
- - (void)dealloc {
- [self.upTableView removeObserver:self.navBar forKeyPath:CONTENT_OFFSET_KEYPATH];
- [self.ladderView.bgScrollView removeObserver:self.navBar forKeyPath:CONTENT_OFFSET_KEYPATH];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- #pragma mark - response
- - (void)networkDidSuccessResponse:(NSDictionary*)response identify:(int)identify header:(MSGHeader*)header {
-
- [self.ladderView.upControl finishRefreshingDirection:RefreshDirectionTop];
- [self.ladderView.downControl finishRefreshingDirection:RefreshDirectionBottom];
-
- if (header.code.intValue == RESPONSE_MSG_NORMAL) {
- if (identify == kProductReqTypeDetail) {
-
- WeakSelf(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.hudView hide:YES];
- [weakSelf.hudView removeFromSuperview];
- weakSelf.hudView = nil;
- });
-
- self.viewModel.dataItem = [FKProductDetailReform parserDataItemWithDict:response];
- [self.viewModel checkSpecImgArray];
- [self refreshContent];
- [self showShareGuide];
- [self reqBrandRecommendList];
-
- }else if (identify == kProductReqTypeAddCollect){
- self.viewModel.dataItem.currentUser.hasCollect = YES;
- self.bottomView.collected = YES;
- }else if (identify == kProductReqTypeRemoveCollect){
- self.viewModel.dataItem.currentUser.hasCollect = NO;
- self.bottomView.collected = NO;
- }else if (identify == kProductReqTypeSpec){
- [self handleSpecResponse:response];
- [self.upTableView reloadData];
- }else if (identify == kProductReqTypeAddToBasket){
- // 执行动画
- self.addBasketAnimTool.image = [self.buySpecView getCurrentShowImg];
- self.addBasketAnimTool.picUrl = [self.buySpecView.dataCenter currentPicUrlToShow];
- [self.addBasketAnimTool showInView:self.view targetView:self.bottomView.goToBasketBtn];
- [[NSNotificationCenter defaultCenter] postNotificationName:BASKET_NEED_TO_REFRESH object:nil];
-
- }else if (identify == kProductReqTypeBrandRecommend) {
- self.viewModel.brandRecItem = [FKProductDetailReform parserBrandRecItemWithDict:response];
- [self.upTableView reloadData];
- }else if (identify == kProductReqTypeAllLookList) {
- self.viewModel.allLookItem = [FKProductDetailReform parserAllLookItemWithDict:response];
- [self.upTableView reloadData];
- }else if (identify == kProductReqTypeRelativePro){
- self.viewModel.relativeProArray = [FKProductDetailReform parserRelativeProItemArrayWithDict:response];
- self.viewModel.totalRelativeCount = [FKProductDetailReform parserTotalRelativeWihtDict:response];
-
- [self refreshBottomState];
- [self.downTableView reloadData];
- }else if (identify == kProductReqTypeMoreRelativePro){
- [self.viewModel appendMoreRelativePro:[FKProductDetailReform parserRelativeProItemArrayWithDict:response]];
- self.viewModel.totalRelativeCount = [FKProductDetailReform parserTotalRelativeWihtDict:response];
-
- [self refreshBottomState];
- [self.downTableView reloadData];
- } else if (identify == kProductReqTypeTagList) {
- self.viewModel.tagArray = [FKProductDetailReform parserFeatureListWithDict:response];
- [self.upTableView reloadData];
- } else if (identify == kProductReqTypeActivity) {
- self.viewModel.activityArray = [FKProductDetailReform parserAcitvityArrayWithDict:response];
- [self.upTableView reloadData];
- } else if (identify == kProductReqTypeTips) {
- self.viewModel.tipsItem = [FKProductDetailReform parserTipsItemWithDict:response];
- if (self.segmentView.currentIndex == 1) [self.downTableView reloadData];
- } else if (identify == kProductReqTypeVipDiscountItem) {
- self.viewModel.discountItem = [FKProductDetailReform parserVipDiscountItem:response];
- [self.upTableView reloadData];
- }
- }else{
- [FLProgressHUDHelper showText:header.msg inView:self.view];
- }
- }
- - (void)networkDidReceiveError:(NSError*)error identify:(int)identify header:(MSGHeader*)header{
-
- if (identify == kProductReqTypeDetail) {
- WeakSelf(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.hudView hide:YES];
- [weakSelf.hudView removeFromSuperview];
- weakSelf.hudView = nil;
- });
- }
-
- [self.ladderView.upControl finishRefreshingDirection:RefreshDirectionTop];
- [self.ladderView.upControl finishRefreshingDirection:RefreshDirectionBottom];
-
- [FLProgressHUDHelper showText:header.msg inView:self.view];
- }
- - (void)handleSpecResponse:(NSDictionary *)response{
-
- NSArray *productItemArray = [FKProductDetailReform parserSpecProductItemArrayWithDict:response];
- [self.viewModel setSelectProductItemWithProductArray:productItemArray];
-
- FKProductSpecDataCenter *dataCenter = [self dataCenterWithType:kSpecTypeNormal response:response];
- [dataCenter configWithViewModel:self.viewModel];
- self.buySpecView.dataCenter = dataCenter;
-
- FKProductSpecDataCenter *priceWarnDataCenter = [self dataCenterWithType:kSpecTypePriceWarn response:response];
- [priceWarnDataCenter configWithViewModel:self.viewModel];
- self.priceWarnSpecView.dataCenter = priceWarnDataCenter;
-
- if (productItemArray.count > 0) {
- self.viewModel.specPicArray = [dataCenter specImgUrlArray:productItemArray];
- } else {
- [self.viewModel checkSpecImgArray];
- }
- self.viewModel.selectSpecId = nil; // 只做第一次默认选中
- [self.bottomView resetContentWithDataModel:self.viewModel.dataItem specDataCenter:dataCenter];
- }
- #pragma mark - request
- - (void)reqAllWithHud:(BOOL)hud{
-
- [self requestForSpecData];
- [self reqInitialDataWithHud:hud];
- [self reqTagList];
- [self reqActivity];
- [self reqWenxinTips];
- [self requestDiscountItem];
- }
- - (void)requestForSpecData{
- [FKProDetailRequest requestWithType:kProductReqTypeSpec
- info:@{PRODUCT_ID_KEY : self.viewModel.productID}
- delegate:self];
- }
- - (void)reqInitialDataWithHud:(BOOL)hud {
- // 请求初始化数据
- if (hud) [self.hudView show:YES];
-
- if (!self.viewModel.productID.length){
- [self.hudView hide:YES];
- return;
- }
-
- [FKProDetailRequest requestWithType:kProductReqTypeDetail
- info:@{PRODUCT_ID_KEY : self.viewModel.productID,
- REFER_KEY : [FLStringHelper replaceNilWithEmpty:self.viewModel.refer]}
- delegate:self];
- }
- - (void)requestForRelativeProduct{
- [FKProDetailRequest requestWithType:kProductReqTypeRelativePro
- info:@{PRODUCT_ID_KEY : self.viewModel.productID,
- PRODUCT_RELATIVE_START_ROW_KEY : @(0)}
- delegate:self];
- }
- - (void)requestForMoreRelative{
- [FKProDetailRequest requestWithType:kProductReqTypeMoreRelativePro
- info:@{PRODUCT_ID_KEY : self.viewModel.productID,
- PRODUCT_RELATIVE_START_ROW_KEY : @(self.viewModel.relativeProArray.count)}
- delegate:self];
- }
- - (void)reqBrandRecommendList{
- // 一次请求,从其他页面回来不请求
- if (!self.viewModel.brandRecItem) {
- NSString *brandID = self.viewModel.dataItem.productInfo.brandId;
- if ([FLStringHelper isValidString:brandID]) {
- [FKProDetailRequest requestWithType:kProductReqTypeBrandRecommend
- info:@{BRAND_ID_KEY : brandID}
- delegate:self];
- }
- }
- }
- - (void)reqAllLookList{
-
- if ([FLStringHelper isValidString:self.viewModel.productID]) {
- [FKProDetailRequest requestWithType:kProductReqTypeAllLookList
- info:@{PRODUCT_ID_KEY : self.viewModel.productID}
- delegate:self];
- }
- }
- - (void)reqTagList{
- [FKProDetailRequest reqTagList:self.viewModel.productID
- identify:kProductReqTypeTagList
- delegate:self];
- }
- - (void)reqActivity{
- [FKProDetailRequest reqAcitvity:self.viewModel.productID
- identify:kProductReqTypeActivity
- delegate:self];
- }
- - (void)reqWenxinTips {
- [FKProDetailRequest reqTipListWithIdentify:kProductReqTypeTips delegate:self];
- }
- - (void)requestDiscountItem {
- [FKProDetailRequest reqVipDiscountWithIdentify:kProductReqTypeVipDiscountItem delegate:self];
- }
- #pragma mark - refresh delegate
- - (void)refreshControl:(FKRefreshControl *)refreshControl didEngageRefreshDirection:(RefreshDirection)direction{
- if (direction == RefreshDirectionTop) {
- [self reqAllWithHud:NO];
- [self requestForRelativeProduct];
- }else if (direction == RefreshDirectionBottom){
- [self requestForMoreRelative];
- }
- }
- #pragma mark - tableView dataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- kProTableType tableType = [self tableTypeForTable:tableView];
- return [self.viewModel numberOfSectionsInTableType:tableType];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- kProTableType tableType = [self tableTypeForTable:tableView];
- return [self.viewModel numberOfRowsInSection:section tableType:tableType];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- kProTableType tableType = [self tableTypeForTable:tableView];
- kProCellType cellType = [self.viewModel cellTypeForIndexPath:indexPath tableType:tableType];
-
- if (cellType == kProCellTypeBCChannelFee) {
- NSString *countryId = self.viewModel.dataItem.countryInfoItem.countryId;
- NSString *urlString = [NSString stringWithFormat:@"%@/detail/income-tax.html?country=%@", [[FKServerUtil sharedInstance] webServer], countryId];
- [self showFeatureDetail:urlString];
- } else if (cellType == kProCellTypeFeature) {
- NSString *countryId = self.viewModel.dataItem.countryInfoItem.countryId;
- NSString *prodId = self.viewModel.productID;
- NSString *channel = self.viewModel.dataItem.productInfo.isBCChannel ? @"&channel=bc" : @"";
-
- if (countryId && prodId) {
- NSString *urlString = [NSString stringWithFormat:@"%@/detail/service_desc.html?country=%@&id=%@%@",
- [[FKServerUtil sharedInstance] webServer],
- countryId,
- prodId,
- channel];
- [self showFeatureDetail:urlString];
- }
- } else if (cellType == kProCellTypeSelectSpec) {
- self.buySpecView.tag = kSpecActionTagSelect;
- [self.buySpecView showInView:self.navigationController.view animated:YES];
- } else if (cellType == kProCellTypeActivityScroll) {
- FKPromotionActivityItem *item = [self.viewModel activityItemAtIndex:indexPath.row];
- if ([FLStringHelper isValidString:item.targetUrl]) {
- [self parseURLSchema:item.targetUrl];
- }
- } else if (cellType == kProCellTypeSource) {
- [self clickSourceMoreAction:nil];
- } else if (cellType == kProCellTypeSeek) {
- [self pushAdviceController];
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- kProTableType tableType = [self tableTypeForTable:tableView];
- kProCellType cellType = [self.viewModel cellTypeForIndexPath:indexPath tableType:tableType];
- NSString *reuseIdentify = [self.viewModel cellIdentifyForIndexPath:indexPath tableType:tableType];
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentify];
-
- switch (cellType) {
- case kProCellTypeTopImgList:{
- FKProBannerCell *bannerCell = (FKProBannerCell *)cell;
- [bannerCell.goToDetailBtn addTarget:self
- action:@selector(clickGoToDetailBtn:)
- forControlEvents:UIControlEventTouchUpInside];
- WeakSelf(weakSelf);
- bannerCell.clickAction = ^(NSInteger index, FKProBannerCell * cell) {
- [weakSelf clickBannerCellAtIndex:index bannerCell:cell];
- };
- }
- break;
- case kProCellTypeTitle:{
- FKProTitleCell *titleCell = (FKProTitleCell *)cell;
- [titleCell.priceWarnActBtn addTarget:self
- action:@selector(clickPriceWarnBtn:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- break;
- case kProCellTypeAmazonScore: {
- break;
- }
- case kProCellTypeProudctShow:{
- PdProductShowCell *showCell = (PdProductShowCell *)cell;
- [showCell configWithShowItem:[self.viewModel.dataItem productShowItemForIndex:indexPath.row]];
- showCell.delegate = self;
- }
- break;
- case kProCellTypeWeight:{
- FKProductWeightCell *weightCell = (FKProductWeightCell *)cell;
- [weightCell.infoBtn addTarget:self
- action:@selector(clickWeightInfo:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- break;
- case kProCellTypeRelative:{
- FKProductRelativeCell *relativieCell = (FKProductRelativeCell *)cell;
-
- WeakSelf(weakSelf);
- relativieCell.clickRelative = ^(NSInteger index){
- [weakSelf clickRelativeAtIndex:index];
- };
- }
- break;
- case kProCellTypeBrand:{
- FKProBrandCell *brandCell = (FKProBrandCell *)cell;
- [brandCell.bookButton addTarget:self
- action:@selector(clickBookBtn:)
- forControlEvents:UIControlEventTouchUpInside];
-
- [brandCell.brandButton addTarget:self
- action:@selector(clickBrandBtn:)
- forControlEvents:UIControlEventTouchUpInside];
- [brandCell.arrowBtn addTarget:self
- action:@selector(clickBrandArrowBtn:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- break;
- case kProCellTypeBrandList:
- case kProCellTypeAllLook:{
- FKProRecommendListCell *listCell = (FKProRecommendListCell *)cell;
- listCell.delegate = self;
- }
- break;
- case kProCellTypeInfo:{
- FKProInfoCell *infoCell = (FKProInfoCell *)cell;
- [infoCell.actionBtn addTarget:self
- action:@selector(clickTranslateBtn:)
- forControlEvents:UIControlEventTouchUpInside];
-
- [infoCell.linkBtn addTarget:self
- action:@selector(clickSourceLinkBtn:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- break;
- case kProCellTypeWeightError:{
- FKProWeightErrorCell *errorCell = (FKProWeightErrorCell *)cell;
- [errorCell.connenctBtn addTarget:self
- action:@selector(clickWeithErrorConnect:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- default:
- break;
- }
- if (cell) {
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell fk_configWithViewModel:self.viewModel indexPath:indexPath];
- } else {
- return [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
- }
-
-
- return cell;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
-
- kProTableType tableType = [self tableTypeForTable:tableView];
- NSIndexPath *targetIndex = [NSIndexPath indexPathForRow:0 inSection:section];
- kProCellType cellType = [self.viewModel cellTypeForIndexPath:targetIndex tableType:tableType];
-
- if (cellType == kProCellTypeAllLook) {
-
- FKProHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([FKProHeaderView class])];
- headerView.titleLabel.text = self.viewModel.allLookItem.title;
- return headerView;
-
- } else if (cellType == kProCellTypeProudctShow) {
-
- FKProHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([FKProHeaderView class])];
- headerView.titleLabel.text = @"商品图片";
- return headerView;
-
- } else if (cellType == kProCellTypeRelative) {
- FKProHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([FKProHeaderView class])];
- headerView.titleLabel.text = @"为你推荐";
- return headerView;
- }
- return nil;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- kProTableType tableType = [self tableTypeForTable:tableView];
- return [self.viewModel cellHeightForIndexPath:indexPath tableType:tableType];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- NSInteger topTableNumOfSection = [self.viewModel numberOfSectionsInTableType:kProTableTypeUp];
- if (section == (topTableNumOfSection - 1)) {
- return (10.0f + 50.0f);
- }
- return 10.0f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
-
- kProTableType tableType = [self tableTypeForTable:tableView];
- NSIndexPath *targetIndex = [NSIndexPath indexPathForRow:0 inSection:section];
- kProCellType cellType = [self.viewModel cellTypeForIndexPath:targetIndex tableType:tableType];
- if (cellType == kProCellTypeAllLook || cellType == kProCellTypeProudctShow) return 35;
-
- if (tableView == self.downTableView) {
- if (section == 0) return 10.0f;
- if (cellType == kProCellTypeRelative) return 45.0f;
- }
-
- return CGFLOAT_MIN;
- }
- #pragma mark - select specView delegate
- - (void)didClickHeaderImgBoxView:(FKProductImgBoxView *)imageBoxView showPicUrl:(NSString *)showPicUrl{
- if (!imageBoxView || !showPicUrl.length) return;
-
- UIImageView *newImgView = [[UIImageView alloc]initWithFrame:imageBoxView.imageView.bounds];
- [newImgView fl_setImageWithURL:[NSURL URLWithString:showPicUrl]];
- [imageBoxView.imageView addSubview:newImgView];
- [self.imageBrowser showWithImageViews:@[newImgView] selectedView:newImgView];
- }
- - (void)specViewSelectDone:(FKProductSelectSpecView *)specView selectedProductItem:(FKProductItem *)productItem{
- if (specView.dataCenter.type == kSpecTypeNormal){
- if (productItem) {
- self.viewModel.selectBuyItem = productItem;
- self.viewModel.hasSelectedSKU = YES;
- [self.upTableView reloadData];
- }
-
- if (specView.tag == kSpecActionTagBuy){
- // 购买
- [self pushSubmitOrderController:productItem];
- } else if (specView.tag == kSpecActionTagAddBasket){
- // 加入购物车
- [self addProductToBasket:productItem];
- } else if (specView.tag == kSpecActionTagSelect) {
- // 规格选择
- self.viewModel.selectBuyItem = productItem;
- [self.upTableView reloadData];
- }
-
- }else if (specView.dataCenter.type == kSpecTypePriceWarn){
- // 降价提醒
- FKPriceWarnEditController *priceWarn = [[FKPriceWarnEditController alloc]initWithPriceWarnItem:[productItem createPriceWarnItem]];
- [priceWarn setHidesBottomBarWhenPushed:YES];
- [self.navigationController pushViewController:priceWarn animated:YES];
- }
- }
- - (void)didClickShowSizeBtn{
- // 展示尺码表
- ProductShowItem *sizeItem = [self.viewModel.dataItem getSizePicItem];
- if (sizeItem){
- UIImageView *newImgView = [[UIImageView alloc]init];
- [self.viewModel configWithSizeImgView:newImgView];
- [self.imageBrowser showWithImageViews:@[newImgView] selectedView:newImgView];
- }
- }
- - (void)didClickShowSizeLinkBtn {
- [self pushWebViewController:@"https://m.fine3q.com/event/chima/chimabiao.html"];
- }
- #pragma mark - Recommendlist delegate
- - (void)listCell:(FKProRecommendListCell *)cell selectAtIndex:(NSIndexPath *)indexpath{
- NSIndexPath *targetIndex = [self.upTableView indexPathForCell:cell];
- if (targetIndex) {
- kProCellType cellType = [self.viewModel cellTypeForIndexPath:targetIndex tableType:kProTableTypeUp];
-
- NSString *pageRefer = nil;
- FKProRecommendItem *item = nil;
-
- if (cellType == kProCellTypeAllLook) {
- pageRefer = PRPageDetailEngineRecommend;
- item = [self.viewModel allLookItemAtIndex:indexpath.row];
- } else if (cellType == kProCellTypeBrandList) {
- pageRefer = PRPageDetailBrandRecommend;
- item = [self.viewModel brandRecItemAtIndex:indexpath.row];
- }
-
- if (item.itemId) {
- FKProDetailController *detail = [[FKProDetailController alloc]initWithProductID:item.itemId];
- [self.navigationController pushViewController:detail animated:YES];
-
- [[FKPageRouterUtil sharedInstance] pushPageRefer:pageRefer
- itemID:item.itemId
- value:item.name];
- }
- }
- }
- #pragma mark - FKCollectAnimationToolDelegate
- - (void)allCollectAnimationFinish:(FKCollectAnimationTool *)tool{
- kProductReqType type = tool.collectSelected ? kProductReqTypeAddCollect : kProductReqTypeRemoveCollect;
- NSDictionary *infoDict = [self.viewModel infoForRequestType:type];
- if (!infoDict)return;
-
- [FKProDetailRequest requestWithType:type info:infoDict delegate:self];
- }
- #pragma mark - Time Count Down Zero Callback
- - (void)timeCountZeroCallback {
- [self reqAllWithHud:YES];
- }
- #pragma mark - Method
- - (void)refreshContent {
-
- [self.buySpecView.dataCenter configWithViewModel:self.viewModel];
- [self.buySpecView resetContent];
-
- [self.priceWarnSpecView.dataCenter configWithViewModel:self.viewModel];
- [self.priceWarnSpecView resetContent];
-
- [self.upTableView reloadData];
- [self.downTableView reloadData];
-
- [self.bottomView resetContentWithDataModel:self.viewModel.dataItem specDataCenter:self.buySpecView.dataCenter];
- }
- - (FKProductSpecDataCenter *)dataCenterWithType:(kSpecType)type response:(NSDictionary *)response{
- FKProductSpecDataCenter *dataCenter = [[FKProductSpecDataCenter alloc]init];
- dataCenter.type = type;
-
- if (type == kSpecTypeNormal) {
- dataCenter.selectedProductItem = self.viewModel.selectBuyItem;
- } else if (type == kSpecTypePriceWarn) {
- dataCenter.selectedProductItem = self.viewModel.selectPriceWarnItem;
- }
- dataCenter.specItemArray = [FKProductDetailReform parserSpecItemArrayWithDict:response];
- dataCenter.productItemArray = [FKProductDetailReform parserSpecProductItemArrayWithDict:response];
- return dataCenter;
- }
- - (void)parseURLSchema:(NSString *)urlString {
- if (urlString.length > 0) {
- NSURL *url = [NSURL URLWithString:urlString];
- if ([url.scheme rangeOfString:@"HTTP" options:NSCaseInsensitiveSearch].length > 0) {
- [self pushWebViewController:urlString];
- } else {
- [[SchemaManager sharedManager] parserURL:url shouldCache:NO];
- }
- }
- }
- - (void)pushWebViewController:(NSString *)urlString {
- WebViewController *newViewController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"WebViewController"];
- newViewController.url = urlString;
- [self.navigationController pushViewController:newViewController animated:YES];
- }
- - (void)hiddenSpecView{
- [self.buySpecView dismissAnimated];
- [self.priceWarnSpecView dismissAnimated];
- }
- - (void)savePageRefer:(NSDictionary *)para {
- NSString *pk = self.openURLPara[@"p_k"];
- NSString *pr = self.openURLPara[@"p_r"];
- if (pr.length > 0) {
- NSArray *values = [[pk stringByRemovingPercentEncoding] componentsSeparatedByString:@"|"];
- [[FKPageRouterUtil sharedInstance] pushPageRefer:pr values:values];
- }
- }
- - (void)showShareGuide{
- BOOL res = [[[NSUserDefaults standardUserDefaults] objectForKey:PRODUCT_HAS_SHOW_GUIDE_KEY] boolValue];
- if (!res) {
- GuideView *guideView = [[GuideView alloc] init];
- [guideView addMaskView:@"product_share_img" withImageRect:CGRectMake((UISCREENWIDTH-285)/2, 63, 285, 247) andBtnRect:CGRectMake(UISCREENWIDTH/2-80, 310-45, 160, 45)];
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:PRODUCT_HAS_SHOW_GUIDE_KEY];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- }
- - (void)refreshBottomState{
-
- if (self.viewModel.showWarn) {
- [self.ladderView.downControl setBottomEnabled:NO];
- } else {
-
- if (self.viewModel.relativeProArray.count < self.viewModel.totalRelativeCount){
- [self.ladderView.downControl setBottomEnabled:YES];
- }else{
- [self.ladderView.downControl setBottomEnabled:NO];
- }
- }
- }
- - (void)showFeatureDetail:(NSString *)urlString {
- if (urlString) {
- [self.featureView requestWithURL:[NSURL URLWithString:urlString]];
- [self.featureView showInView:self.view animated:YES];
- }
- }
- - (kProTableType)tableTypeForTable:(UITableView *)tableView{
-
- if (tableView == self.downTableView) {
- return kProTableTypeDown;
- } else if (tableView == self.upTableView) {
- return kProTableTypeUp;
- }
- return kProTableTypeUnknow;
- }
- - (void)handleBottomAction:(kProBottomAction)actionType{
-
- if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
- [FLControllerHelper presentLoginViewController];
- return;
- }
-
- switch (actionType) {
- case kProBottomActionServer:{
- [self pushChatViewController:@"用户正在看商品:"];
- }
- break;
- case kProBottomActionCollect:{
- [self resetCollectState:self.bottomView.collected];
- [self.collectAnimTool showAnimationWithCollect:self.bottomView.collected inView:self.view];
- }
- break;
- case kProBottomActionGoToBasket:{
- // go to basket
- self.bottomView.redPoint.hidden = YES;
- FKBasketController *basket = [[FKBasketController alloc]init];
- [self.navigationController pushViewController:basket animated:YES];
- }
- break;
- case kProBottomActionAddBasket:{
- // add to basket
- NSError *error;
- if ([self productCanBeBuyWithError:&error]){
- if ([self.buySpecView.dataCenter isOnlyOneSku] || (self.viewModel.selectBuyItem && self.viewModel.hasSelectedSKU)) {
- [self addProductToBasket:self.viewModel.selectBuyItem];
- } else {
- self.buySpecView.tag = kSpecActionTagAddBasket;
- [self.buySpecView showInView:self.navigationController.view animated:YES];
- }
- } else {
- [FLProgressHUDHelper showText:error.localizedDescription inView:self.view];
- }
- }
- break;
- case kProBottomActionBuy:{
- NSError *error;
- if ([self productCanBeBuyWithError:&error]){
- if ([self.buySpecView.dataCenter isOnlyOneSku] || (self.viewModel.selectBuyItem && self.viewModel.hasSelectedSKU)) {
- [self pushSubmitOrderController:self.viewModel.selectBuyItem];
- } else {
- self.buySpecView.tag = kSpecActionTagBuy;
- [self.buySpecView showInView:self.navigationController.view animated:YES];
- }
-
- };
- }
- default:
- break;
- }
- }
- - (void)resetCollectState:(BOOL)collected{
- self.bottomView.collected = collected;
- }
- - (NSDictionary *)chatViewControllerExtData:(NSString *)title {
- return @{EXT_MSG_TYPE_V2: @{EXT_MSG_TYPE_TRACK_V2: @{EXT_MSG_TITLE_V2 : title,
- EXT_MSG_PRICE_V2 : [self.viewModel.dataItem getTotalPrice],
- EXT_MSG_DESC_V2 : [FLStringHelper replaceNilWithEmpty:self.viewModel.dataItem.productInfo.title],
- EXT_MSG_PIC_URL_V2 : [FLStringHelper replaceNilWithEmpty:self.viewModel.dataItem.productInfo.firstPicUrl],
- EXT_MSG_ITEM_URL_V2 : [FLStringHelper replaceNilWithEmpty:self.viewModel.dataItem.webUrl],
- EXT_MSG_USER_ID_V2 : @"",
- EXT_MSG_POST_ID_V2 : self.viewModel.productID
- }},
- EXT_MSG_ORDER_TITLE: [FLStringHelper replaceNilWithEmpty:[FLStringHelper replaceNilWithEmpty:self.viewModel.dataItem.productInfo.title]],
- EXT_QUEUE_NAME : QueueNameShouqian};
- }
- #pragma mark - click action
- - (void)navBackBtnClick{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)clickTranslateBtn:(UIButton *)sender{
-
- self.viewModel.showTranslate = !self.viewModel.showTranslate;
- [self.downTableView reloadData];
- }
- - (void)navShareBtnClick{
-
- FKShareView *shareView = [[FKShareView alloc] initWithLogin:[FKUserManager isUserLogin]];
-
- WeakSelf(weakSelf);
- [shareView showInView:self.view actionBlock:^(kShareViewActionType type, FKShareView *shareView) {
- [weakSelf clickShareForType:type];
- }];
-
- }
- - (void)clickGoToDetailBtn:(UIButton *)sender{
- [self.ladderView goToDown];
- }
- - (void)clickSourceLinkBtn:(UIButton *)sender{
- NSString *buyChannel = self.viewModel.dataItem.productInfo.linkUrl;
- if ([FLStringHelper isUrlString:buyChannel]){
- [self pushWebViewControllerWithUrl:buyChannel];
- }
- }
- - (void)clickSourceMoreAction:(UIButton *)sender {
-
- NSString *keyword = self.viewModel.dataItem.supplier.name;
- NSString *itemID = self.viewModel.dataItem.supplier.supplyID;
- if (![FLStringHelper isValidString:keyword]) return;
-
- FKExploreListController *controller = [[FKExploreListController alloc] initWithSource:FKExploreListSourceSupplier];
- [controller.conditionManager addConditionWithType:FKExploreConditionTypeSupplier
- itemID:itemID
- value:keyword];
- [self.navigationController pushViewController:controller animated:YES];
-
- [[FKPageRouterUtil sharedInstance] pushPageRefer:PRPageSearchSupplier itemID:itemID value:keyword];
- }
- #pragma mark - Brand Cell Action
- - (void)clickBookBtn:(UIButton *)sender{
-
- if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
- [self showLoginActionMenu];
- return;
- }
-
- NSString *brandId = self.viewModel.brandRecItem.brandInfo.itemID;
-
- [FKProDetailRequest reqBookBrand:brandId
- isCancel:sender.selected ? YES : NO
- identify:kProductReqTypeBookBrand
- delegate:self];
-
- sender.selected = !sender.selected;
- }
- - (void)clickBrandBtn:(UIButton *)sender{
- // 跳转品牌搜索
- NSString *keyword = self.viewModel.brandRecItem.brandInfo.brandName;
- NSString *itemID = self.viewModel.brandRecItem.brandInfo.itemID;
- if (![FLStringHelper isValidString:keyword]) return;
-
- FKExploreListController *controller = [[FKExploreListController alloc] initWithSource:FKExploreListSourceBrand];
- [controller.conditionManager addConditionWithType:FKExploreConditionTypeBrand
- itemID:itemID
- value:keyword];
- [self.navigationController pushViewController:controller animated:YES];
-
- }
- - (void)clickBrandArrowBtn:(UIButton *)sender {
- self.viewModel.isBrandDescClose = !self.viewModel.isBrandDescClose;
- [self.upTableView reloadData];
- }
- - (void)clickPriceWarnBtn:(UIButton *)sender {
- if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
- [self showLoginActionMenu];
- return;
- }
-
- // 降价通知
- [self.priceWarnSpecView showInView:self.navigationController.view animated:YES];
- }
- - (void)clickRelativeAtIndex:(NSInteger)index{
- FKProductRelativeItem *item = [self.viewModel relativeItemAtIndex:index];
- if ([FLStringHelper isValidString:item.itemId]){
- FKProDetailController *detail = [[FKProDetailController alloc]initWithProductID:item.itemId];
- [self.navigationController pushViewController:detail animated:YES];
-
- [[FKPageRouterUtil sharedInstance] pushPageRefer:PRPageDetailRecommend
- itemID:self.viewModel.productID
- value:self.viewModel.dataItem.productInfo.name];
- }
- }
- - (void)clickBannerCellAtIndex:(NSInteger)index bannerCell:(FKProBannerCell *)cell{
- [self showBannerImgListWithSelectIndex:index sourceCell:cell];
- }
- - (void)clickProductImg:(PdProductShowCell *)cell{
-
- NSIndexPath *indexPath = [self.downTableView indexPathForCell:cell];
- if (indexPath){
- [self showImgBrowerWithSelectIndex:indexPath.row sourceCell:cell];
- }
- }
- - (void)clickWeightInfo:(UIButton *)sender{
- self.viewModel.showWeightDetail = !self.viewModel.showWeightDetail;
- [self.upTableView reloadData];
- }
- - (void)clickWeithErrorConnect:(UIButton *)sender{
- if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
- [FLControllerHelper presentLoginViewController];
- return;
- }
- [self pushChatViewController:@"重量有疑问:"];
- }
- - (void)showImgBrowerWithSelectIndex:(NSUInteger)index sourceCell:(UITableViewCell *)sourceCell{
-
- NSArray *imgUrlArray = [self.viewModel.dataItem allProductImgUrlArray];
- if (!imgUrlArray.count) return;
-
- NSMutableArray *imgArrayM = [NSMutableArray arrayWithCapacity:imgUrlArray.count];
- for (int i = 0; i < imgUrlArray.count; i++) {
- UIImageView *newImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, UISCREENWIDTH, UISCREENWIDTH)];
-
- ProductShowItem *showItem = [self.viewModel.dataItem productShowItemForIndex:i];
- if (showItem) newImgView.frame = CGRectMake(0, 0, UISCREENWIDTH, [showItem realImgHeightForRealWidth:UISCREENWIDTH]);
- [newImgView sd_setImageWithURL:[NSURL URLWithString:imgUrlArray[i]]];
-
- if (i == index) [sourceCell.contentView addSubview:newImgView];
-
- [imgArrayM addObject:newImgView];
- }
- [self.imageBrowser showWithImageViews:imgArrayM selectedView:(UIImageView *)imgArrayM[index]];
- }
- - (void)showBannerImgListWithSelectIndex:(NSUInteger)index sourceCell:(UITableViewCell *)sourceCell{
-
- NSArray *imgUrlArray = self.viewModel.specPicArray;
- if (!imgUrlArray.count) return;
-
- NSMutableArray *imgArrayM = [NSMutableArray arrayWithCapacity:imgUrlArray.count];
- for (int i = 0; i < imgUrlArray.count; i++) {
-
- UIImageView *newImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, UISCREENWIDTH, UISCREENWIDTH)];
- [newImgView sd_setImageWithURL:[NSURL URLWithString:imgUrlArray[i]]];
- if (i == index) [sourceCell.contentView addSubview:newImgView];
-
- [imgArrayM addObject:newImgView];
- }
- [self.imageBrowser showWithImageViews:imgArrayM selectedView:(UIImageView *)imgArrayM[index]];
- }
- - (BOOL)productCanBeBuyWithError:(NSError **)error{
-
- if (self.buySpecView.dataCenter && [self.buySpecView.dataCenter getTotalStock] <= 0){
- // 抢光
- *error = [NSError errorWithDomain:@"FirstLinkErrorDomain"
- code:0
- userInfo:@{NSLocalizedDescriptionKey : @"该商品已抢光"}];
-
- return NO;
- }else if (!self.viewModel.dataItem.productInfo.productOnLine) {
- // 产品下线
- NSString *errorStr = @"该商品";
- NSString *offLineStr = [self.viewModel.dataItem.productInfo offLineStr];
- if (offLineStr) {
- errorStr = [errorStr stringByAppendingString:offLineStr];
- }else{
- errorStr = @"该商品已失效";
- }
-
- *error = [NSError errorWithDomain:@"FirstLinkErrorDomain"
- code:0
- userInfo:@{NSLocalizedDescriptionKey : errorStr}];
-
- return NO;
-
- }else if (self.viewModel.dataItem.saleRule.isOnlyNew && self.viewModel.dataItem.currentUser.hasEverBuy){
- // 新用户专享
- *error = [NSError errorWithDomain:@"FirstLinkErrorDomain"
- code:0
- userInfo:@{NSLocalizedDescriptionKey : @"该商品为新用户专享"}];
-
- return NO;
- }
-
- *error = nil;
- return YES;
- }
- - (void)clickShareForType:(kShareViewActionType)type{
-
- if (type == kShareViewActionTypeNone) return;
- if (type == kShareViewActionTypeQuestion){
- NSString *qsURL = [NSString stringWithFormat:@"%@/support/about-points.html", [[FKServerUtil sharedInstance] webServer]];
-
- [self pushWebViewControllerWithUrl:qsURL];
- return;
- }
-
- NSString *tagId = self.viewModel.productID;
- NSString *title = self.viewModel.dataItem.shareTargetItem.title;
- NSString *desc = self.viewModel.dataItem.shareTargetItem.shareDesc;
- NSString *url = self.viewModel.dataItem.shareTargetItem.shareUrl;
- NSString *imgUrl = self.viewModel.dataItem.shareTargetItem.picUrl;
-
- NSString *firstImgUrl = [self.viewModel specPicArray].firstObject;
- CGSize size = CGSizeMake(SHARE_IMAGE_LENGTH, SHARE_IMAGE_LENGTH);
- if (type == kShareViewActionTypeWeibo) size = CGSizeMake(SHARE_IMAGE_LENGTH_WEIBO, SHARE_IMAGE_LENGTH_WEIBO);
-
- [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:firstImgUrl] options:0 progress:nil completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
-
- if (image) {
- image = [FLImageHelper generateThumbnailFromCenter:image frame:size];
- } else {
- image = [FLImageHelper generateThumbnailFromCenter:[FLImageHelper getAppIcon] frame:size];
- }
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- switch (type) {
- case kShareViewActionTypeFriend:
- [FLShareHelper shareToWeixin:desc description:title thumbImage:image webURL:url scene:WeixinSceneFriend];
- break;
- case kShareViewActionTypeCircle:
- [FLShareHelper shareToWeixin:desc description:title thumbImage:image webURL:url scene:WeixinSceneCicle];
- break;
- case kShareViewActionTypeWeibo:{
- [FLShareHelper shareToWeiboWithTitle:desc content:title image:image urlString:url tagID:tagId];
- }
- break;
- case kShareViewActionTypeQQzone:
- [FLShareHelper shareToQQZoneWithTitle:title content:desc imgUrl:imgUrl urlString:url];
- break;
- case kShareViewActionTypeURLCopy: {
- if (url.length > 0) {
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.persistent = YES;
- [pasteboard setString:url];
- [FLProgressHUDHelper showText:@"拷贝成功" inView:self.view];
- } else {
- [FLProgressHUDHelper showText:@"无可拷贝内容" inView:self.view];
- }
- break;
- }
- default:
- break;
- }
- });
- }];
-
- }
- #pragma mark - Push Controller
- - (void)pushWebViewControllerWithUrl:(NSString *)url {
- WebViewController *newViewController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"WebViewController"];
- newViewController.url = url;
- newViewController.hidesBottomBarWhenPushed = YES;
- newViewController.naviBarHidden = NO;
- [self.navigationController pushViewController:newViewController animated:YES];
- }
- - (void)pushSubmitOrderController:(FKProductItem *)productItem {
-
- if (!productItem) return;
-
- FKSubmitUnitItem *unitItem = [self.viewModel createSubmitUnitItemWithProductItem:productItem];
- FKSubmitOrderController *submitCtrl = [[FKSubmitOrderController alloc] initWithUnitItemArray:@[unitItem]
- userLevel:[self.viewModel.dataItem.currentUser getCurrentUserLevel]
- entranSouce:kSubmitEnterSourceDetail];
-
- [self.navigationController pushViewController:submitCtrl animated:YES];
- }
- - (void)pushChatViewController:(NSString *)title {
-
- if (!self.viewModel.dataItem) return;
-
- ChatViewController *chatController = [[ChatViewController alloc] initWithChatter:self.viewModel.dataItem.serveUser.serveId
- isGroup:NO];
- chatController.naviTitle = self.viewModel.dataItem.serveUser.nickName;
- chatController.receiverHeadURL = self.viewModel.dataItem.serveUser.headerPicUrl;
-
- chatController.msgExtData = [self chatViewControllerExtData:title];
-
- [self.navigationController pushViewController:chatController animated:YES];
- }
- - (void)pushAdviceController{
-
- FKProductAdviseController *advise = [[FKProductAdviseController alloc]initWithItemID:self.viewModel.productID];
- [self.navigationController pushViewController:advise animated:YES];
- }
- - (void)addProductToBasket:(FKProductItem *)productItem{
- if (productItem.selectedAmount <= 0 || !productItem.goodsID.length) return;
-
-
- NSDictionary *infoDict = @{PRODUCT_ID_KEY : productItem.goodsID,
- PRODUCT_AMOUNT_KEY : @(productItem.selectedAmount)};
-
- [FKProDetailRequest requestWithType:kProductReqTypeAddToBasket
- info:infoDict
- delegate:self];
- }
- #pragma mark - property
- - (FKLadderTableView *)ladderView{
- if (_ladderView == nil) {
- _ladderView = [[FKLadderTableView alloc]initWithUpTableView:self.upTableView
- downTableView:self.downTableView
- downSegmentView:self.segmentView
- delegate:self];
-
- [_ladderView.bgScrollView addObserver:self.navBar forKeyPath:CONTENT_OFFSET_KEYPATH options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
- }
- return _ladderView;
- }
- - (UITableView *)upTableView{
- if (_upTableView == nil) {
- _upTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- _upTableView.delegate = self;
- _upTableView.dataSource = self;
- _upTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _upTableView.backgroundColor = UIColorFromRGB(0xf4f4f4);
-
- [_upTableView addObserver:self.navBar forKeyPath:CONTENT_OFFSET_KEYPATH options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
-
- if (@available(iOS 11.0, *)) {
- _upTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
-
- [_upTableView registerClass:[FKProBannerCell class] forCellReuseIdentifier:NSStringFromClass([FKProBannerCell class])];
- [_upTableView registerClass:[FKProActivityInProgressCell class] forCellReuseIdentifier:NSStringFromClass([FKProActivityInProgressCell class])];
- [_upTableView registerClass:[FKProActivityForeshowCell class] forCellReuseIdentifier:NSStringFromClass([FKProActivityForeshowCell class])];
- [_upTableView registerClass:[FKProActivityThemeCell class] forCellReuseIdentifier:NSStringFromClass([FKProActivityThemeCell class])];
- [_upTableView registerClass:[FKProTitleCell class] forCellReuseIdentifier:NSStringFromClass([FKProTitleCell class])];
- [_upTableView registerClass:[FKProAmazonScoreCell class] forCellReuseIdentifier:NSStringFromClass([FKProAmazonScoreCell class])];
- [_upTableView registerClass:[FKProTagListCell class] forCellReuseIdentifier:NSStringFromClass([FKProTagListCell class])];
- [_upTableView registerClass:[FKProPriceDetailCell class] forCellReuseIdentifier:NSStringFromClass([FKProPriceDetailCell class])];
- [_upTableView registerClass:[FKProductWeightCell class] forCellReuseIdentifier:NSStringFromClass([FKProductWeightCell class])];
- [_upTableView registerClass:[FKProWeightErrorCell class] forCellReuseIdentifier:NSStringFromClass([FKProWeightErrorCell class])];
- [_upTableView registerClass:[FKProSpecResCell class] forCellReuseIdentifier:NSStringFromClass([FKProSpecResCell class])];
- [_upTableView registerClass:[FKProBCChannelFeeCell class] forCellReuseIdentifier:NSStringFromClass([FKProBCChannelFeeCell class])];
- [_upTableView registerClass:[FKProActivityCell class] forCellReuseIdentifier:NSStringFromClass([FKProActivityCell class])];
- [_upTableView registerClass:[FKProFeatureCell class] forCellReuseIdentifier:NSStringFromClass([FKProFeatureCell class])];
- [_upTableView registerClass:[FKProSourceCell class] forCellReuseIdentifier:NSStringFromClass([FKProSourceCell class])];
- [_upTableView registerClass:[FKProSeekCell class] forCellReuseIdentifier:NSStringFromClass([FKProSeekCell class])];
- [_upTableView registerClass:[FKProAskAnswerCell class] forCellReuseIdentifier:NSStringFromClass([FKProAskAnswerCell class])];
- [_upTableView registerClass:[FKProRecommendListCell class] forCellReuseIdentifier:NSStringFromClass([FKProRecommendListCell class])];
- [_upTableView registerClass:[FKProBrandCell class] forCellReuseIdentifier:NSStringFromClass([FKProBrandCell class])];
- [_upTableView registerClass:[FKProRecommendListCell class] forCellReuseIdentifier:NSStringFromClass([FKProRecommendListCell class])];
- [_upTableView registerClass:[FKProHeaderView class] forHeaderFooterViewReuseIdentifier:NSStringFromClass([FKProHeaderView class])];
- }
- return _upTableView;
- }
- - (UITableView *)downTableView{
- if (_downTableView == nil) {
- _downTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- _downTableView.delegate = self;
- _downTableView.dataSource = self;
- _downTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _downTableView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- _downTableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
- _downTableView.scrollsToTop = NO;
-
- if (@available(iOS 11.0, *)) {
- _downTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
-
- [_downTableView registerClass:[FKProRecommendListCell class] forCellReuseIdentifier:NSStringFromClass([FKProRecommendListCell class])];
- [_downTableView registerClass:[FKProductRecommendCell class] forCellReuseIdentifier:NSStringFromClass([FKProductRecommendCell class])];
- [_downTableView registerClass:[FKProInfoCell class] forCellReuseIdentifier:NSStringFromClass([FKProInfoCell class])];
- [_downTableView registerClass:[PdProductShowCell class] forCellReuseIdentifier:NSStringFromClass([PdProductShowCell class])];
- [_downTableView registerClass:[FKProductRelativeCell class] forCellReuseIdentifier:NSStringFromClass([FKProductRelativeCell class])];
- [_downTableView registerClass:[FKProWarnTitleCell class] forCellReuseIdentifier:NSStringFromClass([FKProWarnTitleCell class])];
- [_downTableView registerClass:[FKProProcessCell class] forCellReuseIdentifier:NSStringFromClass([FKProProcessCell class])];
- [_downTableView registerClass:[FKProWarnHeaderCell class] forCellReuseIdentifier:NSStringFromClass([FKProWarnHeaderCell class])];
- [_downTableView registerClass:[FKProHeaderView class] forHeaderFooterViewReuseIdentifier:NSStringFromClass([FKProHeaderView class])];
- }
- return _downTableView;
- }
- - (FKProSegmentView *)segmentView{
- if (_segmentView == nil) {
-
- WeakSelf(weakSelf);
- _segmentView = [[FKProSegmentView alloc]initWithIndexChange:^(NSInteger index) {
- weakSelf.viewModel.showWarn = (index == 0 ? NO : YES);
- [weakSelf refreshBottomState];
- [weakSelf.downTableView reloadData];
- }];
- }
- return _segmentView;
- }
- - (FKProServeDetailView *)featureView{
- if (_featureView == nil) {
- _featureView = [[FKProServeDetailView alloc]init];
- }
- return _featureView;
- }
- - (FKProDetailViewModel *)viewModel{
- if (_viewModel == nil) {
- _viewModel = [[FKProDetailViewModel alloc]init];
- }
- return _viewModel;
- }
- - (FKProBottomView *)bottomView{
- if (_bottomView == nil) {
-
- WeakSelf(weakSelf);
- _bottomView = [[FKProBottomView alloc]initWithAction:^(kProBottomAction actionType) {
- [weakSelf handleBottomAction:actionType];
- }];
- }
- return _bottomView;
- }
- - (FKProductSelectSpecView *)buySpecView{
- if (_buySpecView == nil) {
- _buySpecView = [[FKProductSelectSpecView alloc]init];
- _buySpecView.delegate = self;
- }
- return _buySpecView;
- }
- - (FKProductSelectSpecView *)priceWarnSpecView{
- if (_priceWarnSpecView == nil) {
- _priceWarnSpecView = [[FKProductSelectSpecView alloc]init];
- _priceWarnSpecView.delegate = self;
- }
- return _priceWarnSpecView;
- }
- - (FKProductNavigationBar *)navBar{
- if (_navBar == nil) {
- _navBar = [[FKProductNavigationBar alloc]init];
- [_navBar.backBtn addTarget:self action:@selector(navBackBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [_navBar.shareBtn addTarget:self action:@selector(navShareBtnClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _navBar;
- }
- - (FKAddBasketAnimTool *)addBasketAnimTool{
- if (_addBasketAnimTool == nil) {
- _addBasketAnimTool = [[FKAddBasketAnimTool alloc]init];
-
- WeakSelf(weakSelf);
- _addBasketAnimTool.finishBlock = ^(void){
- weakSelf.bottomView.redPoint.hidden = NO;
- [FLProgressHUDHelper showText:@"成功添加到购物车" inView:weakSelf.view];
- };
- }
- return _addBasketAnimTool;
- }
- - (XHImageViewer *)imageBrowser{
- if (_imageBrowser == nil) {
- _imageBrowser = [[XHImageViewer alloc] init];
- _imageBrowser.dismissInCenter = YES;
- }
- return _imageBrowser;
- }
- - (FKCollectAnimationTool *)collectAnimTool{
- if (_collectAnimTool == nil) {
- _collectAnimTool = [[FKCollectAnimationTool alloc]init];
- _collectAnimTool.delegate = self;
- }
- return _collectAnimTool;
- }
- @end
|