dkahgld

ZBTBShareView.m 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // ZBTBShareView.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/4.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBTBShareView.h"
  9. @implementation ZBTBShareView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
  15. [self addSubview:self.backV];
  16. [self.backV mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.width.mas_equalTo(281);
  18. make.height.mas_equalTo(284);
  19. make.centerX.mas_equalTo(self.centerX);
  20. make.centerY.mas_equalTo(self.centerY);
  21. }];
  22. UIImageView *imgV =[[UIImageView alloc]init];
  23. imgV.image=[UIImage imageNamed:@"copy_sure"];
  24. [self.backV addSubview:imgV];
  25. [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.width.height.mas_equalTo(34);
  27. make.top.mas_equalTo(35);
  28. make.left.mas_equalTo(59);
  29. }];
  30. [self.backV addSubview:self.titleLabel];
  31. [self.backV addSubview:self.contentLabel];
  32. [self.backV addSubview:self.okBtn];
  33. [self.backV addSubview:self.tipeBtn];
  34. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.mas_equalTo(35);
  36. make.height.mas_equalTo(34);
  37. make.left.mas_equalTo(imgV.mas_right).offset(5);
  38. make.right.mas_equalTo(-10);
  39. }];
  40. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(24);
  42. make.height.mas_equalTo(52);
  43. make.left.mas_equalTo(20);
  44. make.right.mas_equalTo(-20);
  45. }];
  46. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.mas_equalTo(26);
  48. make.height.mas_equalTo(43);
  49. make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(30);
  50. make.right.mas_equalTo(-25);
  51. }];
  52. [self.tipeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.mas_equalTo(26);
  54. make.height.mas_equalTo(43);
  55. make.top.mas_equalTo(self.okBtn.mas_bottom).offset(5);
  56. make.right.mas_equalTo(-25);
  57. }];
  58. }
  59. return self;
  60. }
  61. -(void)setAlertDic:(NSDictionary *)alertDic
  62. {
  63. _alertDic = alertDic;
  64. self.contentLabel.text=[NSString stringWithFormat:@"淘口令%@已复制你可以用来分享、购买或推广",alertDic[@"tkl"]];
  65. }
  66. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  67. {
  68. [UIView animateWithDuration:0.3 animations:^{
  69. self.hidden=YES;
  70. }];
  71. }
  72. -(UIView *)backV
  73. {
  74. if (!_backV) {
  75. _backV =[[UIView alloc]init];
  76. _backV.backgroundColor=[UIColor whiteColor];
  77. _backV.layer.cornerRadius=9;
  78. _backV.layer.masksToBounds=YES;
  79. }
  80. return _backV;
  81. }
  82. -(UILabel *)titleLabel
  83. {
  84. if (!_titleLabel ) {
  85. _titleLabel=[[UILabel alloc]init];
  86. _titleLabel.textColor=[UIColor YHColorWithHex:0xFF5400];
  87. _titleLabel.font=[UIFont boldSystemFontOfSize:20];
  88. _titleLabel.text=@"淘口令已复制";
  89. }
  90. return _titleLabel;
  91. }
  92. -(UILabel *)contentLabel
  93. {
  94. if (!_contentLabel) {
  95. _contentLabel=[[UILabel alloc]init];
  96. _contentLabel.textColor=[UIColor YHColorWithHex:0x333333];
  97. _contentLabel.font=[UIFont systemFontOfSize:15];
  98. _contentLabel.numberOfLines=2;
  99. _contentLabel.text=@"正在为您创建快手小店Pid, 在快手上填写该Pid才能获得卖货收益"; _contentLabel.textAlignment=NSTextAlignmentCenter;
  100. }
  101. return _contentLabel;
  102. }
  103. -(UIButton *)okBtn
  104. {
  105. if (!_okBtn) {
  106. _okBtn =[[UIButton alloc]init];
  107. _okBtn.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF8300] toColor:[UIColor YHColorWithHex:0xFF5200] withWidth:230];
  108. [_okBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  109. _okBtn.titleLabel.font=[UIFont systemFontOfSize:15];
  110. [_okBtn setTitle:@"打开淘宝购买" forState:UIControlStateNormal];
  111. _okBtn.layer.cornerRadius=4;
  112. _okBtn.layer.masksToBounds=YES;
  113. [_okBtn addTarget:self action:@selector(clickOpentb) forControlEvents:UIControlEventTouchUpInside];
  114. }
  115. return _okBtn;
  116. }
  117. -(UIButton *)tipeBtn
  118. {
  119. if (!_tipeBtn) {
  120. _tipeBtn =[[UIButton alloc]init];
  121. _tipeBtn.backgroundColor=[UIColor clearColor];
  122. [_tipeBtn setTitleColor:[UIColor YHColorWithHex:0x9B9B9B] forState:UIControlStateNormal];
  123. _tipeBtn.titleLabel.font=[UIFont systemFontOfSize:15];
  124. [_tipeBtn setTitle:@"推广到快手" forState:UIControlStateNormal];
  125. _tipeBtn.layer.cornerRadius=4;
  126. _tipeBtn.layer.masksToBounds=YES;
  127. [_tipeBtn addTarget:self action:@selector(clickTipe) forControlEvents:UIControlEventTouchUpInside];
  128. }
  129. return _tipeBtn;
  130. }
  131. -(void)clickOpentb
  132. {
  133. if (![PublicFunction canOpenURL:@"taobao://"]) {
  134. [MBProgressHUD showTip:TBTipe];
  135. return;
  136. }
  137. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  138. pastboard.string=_alertDic[@"tkl"];
  139. // [self jumpKuaishouWithstr:json[@"data"][@"tkl"]];
  140. NSString* taobao = [NSString stringWithFormat:@"taobao://"];
  141. UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero];
  142. [[UIApplication sharedApplication].keyWindow addSubview:webview];
  143. NSURL*url = [NSURL URLWithString:taobao];
  144. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  145. [webview loadRequest:request];
  146. }
  147. #pragma mark---推广到快手
  148. -(void)clickTipe
  149. {
  150. // [PublicFunction jumpKuaishouWithstr:self.alertDic[@"kwai_url_prime"]];
  151. if (![PublicFunction canOpenURL:kwaiUrl]) {
  152. [MBProgressHUD showTip:KWaiTipe];
  153. return;
  154. }
  155. NSString* taobao = [NSString stringWithFormat:kwaiUrl];
  156. UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero];
  157. [[UIApplication sharedApplication].keyWindow addSubview:webview];
  158. NSURL*url = [NSURL URLWithString:taobao];
  159. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  160. [webview loadRequest:request];
  161. self.hidden=YES;
  162. }
  163. @end