shareRecordDetailsHWViewController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. //
  2. // shareRecordDetailsHWViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/15.
  6. //
  7. #import "shareRecordDetailsHWViewController.h"
  8. @interface shareRecordDetailsHWViewController ()
  9. @property (nonatomic,strong)UIView *whiteBgView;
  10. @property (nonatomic,strong)UILabel *shareTitleLabel;
  11. @property (nonatomic,strong)UILabel *shareBeginDateLabel;
  12. @property (nonatomic,strong)UIImageView *shareQRCodeImageView;
  13. @property (nonatomic,strong)UIButton*checkShareLinkButton;
  14. @property (nonatomic,strong)UIView *extractCodeBgView;
  15. @property (nonatomic,strong)UILabel *extractCodeTip2Lab;
  16. @property (nonatomic,strong)UILabel *shareEndDateLabel;
  17. @property (nonatomic,strong)UIButton*cancelShareLinkButton;
  18. @property (nonatomic,strong)UIButton*shareLinkCopyButton;
  19. @end
  20. @implementation shareRecordDetailsHWViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self.toolBar setHidden:YES];
  25. [self.navigationBar setHidden:YES];
  26. [self.navBarBGView setHidden:NO];
  27. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  28. [self.view setBackgroundColor:[UIColor hwColor:@"#F5F7FA"]];
  29. self.titleLabel.text = NSLocalizedString(@"share_record_title",nil);
  30. [self drawAnyView];
  31. }
  32. - (void)drawAnyView{
  33. //
  34. _whiteBgView = [[UIView alloc] init];
  35. _whiteBgView.backgroundColor = [UIColor whiteColor];
  36. [self.view addSubview:_whiteBgView];
  37. _whiteBgView.layer.cornerRadius = 8;
  38. _whiteBgView.layer.masksToBounds = YES;
  39. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(15);
  41. make.right.mas_equalTo(-15);
  42. make.top.equalTo(self.navBarBGView.mas_bottom).offset(40.f);
  43. make.height.mas_equalTo(448);
  44. }];
  45. //文件夹图标
  46. UIImageView *folderImageView = [[UIImageView alloc] init];
  47. folderImageView.image = [UIImage imageNamed:@"uploadFile_file_icon"];
  48. folderImageView.backgroundColor = [UIColor whiteColor];
  49. [self.view addSubview:folderImageView];
  50. folderImageView.layer.cornerRadius = 44;
  51. folderImageView.layer.masksToBounds = YES;
  52. [folderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  54. make.centerX.mas_equalTo(self.view.mas_centerX);
  55. make.width.mas_equalTo(88);
  56. make.height.mas_equalTo(88);
  57. }];
  58. _shareTitleLabel = [[UILabel alloc] init];
  59. //_shareTitleLabel.text = @"banner.png等多个文件";
  60. _shareTitleLabel.textAlignment = NSTextAlignmentCenter;
  61. _shareTitleLabel.textColor = HW0A132BColor;
  62. _shareTitleLabel.font = [UIFont systemFontOfSize:14.0];
  63. [_whiteBgView addSubview:_shareTitleLabel];
  64. [_shareTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(folderImageView.mas_bottom).offset(5.f);
  66. make.left.mas_equalTo(15);
  67. make.right.mas_equalTo(-15);
  68. make.height.mas_equalTo(20);
  69. }];
  70. _shareBeginDateLabel = [[UILabel alloc] init];
  71. //_shareBeginDateLabel.text = @"2024/04/25 19:45";
  72. _shareBeginDateLabel.textAlignment = NSTextAlignmentCenter;
  73. _shareBeginDateLabel.textColor = HW666666Color;
  74. _shareBeginDateLabel.font = [UIFont systemFontOfSize:12.0];
  75. [_whiteBgView addSubview:_shareBeginDateLabel];
  76. [_shareBeginDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.top.equalTo(_shareTitleLabel.mas_bottom).offset(25.f);
  78. make.left.mas_equalTo(15);
  79. make.right.mas_equalTo(-15);
  80. make.height.mas_equalTo(15);
  81. }];
  82. UIImageView *QRCodeEdgingImageView = [[UIImageView alloc] init];
  83. QRCodeEdgingImageView.image = [UIImage imageNamed:@"share_QRCode_edging"];
  84. [_whiteBgView addSubview:QRCodeEdgingImageView];
  85. [QRCodeEdgingImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.equalTo(_shareBeginDateLabel.mas_bottom).offset(10.f);
  87. make.centerX.mas_equalTo(self.view.mas_centerX);
  88. make.width.mas_equalTo(208);
  89. make.height.mas_equalTo(208);
  90. }];
  91. _shareQRCodeImageView = [[UIImageView alloc] init];
  92. //_shareQRCodeImageView.backgroundColor = [UIColor lightGrayColor];
  93. [QRCodeEdgingImageView addSubview:_shareQRCodeImageView];
  94. [_shareQRCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.top.mas_equalTo(20);
  96. make.bottom.mas_equalTo(-20);
  97. make.left.mas_equalTo(20);
  98. make.right.mas_equalTo(-20);
  99. }];
  100. //_shareQRCodeImageView.image = [self generateQRCodeWithInputMessage:@"http://baidu.com" Width:168 Height:168];
  101. _checkShareLinkButton = [[UIButton alloc] init];
  102. [_checkShareLinkButton setTitle:NSLocalizedString(@"check_share_link_title",nil) forState:UIControlStateNormal];
  103. [_checkShareLinkButton setTitleColor:[UIColor hwColor:@"#01B7EA"] forState:UIControlStateNormal];
  104. _checkShareLinkButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
  105. [_checkShareLinkButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  106. _checkShareLinkButton.tag = 1;
  107. [self.view addSubview:_checkShareLinkButton];
  108. [_checkShareLinkButton mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.left.mas_equalTo(15);
  110. make.right.mas_equalTo(-15);
  111. make.top.equalTo(QRCodeEdgingImageView.mas_bottom).offset(0.f);
  112. make.height.mas_equalTo(30);
  113. }];
  114. //提取码
  115. _extractCodeBgView = [[UIView alloc] init];
  116. _extractCodeBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9"];
  117. [_whiteBgView addSubview:_extractCodeBgView];
  118. _extractCodeBgView.layer.cornerRadius = 8;
  119. _extractCodeBgView.layer.masksToBounds = YES;
  120. [_extractCodeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.mas_equalTo(50);
  122. make.right.mas_equalTo(-50);
  123. make.top.equalTo(_checkShareLinkButton.mas_bottom).offset(15);
  124. make.height.mas_equalTo(40);
  125. }];
  126. UILabel *extractCodeTipLab = [[UILabel alloc] init];
  127. extractCodeTipLab.font = [UIFont systemFontOfSize:14.f];
  128. [extractCodeTipLab setTextColor:HW0A132BColor];
  129. extractCodeTipLab.text = NSLocalizedString(@"share_Extract_code_tip",nil);
  130. [_extractCodeBgView addSubview:extractCodeTipLab];
  131. [extractCodeTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.mas_equalTo(15);
  133. make.right.mas_equalTo(_extractCodeBgView.mas_centerX);
  134. make.top.mas_equalTo(0);
  135. make.bottom.mas_equalTo(0);
  136. }];
  137. _extractCodeTip2Lab = [[UILabel alloc] init];
  138. _extractCodeTip2Lab.font = [UIFont systemFontOfSize:14.f];
  139. //[_extractCodeTip2Lab setTextAlignment:(NSTextAlignmentRight)];
  140. [_extractCodeTip2Lab setTextAlignment:(NSTextAlignmentCenter)];
  141. [_extractCodeTip2Lab setTextColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
  142. [_extractCodeBgView addSubview:_extractCodeTip2Lab];
  143. //extractCodeTip2Lab.text = _addShareMod.data.extractionCode;
  144. [_extractCodeTip2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
  145. //make.left.mas_equalTo(extractCodeTipLab.mas_right);
  146. make.left.mas_equalTo(20);
  147. make.right.mas_equalTo(-20);
  148. make.top.mas_equalTo(0);
  149. make.bottom.mas_equalTo(0);
  150. }];
  151. _shareEndDateLabel = [[UILabel alloc] init];
  152. //_shareEndDateLabel.text = @"2024/04/25 19:45";
  153. _shareEndDateLabel.textAlignment = NSTextAlignmentCenter;
  154. _shareEndDateLabel.textColor = HW0A132BColor;
  155. _shareEndDateLabel.font = [UIFont systemFontOfSize:14.0];
  156. [_whiteBgView addSubview:_shareEndDateLabel];
  157. [_shareEndDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.top.equalTo(_extractCodeBgView.mas_bottom).offset(15.f);
  159. make.left.mas_equalTo(15);
  160. make.right.mas_equalTo(-15);
  161. make.height.mas_equalTo(15);
  162. }];
  163. _cancelShareLinkButton = [[UIButton alloc] init];
  164. [_cancelShareLinkButton setTitle:NSLocalizedString(@"cancel_share_title",nil) forState:UIControlStateNormal];
  165. [_cancelShareLinkButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
  166. _cancelShareLinkButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
  167. [_cancelShareLinkButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  168. _cancelShareLinkButton.tag = 2;
  169. [self.view addSubview:_cancelShareLinkButton];
  170. _cancelShareLinkButton.layer.cornerRadius = 8;
  171. _cancelShareLinkButton.layer.masksToBounds = YES;
  172. _cancelShareLinkButton.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
  173. [_cancelShareLinkButton mas_makeConstraints:^(MASConstraintMaker *make) {
  174. make.left.mas_equalTo(15);
  175. make.width.mas_equalTo(130);
  176. make.top.equalTo(_whiteBgView.mas_bottom).offset(25);
  177. make.height.mas_equalTo(48);
  178. }];
  179. _shareLinkCopyButton = [[UIButton alloc] init];
  180. CGFloat w_btn = SCREEN_W-130 -15 -10 -15;
  181. // gradient
  182. CAGradientLayer *gl = [CAGradientLayer layer];
  183. gl.frame = CGRectMake(0,0,w_btn,48.f);
  184. gl.startPoint = CGPointMake(0, 0.5);
  185. gl.endPoint = CGPointMake(1, 0.5);
  186. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  187. gl.locations = @[@(0), @(1.0f)];
  188. [_shareLinkCopyButton.layer addSublayer:gl];
  189. [_shareLinkCopyButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  190. [_shareLinkCopyButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  191. [_shareLinkCopyButton setTitle:NSLocalizedString(@"copy_share_link_title",nil) forState:(UIControlStateNormal)];
  192. [_shareLinkCopyButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  193. [_shareLinkCopyButton.layer setCornerRadius:8.f];
  194. _shareLinkCopyButton.clipsToBounds = YES;
  195. _shareLinkCopyButton.tag = 11;
  196. [self.view addSubview:_shareLinkCopyButton];
  197. [_shareLinkCopyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  198. make.right.mas_equalTo(-15);
  199. make.width.mas_equalTo(w_btn);
  200. make.top.equalTo(_whiteBgView.mas_bottom).offset(25);
  201. make.height.mas_equalTo(48);
  202. }];
  203. }
  204. // 生成二维码
  205. - (UIImage *)generateQRCodeWithInputMessage:(NSString *)inputMessage
  206. Width:(CGFloat)width
  207. Height:(CGFloat)height{
  208. NSData *inputData = [inputMessage dataUsingEncoding:NSUTF8StringEncoding];
  209. CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
  210. [filter setValue:inputData forKey:@"inputMessage"];
  211. // [filter setValue:@"H" forKey:@"inputCorrectionLevel"]; // 设置二维码不同级别的容错率
  212. CIImage *ciImage = filter.outputImage;
  213. // 消除模糊
  214. CGFloat scaleX = MIN(width, height)/ciImage.extent.size.width;
  215. CGFloat scaleY = MIN(width, height)/ciImage.extent.size.height;
  216. ciImage = [ciImage imageByApplyingTransform:CGAffineTransformScale(CGAffineTransformIdentity, scaleX, scaleY)];
  217. UIImage *returnImage = [UIImage imageWithCIImage:ciImage];
  218. return returnImage;
  219. }
  220. - (void)didClickButtonFun:(UIButton*)but
  221. {
  222. NSInteger tag = but.tag;
  223. if(tag == 1){
  224. NSString *serUrl = shareService;
  225. NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,_dataModel.token];
  226. NSURL *URL = [NSURL URLWithString:shareUrl];
  227. [[UIApplication sharedApplication] openURL:URL];
  228. }
  229. else if(tag == 10){
  230. [self showCancelAlearViewFun];
  231. }
  232. else if(tag == 11){
  233. [self copyShareLinkFun];
  234. }
  235. }
  236. - (void)viewWillAppear:(BOOL)animated
  237. {
  238. [super viewWillAppear:animated];
  239. [self handleDataFun];
  240. }
  241. //- (void)setDataModel:(ShareRecordListModel *)dataModel
  242. - (void)handleDataFun
  243. {
  244. //_dataModel = dataModel;
  245. if(!_dataModel.expirationStatus){
  246. _cancelShareLinkButton.hidden = NO;
  247. _shareLinkCopyButton.hidden = NO;
  248. //失效时间
  249. NSString *tipStr = NSLocalizedString(@"copy_share_link_Invalid_tip3",nil);
  250. _shareEndDateLabel.text = [[NSString alloc] initWithFormat:@"%@: %@",tipStr,_dataModel.expirationTime];
  251. }
  252. else{
  253. _cancelShareLinkButton.hidden = YES;
  254. _shareLinkCopyButton.hidden = YES;
  255. //失效时间
  256. NSString *tipStr = NSLocalizedString(@"copy_share_link_Invalid_tip3",nil);
  257. NSString *tipStr2 = NSLocalizedString(@"copy_share_link_Invalid_tip",nil);
  258. _shareEndDateLabel.text = [[NSString alloc] initWithFormat:@"%@: %@",tipStr,tipStr2];
  259. }
  260. ShareFileDataModel *fileModel = _dataModel.fileListVOS.firstObject;
  261. NSString *titleStr = [[NSString alloc] initWithFormat:@"%@%@%ld%@",fileModel.fileName,NSLocalizedString(@"share_file_more_tip",nil), _dataModel.fileListVOS.count,NSLocalizedString(@"share_file_Numbers_tip",nil)];
  262. if(_dataModel.fileListVOS.count == 1){
  263. titleStr = fileModel.fileName;
  264. }
  265. _shareTitleLabel.text = titleStr;
  266. _shareBeginDateLabel.text = _dataModel.createTime;
  267. NSString *serUrl = shareService;
  268. NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,_dataModel.token];
  269. _shareQRCodeImageView.image = [self generateQRCodeWithInputMessage:shareUrl Width:168 Height:168];
  270. _extractCodeTip2Lab.text = _dataModel.extractionCode;
  271. if(_dataModel.platformType == 4){
  272. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  273. make.left.mas_equalTo(15);
  274. make.right.mas_equalTo(-15);
  275. make.top.equalTo(self.navBarBGView.mas_bottom).offset(40.f);
  276. make.height.mas_equalTo(508);
  277. }];
  278. _extractCodeBgView.hidden = NO;
  279. [_shareEndDateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  280. make.top.equalTo(_extractCodeBgView.mas_bottom).offset(15.f);
  281. make.left.mas_equalTo(15);
  282. make.right.mas_equalTo(-15);
  283. make.height.mas_equalTo(15);
  284. }];
  285. }
  286. else{
  287. [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  288. make.left.mas_equalTo(15);
  289. make.right.mas_equalTo(-15);
  290. make.top.equalTo(self.navBarBGView.mas_bottom).offset(40.f);
  291. make.height.mas_equalTo(448);
  292. }];
  293. _extractCodeBgView.hidden = YES;
  294. [_shareEndDateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  295. make.top.equalTo(_checkShareLinkButton.mas_bottom).offset(15.f);
  296. make.left.mas_equalTo(15);
  297. make.right.mas_equalTo(-15);
  298. make.height.mas_equalTo(15);
  299. }];
  300. }
  301. }
  302. #pragma mark 取消分享
  303. - (void)showCancelAlearViewFun
  304. {
  305. NSString *tipStr = NSLocalizedString(@"cancel_share_Tip_msg",nil);
  306. KWeakSelf
  307. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
  308. msg:tipStr
  309. imageStr:nil
  310. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  311. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  312. didClickOk:^{
  313. [weakSelf cancelShareLinkFun];
  314. } didClickCancel:^{
  315. }];
  316. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  317. [self presentViewController:curAlretVC animated:YES completion:^{
  318. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  319. }];
  320. }
  321. - (void)cancelShareLinkFun
  322. {
  323. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  324. if(_dataModel.addShareId){
  325. //[paraDict setValue:_dataModel.addShareId forKey:@"id"];
  326. [paraDict setValue:@[_dataModel.addShareId] forKey:@"idList"];
  327. }
  328. [paraDict setValue:@1 forKey:@"expirationStatus"];
  329. KWeakSelf
  330. [self showNewIndicatorWithCanBack:NO canTouch:NO];
  331. [[netWorkManager shareInstance] CommonPostCallBackCode:updateShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  332. [weakSelf removeNewIndicator];
  333. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  334. if(model && model.code == 0){
  335. [[iToast makeText:NSLocalizedString(@"cancel_share_suc_msg",nil)] show];
  336. [weakSelf getShareOneFileListFun];
  337. }
  338. else{
  339. [[iToast makeText:NSLocalizedString(@"cancel_share_fail_msg",nil)] show];
  340. }
  341. } failure:^(NSError * _Nonnull error) {
  342. [weakSelf removeNewIndicator];
  343. [[iToast makeText:NSLocalizedString(@"cancel_share_fail_msg",nil)] show];
  344. }];
  345. }
  346. #pragma mark 分享信息重新获取
  347. - (void)getShareOneFileListFun
  348. {
  349. _dataModel.expirationStatus = 1;
  350. [self handleDataFun];
  351. if(_didCancelShareLinkFun){
  352. _didCancelShareLinkFun();
  353. }
  354. }
  355. - (void)copyShareLinkFun
  356. {
  357. if(_dataModel.fileListVOS.count <=0 ){
  358. return;
  359. }
  360. ShareFileDataModel *dataModel = _dataModel.fileListVOS.firstObject;
  361. NSString *copyStr1 = [[NSString alloc] initWithFormat:@"%@%@%@%ld%@",NSLocalizedString(@"share_secret_titile_1_1",nil),dataModel.fileName,NSLocalizedString(@"share_file_more_tip",nil), _dataModel.fileListVOS.count,NSLocalizedString(@"share_file_Numbers_tip",nil)];
  362. if(_dataModel.fileListVOS.count == 1){
  363. copyStr1 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_1",nil),dataModel.fileName];
  364. }
  365. if(_dataModel.platformType == 4) {
  366. copyStr1 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_1",nil),copyStr1];
  367. }
  368. NSString *serUrl = shareService;
  369. NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,_dataModel.token];
  370. NSString *copyStr2 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_2",nil),shareUrl];
  371. NSString *copyStr3 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_3",nil),_dataModel.extractionCode];
  372. NSString *copyStr4 = NSLocalizedString(@"share_secret_titile_4",nil);
  373. NSString *copyTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@\n%@\n%@",copyStr1,copyStr2,copyStr3,copyStr4];
  374. if(_dataModel.platformType != 4) {
  375. copyTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@\n%@",copyStr1,copyStr2,copyStr4];
  376. }
  377. UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
  378. pasteboard.string = copyTotalStr;
  379. [[iToast makeText:NSLocalizedString(@"copy_share_link_suc_tip",nil)] show];
  380. }
  381. @end