editShareView.m 26 KB

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