123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741 |
- //
- // editShareView.m
- // 双子星云手机
- //
- // Created by xd h on 2024/5/14.
- //
- #import "editShareView.h"
- #import "addShareModel.h"
- #import "customShareManageTool.h"
- #import "shareBySecretView.h"
- //微信分享头文件
- #import "WXApi.h"
- #import "WXApiObject.h"
- //QQ分享头文件
- #import <TencentOpenAPI/TencentOAuth.h>
- #import <TencentOpenAPI/QQApiInterface.h>
- #import <TencentOpenAPI/QQApiInterfaceObject.h>
- @interface editShareView ()<UITextFieldDelegate>
- @property(nonatomic,strong) UIView *whiteBgView;
- @property(nonatomic,strong) UIButton*day7Button;
- @property(nonatomic,strong) UIButton*dayForeverButton;
- @property(nonatomic,strong) UIButton*addButton;//+
- @property(nonatomic,strong) UITextField *shareNumberTF;
- @property(nonatomic,strong) UIButton*reduceButton;//-
- @property(nonatomic,strong)UILabel *thridTitleLabel;
- @property(nonatomic,strong) UIButton*wxShareButton;
- @property(nonatomic,strong) UIButton*QQShareButton;
- @property(nonatomic,strong) UIButton*momentsShareButton;
- @property(nonatomic,strong) UIButton*PrivacyShareButton;
- @end
- @implementation editShareView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
- [self drawAnyView];
- _isPortraitType = YES;
- return self;
- }
- - (void)drawAnyView{
-
- //大按钮响应
- UIButton *bigRightButton = [[UIButton alloc] init];
- bigRightButton.tag = 1;
- [bigRightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:bigRightButton];
- //bigRightButton.backgroundColor= [UIColor greenColor];
-
- [bigRightButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- _whiteBgView = [[UIView alloc] init];
- _whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:_whiteBgView];
- _whiteBgView.layer.cornerRadius = 32;
- _whiteBgView.layer.masksToBounds = YES;
-
- [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(345 + AdaptTabHeight);
- }];
-
-
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.font = [UIFont systemFontOfSize:18.0];
- titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [_whiteBgView addSubview:titleLabel];
-
- NSString *leftText = NSLocalizedString(@"share_title_left",nil);
- NSString *rightText = NSLocalizedString(@"share_title_right",nil);
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
-
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
- NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
- UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
- [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
- [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
- titleLabel.attributedText = attrStr;
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(20);
- make.height.mas_equalTo(40);
- }];
-
- NSString *secondTitleStr = NSLocalizedString(@"share_expiration_date",nil);
- UILabel *secondTitleLabel = [[UILabel alloc] init];
- secondTitleLabel.font = [UIFont systemFontOfSize:14.0];
- secondTitleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
- secondTitleLabel.text = secondTitleStr;
- [_whiteBgView addSubview:secondTitleLabel];
-
- CGFloat secondWith = [secondTitleStr boundingRectWithSize:CGSizeMake(300, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width;
-
- [secondTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- //make.width.mas_equalTo(secondWith);
- make.top.equalTo(titleLabel.mas_bottom).offset(10);
- make.height.mas_equalTo(25);
- }];
-
-
- _day7Button = [[UIButton alloc] init];
- [_day7Button setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
- [_day7Button setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
- [_day7Button setTitle:NSLocalizedString(@"share_expiration_date_7",nil) forState:UIControlStateNormal];
- [_day7Button setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
- [_day7Button addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _day7Button.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- _day7Button.tag = 1;
- [_whiteBgView addSubview:_day7Button];
- _day7Button.selected = YES;
-
- [_day7Button mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(secondTitleLabel.mas_right).offset(5);
- make.width.mas_equalTo(100);
- make.top.equalTo(secondTitleLabel.mas_top).offset(0);
- make.height.mas_equalTo(25);
- }];
-
- _dayForeverButton = [[UIButton alloc] init];
- [_dayForeverButton setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
- [_dayForeverButton setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
- [_dayForeverButton setTitle:NSLocalizedString(@"share_expiration_date_forever",nil) forState:UIControlStateNormal];
- [_dayForeverButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
- [_dayForeverButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _dayForeverButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- _dayForeverButton.tag = 2;
- [_whiteBgView addSubview:_dayForeverButton];
-
- [_dayForeverButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_day7Button.mas_right).offset(15);
- make.width.mas_equalTo(100);
- make.top.equalTo(secondTitleLabel.mas_top).offset(0);
- make.height.mas_equalTo(25);
- }];
-
- //1.4.1 添加分享次数限制
- NSString *thridTitleStr = NSLocalizedString(@"share_number_limit_title",nil);
- _thridTitleLabel = [[UILabel alloc] init];
- _thridTitleLabel.font = [UIFont systemFontOfSize:14.0];
- _thridTitleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
- _thridTitleLabel.text = thridTitleStr;
- [_whiteBgView addSubview:_thridTitleLabel];
-
- CGFloat thridWith = [thridTitleStr boundingRectWithSize:CGSizeMake(300, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width + 10;
-
- [_thridTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- make.width.mas_equalTo(thridWith);
- make.top.equalTo(secondTitleLabel.mas_bottom).offset(10);
- make.height.mas_equalTo(25);
- }];
-
- _addButton = [[UIButton alloc] init];
- [_addButton setImage:[UIImage imageNamed:@"common_add_d"] forState:UIControlStateDisabled];
- [_addButton setImage:[UIImage imageNamed:@"common_add_N"] forState:UIControlStateNormal];
- [_addButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _addButton.tag = 3;
- [_whiteBgView addSubview:_addButton];
- _addButton.enabled = NO;
-
- [_addButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-20);
- make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
- make.width.mas_equalTo(30);
- make.height.mas_equalTo(30);
- }];
-
- _shareNumberTF = [[UITextField alloc] init];
- _shareNumberTF.backgroundColor = [UIColor hwColor:@"#F1F2F3" alpha:1.0];
- _shareNumberTF.layer.cornerRadius = 8;
- _shareNumberTF.textColor = [UIColor blackColor];
- _shareNumberTF.textAlignment = NSTextAlignmentCenter;
- _shareNumberTF.font = [UIFont systemFontOfSize:14.0];
- _shareNumberTF.text = @"80";
- _shareNumberTF.delegate = self;
- _shareNumberTF.keyboardType = UIKeyboardTypeNumberPad;
- [_whiteBgView addSubview:_shareNumberTF];
- [_shareNumberTF setTintColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
-
- [_shareNumberTF mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(_addButton.mas_left).offset(-5);
- make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
- make.width.mas_equalTo(50);
- make.height.mas_equalTo(25);
- }];
-
- _reduceButton = [[UIButton alloc] init];
- [_reduceButton setImage:[UIImage imageNamed:@"common_reduce_d"] forState:UIControlStateDisabled];
- [_reduceButton setImage:[UIImage imageNamed:@"common_reduce_N"] forState:UIControlStateNormal];
- [_reduceButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _reduceButton.tag = 4;
- [_whiteBgView addSubview:_reduceButton];
-
- [_reduceButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(_shareNumberTF.mas_left).offset(-5);
- make.centerY.equalTo(_thridTitleLabel.mas_centerY).offset(0);
- make.width.mas_equalTo(30);
- make.height.mas_equalTo(30);
- }];
-
-
-
- NSArray *titleArr = @[NSLocalizedString(@"share_by_weixin",nil),
- NSLocalizedString(@"share_by_QQ",nil),
- NSLocalizedString(@"share_by_timeLine",nil),
- NSLocalizedString(@"share_by_secret",nil)];
-
- NSArray *imageStrArr = @[@"share_weixin_icon",
- @"share_qq_icon",
- @"share_weixin_Timeline_icon",
- @"share_secret_icon"];
-
- CGFloat curButFullWidth = SCREEN_W/4.0;
-
- for (int i = 0; i< titleArr.count; i++) {
- UIButton*curButton = [[UIButton alloc] init];
- [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- curButton.tag = 10+i;
- [_whiteBgView addSubview:curButton];
- [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(i*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
- }];
-
- if(i== 0){
- _wxShareButton = curButton;
- }
- else if(i== 1){
- _QQShareButton = curButton;
- }
- else if(i== 2){
- _momentsShareButton= curButton;
- }
- else if(i== 3){
- _PrivacyShareButton = curButton;
- }
-
- UIView *imageBgView = [[UIView alloc] init];
- imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
- imageBgView.layer.cornerRadius = 8;
- imageBgView.layer.masksToBounds = YES;
- [curButton addSubview:imageBgView];
- imageBgView.userInteractionEnabled = NO;
-
- [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(64);
- make.height.mas_equalTo(52);
- make.centerX.equalTo(curButton.mas_centerX);
- make.top.mas_equalTo(0);
- }];
-
- UIImageView *leftImageV = [[UIImageView alloc] init];
- leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
- [imageBgView addSubview:leftImageV];
- [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(25);
- make.height.mas_equalTo(25);
- make.centerX.equalTo(imageBgView.mas_centerX);
- make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
- }];
- UILabel *leftLabel = [[UILabel alloc] init];
- leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
- leftLabel.textAlignment = NSTextAlignmentCenter;
- leftLabel.font = [UIFont systemFontOfSize:12.0];
- leftLabel.text = titleArr[i];
- [curButton addSubview:leftLabel];
- [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.height.mas_equalTo(25);
- make.centerX.equalTo(curButton.mas_centerX);
- //make.top.equalTo(imageBgView.mas_bottom).offset(10);
- make.bottom.mas_equalTo(0);
- }];
- }
-
-
- UIButton*cancelButton = [[UIButton alloc] init];
- [cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
- [cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
- [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- cancelButton.tag = 100;
- [_whiteBgView addSubview:cancelButton];
-
- [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-AdaptTabHeight);
- make.height.mas_equalTo(40);
- }];
-
- UIView *lineView = [[UIView alloc] init];
- lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
- [_whiteBgView addSubview:lineView];
-
- [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- make.bottom.equalTo(cancelButton.mas_top).offset(-5);
- make.height.mas_equalTo(1);
- }];
-
- UILabel *tipLabel = [[UILabel alloc] init];
- tipLabel.font = [UIFont systemFontOfSize:12.0];
- tipLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
- [_whiteBgView addSubview:tipLabel];
-
- NSString *TipText = NSLocalizedString(@"share_file_tip_msg",nil);
- tipLabel.text = TipText;
-
- [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- make.bottom.equalTo(lineView.mas_bottom).offset(-30);
- make.height.mas_equalTo(15);
- }];
- }
- - (void)didClickButFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
-
- if(tag != 3 && tag != 4 ){//防止重复点击
- but.userInteractionEnabled = NO;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- but.userInteractionEnabled = YES;
- });
- }
-
-
- if(tag==1 && !_day7Button.selected){
- _day7Button.selected = YES;
- _dayForeverButton.selected = NO;
-
- //私密分享
- _PrivacyShareButton.hidden = NO;
- }
- else if(tag==2 && !_dayForeverButton.selected){
- _day7Button.selected = NO;
- _dayForeverButton.selected = YES;
-
- //私密分享
- _PrivacyShareButton.hidden = YES;
- }
- else if(tag==3){
- NSInteger number = _shareNumberTF.text.integerValue;
- number ++;
- _shareNumberTF.text = [[NSString alloc] initWithFormat:@"%ld",number];
- if(number == 80){
- _addButton.enabled = NO;
- }
-
- _reduceButton.enabled = YES;
- }
- else if(tag==4){
- NSInteger number = _shareNumberTF.text.integerValue;
- number --;
- _shareNumberTF.text = [[NSString alloc] initWithFormat:@"%ld",number];
- if(number == 1){
- _reduceButton.enabled = NO;
- }
-
- _addButton.enabled = YES;
- }
- else if(tag == 100 || tag ==1){
- if(_didClickCloseFun){
- _didClickCloseFun();
- }
- [self removeFromSuperview];
- }
- else{
- if(tag == 11){
- if(![QQApiInterface isSupportShareToQQ])
- {
- //[[iToast makeText:@"未安装QQ,请先安装QQ"] show];
- [[iToast makeText:NSLocalizedString(@"share_no_qq",nil)] show];
- return;
- }
- }
- else if (tag == 10 || tag == 12){
- if(![WXApi isWXAppInstalled])
- {
- //[[iToast makeText:@"未安装微信,请先安装微信"] show];
- [[iToast makeText:NSLocalizedString(@"share_no_wx",nil)] show];
- return;
- }
- }
- //请求服务器处理分享数据
- [self addShareDataBy:tag];
- }
- }
- //添加分享
- - (void)addShareDataBy:(NSInteger)tag
- {
- NSString *curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- NSString *platformType = [[NSString alloc] initWithFormat:@"%ld", tag - 9];
- //_shareFileType
- NSInteger expirationDay = _day7Button.selected ? 7 : 0;
-
- NSMutableArray * boxShareFileDTOList = [NSMutableArray new];
-
- for (NASFilePicDataArrModel*dataModel in _didSelectListArr) {
- NSMutableDictionary *modelDict = [NSMutableDictionary new];
-
- if(dataModel.name){
- [modelDict setValue:dataModel.name forKey:@"fileName"];
-
- NSArray * nameArr = [dataModel.name componentsSeparatedByString:@"."];
- if(nameArr.count >= 2){
- NSString*fileSuffix = nameArr.lastObject;
- if(fileSuffix && fileSuffix.length > 0){
- [modelDict setValue:fileSuffix forKey:@"fileSuffix"];
- }
- }
- }
-
- if(dataModel.size >= 0){
- [modelDict setValue:[NSNumber numberWithLong:dataModel.size] forKey:@"fileSize"];
- }
-
- if(dataModel.time){
- [modelDict setValue:dataModel.time forKey:@"fileTime"];
- }
-
- if(dataModel.path){
-
- NSString *filePath = dataModel.path;
- NSString *urlStr = ksharedAppDelegate.NASShareFileService;
- NSString *headUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
- NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
-
- if(headUrl){
- [modelDict setValue:headUrl forKey:@"headUrl"];
- }
- if(headUrl){
- [modelDict setValue:fileUrl forKey:@"fileUrl"];
- }
- }
-
- [boxShareFileDTOList addObject:modelDict];
- }
-
-
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- if(!curSn){
- return;
- }
- [paraDict setValue:curSn forKey:@"sn"];
- [paraDict setValue:platformType forKey:@"platformType"];
- if(_shareFileType){
- [paraDict setValue:_shareFileType forKey:@"fileType"];
- }
- [paraDict setValue:[NSNumber numberWithInteger:expirationDay] forKey:@"expirationDay"];
- [paraDict setValue:boxShareFileDTOList forKey:@"boxShareFileDTOList"];
-
- //1.4.1 新增的字段
- if(_shareNumberTF.text)
- {
- [paraDict setValue:_shareNumberTF.text forKey:@"shareNumber"];
- }
-
- KWeakSelf
- //[ showNewIndicatorWithCanBack:NO canTouch:NO];
- [[netWorkManager shareInstance] CommonPostCallBackCode:addShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
- addShareModel *model = [[addShareModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.code == 0){
- [weakSelf gotoShareFunWith:tag with:model];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];//
- }
-
- } failure:^(NSError * _Nonnull error) {
- [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];
- }];
-
- //文件类型 1=应用 2=图片 3=视频 4=音频 5=文档 6=文件
- //time 7,forever
- //渠道 WX,QQ, Moment private
- //share
-
- //处理数据埋点
- NSString * firstFileType = nil;
- BOOL isSameFileType = YES;
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
- if(!firstFileType){
- firstFileType = dataModel.type;
- }
- else if(![firstFileType isEqualToString:dataModel.type]){
- isSameFileType = NO;
- break;
- }
- }
-
- NSString * shareTypeStr = @"Image";
- if(!isSameFileType){
- shareTypeStr = @"File";
- }
- else if([firstFileType containsString:@"jpg"]){
- shareTypeStr = @"Image";
- }
- else if([firstFileType isEqualToString:@"video"]){
- shareTypeStr = @"Video";
- }
- else if([firstFileType isEqualToString:@"audio"]){
- shareTypeStr = @"Music";
- }
- else{
- shareTypeStr = @"File";
- }
-
- if(_isLastFileType){
- shareTypeStr = @"Recently";
- }
-
- NSString * shareTimeStr = expirationDay == 7 ? @"7" : @"forever";
-
- //type1 朋友圈 2 微信好友 3 QQ
- NSString* shareToType = @"WX";
- if(tag == 10){
- shareToType = @"WX";
- }
- else if(tag == 11){
- shareToType = @"QQ";
- }
- else if(tag == 12){
- shareToType = @"Moments";
- }
- else if(tag == 13){
- shareToType = @"private";
- }
-
- NSString *eventValue = [[NSString alloc] initWithFormat:@"%@_%@_%@_share",shareTypeStr,shareTimeStr,shareToType];
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:eventValue];
- }
- - (void)gotoShareFunWith:(NSInteger)tag with:(addShareModel*)model
- {
-
- //type1 朋友圈 2 微信好友 3 QQ
- NSInteger shareType = 1;
- if(tag == 10){
- shareType =2;
- }
- else if(tag == 11){
- shareType = 3;
- }
- else if(tag == 12){
- shareType = 1;
- }
- else if(tag == 13){
- [self showSecretShareViewFunwith:model];
- [self removeFromSuperview];
- return;
- }
-
- [self removeFromSuperview];
-
- NSString *serUrl = shareService;
- NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,model.data.token];
- //NSString *shareTitle = [[NSString alloc] initWithFormat:@"Private-X%@",NSLocalizedString(@"common_edit_share",nil)];
- NSString *shareTitle = @"Private-X分享";
-
-
- NSString *firstname = nil;
- if (_didSelectListArr.count > 0) {
- NASFilePicDataArrModel*dataModel = _didSelectListArr[0];
- firstname = dataModel.name;
- }
-
- //我正在使用Private-X魔盒,给大家分享 文件名称文件名称.jpg 等 2 个文件 ,快来看看吧~
- NSString *shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@等%ld个文件 ,快来看看吧~",firstname,_didSelectListArr.count];
-
- if(_didSelectListArr.count == 1){
- shareContent = [[NSString alloc] initWithFormat:@"我正在使用Private-X魔盒,给大家分享%@ ,快来看看吧~",firstname];
- }
-
- [[customShareManageTool sharedManager] shareType:shareType withShareUrl:shareUrl withShareTitle:shareTitle withShareContent:shareContent];
- }
- - (void)showSecretShareViewFunwith:(addShareModel*)model
- {
-
- shareBySecretView *secretView = [[shareBySecretView alloc] init];
- secretView.addShareMod = model;
- secretView.didSelectListArr = _didSelectListArr;
- secretView.isPortraitType = _isPortraitType;
-
- UIView * curSuperView = [self superview];
- if(curSuperView){//修复横竖视频播放隐私分享出问题
- [curSuperView addSubview:secretView];
- }
- else{
- [ksharedAppDelegate.window addSubview:secretView];
- }
-
- _secretShareView = secretView;
-
- [secretView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- KWeakSelf
- secretView.didClickCloseFun = ^{
- if(weakSelf.didClickCloseFun){
- weakSelf.didClickCloseFun();
- }
- };
- }
- #pragma mark 分享次数编辑完成
- - (void)textFieldDidEndEditing:(UITextField *)textField
- {
- NSInteger shareNum = textField.text.integerValue;
- if(shareNum > 80 || shareNum <= 0){
- textField.text = @"80";
-
- [[iToast makeText:NSLocalizedString(@"share_number_limit_error_tip",nil)] show];
- }
-
- [self setAddOrReduceButtonFun];
- }
- #pragma mark 设置加减按钮状态
- - (void)setAddOrReduceButtonFun
- {
- NSInteger number = _shareNumberTF.text.integerValue;
-
- if(number == 1){
- _reduceButton.enabled = NO;
- _addButton.enabled = YES;
- }
- else if (number == 80){
- _reduceButton.enabled = YES;
- _addButton.enabled = NO;
- }
- else{
- _reduceButton.enabled = YES;
- _addButton.enabled = YES;
- }
- }
- - (void)setIsPortraitType:(BOOL)isPortraitType
- {
- _isPortraitType = isPortraitType;
-
- CGFloat curButFullWidth = 0.0;
-
- if(_isPortraitType){
- _whiteBgView.layer.cornerRadius = 32;
- [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(345 + AdaptTabHeight);
- }];
-
- CGFloat width = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
- curButFullWidth = width/4.0;
- }
- else{
- CGFloat height = SCREEN_W < SCREEN_H ? SCREEN_W : SCREEN_H;
-
- _whiteBgView.layer.cornerRadius = 0;
- [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(400);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- //make.height.mas_equalTo(345 + AdaptTabHeight);
- make.height.mas_equalTo(height);
- }];
-
- curButFullWidth = 400.0/4.0;
- }
-
- //四个分享按钮
- [_wxShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(0*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
- }];
-
- [_QQShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(1*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
- }];
-
- [_momentsShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(2*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
- }];
-
- [_PrivacyShareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(3*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(_thridTitleLabel.mas_bottom).offset(20);
- }];
-
- }
- @end
|