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