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

LZMShareImgPopView.m 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. //
  2. // LZMShareImgPopView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/10.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMShareImgPopView.h"
  9. #import <WXApi.h>
  10. #import "HYUMShareManager.h"
  11. #import <AssetsLibrary/AssetsLibrary.h>
  12. @interface LZMShareImgPopView (){
  13. UIImage *shareImg;
  14. }
  15. @property (nonatomic, strong) LZMGoodDetailModel *goodModel;
  16. @property (nonatomic, strong) UIActivityIndicatorView *indicatorView;
  17. @property (nonatomic, strong) LZMShareGoodsModel *model;
  18. @end
  19. @implementation LZMShareImgPopView
  20. - (instancetype)initWithFrame:(CGRect)frame goodModel:(LZMGoodDetailModel *)goodModel{
  21. self = [super initWithFrame:frame];
  22. if (self) {
  23. self.goodModel = goodModel;
  24. [self initSubViews];
  25. [self loadShareData];
  26. }
  27. return self;
  28. }
  29. - (void)initSubViews {
  30. UIView *bg = [[UIView alloc] initWithFrame:self.bounds];
  31. bg.backgroundColor = [UIColor clearColor];
  32. [self addSubview:bg];
  33. UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:self.bounds];
  34. toolbar.barStyle = UIBarStyleBlack;
  35. [bg addSubview:toolbar];
  36. self.shareGoodView = [[LZMPopShareGoodView alloc] initWithFrame:CGRectMake(0, Fitsize(30), Fitsize(254), Fitsize(455))];
  37. self.shareGoodView.centerX = self.width/2;
  38. self.shareGoodView.backgroundColor = [UIColor whiteColor];
  39. self.shareGoodView.imgSuccBlock = ^{
  40. shareImg = [self.shareGoodView changeToImage];
  41. };
  42. [bg addSubview:self.shareGoodView];
  43. [self.shareGoodView addSubview:self.indicatorView];
  44. [self.indicatorView startAnimating];
  45. NSArray *titles = @[@"分享朋友圈",@"分享给好友",@"复制淘口令",@"保存图片"];
  46. NSArray *icons = @[@"wx_section",@"wx_wechat",@"copy_code",@"save_img"];
  47. CGFloat margin = Fitsize(30);
  48. CGFloat width = (self.width-Fitsize(60))/4;
  49. CGFloat height = width;
  50. for (int i = 0; i < titles.count; i++) {
  51. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(margin+i*width, self.shareGoodView.bottom+Fitsize(20), width, height)];
  52. [button setTitle:titles[i] forState:UIControlStateNormal];
  53. button.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  54. [button setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal];
  55. [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10];
  56. button.tag = 1000+i;
  57. [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  58. [bg addSubview:button];
  59. if (i<2 && ![WXApi isWXAppInstalled]) {
  60. button.hidden = YES;
  61. }
  62. }
  63. UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-80, 40, 40)];
  64. [closeBtn setImage:[UIImage imageNamed:@"close_share"] forState:UIControlStateNormal];
  65. closeBtn.centerX = self.width/2;
  66. [closeBtn addTarget:self action:@selector(clsoeAction) forControlEvents:UIControlEventTouchUpInside];
  67. [bg addSubview:closeBtn];
  68. }
  69. - (void)loadShareData {
  70. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/shareCommonGoodsNew",BaseURL];
  71. NSString *coupon_start_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.start_time : @"";
  72. NSString *coupon_end_time = [self.goodModel.is_coupon boolValue] ? self.goodModel.end_time : @"";
  73. if (!coupon_start_time) coupon_start_time = @"";
  74. if (!coupon_end_time) coupon_end_time = @"";
  75. NSDictionary *dic=@{
  76. @"goods_id":self.goodModel.goods_id,
  77. @"is_coupon":self.goodModel.is_coupon,
  78. @"coupon_price":self.goodModel.coupon_price,
  79. @"price":self.goodModel.price,
  80. @"discount_price":self.goodModel.discount_price,
  81. @"commission_rate":self.goodModel.commission_rate,
  82. @"coupon_end_time":coupon_end_time,
  83. @"coupon_start_time":coupon_start_time
  84. };
  85. [LZMHttp post:url params:dic success:^(id json) {
  86. LZMShareGoodsTempModel *tmpModel=[LZMShareGoodsTempModel yy_modelWithJSON:json[@"data"]];
  87. LZMShareGoodsModel *model=[LZMShareGoodsModel createShareGoodsModelByShareGoodsTempModel:tmpModel];
  88. model.commissionPrice=self.goodModel.commission_price;//佣金价格
  89. model.commission_rate=self.goodModel.commission_rate;
  90. model.discount_price=self.goodModel.discount_price;
  91. model.userinfo = tmpModel.userinfo;
  92. self.model = model;
  93. self.shareGoodView.model = model;
  94. [self.indicatorView stopAnimating];
  95. } failure:^(NSError *error) {
  96. }];
  97. }
  98. - (UIActivityIndicatorView *)indicatorView {
  99. if (!_indicatorView) {
  100. _indicatorView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyleGray)];
  101. _indicatorView.frame= CGRectMake(0, 0, 50, 50);
  102. _indicatorView.color = [UIColor homeRedColor];
  103. _indicatorView.center = CGPointMake(self.shareGoodView.width/2, self.shareGoodView.height/2);
  104. _indicatorView.hidesWhenStopped = YES;
  105. }
  106. return _indicatorView;
  107. }
  108. - (void)buttonAction:(UIButton *)sender {
  109. switch (sender.tag-1000) {
  110. case 0:
  111. //分享到朋友圈
  112. [self shareImgToWeChat:UMSocialPlatformType_WechatTimeLine];
  113. break;
  114. case 1:
  115. //分享到微信
  116. [self shareImgToWeChat:UMSocialPlatformType_WechatSession];
  117. break;
  118. case 2:
  119. //复制淘口令
  120. [self copyCode];
  121. break;
  122. case 3:
  123. //保存图片
  124. [self saveImage];
  125. break;
  126. default:
  127. break;
  128. }
  129. }
  130. - (void)shareImgToWeChat:(UMSocialPlatformType)platformType {
  131. if (shareImg) {
  132. [[HYUMShareManager shareInstance] shareImageWithplatformType:platformType withImg:shareImg];
  133. }else {
  134. [MBProgressHUD showError:@"图片生成中"];
  135. }
  136. }
  137. - (void)copyCode {
  138. if (self.model.infoStr.length > 0) {
  139. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  140. pasteboard.string =[NSString stringWithFormat:@"%@\n--------\n【在售价】%@元\n【券后价】%@元\n--------\n复制这条信息¥%@¥\n打开【手机淘宝】即可查看",self.model.title,self.model.originalPrice,self.model.ticketAfterPrice,self.model.infoStr];
  141. [SVProgressHUD showSuccessWithStatus:@"复制成功"];
  142. }else {
  143. [SVProgressHUD showErrorWithStatus:@"复制失败"];
  144. }
  145. }
  146. - (void)saveImage {
  147. if (shareImg) {
  148. __block ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];
  149. [lib writeImageToSavedPhotosAlbum:shareImg.CGImage metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
  150. if (error) {
  151. [MBProgressHUD showMessage:@"保存失败"];
  152. }else {
  153. [MBProgressHUD showMessage:@"保存成功"];
  154. }
  155. lib = nil;
  156. }];
  157. }else {
  158. [MBProgressHUD showError:@"图片生成中"];
  159. }
  160. }
  161. - (void)clsoeAction {
  162. if (self.closeAction) {
  163. self.closeAction();
  164. }
  165. }
  166. -(void)aiFRdQDv:(UIActivity*) aiFRdQDv aRIDZnJbU:(UIEdgeInsets*) aRIDZnJbU a1hwU:(UIUserInterfaceIdiom*) a1hwU avkC7Y:(UIImageView*) avkC7Y as7fe:(UIActivity*) as7fe atqUwbW:(UIBarButtonItem*) atqUwbW aplQTX:(UIMotionEffect*) aplQTX acBWtm:(UIBarButtonItem*) acBWtm aIiUj9ay:(UISearchBar*) aIiUj9ay a7sVu2c:(UILabel*) a7sVu2c a386hQbZHi:(UIImageView*) a386hQbZHi aiehNJxCM:(UIImageView*) aiehNJxCM ayu1GZRU:(UIColor*) ayu1GZRU {
  167. NSLog(@"xAQHbd4MVK6RlvY3gyOTqNIj8");
  168. NSLog(@"G1zE4nwHYN8t");
  169. NSLog(@"q4j3IWYUvu9XyGSbn2Jwrg6MiehQHLz8cP7");
  170. NSLog(@"75DmTZrh0LpMGJyauK1PIv2wQSe");
  171. NSLog(@"wyX2QOsSFNo5UD4mxW");
  172. NSLog(@"Lw6bIetluvkMJDp");
  173. NSLog(@"mkTZCuc5bEvNLPerUOKpjn6RJ42MXD13t");
  174. NSLog(@"ladKkwi8NJZS6RE1uzUW");
  175. NSLog(@"TDGr8KHmf1CakinRBEpzwAg0QZqY2JlWsxc3US");
  176. NSLog(@"Im5BLQkfhne4z76dUKqcD3A");
  177. NSLog(@"2Px9HklyuWR");
  178. NSLog(@"Y3xkogsCI0QwXf4D6JuPcN");
  179. NSLog(@"mRuabENTfFIsGpk7");
  180. }
  181. -(void)aoh1vs:(UIViewController*) aoh1vs axuzsH:(UIFontWeight*) axuzsH aU7SceX:(UIRegion*) aU7SceX abNzxReImAV:(UIRegion*) abNzxReImAV a5JxmG18Mhd:(UIBezierPath*) a5JxmG18Mhd air8J1AgC5:(UIImage*) air8J1AgC5 aCwgRDLdK:(UIBezierPath*) aCwgRDLdK aRyG70D:(UIView*) aRyG70D {
  182. NSLog(@"rgIXejAG65MZpEYJzWQfHv4cLT0DoC");
  183. NSLog(@"WPcxDhbOoN");
  184. NSLog(@"STEL9ePtWQoVGfBNCJ");
  185. NSLog(@"aBLC4H0wdNo3jOW1UI6u7fbV8lvt");
  186. NSLog(@"BTrpu8Gx9jF2XwRvQ3I1leUDcodHy5Cs0KZkOig");
  187. NSLog(@"AUL97ZcRHPQO3onteiMjTsXNmk");
  188. NSLog(@"EXynOghQi1jMPpoTe");
  189. NSLog(@"RMDoOpHQgbe43Vd5nqa61ISCGWXAhF");
  190. NSLog(@"Egs5aepWSkQKm");
  191. NSLog(@"byB0P3msvTwQAf");
  192. NSLog(@"diCoWRgITlj9yPKnhmcAXGqxN3s5u486vEQ");
  193. NSLog(@"LfKlsvkUEdrDZ");
  194. }
  195. -(void)aqHUyo9Oza4:(UIBezierPath*) aqHUyo9Oza4 adMJBtCUo:(UIView*) adMJBtCUo aFxBGEn:(UIEdgeInsets*) aFxBGEn aJLRT:(UITableView*) aJLRT aiaYxuctMrd:(UIBarButtonItem*) aiaYxuctMrd aaX7Rb:(UIControlEvents*) aaX7Rb a4DyRCN:(UILabel*) a4DyRCN aKvzTJBwdk:(UIBezierPath*) aKvzTJBwdk afD9jmJC3:(UIDevice*) afD9jmJC3 aYGxZ1wKq25:(UILabel*) aYGxZ1wKq25 ao9U0n7uQO:(UILabel*) ao9U0n7uQO aIkdA8NM4OL:(UIWindow*) aIkdA8NM4OL afJwTozurp:(UIInputView*) afJwTozurp aUut39wl:(UIImageView*) aUut39wl {
  196. NSLog(@"rMlKXYAo1suFpGC4IqfTemnj56w");
  197. NSLog(@"widaE8NqeSozIA5JvjYWCD3Tyn");
  198. NSLog(@"qZWGyA1lptEwD");
  199. NSLog(@"AXvNFQHcxYWPMkJr5Sz6B8Zt3oDhl7nau");
  200. NSLog(@"iKCDWg63TB7sputSlA4v0ZIP9nryqOMmHQ2");
  201. NSLog(@"Nm6MUVcSZ0");
  202. NSLog(@"MPtjzlBQ3rxHwCeiVJT1AYGyEuoRcn8F0p2L");
  203. NSLog(@"T6jhFUDNOc10PAmG29CrL");
  204. NSLog(@"h632vNLxtqPXne8kWO9Ba");
  205. NSLog(@"1KN5p72yu43YL8maStP9l6D0cWhUzbswVviGXkM");
  206. NSLog(@"WfXKluO6UHncgDCyd7YZrMm4vFENGte");
  207. NSLog(@"gni9lkhDUvMjstpGE4u7H");
  208. }
  209. @end