猎豆优选

LDShareGoodsViewController.m 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. //
  2. // LDShareGoodsViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDShareGoodsViewController.h"
  9. #import "LDShareGoodsTop.h"
  10. #import "LDShareGoodsView.h"
  11. #import "shareView.h"
  12. #import "HYUMShareManager.h"
  13. #import "LDLinkFansController.h"
  14. #import "LDPrivilegeReferralViewController.h"
  15. @interface LDShareGoodsViewController ()<UITextViewDelegate>
  16. @property(nonatomic,strong)UIScrollView *scrollView;
  17. @property(nonatomic,strong)UIView *topView;
  18. @property(nonatomic,strong)LDShareGoodsView *shareGoodsView;
  19. @property(nonatomic,strong)UIImageView *imageView;
  20. @property(nonatomic,strong)UIView *centerGrayView;
  21. @property(nonatomic,strong)UITextView *textView;
  22. @property(nonatomic,strong)UIImageView *imaginaryLineView;
  23. @property(nonatomic,strong)UILabel *moneyLabel;
  24. @property(nonatomic,strong)UILabel *infoLabel;
  25. @property(nonatomic,strong)UIButton *copyButton;
  26. @property(nonatomic,strong)UIButton *shareUrlButton;
  27. @property(nonatomic,strong)UIButton *shareImageButton;
  28. @property(nonatomic,strong)UIView *backShareView;
  29. @property(nonatomic,strong)shareView *shareView;
  30. @property(nonatomic,copy )NSNumber *flag;
  31. @property(nonatomic,copy )NSNumber *isSuper;
  32. @property(nonatomic )BOOL canShareImg;
  33. @end
  34. @implementation LDShareGoodsViewController
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.canShareImg=NO;
  38. [self configNavigationBar];
  39. [self initHUD];
  40. [self loadSubViewsConfiguration];
  41. [self request];
  42. [self adjustUI];
  43. [SVProgressHUD show];
  44. [SVProgressHUD dismissWithDelay:2.0f];
  45. }
  46. -(void)viewDidAppear:(BOOL)animated{
  47. [super viewDidAppear:animated];
  48. }
  49. - (void)configNavigationBar {
  50. self.view.backgroundColor = [UIColor whiteColor];
  51. [self.navigationBar setNavTitle:@"分享商品"];
  52. self.navigationBar.showNavigationBarBottomLine = YES;
  53. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  54. [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  55. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  56. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  57. [self.navigationBar setShowNavigationBarBottomLine:YES];
  58. }
  59. - (void)initHUD {
  60. [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
  61. [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
  62. [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
  63. }
  64. -(void)request{
  65. self.flag=@(-1);
  66. self.isSuper=@(-1);
  67. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/shareCommonGoods",BaseURL];
  68. NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.start_time : @"";
  69. NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.end_time : @"";
  70. if (!coupon_start_time) coupon_start_time = @"";
  71. if (!coupon_end_time) coupon_end_time = @"";
  72. NSDictionary *dic=@{
  73. @"goods_id":self.goodModel.goods_id,
  74. @"is_coupon":self.goodModel.is_coupon,
  75. @"coupon_price":self.goodModel.coupon_price,
  76. @"price":self.goodModel.price,
  77. @"discount_price":self.goodModel.discount_price,
  78. @"commission_rate":self.goodModel.commission_rate,
  79. @"coupon_end_time":coupon_end_time,
  80. @"coupon_start_time":coupon_start_time
  81. };
  82. [LDHttp post:url params:dic success:^(id json) {
  83. // LDShareGoodsViewController *vc=[[LDShareGoodsViewController alloc]init];
  84. LDShareGoodsTempModel *tmpModel=[LDShareGoodsTempModel yy_modelWithJSON:json[@"data"]];
  85. LDShareGoodsModel *model=[LDShareGoodsModel createShareGoodsModelByShareGoodsTempModel:tmpModel];
  86. model.commissionPrice=self.goodModel.commission_price;//佣金价格
  87. model.commission_rate=self.goodModel.commission_rate;
  88. model.discount_price=self.goodModel.discount_price;
  89. self.model=model;
  90. //第二次加载使用
  91. self.imageView.image=[self.shareGoodsView changeToImage];
  92. kWeak(self)
  93. self.shareGoodsView.imgSuccBlock = ^{
  94. //第一次加载使用
  95. NSLog(@"图片加载完成");
  96. selfWeak.imageView.image=[selfWeak.shareGoodsView changeToImage];
  97. selfWeak.canShareImg=YES;
  98. NSLog(@"图片加载完成2");
  99. };
  100. self.textView.text=self.model.title;
  101. self.moneyLabel.text=[NSString stringWithFormat:@"【原价】%@元 \n【券后】%@元",self.model.originalPrice,self.model.ticketAfterPrice];
  102. self.infoLabel.text=[NSString stringWithFormat:@"复制这条信息%@\n打开【手机淘宝】即可查看",self.model.infoStr];
  103. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/shareTheTextNew",BaseURL];
  104. NSDictionary *dic=@{@"commission_rate":self.model.commission_rate,
  105. @"discount_price":self.model.discount_price
  106. };
  107. [LDHttp post:url params:dic success:^(id json) {
  108. if (json[@"data"]) {
  109. [SVProgressHUD dismiss];
  110. NSString *text=json[@"data"][@"text"];
  111. NSNumber *flag=json[@"data"][@"flag"];
  112. NSNumber *isSuper=json[@"data"][@"isSuper"];
  113. UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
  114. label.frame=CGRectMake(FITSIZE(15), 10, SCREEN_WIDTH-FITSIZE((70)), 0);
  115. label.text=text;
  116. [label sizeToFit];
  117. [UIView animateWithDuration:0.5f animations:^{
  118. self.scrollView.frame=CGRectMake(0,NavBarHeight+label.height, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-label.height);
  119. }];
  120. self.flag=flag;
  121. self.isSuper=isSuper;
  122. [self.topView mas_updateConstraints:^(MASConstraintMaker *make) {
  123. make.left.right.mas_equalTo(0);
  124. make.top.mas_equalTo(NavBarHeight);
  125. make.height.mas_equalTo((label.height+20));
  126. }];
  127. UIView *rightBtn=[self.topView viewWithTag:10002];
  128. [rightBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  129. make.right.mas_equalTo(0);
  130. make.height.mas_equalTo(self.topView.mas_height);
  131. make.top.mas_equalTo(0);
  132. make.width.mas_equalTo(FITSIZE(70));
  133. }];
  134. self.topView.hidden=NO;
  135. }
  136. } failure:^(NSError *error) {
  137. self.flag=0;
  138. }];
  139. } failure:^(NSError *error) {
  140. }];
  141. }
  142. -(void)loadSubViewsConfiguration{
  143. [self.view addSubview:self.scrollView];
  144. [self.scrollView addSubview:self.imageView];
  145. [self.scrollView addSubview:self.centerGrayView];
  146. [self.scrollView addSubview:self.textView];
  147. [self.scrollView addSubview:self.imaginaryLineView];
  148. [self.scrollView addSubview:self.moneyLabel];
  149. [self.scrollView addSubview:self.infoLabel];
  150. [self.scrollView addSubview:self.copyButton];
  151. self.copyButton.hidden=YES;
  152. //view顶层
  153. [self.view addSubview:self.topView];
  154. [self.view addSubview:self.shareImageButton];
  155. [self.view addSubview:self.shareUrlButton];
  156. [[UIApplication sharedApplication].keyWindow addSubview:self.backShareView];
  157. [[UIApplication sharedApplication].keyWindow addSubview:self.shareView];
  158. }
  159. -(void)adjustUI{
  160. UILabel *topLabel=[self.topView viewWithTag:10001];
  161. [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.left.right.mas_equalTo(0);
  163. make.top.mas_equalTo(NavBarHeight);
  164. make.height.mas_equalTo((topLabel.height+20));
  165. }];
  166. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  167. make.top.mas_equalTo((topLabel.height+30+20));
  168. make.left.mas_equalTo(54);
  169. make.width.mas_equalTo(SCREEN_WIDTH-2*FITSIZE(54));
  170. make.height.mas_equalTo(474);
  171. }];
  172. [self.centerGrayView mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.left.mas_equalTo(0);
  174. make.width.mas_equalTo(SCREEN_WIDTH);
  175. make.top.equalTo(self.imageView.mas_bottom).offset(20);
  176. make.height.mas_equalTo(5);
  177. }];
  178. [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.left.mas_equalTo(FITSIZE(17));
  180. make.width.mas_equalTo(SCREEN_WIDTH-FITSIZE((17*2)));
  181. make.top.equalTo(self.centerGrayView.mas_bottom).offset(5);
  182. make.height.mas_equalTo(53);
  183. }];
  184. [self.imaginaryLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.left.mas_equalTo(FITSIZE(17));
  186. make.width.mas_equalTo(SCREEN_WIDTH-FITSIZE(17*2));
  187. make.top.equalTo(self.textView.mas_bottom).offset(7);
  188. make.height.mas_equalTo(5);
  189. }];
  190. [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  191. make.left.equalTo(self.imaginaryLineView.mas_left).offset(-FITSIZE(7));
  192. make.top.equalTo(self.imaginaryLineView.mas_bottom).offset(8);
  193. }];
  194. [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  195. make.left.equalTo(self.imaginaryLineView.mas_left);
  196. make.top.equalTo(self.moneyLabel.mas_bottom).offset(10);
  197. }];
  198. [self.copyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.right.equalTo(self.imaginaryLineView.mas_right).offset(FITSIZE(-10));
  200. make.top.equalTo(self.imaginaryLineView.mas_bottom).offset(28);
  201. make.width.mas_equalTo(FITSIZE(92));
  202. make.height.mas_equalTo(24);
  203. }];
  204. }
  205. - (void)backAction {
  206. [self.navigationController popViewControllerAnimated:YES];
  207. }
  208. -(void)ShareImg{
  209. if (self.canShareImg) {
  210. self.backShareView.hidden=NO;
  211. [self.shareView shareImage:[self.shareGoodsView changeToImage]];
  212. //分享图片
  213. [UIView animateWithDuration:0.2f animations:^{
  214. self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT-200-SafeBottomHeight, SCREEN_WIDTH, 200+SafeBottomHeight);
  215. }];
  216. }else{
  217. [MBProgressHUD showMessage:@"图片还在加载中,请稍后重试"];
  218. }
  219. }
  220. -(void)copyCode{
  221. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  222. pasteboard.string =[NSString stringWithFormat:@"%@\n--------\n【在售价】%@元\n【券后价】%@元\n--------\n复制这条信息¥%@¥\n打开【手机淘宝】即可查看",self.model.title,self.model.originalPrice,self.model.ticketAfterPrice,self.model.infoStr];
  223. [SVProgressHUD showSuccessWithStatus:@"复制成功"];
  224. }
  225. #pragma mark 代理 UITextViewDelegate
  226. - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
  227. return YES;
  228. }
  229. #pragma mark -点击方法
  230. -(void)shareAction:(UIButton *)sender{
  231. switch (sender.tag) {
  232. case 50001://分享链接
  233. {
  234. // [self.shareView shareWeChatTitle:self.model.title desc:@"领完券再购物,不光省钱还能赚钱" imageUrl:self.model.mainImageUrl webUrl:self.model.QRcodeImageUrl];
  235. // //分享链接
  236. // [UIView animateWithDuration:0.2f animations:^{
  237. // self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT-200-SafeBottomHeight, SCREEN_WIDTH, 200+SafeBottomHeight);
  238. // }];
  239. }
  240. break;
  241. case 50002:
  242. {
  243. if (!([self.flag integerValue]==0)) {
  244. if ([self.flag integerValue]==1 &&[self.isSuper integerValue]==0) {
  245. //会员
  246. UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
  247. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享赚佣金" message:[NSString stringWithFormat:@"\n%@",label.text] preferredStyle:UIAlertControllerStyleAlert];
  248. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"去升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  249. LDPrivilegeReferralViewController *vc=[[LDPrivilegeReferralViewController alloc]init];
  250. [self.navigationController pushViewController:vc animated:YES];
  251. }];
  252. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  253. [self ShareImg];
  254. }];
  255. [alert addAction:cancelAction];
  256. [alert addAction:defaultAction];
  257. alert.modalPresentationStyle = UIModalPresentationFullScreen;
  258. [self presentViewController:alert animated:YES completion:nil];
  259. }else{
  260. [self ShareImg];
  261. }
  262. }else{
  263. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"\n您还没有绑定邀请码哟" preferredStyle:UIAlertControllerStyleAlert];
  264. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  265. LDLinkFansController *linkFans = [[LDLinkFansController alloc] init];
  266. linkFans.linkFansBlock = ^{
  267. [self request];
  268. };
  269. [self.navigationController pushViewController:linkFans animated:YES];
  270. }];
  271. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  272. }];
  273. [alert addAction:defaultAction];
  274. [alert addAction:cancelAction];
  275. alert.modalPresentationStyle = UIModalPresentationFullScreen;
  276. [self presentViewController:alert animated:YES completion:nil];
  277. }
  278. }
  279. break;
  280. default:
  281. break;
  282. }
  283. }
  284. -(void)doTapChange{
  285. self.backShareView.hidden=YES;
  286. [UIView animateWithDuration:0.2f animations:^{
  287. self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 200+SafeBottomHeight);
  288. } completion:^(BOOL finished) {
  289. }];
  290. }
  291. -(void)copyAction{
  292. if ([self.flag integerValue]==-1) {
  293. [MBProgressHUD showMessage:@"努力生成邀请码中,请稍后尝试"];
  294. return;
  295. }
  296. if (!([self.flag integerValue]==0)) {
  297. if ([self.flag integerValue]==1 &&[self.isSuper integerValue]==0) {
  298. //会员
  299. UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
  300. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享赚佣金" message:[NSString stringWithFormat:@"\n%@",label.text] preferredStyle:UIAlertControllerStyleAlert];
  301. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"去升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  302. LDPrivilegeReferralViewController *vc=[[LDPrivilegeReferralViewController alloc]init];
  303. [self.navigationController pushViewController:vc animated:YES];
  304. }];
  305. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  306. [self copyCode];
  307. }];
  308. [alert addAction:cancelAction];
  309. [alert addAction:defaultAction];
  310. alert.modalPresentationStyle = UIModalPresentationFullScreen;
  311. [self presentViewController:alert animated:YES completion:nil];
  312. }else{
  313. [self copyCode];
  314. }
  315. }else{
  316. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示"
  317. message:@"\n您还没有绑定邀请码"
  318. preferredStyle:UIAlertControllerStyleAlert];
  319. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  320. LDLinkFansController *linkFans = [[LDLinkFansController alloc] init];
  321. linkFans.linkFansBlock = ^{
  322. [self request];
  323. };
  324. [self.navigationController pushViewController:linkFans animated:YES];
  325. }];
  326. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  327. }];
  328. [alert addAction:defaultAction];
  329. [alert addAction:cancelAction];
  330. alert.modalPresentationStyle = UIModalPresentationFullScreen;
  331. [self presentViewController:alert animated:YES completion:nil];
  332. }
  333. }
  334. -(void)rightAction:(id )sender{
  335. LDPrivilegeReferralViewController *vc=[[LDPrivilegeReferralViewController alloc]init];
  336. vc.flag=self.flag;
  337. vc.isSuper=self.isSuper;
  338. [self.navigationController pushViewController:vc animated:YES];
  339. }
  340. #pragma mark 懒加载
  341. -(LDShareGoodsView *)shareGoodsView{
  342. if (!_shareGoodsView) {
  343. _shareGoodsView=[[LDShareGoodsView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
  344. kWeak(self)
  345. _shareGoodsView.imgSuccBlock = ^{
  346. //第一次加载使用
  347. NSLog(@"图片加载完成");
  348. selfWeak.imageView.image=[selfWeak.shareGoodsView changeToImage];
  349. selfWeak.canShareImg=YES;
  350. NSLog(@"图片加载完成2");
  351. };
  352. _shareGoodsView.model=self.model;
  353. }
  354. return _shareGoodsView;
  355. }
  356. -(UIImageView *)imageView{
  357. if (!_imageView) {
  358. _imageView=[[UIImageView alloc]init];
  359. _imageView.backgroundColor=[UIColor whiteColor];
  360. _imageView.layer.shadowColor = [UIColor YHColorWithHex:0xF16767].CGColor;//shadowColor阴影颜色
  361. _imageView.layer.shadowOpacity = 0.2;//阴影透明度,默认0
  362. _imageView.layer.shadowRadius = 10;//阴影半径,默认3
  363. }
  364. return _imageView;
  365. }
  366. -(UIView *)topView{
  367. if (!_topView) {
  368. _topView=[[UIView alloc]init];
  369. _topView.hidden=YES;
  370. _topView.backgroundColor=[UIColor YHColorWithHex:0xFF502E];//[UIColor YHColorWithHex:0xF2F2F2];
  371. UILabel *leftLabel=[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(15), 10, SCREEN_WIDTH-FITSIZE((70)), 0)];
  372. leftLabel.numberOfLines=0;
  373. leftLabel.tag=10001;
  374. leftLabel.font=[UIFont systemFontOfSize:14.0f];
  375. leftLabel.textColor=[UIColor whiteColor];
  376. leftLabel.text=@"";
  377. [leftLabel sizeToFit];
  378. UIButton *rightBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-FITSIZE(70), leftLabel.y, FITSIZE(70), leftLabel.height)];
  379. rightBtn.tag=10002;
  380. [rightBtn setTitle:@"规则 " forState:UIControlStateNormal];
  381. UIImage *image=[UIImage imageNamed:@"share_right_regulation"];
  382. [rightBtn setImage:image forState:UIControlStateNormal];
  383. rightBtn.titleLabel.font=[UIFont systemFontOfSize:13.0f];
  384. [rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width, 0, image.size.width)];
  385. [rightBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -FITSIZE(60))];
  386. [rightBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
  387. [rightBtn setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
  388. UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(rightAction:)];
  389. singleTapGesture.numberOfTapsRequired =1;
  390. singleTapGesture.numberOfTouchesRequired =1;
  391. [_topView addGestureRecognizer:singleTapGesture];
  392. [_topView addSubview:leftLabel];
  393. [_topView addSubview:rightBtn];
  394. }
  395. return _topView;
  396. }
  397. -(UIScrollView *)scrollView{
  398. if (!_scrollView) {
  399. _scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
  400. _scrollView.showsVerticalScrollIndicator = NO;
  401. _scrollView.showsHorizontalScrollIndicator = NO;
  402. _scrollView.contentSize=CGSizeMake(SCREEN_WIDTH, 851-NavBarHeight);
  403. }
  404. return _scrollView;
  405. }
  406. -(UIView *)centerGrayView{
  407. if (!_centerGrayView) {
  408. _centerGrayView=[[UIView alloc]init];
  409. _centerGrayView.backgroundColor=[[UIColor YHColorWithHex:0x999999] colorWithAlphaComponent:0.2f];
  410. }
  411. return _centerGrayView;
  412. }
  413. -(UITextView *)textView{
  414. if (!_textView) {
  415. _textView=[[UITextView alloc]init];
  416. _textView.font=[UIFont systemFontOfSize:16.0f];
  417. // _textView.text=self.model.title;
  418. _textView.text=@"";
  419. _textView.textColor=[UIColor YHColorWithHex:0x444444];
  420. // _textView.layer.borderWidth=1;
  421. // _textView.layer.borderColor=[UIColor lightGrayColor].CGColor;
  422. // _textView.layer.cornerRadius = 3;
  423. // _textView.layer.masksToBounds=YES;
  424. _textView.delegate=self;
  425. }
  426. return _textView;
  427. }
  428. -(UIImageView *)imaginaryLineView{
  429. if (!_imaginaryLineView) {
  430. _imaginaryLineView=[[UIImageView alloc]init];
  431. [_imaginaryLineView setImage:[UIImage imageNamed:@"share_imaginary_line"]];
  432. }
  433. return _imaginaryLineView;
  434. }
  435. -(UILabel *)moneyLabel{
  436. if (!_moneyLabel) {
  437. _moneyLabel=[[UILabel alloc]init];
  438. // _moneyLabel.text=[NSString stringWithFormat:@"【原价】%@元 \n【券后】%@元",self.model.originalPrice,self.model.ticketAfterPrice];
  439. _moneyLabel.text=[NSString stringWithFormat:@"【原价】--元 \n【券后】--元"];
  440. _moneyLabel.textColor=[UIColor YHColorWithHex:0x777777];
  441. _moneyLabel.font=[UIFont systemFontOfSize:14.0f];
  442. _moneyLabel.numberOfLines=2;
  443. [_moneyLabel sizeToFit];
  444. }
  445. return _moneyLabel;
  446. }
  447. -(UILabel *)infoLabel{
  448. if (!_infoLabel) {
  449. _infoLabel=[[UILabel alloc]init];
  450. // _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看",self.model.infoStr];
  451. _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看"];
  452. _infoLabel.textColor=[UIColor YHColorWithHex:0x878787];
  453. _infoLabel.font=[UIFont systemFontOfSize:14.0f];
  454. _infoLabel.numberOfLines=2;
  455. [_infoLabel sizeToFit];
  456. }
  457. return _infoLabel;
  458. }
  459. -(UIButton *)copyButton{
  460. if (!_copyButton) {
  461. _copyButton=[[UIButton alloc]init];
  462. [_copyButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
  463. _copyButton.titleLabel.font=[UIFont systemFontOfSize:14];
  464. _copyButton.titleLabel.textAlignment=NSTextAlignmentCenter;
  465. _copyButton.layer.borderWidth=1;
  466. _copyButton.layer.cornerRadius=12;
  467. _copyButton.layer.masksToBounds=YES;
  468. _copyButton.layer.borderColor=[UIColor YHColorWithHex:0xFFDB00].CGColor;
  469. [_copyButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
  470. [_copyButton setTitleColor:[UIColor YHColorWithHex:0xED5B5B] forState:UIControlStateNormal];
  471. }
  472. return _copyButton;
  473. }
  474. -(UIButton *)shareUrlButton{
  475. if (!_shareUrlButton) {
  476. _shareUrlButton=[UIButton buttonWithType:UIButtonTypeCustom];
  477. _shareUrlButton.tag=50001;
  478. _shareUrlButton.frame=CGRectMake(0, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
  479. CAGradientLayer *layer = [CAGradientLayer layer];
  480. layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
  481. layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
  482. layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFEC800].CGColor,(id)[UIColor YHColorWithHex:0xFD9D03].CGColor, nil];
  483. layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
  484. layer.frame = _shareUrlButton.layer.bounds;
  485. [_shareUrlButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
  486. _shareUrlButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
  487. [_shareUrlButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  488. [_shareUrlButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
  489. [_shareUrlButton.layer insertSublayer:layer atIndex:0];
  490. }
  491. return _shareUrlButton;
  492. }
  493. -(UIButton *)shareImageButton{
  494. if (!_shareImageButton) {
  495. _shareImageButton=[UIButton buttonWithType:UIButtonTypeCustom];
  496. _shareImageButton.tag=50002;
  497. _shareImageButton.frame=CGRectMake(SCREEN_WIDTH/2, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
  498. CAGradientLayer *layer = [CAGradientLayer layer];
  499. layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
  500. layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
  501. layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFE6735].CGColor,(id)[UIColor YHColorWithHex:0xFF2D23].CGColor, nil];
  502. layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
  503. layer.frame = _shareImageButton.layer.bounds;
  504. [_shareImageButton setTitle:@"分享图片" forState:UIControlStateNormal];
  505. _shareImageButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
  506. [_shareImageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  507. [_shareImageButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
  508. [_shareImageButton.layer insertSublayer:layer atIndex:0];
  509. }
  510. return _shareImageButton;
  511. }
  512. -(UIView *)shareView{
  513. if (!_shareView) {
  514. _shareView=[[[NSBundle mainBundle] loadNibNamed:@"shareView" owner:self options:nil] lastObject];
  515. _shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH,SCREEN_HEIGHT);
  516. [_shareView.cancelButton addTarget:self action:@selector(doTapChange) forControlEvents:UIControlEventTouchUpInside];
  517. WeakSelf(weakSelf)
  518. _shareView.shareButtonTwoBlock=^(void){
  519. __strong typeof(self) strongSelf=weakSelf;
  520. [strongSelf doTapChange];
  521. };
  522. _shareView.shareButtonOneBlock=^(void){
  523. __strong typeof(self) strongSelf=weakSelf;
  524. [strongSelf doTapChange];
  525. };
  526. }
  527. return _shareView;
  528. }
  529. -(UIView *)backShareView{
  530. if (!_backShareView) {
  531. _backShareView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  532. _backShareView.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.3f];
  533. _backShareView.hidden=YES;
  534. UITapGestureRecognizer *r5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange)];
  535. r5.numberOfTapsRequired = 1;
  536. [_backShareView addGestureRecognizer:r5];
  537. }
  538. return _backShareView;
  539. }
  540. @end