两折卖----返利app-----返利圈

LZMGoodDetailViewController.m 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. //
  2. // LZMGoodDetailViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/22.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMGoodDetailViewController.h"
  9. #import <WebKit/WebKit.h>
  10. #import "LZMGoodDetailRequestViewModel.h"
  11. #import "SDCycleScrollView.h"
  12. #import "LZMTableView.h"
  13. #import "LZMGoodDetailBottomView.h"
  14. #import "LZMGoodDetailView.h"
  15. #import "LZMCollectionView.h"
  16. #import "LZMGoodCollectionCell.h"
  17. #import "LZMShopDetailViewController.h"
  18. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  19. #import "LZMHistoryTool.h"
  20. #import "LZMHistoryModel.h"
  21. #import "LZMGoodListViewController.h"
  22. #import "LZMLoginViewController.h"
  23. #import "LZMAdWebViewController.h"
  24. #import "LZMEventTool.h"
  25. #import "LZMGotoDetailView.h"
  26. #import "LZMShareGoodsViewController.h"
  27. #import "LZMWebDetailController.h"
  28. #import "LZMLinkFansController.h"
  29. #import "LZMPrivilegeReferralViewController.h"
  30. #import "LZMModuleView.h"
  31. #import "LZMDetailHeaderTitle.h"
  32. #import "CCAlertShowView.h"
  33. #import "LZMShareImgPopView.h"
  34. #import "LZMShopInfoView.h"
  35. #import "LZMDetailGuideView.h"
  36. #import "PhoneLoginManager.h"
  37. #import "PhoneLoginManager.h"
  38. #define GoodSimilarViewHeight ((self.goodSimilarArr.count-1)/2+1)*FITSIZE(292)+FITSIZE(45)
  39. static CGFloat detailDescWebHeight = 0.1;
  40. static NSInteger const detailDescWebTag = 111;
  41. static NSString *const cellID = @"LZMGoodCollectionCell";
  42. static NSString *const collectionViewHeader = @"collectionViewHeader";
  43. @interface LZMGoodDetailViewController ()
  44. <
  45. SDCycleScrollViewDelegate,
  46. UITableViewDelegate,
  47. UITableViewDataSource,
  48. YHGoodDetailBottomViewDelegate,
  49. YHGoodDetailViewDelegate,
  50. UIWebViewDelegate,
  51. UICollectionViewDelegate,
  52. UICollectionViewDataSource,
  53. UICollectionViewDelegateFlowLayout,
  54. SGPageTitleViewDelegate,
  55. UIWebViewDelegate,
  56. WKNavigationDelegate
  57. >
  58. {
  59. NSInteger _page;
  60. }
  61. @property (nonatomic, strong) LZMGoodDetailModel *goodModel;
  62. @property (nonatomic, strong) UITableView *tableView;
  63. @property (nonatomic, strong) WKWebView *detailDescWebView;
  64. @property (nonatomic, strong) UIView *tableHeaderView;
  65. @property (nonatomic, strong) LZMGoodDetailView *goodDetailView;
  66. @property (nonatomic, strong) SDCycleScrollView *cycleView;
  67. @property (nonatomic, strong) NSArray *goodSimilarArr;
  68. @property (nonatomic, strong) UICollectionView *collectionView;
  69. @property (nonatomic, strong) UIButton *backButton;
  70. @property (nonatomic, strong) SGPageTitleView *topTitleView;
  71. @property (nonatomic, strong) YYFPSLabel *fpsLabel;
  72. @property (nonatomic, strong) LZMGoodDetailBottomView *goodBottomView;
  73. @property (nonatomic, strong) NSNumber *flag;//用户等级 1 会员 2 超级会员 3 运营商
  74. @property (nonatomic, strong) LZMModuleView *moduleView;
  75. @property (nonatomic, strong) LZMShopInfoView *shopInfoView;
  76. @end
  77. @implementation LZMGoodDetailViewController
  78. - (void)dealloc {
  79. [self.detailDescWebView removeObserver:self forKeyPath:@"scrollView.contentSize"];
  80. NSLog(@"释放了------------");
  81. }
  82. - (void)viewWillDisappear:(BOOL)animated {
  83. [super viewWillDisappear:animated];
  84. [SVProgressHUD dismiss];
  85. }
  86. - (void)viewDidLoad {
  87. [super viewDidLoad];
  88. [self initHUD];
  89. [self initNavBar];
  90. [self request];
  91. [self requestCount];
  92. }
  93. -(void)viewDidAppear:(BOOL)animated{
  94. [super viewDidAppear:animated];
  95. }
  96. - (void)configParam {
  97. _page = 1;
  98. }
  99. - (void)requestCount {
  100. [LZMEventTool eventWithEventType:0 origin:self.eventModel.origin category_id:self.eventModel.category_id goods_id:self.requestModel.goods_id source:self.eventModel.source];
  101. }
  102. - (void)viewWillAppear:(BOOL)animated {
  103. [super viewWillAppear:animated];
  104. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  105. self.navigationController.navigationBar.hidden = YES;
  106. }
  107. - (void)didReceiveMemoryWarning {
  108. [super didReceiveMemoryWarning];
  109. }
  110. - (void)initNavBar {
  111. [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.0]];
  112. UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
  113. leftButton.frame = CGRectMake(0, 0, FITSIZE(22), FITSIZE(22));
  114. leftButton.backgroundColor = [UIColor clearColor];
  115. [leftButton setImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
  116. [leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  117. self.backButton = leftButton;
  118. [self.navigationBar setCustomLeftButtons:@[leftButton]];
  119. [self.navigationBar addSubview:self.topTitleView];
  120. }
  121. - (void)initSubviews {
  122. __weak typeof(self) weakSelf = self;
  123. //底部栏
  124. LZMGoodDetailBottomView *bottomView = [[LZMGoodDetailBottomView alloc] initWithFrame:CGRectMake(0, kScreenHeight-FITSIZE(55)-BottomMargin, kScreenWidth, FITSIZE(55))];
  125. bottomView.delegate = self;
  126. bottomView.goodModel = self.goodModel;
  127. [self.view addSubview:bottomView];
  128. self.goodBottomView = bottomView;
  129. //轮播
  130. SDCycleScrollView *cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, FITSIZE(375), FITSIZE(375)) delegate:self placeholderImage:[UIImage imageNamed:@""]];
  131. cycleView.imageURLStringsGroup = self.goodModel.small_img;
  132. cycleView.currentPageDotImage = [UIImage imageNamed:@"page_sel"];
  133. cycleView.pageDotImage = [UIImage imageNamed:@"page_nor"];
  134. self.cycleView = cycleView;
  135. //商品信息
  136. self.goodDetailView = [[LZMGoodDetailView alloc] initWithFrame:CGRectMake(0, cycleView.height, kScreenWidth, FITSIZE(140))];
  137. self.goodDetailView.delegate = self;
  138. self.goodDetailView.goodModel = self.goodModel;
  139. LZMDetailGuideView *guide = [[LZMDetailGuideView alloc] initWithFrame:CGRectMake(0, self.goodDetailView.bottom, SCREEN_WIDTH, 35)];
  140. guide.tapAction = ^{
  141. LZMPrivilegeReferralViewController *Privilege = [[LZMPrivilegeReferralViewController alloc] init];
  142. [weakSelf.navigationController pushViewController:Privilege animated:YES];
  143. };
  144. guide.height = 0;//省钱快报不需要展示
  145. //店铺信息
  146. LZMShopModel *model = self.goodModel.shop;
  147. CGFloat shopViewHeight = model==nil?0:Fitsize(68);
  148. self.shopInfoView = [[LZMShopInfoView alloc] initWithFrame:CGRectMake(0, guide.bottom+5, SCREEN_WIDTH, shopViewHeight) shopModel:model];
  149. //推荐模块
  150. UIView *moduleBg = [[UIView alloc] initWithFrame:CGRectMake(0, self.shopInfoView.bottom+5, SCREEN_WIDTH, Fitsize(202))];
  151. LZMDetailHeaderTitle *headerTitle = [[LZMDetailHeaderTitle alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Fitsize(34)) title:@"相关推荐" color:[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xF62259] toColor:[UIColor YHColorWithHex:0xFC0E2F] withWidth:SCREEN_WIDTH]];
  152. [moduleBg addSubview:headerTitle];
  153. self.moduleView = [[LZMModuleView alloc] initWithFrame:CGRectMake(0, headerTitle.height, SCREEN_WIDTH, moduleBg.height-Fitsize(34))];
  154. self.moduleView.didSelectedGood = ^(LZMChildGoodModel *model) {
  155. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  156. LZMGoodDetailViewController *detail = [[LZMGoodDetailViewController alloc] init];
  157. detail.requestModel = requestModel;
  158. LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:model.origin category_id:@"0" source:goodsDetailTopRecommendAction];
  159. detail.eventModel = evevtModel;
  160. [weakSelf.navigationController pushViewController:detail animated:YES];
  161. [MobClick event:GoodsDetailRecommend];
  162. };
  163. [moduleBg addSubview:self.moduleView];
  164. self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, moduleBg.bottom+5)];
  165. //详情webview
  166. LZMDetailHeaderTitle *detailHeader = [[LZMDetailHeaderTitle alloc] initWithFrame:CGRectMake(0, moduleBg.bottom+5, SCREEN_WIDTH, Fitsize(34)) title:@"宝贝详情" color:[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0x8976FB] toColor:[UIColor YHColorWithHex:0x3CC1F8] withWidth:SCREEN_WIDTH]];
  167. _detailDescWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, detailHeader.bottom, kScreenWidth, detailDescWebHeight)];
  168. _detailDescWebView.tag = detailDescWebTag;
  169. _detailDescWebView.navigationDelegate = self;
  170. _detailDescWebView.scrollView.scrollEnabled = NO;
  171. // _detailDescWebView.scalesPageToFit = YES;
  172. NSURL *url = [NSURL URLWithString:self.goodModel.detail_url];
  173. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  174. [_detailDescWebView loadRequest:request];
  175. [self.tableHeaderView addSubview:cycleView];
  176. [self.tableHeaderView addSubview:self.goodDetailView];
  177. [self.tableHeaderView addSubview:guide];
  178. [self.tableHeaderView addSubview:self.shopInfoView];
  179. [self.tableHeaderView addSubview:moduleBg];
  180. [self.tableHeaderView addSubview:detailHeader];
  181. [self.tableHeaderView addSubview:_detailDescWebView];
  182. self.tableView.tableHeaderView = self.tableHeaderView;
  183. [self.view addSubview:self.tableView];
  184. [self.view bringSubviewToFront:self.navigationBar];
  185. //添加监听
  186. [_detailDescWebView addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
  187. [self.view bringSubviewToFront:self.navigationBar];
  188. [LZMGoodDetailRequestViewModel requestGoodSimilarParamGoods_id:self.requestModel.goods_id page:@(_page) success:^(NSArray *array) {
  189. if (array.count > 0) {
  190. self.goodSimilarArr = array;
  191. self.tableView.tableFooterView = self.collectionView;
  192. }
  193. } failure:^(NSError *error) {
  194. }];
  195. }
  196. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
  197. if ([keyPath isEqualToString:@"scrollView.contentSize"]) {
  198. id height = [change valueForKey:NSKeyValueChangeNewKey];
  199. CGSize size;
  200. [(NSValue *)height getValue:&size];
  201. if (detailDescWebHeight != size.height) {
  202. detailDescWebHeight = size.height;
  203. self.detailDescWebView.height = size.height;
  204. self.tableHeaderView.height = self.detailDescWebView.top+size.height;
  205. self.tableView.tableHeaderView = self.tableHeaderView;
  206. }
  207. }
  208. }
  209. - (void)backAction {
  210. [self.navigationController popViewControllerAnimated:YES];
  211. }
  212. #pragma mark - HUD
  213. - (void)initHUD {
  214. [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
  215. [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
  216. [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
  217. }
  218. #pragma mark - request
  219. - (void)request {
  220. [SVProgressHUD show];
  221. [LZMGoodDetailRequestViewModel requestGoodDetailParamGoods_id:self.requestModel success:^(LZMGoodDetailModel *model,NSDictionary *dic) {
  222. if (model) {
  223. self.goodModel = model;
  224. [self initSubviews];
  225. [self requestUserIdentity];
  226. [self requestThressRecommon];
  227. [self saveGoodsInfoAsBrowserHistoryWith:dic];
  228. }
  229. [SVProgressHUD dismiss];
  230. } failure:^(NSError *error) {
  231. [SVProgressHUD dismiss];
  232. [MBProgressHUD showMessage:@"加载失败"];
  233. }];
  234. }
  235. /**
  236. 加载上部相关推荐
  237. */
  238. - (void)requestThressRecommon {
  239. NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/recommendtop",BaseURL];
  240. NSDictionary *para = @{@"goods_id":self.requestModel.goods_id};
  241. [LZMHttp post:url params:para success:^(id json) {
  242. NSArray *list = [NSArray yy_modelArrayWithClass:[LZMChildGoodModel class] json:json[@"data"]];
  243. [self.moduleView setRecommonData:list];
  244. } failure:^(NSError *error) {
  245. }];
  246. }
  247. - (void)requestUserIdentity {
  248. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/userIdentity",BaseURL];
  249. [LZMHttp post:url params:nil success:^(id json) {
  250. if (json[@"data"]) {
  251. NSNumber *flag=json[@"data"][@"flag"];
  252. self.flag=flag;
  253. }
  254. } failure:^(NSError *error) {
  255. self.flag=0;
  256. }];
  257. }
  258. /**
  259. 保存浏览记录
  260. */
  261. - (void)saveGoodsInfoAsBrowserHistoryWith:(NSDictionary *)dic {
  262. if (![AccountTool isLogin]) {
  263. return;
  264. }
  265. NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/brower/record", BaseURL];
  266. NSDictionary *para = [self.requestModel modelToDictionary];
  267. [LZMHttp post:urlString params:para success:^(id json) {
  268. } failure:^(NSError *error) {
  269. }];
  270. }
  271. #pragma mark - scrollView
  272. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  273. CGFloat offsetY = scrollView.contentOffset.y;
  274. // CGFloat standard = FITSIZE(734)-NavBarHeight;
  275. CGFloat standard = self.cycleView.height-NavBarHeight;
  276. if (offsetY > -standard && offsetY < standard) {
  277. [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:offsetY/standard]];
  278. self.topTitleView.alpha = offsetY/standard;
  279. if (offsetY/standard < 0.5) {
  280. [self.backButton setImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
  281. self.backButton.alpha = 1-offsetY/standard;
  282. }
  283. else {
  284. [self.backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  285. self.backButton.alpha = offsetY/standard;
  286. }
  287. }
  288. else {
  289. }
  290. if (offsetY >= standard) {
  291. [self.navigationBar setShowNavigationBarBottomLine:YES];
  292. } else {
  293. [self.navigationBar setShowNavigationBarBottomLine:NO];
  294. }
  295. //设置导航栏头部seg下标
  296. CGFloat indexOneHeight = self.moduleView.superview.bottom+5-NavBarHeight;
  297. CGFloat indexTwoHeight = self.tableHeaderView.height-NavBarHeight;
  298. if (offsetY < indexOneHeight) {
  299. self.topTitleView.newSelectedIndex = 0;
  300. }else if (offsetY>=indexOneHeight && offsetY<indexTwoHeight){
  301. self.topTitleView.newSelectedIndex = 1;
  302. }else {
  303. self.topTitleView.newSelectedIndex = 2;
  304. }
  305. }
  306. #pragma mark - topTitleViewDelegate
  307. - (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
  308. CGFloat indexOneHeight = self.moduleView.superview.bottom+5-NavBarHeight;
  309. CGFloat indexTwoHeight = self.tableHeaderView.height-NavBarHeight;
  310. switch (selectedIndex) {
  311. case 0:
  312. [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
  313. break;
  314. case 1:
  315. [self.tableView setContentOffset:CGPointMake(0, indexOneHeight) animated:NO];
  316. break;
  317. case 2:
  318. [self.tableView setContentOffset:CGPointMake(0, indexTwoHeight) animated:NO];
  319. break;
  320. default:
  321. break;
  322. }
  323. }
  324. #pragma mark - goodDetailBottomViewDelegate
  325. /**
  326. 分享
  327. */
  328. - (void)yh_GoodDetailBottomViewClickCommissionButton {
  329. if ([AccountTool isLogin]) {
  330. LZMShareImgPopView *shareView = [[LZMShareImgPopView alloc] initWithFrame:self.view.bounds goodModel:self.goodModel];
  331. CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:shareView backgroundDismissEnable:YES];
  332. shareView.closeAction = ^{
  333. [showView dismiss];
  334. };
  335. showView.backgroundView.backgroundColor = [UIColor clearColor];
  336. [showView show];
  337. }else{
  338. LZMLoginViewController *login = [[LZMLoginViewController alloc] init];
  339. login.loginSucc = ^{
  340. [self request];
  341. };
  342. [self.navigationController presentViewController:login animated:YES completion:nil];
  343. }
  344. }
  345. - (void)yh_GoodDetailBottomViewClickCollectButton {
  346. if ([AccountTool isLogin]) {
  347. [MobClick event:collection_count];
  348. NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_start_time : @"";
  349. NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.requestModel.coupon_end_time : @"";
  350. NSNumber *is_coupon = self.goodModel.is_coupon;
  351. NSString *coupon_price = self.goodModel.coupon_price;
  352. NSString *price = self.goodModel.price;
  353. NSString *discount_price = self.goodModel.discount_price;
  354. NSString *commission_rate = self.goodModel.commission_rate;
  355. if (!coupon_start_time) coupon_start_time = @"";
  356. if (!coupon_end_time) coupon_end_time = @"";
  357. if (!is_coupon) is_coupon = @0;
  358. if (!coupon_price) coupon_price = @"";
  359. if (!price) price = @"";
  360. if (!discount_price) discount_price = @"";
  361. if (!commission_rate) commission_rate = @"";
  362. NSDictionary *para = @{@"goods_id":self.goodModel.goods_id,
  363. @"is_coupon":is_coupon,
  364. @"coupon_price":coupon_price,
  365. @"price":price,
  366. @"discount_price":discount_price,
  367. @"commission_rate":commission_rate,
  368. @"coupon_end_time":coupon_end_time,
  369. @"coupon_start_time":coupon_start_time
  370. };
  371. [LZMGoodDetailRequestViewModel requestCollectGoodParamGoods_id:para success:^(NSString *msg) {
  372. [SVProgressHUD showSuccessWithStatus:msg];
  373. if ([msg isEqualToString:@"收藏成功"]) {
  374. self.goodModel.is_favorites = @1;
  375. self.goodBottomView.collectButton.selected = YES;
  376. }
  377. else {
  378. self.goodModel.is_favorites = @0;
  379. self.goodBottomView.collectButton.selected = NO;
  380. }
  381. } failure:^(NSError *error) {
  382. }];
  383. }
  384. else {
  385. LZMLoginViewController *login = [[LZMLoginViewController alloc] init];
  386. login.loginSucc = ^{
  387. [self request];
  388. };
  389. [self.navigationController presentViewController:login animated:YES completion:nil];
  390. }
  391. }
  392. /**
  393. 跳到淘宝领券
  394. */
  395. - (void)yh_GoodDetailBottomViewClickBuyButton {
  396. [self getTicketTaoBaoUrl];
  397. }
  398. /**
  399. 获取商品链接
  400. */
  401. - (void)getTicketTaoBaoUrl {
  402. [self goBuy];
  403. [MobClick event:pay_count];
  404. // if (![AccountTool account]) {
  405. // LZMLoginViewController *login = [[LZMLoginViewController alloc] init];
  406. // [self presentViewController:login animated:YES completion:nil];
  407. // return;
  408. // }
  409. //
  410. //
  411. //
  412. // if ([self.flag integerValue]==1) {
  413. // UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"升级赚佣金" message:[NSString stringWithFormat:@"\n成为超级会员后,您购买商品就可以拿到%.2f元佣金哦~",[self.goodModel.super_commission_price floatValue]] preferredStyle:UIAlertControllerStyleAlert];
  414. // UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"直接领劵" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  415. // [self goBuy];
  416. //
  417. // }];
  418. // UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"成为超级会员" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  419. // LZMPrivilegeReferralViewController *vc=[[LZMPrivilegeReferralViewController alloc]init];
  420. // vc.flag=@(1);
  421. // vc.isSuper=@(0);
  422. // [self.navigationController pushViewController:vc animated:YES];
  423. // }];
  424. // [alert addAction:defaultAction];
  425. // [alert addAction:cancelAction];
  426. // [self presentViewController:alert animated:YES completion:nil];
  427. // return;
  428. // }else{
  429. // [self goBuy];
  430. // }
  431. }
  432. -(void)goBuy{
  433. [SVProgressHUD show];
  434. NSDictionary *param = @{@"goods_id":self.requestModel.goods_id,
  435. @"is_coupon":self.requestModel.is_coupon,
  436. @"category_id":(self.eventModel.category_id==nil?@"":self.eventModel.category_id),
  437. @"path":(self.eventModel.source==nil?@"":self.eventModel.source)
  438. };
  439. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/orderDown",BaseURL];
  440. [LZMHttp post:url params:param success:^(id json) {
  441. if (url.length > 0) {
  442. [self jumpToTaobaoWithGoodsUrl:json[@"url"]];
  443. }
  444. [SVProgressHUD dismiss];
  445. } failure:^(NSError *error) {
  446. [SVProgressHUD dismiss];
  447. [MBProgressHUD showMessage:@"加载失败"];
  448. }];
  449. }
  450. - (void)jumpToTaobaoWithGoodsUrl:(NSString *)url {
  451. [LZMEventTool eventWithEventType:1 origin:self.eventModel.origin category_id:self.eventModel.category_id goods_id:self.requestModel.goods_id source:self.eventModel.source];
  452. if ([self isInstallTaobaoAPP]) {
  453. id<AlibcTradePage> page = [AlibcTradePageFactory page:url];
  454. //淘客信息
  455. AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
  456. taoKeParams.pid = ALTK_PID; //
  457. //打开方式
  458. AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
  459. showParam.openType = AlibcOpenTypeNative;
  460. [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
  461. } tradeProcessFailedCallback:^(NSError * _Nullable error) {
  462. }];
  463. }else {
  464. LZMAdWebViewController *webVc = [[LZMAdWebViewController alloc] init];
  465. webVc.url = url;
  466. [self.navigationController pushViewController:webVc animated:YES];
  467. }
  468. }
  469. /**
  470. 判断是否安装淘宝app
  471. */
  472. - (BOOL)isInstallTaobaoAPP {
  473. if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"taobao://"]]) {
  474. return YES;
  475. }else {
  476. return NO;
  477. }
  478. }
  479. #pragma mark - goodDetailViewDelegate
  480. - (void)yh_GoodDetailViewTapCoupon {
  481. [LZMGoodDetailRequestViewModel requestTicketProcessParamGoods_id:self.requestModel.goods_id coupon_price:self.goodModel.coupon_price success:^(NSString *msg) {
  482. [self yh_GoodDetailBottomViewClickBuyButton];
  483. } failure:^(NSError *error) {
  484. }];
  485. }
  486. - (void)yh_GoodDetailViewTapShop {
  487. LZMShopDetailViewController *shopVC = [[LZMShopDetailViewController alloc] init];
  488. shopVC.goodModel = self.goodModel;
  489. [self.navigationController pushViewController:shopVC animated:YES];
  490. }
  491. #pragma mark - webView
  492. - (void)webViewDidStartLoad:(UIWebView *)webView {
  493. [SVProgressHUD dismiss];
  494. }
  495. - (void)webViewDidFinishLoad:(UIWebView *)webView {
  496. [SVProgressHUD dismiss];
  497. CGSize contentSize = webView.scrollView.contentSize;
  498. CGSize viewSize = self.detailDescWebView.bounds.size;
  499. float rw = viewSize.width / contentSize.width;
  500. webView.scrollView.minimumZoomScale = rw;
  501. webView.scrollView.maximumZoomScale = rw;
  502. webView.scrollView.zoomScale = rw;
  503. }
  504. - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
  505. [SVProgressHUD dismiss];
  506. }
  507. #pragma mark ------ wkWebView delegate ------
  508. // main frame的导航开始请求时调用
  509. - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{
  510. }
  511. // 当main frame开始加载数据失败时,会回调
  512. - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
  513. }
  514. //当main frame导航完成时,会回调
  515. - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
  516. // 页面加载完成之后调用
  517. }
  518. #pragma mark - tableView
  519. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  520. return 1;
  521. }
  522. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  523. return 1;
  524. }
  525. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  526. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
  527. return cell;
  528. }
  529. #pragma mark - collectionView
  530. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  531. return 1;
  532. }
  533. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  534. return self.goodSimilarArr.count;
  535. }
  536. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  537. CGFloat width = (SCREEN_WIDTH-5)/2;
  538. CGFloat height = width + 102;
  539. return CGSizeMake(width, height);
  540. }
  541. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  542. LZMGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  543. cell.backgroundColor = [UIColor whiteColor];
  544. cell.backgroundView.backgroundColor = [UIColor whiteColor];
  545. cell.contentView.backgroundColor = [UIColor whiteColor];
  546. LZMChildGoodModel *model = self.goodSimilarArr[indexPath.item];
  547. cell.model = model;
  548. return cell;
  549. }
  550. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  551. UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader forIndexPath:indexPath];
  552. CALayer *lineGapLayer = [CALayer layer];
  553. lineGapLayer.frame = CGRectMake(0, 0, kScreenWidth, FITSIZE(5));
  554. lineGapLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor;
  555. [view.layer addSublayer:lineGapLayer];
  556. UILabel *lineGapLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, kScreenWidth, FITSIZE(40))];
  557. lineGapLabel.backgroundColor = [UIColor whiteColor];
  558. lineGapLabel.textColor = [UIColor YHColorWithHex:0x222222];
  559. lineGapLabel.font = [UIFont systemFontOfSize:FITSIZE(13)];
  560. lineGapLabel.text = @"相关推荐";
  561. lineGapLabel.textAlignment = NSTextAlignmentCenter;
  562. [view addSubview:lineGapLabel];
  563. return view;
  564. }
  565. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  566. return CGSizeMake(kScreenWidth, FITSIZE(45));
  567. }
  568. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  569. LZMChildGoodModel *model = self.goodSimilarArr[indexPath.item];
  570. //详情
  571. LZMGoodDetailViewController *detailVC = [[LZMGoodDetailViewController alloc] init];
  572. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  573. detailVC.requestModel = requestModel;
  574. LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:goodsDetailRecommendAction];
  575. detailVC.eventModel = evevtModel;
  576. [self.navigationController pushViewController:detailVC animated:YES];
  577. }
  578. #pragma mark - lazy
  579. - (UITableView *)tableView {
  580. if (!_tableView) {
  581. _tableView = [[LZMTableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-FITSIZE(55)-BottomMargin) style:UITableViewStylePlain];
  582. _tableView.rowHeight = 0.1;
  583. _tableView.estimatedRowHeight = 0;
  584. _tableView.estimatedSectionHeaderHeight = 0;
  585. _tableView.estimatedSectionFooterHeight = 0;
  586. _tableView.delegate = self;
  587. _tableView.dataSource = self;
  588. [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
  589. if (@available(iOS 11.0, *)) {
  590. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  591. }
  592. }
  593. return _tableView;
  594. }
  595. - (UICollectionView *)collectionView {
  596. if (!_collectionView) {
  597. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  598. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  599. flowLayout.minimumLineSpacing = FITSIZE(5);
  600. flowLayout.minimumInteritemSpacing = FITSIZE(0);
  601. _collectionView = [[LZMCollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, GoodSimilarViewHeight) collectionViewLayout:flowLayout];
  602. _collectionView.scrollEnabled = NO;
  603. _collectionView.bounces = NO;
  604. _collectionView.showsVerticalScrollIndicator = NO;
  605. _collectionView.delegate = self;
  606. _collectionView.dataSource = self;
  607. [_collectionView registerClass:[LZMGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  608. [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader];
  609. }
  610. return _collectionView;
  611. }
  612. - (SGPageTitleView *)topTitleView {
  613. if (!_topTitleView) {
  614. SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
  615. configure.titleFont = [UIFont systemFontOfSize:FITSIZE(14)];
  616. configure.titleColor = [UIColor YHColorWithHex:0x222222];
  617. configure.titleSelectedColor = [UIColor YHColorWithHex:0xff2420];
  618. configure.indicatorColor = [UIColor YHColorWithHex:0xff2420];
  619. configure.indicatorScrollStyle = SGIndicatorScrollStyleHalf;
  620. _topTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kScreenWidth/2-FITSIZE(100), KStatusBarHeight, FITSIZE(200), 44) delegate:self titleNames:@[@"宝贝",@"详情",@"推荐"] configure:configure];
  621. _topTitleView.backgroundColor = [UIColor clearColor];
  622. _topTitleView.alpha = 0.0;
  623. _topTitleView.isNeedBounces = NO;
  624. _topTitleView.isTitleGradientEffect = NO;
  625. _topTitleView.isOpenTitleTextZoom = YES;
  626. _topTitleView.isShowBottomSeparator = NO;
  627. }
  628. return _topTitleView;
  629. }
  630. -(void)aZYGj:(UIApplication*) aZYGj as4i0jqN:(UITableView*) as4i0jqN a6qy0U:(UIDocument*) a6qy0U afgmsEo1Ac:(UIAlertView*) afgmsEo1Ac aLaUe:(UIDocument*) aLaUe aetMn0Q6:(UIColor*) aetMn0Q6 amJwXBruE9W:(UIDocument*) amJwXBruE9W augaRm:(UISearchBar*) augaRm awHz6LoK:(UIEdgeInsets*) awHz6LoK arbnmA9k5za:(UIEdgeInsets*) arbnmA9k5za aVZeDd7:(UIApplication*) aVZeDd7 arWHXPSVzt:(UIImageView*) arWHXPSVzt aNKLE:(UIWindow*) aNKLE anI8vUsm4:(UIView*) anI8vUsm4 aRaYVz:(UIUserInterfaceIdiom*) aRaYVz a8C5rsp:(UISearchBar*) a8C5rsp aqQ5ieWtpO:(UIImageView*) aqQ5ieWtpO {
  631. NSLog(@"j65VS8tHQw7J0uyNd");
  632. NSLog(@"h4ZV1gbY6PqnJmckjOUuQStfMW7FCEIeiT");
  633. NSLog(@"lJmfPHQ6sz910MZLGyTcCDId87");
  634. NSLog(@"AMQVyUq1p2");
  635. NSLog(@"HC5QSOi7NTJqA");
  636. NSLog(@"ackVKBpLMejHDtsmPZf3nliI1UO0TybFS4J5");
  637. NSLog(@"bjFaTSCA3ufWqwKz0YE");
  638. NSLog(@"jxQemP9HgNF5D381TL4zZAnYwkotM");
  639. NSLog(@"evWuJTOXENClctHbiYaFLyzDjI1q97V8A6n4");
  640. NSLog(@"MdTEWGYlFL21yxJewR9Skq3mb4nUZNIoDputzrBO");
  641. NSLog(@"HNicxogRrqXQ03IvMjAw72Kp1FJdu");
  642. NSLog(@"BJMeTH9pyVqgcOl83bXd1kuFU5tAjIoNf7PxZs");
  643. NSLog(@"G94J8bNtgZH0E6YhpMIzymWkBvqsLo");
  644. }
  645. -(void)aXzJ0McV:(UIMenuItem*) aXzJ0McV aUBbF:(UIInputView*) aUBbF aGBRh9Ha:(UIMotionEffect*) aGBRh9Ha aQ5hjnfs0C6:(UIControlEvents*) aQ5hjnfs0C6 a2718hG:(UIMotionEffect*) a2718hG av1DUE:(UIRegion*) av1DUE aJ29bqxRo:(UIAlertView*) aJ29bqxRo aUwFNb:(UIEvent*) aUwFNb ayC3NI5H:(UIKeyCommand*) ayC3NI5H aaKfg3V:(UIUserInterfaceIdiom*) aaKfg3V a7WlhgB:(UILabel*) a7WlhgB aNzQbmR:(UIUserInterfaceIdiom*) aNzQbmR a3KT9GtwONW:(UIUserInterfaceIdiom*) a3KT9GtwONW avjeL4:(UIWindow*) avjeL4 aEP50D1s:(UIAlertView*) aEP50D1s ajn4elLUDCz:(UIUserInterfaceIdiom*) ajn4elLUDCz aUkNE:(UIFont*) aUkNE aQJ9DA:(UIMotionEffect*) aQJ9DA am3pMVA:(UIFont*) am3pMVA aKefY:(UIMotionEffect*) aKefY {
  646. NSLog(@"6tcykoQb5frugpBiYSa08zWZEC");
  647. NSLog(@"cflqw8XFE9I26pVYAdaeSMkKTvtOBiGH");
  648. NSLog(@"93GDr8Weqv");
  649. NSLog(@"KneqjMDvaT2iRhZ0uQ8m5cp9LU");
  650. NSLog(@"z1BWPTNmkcFplej");
  651. NSLog(@"2GyakV608gtXPCrSNzcMQlhnbf9iej");
  652. NSLog(@"KfugmaNikV74yHclbEvGRXDt130Bjwqe9M");
  653. NSLog(@"XHWazfbtgjcVlTwSrs9BRQYG0ouZCkUAvENqK");
  654. NSLog(@"tueUYGwjpkS0IoxamL37");
  655. NSLog(@"9R8flJITxZ3OFqiaCsyvVhcYrwSBGPWgbtz");
  656. NSLog(@"LEARKJmplacgrF9");
  657. NSLog(@"yJ4uo6pCkT7NZh9U1jRWc2B5HMizPXVxKYrgb8f");
  658. NSLog(@"Cv5T20bjwYelfEX4PJHBKZ7gdmWUIxqG8NoOat");
  659. NSLog(@"Nqzl2gpxtDoZwR3ISFkdnsXf6Ue");
  660. NSLog(@"UCI8ghWNrj7nJs1oi");
  661. }
  662. -(void)aJryW:(UIRegion*) aJryW a0iAtJV:(UIVisualEffectView*) a0iAtJV aWa5LXHBoQY:(UIScreen*) aWa5LXHBoQY aP62t:(UIEdgeInsets*) aP62t ab5pFH:(UIKeyCommand*) ab5pFH a27oFQCHVd9:(UIRegion*) a27oFQCHVd9 aO0Y25bx:(UIDevice*) aO0Y25bx {
  663. NSLog(@"xyUKhNGk1nutOBYgoRMpL5Qwa");
  664. NSLog(@"3a8XTxv1jCOZVobQrWScyEY9zHd0");
  665. NSLog(@"O90INpcnJom7ZhuMU48RieWxj");
  666. NSLog(@"bMU4GeFfKA3aZLXWgkNBmj8w5syuzDvH");
  667. NSLog(@"NFMkXeCqAjPImdSrxpvYL26EZlK3siT1Hnf7G");
  668. NSLog(@"NCa84D19cOg7MxoZXdiK");
  669. NSLog(@"VweHBtiKgvlT7xFh49MyACuc8XZsOdjobI1m25J");
  670. NSLog(@"QxOdyTbBqzJS67oat2ADrmLIn5MuvXR3sigf");
  671. NSLog(@"4CYKjS3nB0x7DgXHyWhtTvZPf2bmG9qVcop");
  672. NSLog(@"SprVQHZdXnW2eywxgM");
  673. NSLog(@"K1EfqGw3JLCX8YlaxAu6Hk");
  674. NSLog(@"BfaHApZn7d");
  675. NSLog(@"jAvum8LRNZkQiMP2DECOft");
  676. }
  677. @end