口袋优选

KBShareGoodsViewController.m 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. //
  2. // KBShareGoodsViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBShareGoodsViewController.h"
  9. #import "KBShareGoodsTop.h"
  10. #import "KBShareGoodsView.h"
  11. #import "shareView.h"
  12. #import "HYUMShareManager.h"
  13. #import "KBLinkFansController.h"
  14. #import "KBPrivilegeReferralViewController.h"
  15. @interface KBShareGoodsViewController ()<UITextViewDelegate>
  16. @property(nonatomic,strong)UIScrollView *scrollView;
  17. @property(nonatomic,strong)UIView *topView;
  18. @property(nonatomic,strong)KBShareGoodsView *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 KBShareGoodsViewController
  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/shareCommonGoodsNew",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. [KBHttp post:url params:dic success:^(id json) {
  83. // KBShareGoodsViewController *vc=[[KBShareGoodsViewController alloc]init];
  84. KBShareGoodsTempModel *tmpModel=[KBShareGoodsTempModel yy_modelWithJSON:json[@"data"]];
  85. KBShareGoodsModel *model=[KBShareGoodsModel 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. [KBHttp 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. KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController 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. [self presentViewController:alert animated:YES completion:nil];
  258. }else{
  259. [self ShareImg];
  260. }
  261. }else{
  262. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"\n您还没有绑定邀请码哟" preferredStyle:UIAlertControllerStyleAlert];
  263. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  264. KBLinkFansController *linkFans = [[KBLinkFansController alloc] init];
  265. linkFans.linkFansBlock = ^{
  266. [self request];
  267. };
  268. [self.navigationController pushViewController:linkFans animated:YES];
  269. }];
  270. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  271. }];
  272. [alert addAction:defaultAction];
  273. [alert addAction:cancelAction];
  274. [self presentViewController:alert animated:YES completion:nil];
  275. }
  276. }
  277. break;
  278. default:
  279. break;
  280. }
  281. }
  282. -(void)doTapChange{
  283. self.backShareView.hidden=YES;
  284. [UIView animateWithDuration:0.2f animations:^{
  285. self.shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 200+SafeBottomHeight);
  286. } completion:^(BOOL finished) {
  287. }];
  288. }
  289. -(void)copyAction{
  290. if ([self.flag integerValue]==-1) {
  291. [MBProgressHUD showMessage:@"努力生成邀请码中,请稍后尝试"];
  292. return;
  293. }
  294. if (!([self.flag integerValue]==0)) {
  295. if ([self.flag integerValue]==1 &&[self.isSuper integerValue]==0) {
  296. //会员
  297. UILabel *label=(UILabel *)[self.topView viewWithTag:10001];
  298. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享赚佣金" message:[NSString stringWithFormat:@"\n%@",label.text] preferredStyle:UIAlertControllerStyleAlert];
  299. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"去升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  300. KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController alloc]init];
  301. [self.navigationController pushViewController:vc animated:YES];
  302. }];
  303. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  304. [self copyCode];
  305. }];
  306. [alert addAction:cancelAction];
  307. [alert addAction:defaultAction];
  308. [self presentViewController:alert animated:YES completion:nil];
  309. }else{
  310. [self copyCode];
  311. }
  312. }else{
  313. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示"
  314. message:@"\n您还没有绑定邀请码"
  315. preferredStyle:UIAlertControllerStyleAlert];
  316. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"前往绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  317. KBLinkFansController *linkFans = [[KBLinkFansController alloc] init];
  318. linkFans.linkFansBlock = ^{
  319. [self request];
  320. };
  321. [self.navigationController pushViewController:linkFans animated:YES];
  322. }];
  323. UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  324. }];
  325. [alert addAction:defaultAction];
  326. [alert addAction:cancelAction];
  327. [self presentViewController:alert animated:YES completion:nil];
  328. }
  329. }
  330. -(void)rightAction:(id )sender{
  331. KBPrivilegeReferralViewController *vc=[[KBPrivilegeReferralViewController alloc]init];
  332. vc.flag=self.flag;
  333. vc.isSuper=self.isSuper;
  334. [self.navigationController pushViewController:vc animated:YES];
  335. }
  336. #pragma mark 懒加载
  337. -(KBShareGoodsView *)shareGoodsView{
  338. if (!_shareGoodsView) {
  339. _shareGoodsView=[[KBShareGoodsView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
  340. kWeak(self)
  341. _shareGoodsView.imgSuccBlock = ^{
  342. //第一次加载使用
  343. NSLog(@"图片加载完成");
  344. selfWeak.imageView.image=[selfWeak.shareGoodsView changeToImage];
  345. selfWeak.canShareImg=YES;
  346. NSLog(@"图片加载完成2");
  347. };
  348. _shareGoodsView.model=self.model;
  349. }
  350. return _shareGoodsView;
  351. }
  352. -(UIImageView *)imageView{
  353. if (!_imageView) {
  354. _imageView=[[UIImageView alloc]init];
  355. _imageView.backgroundColor=[UIColor whiteColor];
  356. _imageView.layer.shadowColor = [UIColor YHColorWithHex:0xF16767].CGColor;//shadowColor阴影颜色
  357. _imageView.layer.shadowOpacity = 0.2;//阴影透明度,默认0
  358. _imageView.layer.shadowRadius = 10;//阴影半径,默认3
  359. }
  360. return _imageView;
  361. }
  362. -(UIView *)topView{
  363. if (!_topView) {
  364. _topView=[[UIView alloc]init];
  365. _topView.hidden=YES;
  366. _topView.backgroundColor=[UIColor YHColorWithHex:0xFF502E];//[UIColor YHColorWithHex:0xF2F2F2];
  367. UILabel *leftLabel=[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(15), 10, SCREEN_WIDTH-FITSIZE((70)), 0)];
  368. leftLabel.numberOfLines=0;
  369. leftLabel.tag=10001;
  370. leftLabel.font=[UIFont systemFontOfSize:14.0f];
  371. leftLabel.textColor=[UIColor whiteColor];
  372. leftLabel.text=@"";
  373. [leftLabel sizeToFit];
  374. UIButton *rightBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-FITSIZE(70), leftLabel.y, FITSIZE(70), leftLabel.height)];
  375. rightBtn.tag=10002;
  376. [rightBtn setTitle:@"规则 " forState:UIControlStateNormal];
  377. UIImage *image=[UIImage imageNamed:@"share_right_regulation"];
  378. [rightBtn setImage:image forState:UIControlStateNormal];
  379. rightBtn.titleLabel.font=[UIFont systemFontOfSize:13.0f];
  380. [rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width, 0, image.size.width)];
  381. [rightBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -FITSIZE(60))];
  382. [rightBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
  383. [rightBtn setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
  384. UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(rightAction:)];
  385. singleTapGesture.numberOfTapsRequired =1;
  386. singleTapGesture.numberOfTouchesRequired =1;
  387. [_topView addGestureRecognizer:singleTapGesture];
  388. [_topView addSubview:leftLabel];
  389. [_topView addSubview:rightBtn];
  390. }
  391. return _topView;
  392. }
  393. -(UIScrollView *)scrollView{
  394. if (!_scrollView) {
  395. _scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
  396. _scrollView.showsVerticalScrollIndicator = NO;
  397. _scrollView.showsHorizontalScrollIndicator = NO;
  398. _scrollView.contentSize=CGSizeMake(SCREEN_WIDTH, 851-NavBarHeight);
  399. }
  400. return _scrollView;
  401. }
  402. -(UIView *)centerGrayView{
  403. if (!_centerGrayView) {
  404. _centerGrayView=[[UIView alloc]init];
  405. _centerGrayView.backgroundColor=[[UIColor YHColorWithHex:0x999999] colorWithAlphaComponent:0.2f];
  406. }
  407. return _centerGrayView;
  408. }
  409. -(UITextView *)textView{
  410. if (!_textView) {
  411. _textView=[[UITextView alloc]init];
  412. _textView.font=[UIFont systemFontOfSize:16.0f];
  413. // _textView.text=self.model.title;
  414. _textView.text=@"";
  415. _textView.textColor=[UIColor YHColorWithHex:0x444444];
  416. // _textView.layer.borderWidth=1;
  417. // _textView.layer.borderColor=[UIColor lightGrayColor].CGColor;
  418. // _textView.layer.cornerRadius = 3;
  419. // _textView.layer.masksToBounds=YES;
  420. _textView.delegate=self;
  421. }
  422. return _textView;
  423. }
  424. -(UIImageView *)imaginaryLineView{
  425. if (!_imaginaryLineView) {
  426. _imaginaryLineView=[[UIImageView alloc]init];
  427. [_imaginaryLineView setImage:[UIImage imageNamed:@"share_imaginary_line"]];
  428. }
  429. return _imaginaryLineView;
  430. }
  431. -(UILabel *)moneyLabel{
  432. if (!_moneyLabel) {
  433. _moneyLabel=[[UILabel alloc]init];
  434. // _moneyLabel.text=[NSString stringWithFormat:@"【原价】%@元 \n【券后】%@元",self.model.originalPrice,self.model.ticketAfterPrice];
  435. _moneyLabel.text=[NSString stringWithFormat:@"【原价】--元 \n【券后】--元"];
  436. _moneyLabel.textColor=[UIColor YHColorWithHex:0x777777];
  437. _moneyLabel.font=[UIFont systemFontOfSize:14.0f];
  438. _moneyLabel.numberOfLines=2;
  439. [_moneyLabel sizeToFit];
  440. }
  441. return _moneyLabel;
  442. }
  443. -(UILabel *)infoLabel{
  444. if (!_infoLabel) {
  445. _infoLabel=[[UILabel alloc]init];
  446. // _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看",self.model.infoStr];
  447. _infoLabel.text=[NSString stringWithFormat:@"复制这条信息¥-------\n打开【手机淘宝】即可查看"];
  448. _infoLabel.textColor=[UIColor YHColorWithHex:0x878787];
  449. _infoLabel.font=[UIFont systemFontOfSize:14.0f];
  450. _infoLabel.numberOfLines=2;
  451. [_infoLabel sizeToFit];
  452. }
  453. return _infoLabel;
  454. }
  455. -(UIButton *)copyButton{
  456. if (!_copyButton) {
  457. _copyButton=[[UIButton alloc]init];
  458. [_copyButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
  459. _copyButton.titleLabel.font=[UIFont systemFontOfSize:14];
  460. _copyButton.titleLabel.textAlignment=NSTextAlignmentCenter;
  461. _copyButton.layer.borderWidth=1;
  462. _copyButton.layer.cornerRadius=12;
  463. _copyButton.layer.masksToBounds=YES;
  464. _copyButton.layer.borderColor=[UIColor YHColorWithHex:0xFFDB00].CGColor;
  465. [_copyButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
  466. [_copyButton setTitleColor:[UIColor YHColorWithHex:0xED5B5B] forState:UIControlStateNormal];
  467. }
  468. return _copyButton;
  469. }
  470. -(UIButton *)shareUrlButton{
  471. if (!_shareUrlButton) {
  472. _shareUrlButton=[UIButton buttonWithType:UIButtonTypeCustom];
  473. _shareUrlButton.tag=50001;
  474. _shareUrlButton.frame=CGRectMake(0, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
  475. CAGradientLayer *layer = [CAGradientLayer layer];
  476. layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
  477. layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
  478. layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFEC800].CGColor,(id)[UIColor YHColorWithHex:0xFD9D03].CGColor, nil];
  479. layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
  480. layer.frame = _shareUrlButton.layer.bounds;
  481. [_shareUrlButton setTitle:@"复制淘口令" forState:UIControlStateNormal];
  482. _shareUrlButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
  483. [_shareUrlButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  484. [_shareUrlButton addTarget:self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
  485. [_shareUrlButton.layer insertSublayer:layer atIndex:0];
  486. }
  487. return _shareUrlButton;
  488. }
  489. -(UIButton *)shareImageButton{
  490. if (!_shareImageButton) {
  491. _shareImageButton=[UIButton buttonWithType:UIButtonTypeCustom];
  492. _shareImageButton.tag=50002;
  493. _shareImageButton.frame=CGRectMake(SCREEN_WIDTH/2, SCREEN_HEIGHT-50-SafeTopHeight, SCREEN_WIDTH/2, 50+SafeTopHeight);
  494. CAGradientLayer *layer = [CAGradientLayer layer];
  495. layer.startPoint = CGPointMake(0, 0);//(0,0)表示从左上角开始变化。默认值是(0.5,0.0)表示从x轴为中间,y为顶端的开始变化
  496. layer.endPoint = CGPointMake(1, 1);//(1,1)表示到右下角变化结束。默认值是(0.5,1.0) 表示从x轴为中间,y为低端的结束变化
  497. layer.colors = [NSArray arrayWithObjects:(id)[UIColor YHColorWithHex:0xFE6735].CGColor,(id)[UIColor YHColorWithHex:0xFF2D23].CGColor, nil];
  498. layer.locations = @[@0.0f,@1.0f];//渐变颜色的区间分布,locations的数组长度和color一致,这个值一般不用管它,默认是nil,会平均分布
  499. layer.frame = _shareImageButton.layer.bounds;
  500. [_shareImageButton setTitle:@"分享图片" forState:UIControlStateNormal];
  501. _shareImageButton.titleLabel.font=[UIFont systemFontOfSize:14.0f];
  502. [_shareImageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  503. [_shareImageButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
  504. [_shareImageButton.layer insertSublayer:layer atIndex:0];
  505. }
  506. return _shareImageButton;
  507. }
  508. -(UIView *)shareView{
  509. if (!_shareView) {
  510. _shareView=[[[NSBundle mainBundle] loadNibNamed:@"shareView" owner:self options:nil] lastObject];
  511. _shareView.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH,SCREEN_HEIGHT);
  512. [_shareView.cancelButton addTarget:self action:@selector(doTapChange) forControlEvents:UIControlEventTouchUpInside];
  513. WeakSelf(weakSelf)
  514. _shareView.shareButtonTwoBlock=^(void){
  515. __strong typeof(self) strongSelf=weakSelf;
  516. [strongSelf doTapChange];
  517. };
  518. _shareView.shareButtonOneBlock=^(void){
  519. __strong typeof(self) strongSelf=weakSelf;
  520. [strongSelf doTapChange];
  521. };
  522. }
  523. return _shareView;
  524. }
  525. -(UIView *)backShareView{
  526. if (!_backShareView) {
  527. _backShareView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  528. _backShareView.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.3f];
  529. _backShareView.hidden=YES;
  530. UITapGestureRecognizer *r5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange)];
  531. r5.numberOfTapsRequired = 1;
  532. [_backShareView addGestureRecognizer:r5];
  533. }
  534. return _backShareView;
  535. }
  536. @end