editShareView.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. //
  2. // editShareView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/14.
  6. //
  7. #import "editShareView.h"
  8. #import "addShareModel.h"
  9. #import "customShareManageTool.h"
  10. #import "shareBySecretView.h"
  11. //微信分享头文件
  12. #import "WXApi.h"
  13. #import "WXApiObject.h"
  14. //QQ分享头文件
  15. #import <TencentOpenAPI/TencentOAuth.h>
  16. #import <TencentOpenAPI/QQApiInterface.h>
  17. #import <TencentOpenAPI/QQApiInterfaceObject.h>
  18. @interface editShareView ()<UITextFieldDelegate>
  19. @property(nonatomic,strong) UIView *whiteBgView;
  20. @property(nonatomic,strong) UIButton*day7Button;
  21. @property(nonatomic,strong) UIButton*dayForeverButton;
  22. @property(nonatomic,strong) UIButton*addButton;//+
  23. @property(nonatomic,strong) UITextField *shareNumberTF;
  24. @property(nonatomic,strong) UIButton*reduceButton;//-
  25. @property(nonatomic,strong)UILabel *thridTitleLabel;
  26. @property(nonatomic,strong) UIButton*wxShareButton;
  27. @property(nonatomic,strong) UIButton*QQShareButton;
  28. @property(nonatomic,strong) UIButton*momentsShareButton;
  29. @property(nonatomic,strong) UIButton*PrivacyShareButton;
  30. @end
  31. @implementation editShareView
  32. - (id)initWithFrame:(CGRect)frame{
  33. self = [super initWithFrame:frame];
  34. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  35. [self drawAnyView];
  36. return self;
  37. }
  38. - (void)drawAnyView{
  39. //大按钮响应
  40. UIButton *bigRightButton = [[UIButton alloc] init];
  41. bigRightButton.tag = 1;
  42. [bigRightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  43. [self addSubview:bigRightButton];
  44. //bigRightButton.backgroundColor= [UIColor greenColor];
  45. [bigRightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(0);
  47. make.left.mas_equalTo(0);
  48. make.right.mas_equalTo(0);
  49. make.bottom.mas_equalTo(0);
  50. }];
  51. _whiteBgView = [[UIView alloc] init];
  52. _whiteBgView.backgroundColor = [UIColor whiteColor];
  53. [self addSubview:_whiteBgView];
  54. _whiteBgView.layer.cornerRadius = 32;
  55. _whiteBgView.layer.masksToBounds = YES;
  56. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(0);
  58. make.right.mas_equalTo(0);
  59. make.bottom.mas_equalTo(0);
  60. make.height.mas_equalTo(345 + AdaptTabHeight);
  61. }];
  62. UILabel *titleLabel = [[UILabel alloc] init];
  63. titleLabel.font = [UIFont systemFontOfSize:18.0];
  64. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  65. [_whiteBgView addSubview:titleLabel];
  66. NSString *leftText = NSLocalizedString(@"share_title_left",nil);
  67. NSString *rightText = NSLocalizedString(@"share_title_right",nil);
  68. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
  69. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  70. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
  71. UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
  72. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
  73. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  74. titleLabel.attributedText = attrStr;
  75. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(25);
  77. make.right.mas_equalTo(0);
  78. make.top.mas_equalTo(20);
  79. make.height.mas_equalTo(40);
  80. }];
  81. NSString *secondTitleStr = NSLocalizedString(@"share_expiration_date",nil);
  82. UILabel *secondTitleLabel = [[UILabel alloc] init];
  83. secondTitleLabel.font = [UIFont systemFontOfSize:14.0];
  84. secondTitleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
  85. secondTitleLabel.text = secondTitleStr;
  86. [_whiteBgView addSubview:secondTitleLabel];
  87. CGFloat secondWith = [secondTitleStr boundingRectWithSize:CGSizeMake(300, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width;
  88. [secondTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.mas_equalTo(25);
  90. make.width.mas_equalTo(secondWith);
  91. make.top.equalTo(titleLabel.mas_bottom).offset(10);
  92. make.height.mas_equalTo(25);
  93. }];
  94. _day7Button = [[UIButton alloc] init];
  95. [_day7Button setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
  96. [_day7Button setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
  97. [_day7Button setTitle:NSLocalizedString(@"share_expiration_date_7",nil) forState:UIControlStateNormal];
  98. [_day7Button setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  99. [_day7Button addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  100. _day7Button.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  101. _day7Button.tag = 1;
  102. [_whiteBgView addSubview:_day7Button];
  103. _day7Button.selected = YES;
  104. [_day7Button mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.left.equalTo(secondTitleLabel.mas_right).offset(5);
  106. make.width.mas_equalTo(100);
  107. make.top.equalTo(secondTitleLabel.mas_top).offset(0);
  108. make.height.mas_equalTo(25);
  109. }];
  110. _dayForeverButton = [[UIButton alloc] init];
  111. [_dayForeverButton setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
  112. [_dayForeverButton setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
  113. [_dayForeverButton setTitle:NSLocalizedString(@"share_expiration_date_forever",nil) forState:UIControlStateNormal];
  114. [_dayForeverButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  115. [_dayForeverButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  116. _dayForeverButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  117. _dayForeverButton.tag = 2;
  118. [_whiteBgView addSubview:_dayForeverButton];
  119. [_dayForeverButton mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.left.equalTo(_day7Button.mas_right).offset(15);
  121. make.width.mas_equalTo(100);
  122. make.top.equalTo(secondTitleLabel.mas_top).offset(0);
  123. make.height.mas_equalTo(25);
  124. }];
  125. //1.4.1 添加分享次数限制
  126. NSString *thridTitleStr = NSLocalizedString(@"share_number_limit_title",nil);
  127. _thridTitleLabel = [[UILabel alloc] init];
  128. _thridTitleLabel.font = [UIFont systemFontOfSize:14.0];
  129. _thridTitleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
  130. _thridTitleLabel.text = thridTitleStr;
  131. [_whiteBgView addSubview:_thridTitleLabel];
  132. CGFloat thridWith = [thridTitleStr boundingRectWithSize:CGSizeMake(300, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width + 10;
  133. [_thridTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.left.mas_equalTo(25);
  135. make.width.mas_equalTo(thridWith);
  136. make.top.equalTo(secondTitleLabel.mas_bottom).offset(10);
  137. make.height.mas_equalTo(25);
  138. }];
  139. _addButton = [[UIButton alloc] init];
  140. [_addButton setImage:[UIImage imageNamed:@"common_add_d"] forState:UIControlStateDisabled];
  141. [_addButton setImage:[UIImage imageNamed:@"common_add_N"] forState:UIControlStateNormal];
  142. [_addButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  143. _addButton.tag = 3;
  144. [_whiteBgView addSubview:_addButton];
  145. _addButton.enabled = NO;
  146. [_addButton mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.right.mas_equalTo(-20);
  148. make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
  149. make.width.mas_equalTo(30);
  150. make.height.mas_equalTo(30);
  151. }];
  152. _shareNumberTF = [[UITextField alloc] init];
  153. _shareNumberTF.backgroundColor = [UIColor hwColor:@"#F1F2F3" alpha:1.0];
  154. _shareNumberTF.layer.cornerRadius = 8;
  155. _shareNumberTF.textColor = [UIColor blackColor];
  156. _shareNumberTF.textAlignment = NSTextAlignmentCenter;
  157. _shareNumberTF.font = [UIFont systemFontOfSize:14.0];
  158. _shareNumberTF.text = @"80";
  159. _shareNumberTF.delegate = self;
  160. _shareNumberTF.keyboardType = UIKeyboardTypeNumberPad;
  161. [_whiteBgView addSubview:_shareNumberTF];
  162. [_shareNumberTF setTintColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
  163. [_shareNumberTF mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.right.equalTo(_addButton.mas_left).offset(-5);
  165. make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
  166. make.width.mas_equalTo(50);
  167. make.height.mas_equalTo(25);
  168. }];
  169. _reduceButton = [[UIButton alloc] init];
  170. [_reduceButton setImage:[UIImage imageNamed:@"common_reduce_d"] forState:UIControlStateDisabled];
  171. [_reduceButton setImage:[UIImage imageNamed:@"common_reduce_N"] forState:UIControlStateNormal];
  172. [_reduceButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  173. _reduceButton.tag = 4;
  174. [_whiteBgView addSubview:_reduceButton];
  175. [_reduceButton mas_makeConstraints:^(MASConstraintMaker *make) {
  176. make.right.equalTo(_shareNumberTF.mas_left).offset(-5);
  177. make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
  178. make.width.mas_equalTo(30);
  179. make.height.mas_equalTo(30);
  180. }];
  181. NSArray *titleArr = @[NSLocalizedString(@"share_by_weixin",nil),
  182. NSLocalizedString(@"share_by_QQ",nil),
  183. NSLocalizedString(@"share_by_timeLine",nil),
  184. NSLocalizedString(@"share_by_secret",nil)];
  185. NSArray *imageStrArr = @[@"share_weixin_icon",
  186. @"share_qq_icon",
  187. @"share_weixin_Timeline_icon",
  188. @"share_secret_icon"];
  189. CGFloat curButFullWidth = SCREEN_W/4.0;
  190. for (int i = 0; i< titleArr.count; i++) {
  191. UIButton*curButton = [[UIButton alloc] init];
  192. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  193. curButton.tag = 10+i;
  194. [_whiteBgView addSubview:curButton];
  195. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.width.mas_equalTo(curButFullWidth);
  197. make.left.mas_equalTo(i*curButFullWidth);
  198. make.height.mas_equalTo(80);
  199. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  200. }];
  201. if(i== 0){
  202. _wxShareButton = curButton;
  203. }
  204. else if(i== 1){
  205. _QQShareButton = curButton;
  206. }
  207. else if(i== 2){
  208. _momentsShareButton= curButton;
  209. }
  210. else if(i== 3){
  211. _PrivacyShareButton = curButton;
  212. }
  213. UIView *imageBgView = [[UIView alloc] init];
  214. imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
  215. imageBgView.layer.cornerRadius = 8;
  216. imageBgView.layer.masksToBounds = YES;
  217. [curButton addSubview:imageBgView];
  218. imageBgView.userInteractionEnabled = NO;
  219. [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.width.mas_equalTo(64);
  221. make.height.mas_equalTo(52);
  222. make.centerX.equalTo(curButton.mas_centerX);
  223. make.top.mas_equalTo(0);
  224. }];
  225. UIImageView *leftImageV = [[UIImageView alloc] init];
  226. leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
  227. [imageBgView addSubview:leftImageV];
  228. [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  229. make.width.mas_equalTo(25);
  230. make.height.mas_equalTo(25);
  231. make.centerX.equalTo(imageBgView.mas_centerX);
  232. make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
  233. }];
  234. UILabel *leftLabel = [[UILabel alloc] init];
  235. leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
  236. leftLabel.textAlignment = NSTextAlignmentCenter;
  237. leftLabel.font = [UIFont systemFontOfSize:12.0];
  238. leftLabel.text = titleArr[i];
  239. [curButton addSubview:leftLabel];
  240. [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  241. make.width.mas_equalTo(curButFullWidth);
  242. make.height.mas_equalTo(25);
  243. make.centerX.equalTo(curButton.mas_centerX);
  244. //make.top.equalTo(imageBgView.mas_bottom).offset(10);
  245. make.bottom.mas_equalTo(0);
  246. }];
  247. }
  248. UIButton*cancelButton = [[UIButton alloc] init];
  249. [cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  250. [cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  251. [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  252. cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  253. cancelButton.tag = 100;
  254. [_whiteBgView addSubview:cancelButton];
  255. [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  256. make.left.mas_equalTo(0);
  257. make.right.mas_equalTo(0);
  258. make.bottom.mas_equalTo(-AdaptTabHeight);
  259. make.height.mas_equalTo(40);
  260. }];
  261. UIView *lineView = [[UIView alloc] init];
  262. lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
  263. [_whiteBgView addSubview:lineView];
  264. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  265. make.left.mas_equalTo(25);
  266. make.right.mas_equalTo(-25);
  267. make.bottom.equalTo(cancelButton.mas_top).offset(-5);
  268. make.height.mas_equalTo(1);
  269. }];
  270. UILabel *tipLabel = [[UILabel alloc] init];
  271. tipLabel.font = [UIFont systemFontOfSize:12.0];
  272. tipLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
  273. [_whiteBgView addSubview:tipLabel];
  274. NSString *TipText = NSLocalizedString(@"share_file_tip_msg",nil);
  275. tipLabel.text = TipText;
  276. [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  277. make.left.mas_equalTo(25);
  278. make.right.mas_equalTo(-25);
  279. make.bottom.equalTo(lineView.mas_bottom).offset(-30);
  280. make.height.mas_equalTo(15);
  281. }];
  282. }
  283. - (void)didClickButFun:(UIButton*)but
  284. {
  285. NSInteger tag = but.tag;
  286. if(tag != 3 && tag != 4 ){//防止重复点击
  287. but.userInteractionEnabled = NO;
  288. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  289. but.userInteractionEnabled = YES;
  290. });
  291. }
  292. if(tag==1 && !_day7Button.selected){
  293. _day7Button.selected = YES;
  294. _dayForeverButton.selected = NO;
  295. //私密分享
  296. _PrivacyShareButton.hidden = NO;
  297. }
  298. else if(tag==2 && !_dayForeverButton.selected){
  299. _day7Button.selected = NO;
  300. _dayForeverButton.selected = YES;
  301. //私密分享
  302. _PrivacyShareButton.hidden = YES;
  303. }
  304. else if(tag==3){
  305. NSInteger number = _shareNumberTF.text.integerValue;
  306. number ++;
  307. _shareNumberTF.text = [[NSString alloc] initWithFormat:@"%ld",number];
  308. if(number == 80){
  309. _addButton.enabled = NO;
  310. }
  311. _reduceButton.enabled = YES;
  312. }
  313. else if(tag==4){
  314. NSInteger number = _shareNumberTF.text.integerValue;
  315. number --;
  316. _shareNumberTF.text = [[NSString alloc] initWithFormat:@"%ld",number];
  317. if(number == 1){
  318. _reduceButton.enabled = NO;
  319. }
  320. _addButton.enabled = YES;
  321. }
  322. else if(tag == 100 || tag ==1){
  323. [self removeFromSuperview];
  324. }
  325. else{
  326. if(tag == 11){
  327. if(![QQApiInterface isSupportShareToQQ])
  328. {
  329. //[[iToast makeText:@"未安装QQ,请先安装QQ"] show];
  330. [[iToast makeText:NSLocalizedString(@"share_no_qq",nil)] show];
  331. return;
  332. }
  333. }
  334. else if (tag == 10 || tag == 12){
  335. if(![WXApi isWXAppInstalled])
  336. {
  337. //[[iToast makeText:@"未安装微信,请先安装微信"] show];
  338. [[iToast makeText:NSLocalizedString(@"share_no_wx",nil)] show];
  339. return;
  340. }
  341. }
  342. //请求服务器处理分享数据
  343. [self addShareDataBy:tag];
  344. }
  345. }
  346. //添加分享
  347. - (void)addShareDataBy:(NSInteger)tag
  348. {
  349. NSString *curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  350. NSString *platformType = [[NSString alloc] initWithFormat:@"%ld", tag - 9];
  351. //_shareFileType
  352. NSInteger expirationDay = _day7Button.selected ? 7 : 0;
  353. NSMutableArray * boxShareFileDTOList = [NSMutableArray new];
  354. for (NASFilePicDataArrModel*dataModel in _didSelectListArr) {
  355. NSMutableDictionary *modelDict = [NSMutableDictionary new];
  356. if(dataModel.name){
  357. [modelDict setValue:dataModel.name forKey:@"fileName"];
  358. NSArray * nameArr = [dataModel.name componentsSeparatedByString:@"."];
  359. if(nameArr.count >= 2){
  360. NSString*fileSuffix = nameArr.lastObject;
  361. if(fileSuffix && fileSuffix.length > 0){
  362. [modelDict setValue:fileSuffix forKey:@"fileSuffix"];
  363. }
  364. }
  365. }
  366. if(dataModel.size >= 0){
  367. [modelDict setValue:[NSNumber numberWithLong:dataModel.size] forKey:@"fileSize"];
  368. }
  369. if(dataModel.time){
  370. [modelDict setValue:dataModel.time forKey:@"fileTime"];
  371. }
  372. if(dataModel.path){
  373. NSString *filePath = dataModel.path;
  374. NSString *urlStr = ksharedAppDelegate.NASShareFileService;
  375. NSString *headUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
  376. NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
  377. if(headUrl){
  378. [modelDict setValue:headUrl forKey:@"headUrl"];
  379. }
  380. if(headUrl){
  381. [modelDict setValue:fileUrl forKey:@"fileUrl"];
  382. }
  383. }
  384. [boxShareFileDTOList addObject:modelDict];
  385. }
  386. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  387. if(!curSn){
  388. return;
  389. }
  390. [paraDict setValue:curSn forKey:@"sn"];
  391. [paraDict setValue:platformType forKey:@"platformType"];
  392. if(_shareFileType){
  393. [paraDict setValue:_shareFileType forKey:@"fileType"];
  394. }
  395. [paraDict setValue:[NSNumber numberWithInteger:expirationDay] forKey:@"expirationDay"];
  396. [paraDict setValue:boxShareFileDTOList forKey:@"boxShareFileDTOList"];
  397. //1.4.1 新增的字段
  398. if(_shareNumberTF.text)
  399. {
  400. [paraDict setValue:_shareNumberTF.text forKey:@"shareNumber"];
  401. }
  402. KWeakSelf
  403. //[ showNewIndicatorWithCanBack:NO canTouch:NO];
  404. [[netWorkManager shareInstance] CommonPostCallBackCode:addShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  405. addShareModel *model = [[addShareModel alloc] initWithDictionary:responseObject error:nil];
  406. if(model && model.code == 0){
  407. [weakSelf gotoShareFunWith:tag with:model];
  408. }
  409. else{
  410. [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];//
  411. }
  412. } failure:^(NSError * _Nonnull error) {
  413. [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];
  414. }];
  415. //文件类型 1=应用 2=图片 3=视频 4=音频 5=文档 6=文件
  416. //time 7,forever
  417. //渠道 WX,QQ, Moment private
  418. //share
  419. NSString * shareTypeStr = @"Image";
  420. if([_shareFileType isEqualToString:@"2"]){
  421. shareTypeStr = @"Image";
  422. }
  423. else if ([_shareFileType isEqualToString:@"3"]){
  424. shareTypeStr = @"Video";
  425. }
  426. else if ([_shareFileType isEqualToString:@"4"]){
  427. shareTypeStr = @"Music";
  428. }
  429. else if ([_shareFileType isEqualToString:@"5"]){
  430. shareTypeStr = @"File";
  431. }
  432. if(_isLastFileType){
  433. shareTypeStr = @"Recently";
  434. }
  435. NSString * shareTimeStr = expirationDay == 7 ? @"7" : @"forever";
  436. //type1 朋友圈 2 微信好友 3 QQ
  437. NSString* shareToType = @"WX";
  438. if(tag == 10){
  439. shareToType = @"WX";
  440. }
  441. else if(tag == 11){
  442. shareToType = @"QQ";
  443. }
  444. else if(tag == 12){
  445. shareToType = @"Moments";
  446. }
  447. else if(tag == 13){
  448. shareToType = @"private";
  449. }
  450. NSString *eventValue = [[NSString alloc] initWithFormat:@"%@_%@_%@_share",shareTypeStr,shareTimeStr,shareToType];
  451. //数据埋点
  452. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:eventValue];
  453. }
  454. - (void)gotoShareFunWith:(NSInteger)tag with:(addShareModel*)model
  455. {
  456. //type1 朋友圈 2 微信好友 3 QQ
  457. NSInteger shareType = 1;
  458. if(tag == 10){
  459. shareType =2;
  460. }
  461. else if(tag == 11){
  462. shareType = 3;
  463. }
  464. else if(tag == 12){
  465. shareType = 1;
  466. }
  467. else if(tag == 13){
  468. [self showSecretShareViewFunwith:model];
  469. [self removeFromSuperview];
  470. return;
  471. }
  472. [self removeFromSuperview];
  473. NSString *serUrl = shareService;
  474. NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,model.data.token];
  475. //NSString *shareTitle = [[NSString alloc] initWithFormat:@"Private-X%@",NSLocalizedString(@"common_edit_share",nil)];
  476. NSString *shareTitle = @"Private-X分享";
  477. NSString *firstname = nil;
  478. if (_didSelectListArr.count > 0) {
  479. NASFilePicDataArrModel*dataModel = _didSelectListArr[0];
  480. firstname = dataModel.name;
  481. }
  482. //我正在使用Private-X魔盒,给大家分享 文件名称文件名称.jpg 等 2 个文件 ,快来看看吧~
  483. NSString *shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@等%ld个文件 ,快来看看吧~",firstname,_didSelectListArr.count];
  484. if(_didSelectListArr.count == 1){
  485. shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@ ,快来看看吧~",firstname];
  486. }
  487. [[customShareManageTool sharedManager] shareType:shareType withShareUrl:shareUrl withShareTitle:shareTitle withShareContent:shareContent];
  488. }
  489. - (void)showSecretShareViewFunwith:(addShareModel*)model
  490. {
  491. shareBySecretView *secretView = [[shareBySecretView alloc] init];
  492. secretView.addShareMod = model;
  493. secretView.didSelectListArr = _didSelectListArr;
  494. secretView.isPortraitType = _isPortraitType;
  495. UIView * curSuperView = [self superview];
  496. if(curSuperView){//修复横竖视频播放隐私分享出问题
  497. [curSuperView addSubview:secretView];
  498. }
  499. else{
  500. [ksharedAppDelegate.window addSubview:secretView];
  501. }
  502. _secretShareView = secretView;
  503. [secretView mas_makeConstraints:^(MASConstraintMaker *make) {
  504. make.left.mas_equalTo(0);
  505. make.right.mas_equalTo(0);
  506. make.top.mas_equalTo(0);
  507. make.bottom.mas_equalTo(0);
  508. }];
  509. }
  510. #pragma mark 分享次数编辑完成
  511. - (void)textFieldDidEndEditing:(UITextField *)textField
  512. {
  513. NSInteger shareNum = textField.text.integerValue;
  514. if(shareNum > 80 || shareNum <= 0){
  515. textField.text = @"80";
  516. [[iToast makeText:NSLocalizedString(@"share_number_limit_error_tip",nil)] show];
  517. }
  518. [self setAddOrReduceButtonFun];
  519. }
  520. #pragma mark 设置加减按钮状态
  521. - (void)setAddOrReduceButtonFun
  522. {
  523. NSInteger number = _shareNumberTF.text.integerValue;
  524. if(number == 1){
  525. _reduceButton.enabled = NO;
  526. _addButton.enabled = YES;
  527. }
  528. else if (number == 80){
  529. _reduceButton.enabled = YES;
  530. _addButton.enabled = NO;
  531. }
  532. else{
  533. _reduceButton.enabled = YES;
  534. _addButton.enabled = YES;
  535. }
  536. }
  537. - (void)setIsPortraitType:(BOOL)isPortraitType
  538. {
  539. _isPortraitType = isPortraitType;
  540. CGFloat curButFullWidth = 0.0;
  541. if(_isPortraitType){
  542. _whiteBgView.layer.cornerRadius = 32;
  543. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  544. make.left.mas_equalTo(0);
  545. make.right.mas_equalTo(0);
  546. make.bottom.mas_equalTo(0);
  547. make.height.mas_equalTo(345 + AdaptTabHeight);
  548. }];
  549. CGFloat width = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
  550. curButFullWidth = width/4.0;
  551. }
  552. else{
  553. CGFloat height = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
  554. _whiteBgView.layer.cornerRadius = 0;
  555. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  556. make.width.mas_equalTo(400);
  557. make.right.mas_equalTo(0);
  558. make.bottom.mas_equalTo(0);
  559. //make.height.mas_equalTo(345 + AdaptTabHeight);
  560. make.height.mas_equalTo(height);
  561. }];
  562. curButFullWidth = 400.0/4.0;
  563. }
  564. //四个分享按钮
  565. [_wxShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  566. make.width.mas_equalTo(curButFullWidth);
  567. make.left.mas_equalTo(0*curButFullWidth);
  568. make.height.mas_equalTo(80);
  569. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  570. }];
  571. [_QQShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  572. make.width.mas_equalTo(curButFullWidth);
  573. make.left.mas_equalTo(1*curButFullWidth);
  574. make.height.mas_equalTo(80);
  575. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  576. }];
  577. [_momentsShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  578. make.width.mas_equalTo(curButFullWidth);
  579. make.left.mas_equalTo(2*curButFullWidth);
  580. make.height.mas_equalTo(80);
  581. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  582. }];
  583. [_PrivacyShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  584. make.width.mas_equalTo(curButFullWidth);
  585. make.left.mas_equalTo(3*curButFullWidth);
  586. make.height.mas_equalTo(80);
  587. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  588. }];
  589. }
  590. @end