editShareView.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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. if(_didClickCloseFun){
  324. _didClickCloseFun();
  325. }
  326. [self removeFromSuperview];
  327. }
  328. else{
  329. if(tag == 11){
  330. if(![QQApiInterface isSupportShareToQQ])
  331. {
  332. //[[iToast makeText:@"未安装QQ,请先安装QQ"] show];
  333. [[iToast makeText:NSLocalizedString(@"share_no_qq",nil)] show];
  334. return;
  335. }
  336. }
  337. else if (tag == 10 || tag == 12){
  338. if(![WXApi isWXAppInstalled])
  339. {
  340. //[[iToast makeText:@"未安装微信,请先安装微信"] show];
  341. [[iToast makeText:NSLocalizedString(@"share_no_wx",nil)] show];
  342. return;
  343. }
  344. }
  345. //请求服务器处理分享数据
  346. [self addShareDataBy:tag];
  347. }
  348. }
  349. //添加分享
  350. - (void)addShareDataBy:(NSInteger)tag
  351. {
  352. NSString *curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  353. NSString *platformType = [[NSString alloc] initWithFormat:@"%ld", tag - 9];
  354. //_shareFileType
  355. NSInteger expirationDay = _day7Button.selected ? 7 : 0;
  356. NSMutableArray * boxShareFileDTOList = [NSMutableArray new];
  357. for (NASFilePicDataArrModel*dataModel in _didSelectListArr) {
  358. NSMutableDictionary *modelDict = [NSMutableDictionary new];
  359. if(dataModel.name){
  360. [modelDict setValue:dataModel.name forKey:@"fileName"];
  361. NSArray * nameArr = [dataModel.name componentsSeparatedByString:@"."];
  362. if(nameArr.count >= 2){
  363. NSString*fileSuffix = nameArr.lastObject;
  364. if(fileSuffix && fileSuffix.length > 0){
  365. [modelDict setValue:fileSuffix forKey:@"fileSuffix"];
  366. }
  367. }
  368. }
  369. if(dataModel.size >= 0){
  370. [modelDict setValue:[NSNumber numberWithLong:dataModel.size] forKey:@"fileSize"];
  371. }
  372. if(dataModel.time){
  373. [modelDict setValue:dataModel.time forKey:@"fileTime"];
  374. }
  375. if(dataModel.path){
  376. NSString *filePath = dataModel.path;
  377. NSString *urlStr = ksharedAppDelegate.NASShareFileService;
  378. NSString *headUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
  379. NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
  380. if(headUrl){
  381. [modelDict setValue:headUrl forKey:@"headUrl"];
  382. }
  383. if(headUrl){
  384. [modelDict setValue:fileUrl forKey:@"fileUrl"];
  385. }
  386. }
  387. [boxShareFileDTOList addObject:modelDict];
  388. }
  389. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  390. if(!curSn){
  391. return;
  392. }
  393. [paraDict setValue:curSn forKey:@"sn"];
  394. [paraDict setValue:platformType forKey:@"platformType"];
  395. if(_shareFileType){
  396. [paraDict setValue:_shareFileType forKey:@"fileType"];
  397. }
  398. [paraDict setValue:[NSNumber numberWithInteger:expirationDay] forKey:@"expirationDay"];
  399. [paraDict setValue:boxShareFileDTOList forKey:@"boxShareFileDTOList"];
  400. //1.4.1 新增的字段
  401. if(_shareNumberTF.text)
  402. {
  403. [paraDict setValue:_shareNumberTF.text forKey:@"shareNumber"];
  404. }
  405. KWeakSelf
  406. //[ showNewIndicatorWithCanBack:NO canTouch:NO];
  407. [[netWorkManager shareInstance] CommonPostCallBackCode:addShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  408. addShareModel *model = [[addShareModel alloc] initWithDictionary:responseObject error:nil];
  409. if(model && model.code == 0){
  410. [weakSelf gotoShareFunWith:tag with:model];
  411. }
  412. else{
  413. [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];//
  414. }
  415. } failure:^(NSError * _Nonnull error) {
  416. [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];
  417. }];
  418. //文件类型 1=应用 2=图片 3=视频 4=音频 5=文档 6=文件
  419. //time 7,forever
  420. //渠道 WX,QQ, Moment private
  421. //share
  422. //处理数据埋点
  423. NSString * firstFileType = nil;
  424. BOOL isSameFileType = YES;
  425. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  426. if(!firstFileType){
  427. firstFileType = dataModel.type;
  428. }
  429. else if(![firstFileType isEqualToString:dataModel.type]){
  430. isSameFileType = NO;
  431. break;
  432. }
  433. }
  434. NSString * shareTypeStr = @"Image";
  435. if(!isSameFileType){
  436. shareTypeStr = @"File";
  437. }
  438. else if([firstFileType containsString:@"jpg"]){
  439. shareTypeStr = @"Image";
  440. }
  441. else if([firstFileType isEqualToString:@"video"]){
  442. shareTypeStr = @"Video";
  443. }
  444. else if([firstFileType isEqualToString:@"audio"]){
  445. shareTypeStr = @"Music";
  446. }
  447. else{
  448. shareTypeStr = @"File";
  449. }
  450. if(_isLastFileType){
  451. shareTypeStr = @"Recently";
  452. }
  453. NSString * shareTimeStr = expirationDay == 7 ? @"7" : @"forever";
  454. //type1 朋友圈 2 微信好友 3 QQ
  455. NSString* shareToType = @"WX";
  456. if(tag == 10){
  457. shareToType = @"WX";
  458. }
  459. else if(tag == 11){
  460. shareToType = @"QQ";
  461. }
  462. else if(tag == 12){
  463. shareToType = @"Moments";
  464. }
  465. else if(tag == 13){
  466. shareToType = @"private";
  467. }
  468. NSString *eventValue = [[NSString alloc] initWithFormat:@"%@_%@_%@_share",shareTypeStr,shareTimeStr,shareToType];
  469. //数据埋点
  470. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:eventValue];
  471. }
  472. - (void)gotoShareFunWith:(NSInteger)tag with:(addShareModel*)model
  473. {
  474. //type1 朋友圈 2 微信好友 3 QQ
  475. NSInteger shareType = 1;
  476. if(tag == 10){
  477. shareType =2;
  478. }
  479. else if(tag == 11){
  480. shareType = 3;
  481. }
  482. else if(tag == 12){
  483. shareType = 1;
  484. }
  485. else if(tag == 13){
  486. [self showSecretShareViewFunwith:model];
  487. [self removeFromSuperview];
  488. return;
  489. }
  490. [self removeFromSuperview];
  491. NSString *serUrl = shareService;
  492. NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,model.data.token];
  493. //NSString *shareTitle = [[NSString alloc] initWithFormat:@"Private-X%@",NSLocalizedString(@"common_edit_share",nil)];
  494. NSString *shareTitle = @"Private-X分享";
  495. NSString *firstname = nil;
  496. if (_didSelectListArr.count > 0) {
  497. NASFilePicDataArrModel*dataModel = _didSelectListArr[0];
  498. firstname = dataModel.name;
  499. }
  500. //我正在使用Private-X魔盒,给大家分享 文件名称文件名称.jpg 等 2 个文件 ,快来看看吧~
  501. NSString *shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@等%ld个文件 ,快来看看吧~",firstname,_didSelectListArr.count];
  502. if(_didSelectListArr.count == 1){
  503. shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@ ,快来看看吧~",firstname];
  504. }
  505. [[customShareManageTool sharedManager] shareType:shareType withShareUrl:shareUrl withShareTitle:shareTitle withShareContent:shareContent];
  506. }
  507. - (void)showSecretShareViewFunwith:(addShareModel*)model
  508. {
  509. shareBySecretView *secretView = [[shareBySecretView alloc] init];
  510. secretView.addShareMod = model;
  511. secretView.didSelectListArr = _didSelectListArr;
  512. secretView.isPortraitType = _isPortraitType;
  513. UIView * curSuperView = [self superview];
  514. if(curSuperView){//修复横竖视频播放隐私分享出问题
  515. [curSuperView addSubview:secretView];
  516. }
  517. else{
  518. [ksharedAppDelegate.window addSubview:secretView];
  519. }
  520. _secretShareView = secretView;
  521. [secretView mas_makeConstraints:^(MASConstraintMaker *make) {
  522. make.left.mas_equalTo(0);
  523. make.right.mas_equalTo(0);
  524. make.top.mas_equalTo(0);
  525. make.bottom.mas_equalTo(0);
  526. }];
  527. KWeakSelf
  528. secretView.didClickCloseFun = ^{
  529. if(weakSelf.didClickCloseFun){
  530. weakSelf.didClickCloseFun();
  531. }
  532. };
  533. }
  534. #pragma mark 分享次数编辑完成
  535. - (void)textFieldDidEndEditing:(UITextField *)textField
  536. {
  537. NSInteger shareNum = textField.text.integerValue;
  538. if(shareNum > 80 || shareNum <= 0){
  539. textField.text = @"80";
  540. [[iToast makeText:NSLocalizedString(@"share_number_limit_error_tip",nil)] show];
  541. }
  542. [self setAddOrReduceButtonFun];
  543. }
  544. #pragma mark 设置加减按钮状态
  545. - (void)setAddOrReduceButtonFun
  546. {
  547. NSInteger number = _shareNumberTF.text.integerValue;
  548. if(number == 1){
  549. _reduceButton.enabled = NO;
  550. _addButton.enabled = YES;
  551. }
  552. else if (number == 80){
  553. _reduceButton.enabled = YES;
  554. _addButton.enabled = NO;
  555. }
  556. else{
  557. _reduceButton.enabled = YES;
  558. _addButton.enabled = YES;
  559. }
  560. }
  561. - (void)setIsPortraitType:(BOOL)isPortraitType
  562. {
  563. _isPortraitType = isPortraitType;
  564. CGFloat curButFullWidth = 0.0;
  565. if(_isPortraitType){
  566. _whiteBgView.layer.cornerRadius = 32;
  567. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  568. make.left.mas_equalTo(0);
  569. make.right.mas_equalTo(0);
  570. make.bottom.mas_equalTo(0);
  571. make.height.mas_equalTo(345 + AdaptTabHeight);
  572. }];
  573. CGFloat width = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
  574. curButFullWidth = width/4.0;
  575. }
  576. else{
  577. CGFloat height = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
  578. _whiteBgView.layer.cornerRadius = 0;
  579. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  580. make.width.mas_equalTo(400);
  581. make.right.mas_equalTo(0);
  582. make.bottom.mas_equalTo(0);
  583. //make.height.mas_equalTo(345 + AdaptTabHeight);
  584. make.height.mas_equalTo(height);
  585. }];
  586. curButFullWidth = 400.0/4.0;
  587. }
  588. //四个分享按钮
  589. [_wxShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  590. make.width.mas_equalTo(curButFullWidth);
  591. make.left.mas_equalTo(0*curButFullWidth);
  592. make.height.mas_equalTo(80);
  593. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  594. }];
  595. [_QQShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  596. make.width.mas_equalTo(curButFullWidth);
  597. make.left.mas_equalTo(1*curButFullWidth);
  598. make.height.mas_equalTo(80);
  599. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  600. }];
  601. [_momentsShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  602. make.width.mas_equalTo(curButFullWidth);
  603. make.left.mas_equalTo(2*curButFullWidth);
  604. make.height.mas_equalTo(80);
  605. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  606. }];
  607. [_PrivacyShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  608. make.width.mas_equalTo(curButFullWidth);
  609. make.left.mas_equalTo(3*curButFullWidth);
  610. make.height.mas_equalTo(80);
  611. make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
  612. }];
  613. }
  614. @end