123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- //
- // DocumentLibraryListVC.m
- // Telemarketing
- //
- // Created by apple on 2021/4/28.
- // Copyright © 2021 刘惠萍. All rights reserved.
- //
- #import "DocumentLibraryListVC.h"
- #import "NewDynamicListShieldView.h"
- #import "WXApi.h"
- @interface DocumentLibraryListVC ()
- @end
- @implementation DocumentLibraryListVC
- - (BOOL)isShowNoResult{//显示无结果页
- return true;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.tableView registerClass:[DocumentLibraryListCell class] forCellReuseIdentifier:@"DocumentLibraryListCell"];
- [self addRefresh];
- }
- #pragma mark table view delegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.aryDatas.count;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- DocumentLibraryListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DocumentLibraryListCell" forIndexPath:indexPath];
- [cell resetCellWithModel:self.aryDatas[indexPath.row]];
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [DocumentLibraryListCell fetchHeight:self.aryDatas[indexPath.row]];
- }
- - (void)requestList{
- [RequestApi requestGetInformationListWithPage:strDotF(self.pageNum) size:@"20" typeId:UnPackStr(self.activeStatus) delegate:self success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"][@"dataList"] toAryWithModelName:@"ModelDocumentLibrary"];
- if (self.isRemoveAll) {
- [self.aryDatas removeAllObjects];
- }
- self.pageNum ++;
- if (!isAry(ary)) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- [self.aryDatas addObjectsFromArray:ary];
- [self.tableView reloadData];
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
- }
- #pragma mark scroll delegate
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- [scrollView scrollLink:(LinkScrollView *)scrollView.superview.superview.superview];
- }
- @end
- @implementation DocumentLibraryListCell
- #pragma mark 懒加载
- - (UIImageView *)iconImg{
- if (_iconImg == nil) {
- _iconImg = [UIImageView new];
- _iconImg.widthHeight = XY(W(50),W(50));
- [GlobalMethod setRoundView:_iconImg color:[UIColor clearColor] numRound:_iconImg.width/2 width:0];
- }
- return _iconImg;
- }
- - (UILabel *)labelName{
- if (_labelName == nil) {
- _labelName = [UILabel new];
- [GlobalMethod setLabel:_labelName widthLimit:0 numLines:0 fontNum:F(14) textColor:COLOR_LABEL text:@""];
- }
- return _labelName;
- }
- - (UILabel *)labelTime{
- if (_labelTime == nil) {
- _labelTime = [UILabel new];
- [GlobalMethod setLabel:_labelTime widthLimit:0 numLines:0 fontNum:F(10) textColor:COLOR_DETAIL text:@""];
- }
- return _labelTime;
- }
- - (UILabel *)labelTitle{
- if (_labelTitle == nil) {
- _labelTitle = [UILabel new];
- [GlobalMethod setLabel:_labelTitle widthLimit:0 numLines:0 fontNum:F(17) textColor:COLOR_LABEL text:@""];
- }
- return _labelTitle;
- }
- - (MineListMindImgView *)contentImg{
- if (_contentImg == nil) {
- _contentImg = [MineListMindImgView new];
- }
- return _contentImg;
- }
- -(UIButton *)titleBtn{
- if (_titleBtn == nil) {
- _titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _titleBtn.tag = 1;
- [_titleBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _titleBtn.titleLabel.font = [UIFont systemFontOfSize:F(11)];
- [_titleBtn setTitle:@" 复制文字" forState:(UIControlStateNormal)];
- [_titleBtn setTitleColor:COLOR_DETAIL forState:(UIControlStateNormal)];
- [_titleBtn setImage:[UIImage imageNamed:@"aicon_02"] forState:(UIControlStateNormal)];
- _titleBtn.widthHeight = XY(W(70),W(40));
- }
- return _titleBtn;
- }
- -(UIButton *)imgBtn{
- if (_imgBtn == nil) {
- _imgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _imgBtn.tag = 2;
- [_imgBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _imgBtn.titleLabel.font = [UIFont systemFontOfSize:F(11)];
- [_imgBtn setTitle:@" 保存图片" forState:(UIControlStateNormal)];
- [_imgBtn setTitleColor:COLOR_DETAIL forState:(UIControlStateNormal)];
- [_imgBtn setImage:[UIImage imageNamed:@"aicon_01"] forState:(UIControlStateNormal)];
- _imgBtn.widthHeight = XY(W(70),W(40));
- }
- return _imgBtn;
- }
- -(UIButton *)shareBtn{
- if (_shareBtn == nil) {
- _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _shareBtn.tag = 3;
- [_shareBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _shareBtn.titleLabel.font = [UIFont systemFontOfSize:F(11)];
- [_shareBtn setTitle:@" 分享" forState:(UIControlStateNormal)];
- [_shareBtn setTitleColor:COLOR_DETAIL forState:(UIControlStateNormal)];
- [_shareBtn setImage:[UIImage imageNamed:@"aicon_03"] forState:(UIControlStateNormal)];
- _shareBtn.widthHeight = XY(W(70),W(40));
- }
- return _shareBtn;
- }
- #pragma mark 初始化
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = [UIColor whiteColor];
- self.backgroundColor = [UIColor whiteColor];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- [self.contentView addSubview:self.iconImg];
- [self.contentView addSubview:self.labelName];
- [self.contentView addSubview:self.labelTime];
- [self.contentView addSubview:self.labelTitle];
- [self.contentView addSubview:self.contentImg];
- [self.contentView addSubview:self.titleBtn];
- [self.contentView addSubview:self.imgBtn];
- [self.contentView addSubview:self.shareBtn];
- }
- return self;
- }
- #pragma mark 刷新cell
- - (void)resetCellWithModel:(ModelDocumentLibrary *)model{
- [self.contentView removeSubViewWithTag:TAG_LINE];//移除线
- //刷新view
- self.model=model;
- [self.iconImg sd_setImageWithURL:[NSURL URLWithString:UnPackStr(model.sendicon)] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- self.iconImg.leftTop = XY(W(15),W(15));
- [self.labelName fitTitle:UnPackStr(model.sendname) variable:0];
- self.labelName.leftCenterY = XY(self.iconImg.right+W(10),self.iconImg.centerY);
- [self.labelTime fitTitle:UnPackStr(model.createtime) variable:0];;
- self.labelTime.rightCenterY = XY(SCREEN_WIDTH-W(15),self.labelName.centerY);
- [self.labelTitle fitTitle:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] variable:SCREEN_WIDTH-W(30)];
- self.labelTitle.leftTop = XY(W(15),self.iconImg.bottom+W(15));
- [GlobalMethod setAttributeLabel:self.labelTitle content:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] width:self.labelTitle.width lineSpace:10];
- NSMutableArray *arr=[NSMutableArray new];
- NSArray *saleArray = [model.imageone componentsSeparatedByString:@","];
- if (isAry(saleArray)) {
- for (NSString *modelp in saleArray) {
- ModelImage *modeli=[ModelImage new];
- NSString *url=[modelp hasPrefix:@"http"]?modelp:modelp;
- modeli.url=url;
- [arr addObject:modeli];
- }
- self.contentImg.leftTop = XY(W(0),self.labelTitle.bottom+W(15));
- [self.contentImg resetViewWithArray:arr totalNum:arr.count];
- self.contentImg.hidden=false;
- }else{
- self.contentImg.hidden=true;
- }
- self.shareBtn.rightTop = XY(SCREEN_WIDTH-W(15),isAry(saleArray)?self.contentImg.bottom+W(15):self.labelTitle.bottom+W(15));
- self.imgBtn.rightCenterY = XY(self.shareBtn.left-W(5),self.shareBtn.centerY);
- self.titleBtn.rightCenterY = XY(self.imgBtn.left-W(5),self.shareBtn.centerY);
- self.height = [self.contentView addLineFrame:CGRectMake(0, self.shareBtn.bottom+W(15), SCREEN_WIDTH, 1)];
- }
- #pragma mark 点击事件
- - (void)btnClick:(UIButton *)sender{
- switch (sender.tag) {
- case 1:
- {
- [GlobalMethod copyToPlte:UnPackStr(self.model.content)];
- [GlobalMethod showAlert:@"复制成功"];
- }
- break;
- case 2:
- {
- NSMutableArray *arr=[NSMutableArray new];
- NSArray *saleArray = [self.model.imageone componentsSeparatedByString:@","];
- if (isAry(saleArray)) {
- for (NSString *modelp in saleArray) {
- ModelImage *modeli=[ModelImage new];
- modeli.url=modelp;
- [arr addObject:modeli];
- }
- }
- for (ModelImage *model in arr) {
- UIImageView * _iv = [UIImageView new];
- _iv.backgroundColor = [UIColor clearColor];
- _iv.widthHeight = XY(SCREEN_WIDTH,SCREEN_HEIGHT);
- _iv.leftTop = XY(0,0);
- _iv.contentMode = UIViewContentModeScaleAspectFit;
- NSString *cacheKey = [[SDWebImageManager sharedManager] cacheKeyForURL:[NSURL URLWithString:model.url]];
- [[SDWebImageManager sharedManager].imageCache queryCacheOperationForKey:cacheKey done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
- if (image) {
- _iv.image = image;
- [_iv sd_setImageWithURL:[NSURL URLWithString:UnPackStr(model.url)] placeholderImage:[UIImage imageNamed:IMAGE_BIG_DEFAULT]];
- UIImageWriteToSavedPhotosAlbum(_iv.image,self,@selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:),nil);
- return;
- }
- }];
- }
- }
- break;
- case 3:
- {
- WEAKSELF
- NewDynamicListShieldView * vc = [NewDynamicListShieldView new];
- vc.blockSelectBtnModel = ^(ModelBtn *modelBtn){
- [weakSelf modelBtnClick:modelBtn];
- };
- [vc resetWithModel:nil];
- UIView * window = [UIApplication sharedApplication].keyWindow;
- [window addSubview:vc];
- }
- break;
- default:
- break;
- }
- }
- - (void)imageSavedToPhotosAlbum:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo{
- NSString*message =@"";
- if(!error) {
- [GlobalMethod showAlert:@"成功保存到相册"];
- }else
- {
- message = [error description];
- [GlobalMethod showAlert:message];
- }
- }
- - (void)modelBtnClick:(ModelBtn *)model {
- switch (model.tag) {
- case 0:
- {
- [self shareWithWechatType:WXSceneSession];
- }
- break;
- case 1:
- {
- [self shareWithWechatType:WXSceneTimeline];
- }
- break;
- default:
- break;
- }
- }
- //微信
- - (void)shareWithWechatType:(int)type
- {
- if ([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi]) {
-
- // 分享出去,没有返回信息
- WXWebpageObject *webpageObject = [WXWebpageObject object];
- webpageObject.webpageUrl = [NSString stringWithFormat:@"%@phoneMobile/userRecCode?recCode=%@",URL_HEAD,[GlobalData sharedInstance].GB_UserModel.recCode];
-
- WXMediaMessage *message = [WXMediaMessage message];
- message.title = @"立即注册,开启您的财富之旅";
- message.description = @"POS机办理,信用卡申请,积分换钱......";
- [message setThumbImage:[UIImage imageNamed: @"icon"]];
- message.mediaObject = webpageObject;
-
- SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
- req.bText = NO;
- req.message = message;
- req.scene = type;
- [WXApi sendReq:req];
-
- } else {
- [GlobalMethod showAlert:@"你还没有安装微信"];
- }
- }
- @end
|