| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- //
- // BogoNewsSystemViewController.m
- // BuguLive
- //
- // Created by 宋晨光 on 2021/5/14.
- // Copyright © 2021 xfg. All rights reserved.
- //
- #import "BogoNewsSystemViewController.h"
- #import "ChatFriendCell.h"
- #import "ChatTradeCell.h"
- #import "BGBaseChatController.h"
- #import "BGConversationServiceController.h"
- #import "IMModel.h"
- #import "JSBadgeView.h"
- #import "M80AttributedLabel.h"
- #import "BGSystemMsgModel.h"
- #import "MsgCellRight.h"
- #import "MsgTimeCell.h"
- @interface BogoNewsSystemViewController ()<UITableViewDelegate, UITableViewDataSource>
- @property(nonatomic, strong) UILabel *titleL;
- @property(nonatomic, strong) UIButton *backBtn;
- @end
- @implementation BogoNewsSystemViewController{
- // int _select; //1.交易 2.好友 3.未关注
- int _page; //页数
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:YES animated:NO];
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)viewDidLoad
- {
-
- // self.title = @"系统消息";
-
- _conversationArr = NSMutableArray.new;
- _page = 1;
- self.mTableView = [[UITableView alloc] initWithFrame:CGRectZero];
- self.mTableView.delegate = self;
- self.mTableView.dataSource = self;
- self.mTableView.backgroundColor = kBackGroundColor;
- [self.view addSubview:self.mTableView];
- self.mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-
- UINib *nib = [UINib nibWithNibName:@"MsgCellLeft" bundle:nil];
- [self.mTableView registerNib:nib forCellReuseIdentifier:@"leftcell"];
- nib = [UINib nibWithNibName:@"MsgCellRight" bundle:nil];
- // [self.mtableview registerNib:nib forCellReuseIdentifier:@"rightcell"];
- nib = [UINib nibWithNibName:@"MsgTimeCell" bundle:nil];
- [self.mTableView registerNib:nib forCellReuseIdentifier:@"timecell"];
-
- [BGMJRefreshManager refresh:self.mTableView target:self headerRereshAction:@selector(headerStartRefresh) footerRereshAction:nil];
-
-
- self.titleL = [[UILabel alloc]initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenW, kTopHeight - kStatusBarHeight)];
- self.titleL.text =ASLocalizedString( @"系统消息");
- self.titleL.textAlignment = NSTextAlignmentCenter;
- self.titleL.font = [UIFont systemFontOfSize:18];
- [self.view addSubview:self.titleL];
-
- self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [self.backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
- [self.backBtn addTarget:self action:@selector(clickBackBtn:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:self.backBtn];
-
- self.titleL.centerX = kScreenW / 2;
- self.backBtn.frame = CGRectMake(kRealValue(10), kStatusBarHeight, kRealValue(40), kRealValue(40));
-
- [self requestPageWithIndex:_page];
- [self.view addSubview:self.mTableView];
- [self.mTableView setFrame:CGRectMake(0, kTopHeight, kScreenW, kScreenHeight - kTopHeight - MG_BOTTOM_MARGIN)];
-
- self.mTableView.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
-
- id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
- UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
- [self.view addGestureRecognizer:pan];
- }
- -(void)clickBackBtn:(UIButton *)sender{
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)requestPageWithIndex:(NSInteger)pageIndex{
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
-
- [parmDict setObject:@"index" forKey:@"ctl"];
- [parmDict setObject:@"msg_list" forKey:@"act"];
- [parmDict setObject:[NSString stringWithFormat:@"%ld",pageIndex] forKey:@"p"];
-
- FWWeakify(self)
-
- [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- FWStrongify(self)
- if (_page == 1) {
- [_conversationArr removeAllObjects];
-
- }
-
- NSArray *arr = [NSArray modelArrayWithClass:[BGSystemMsgModel class] json:responseJson[@"list"]];
- for (int i = 0; i < arr.count ; i ++) {
-
- BGSystemMsgModel *timemodel = [BGSystemMsgModel new];
-
-
-
- BGSystemMsgModel *model = arr[i];
- model.mMsgType = 1;
-
- timemodel.mMsgType = 0;
- timemodel.addtime = model.addtime;
-
- [_conversationArr addObject:timemodel];
- [_conversationArr addObject:model];
- }
-
- // [_conversationArr addObjectsFromArray:arr];
-
- [BGMJRefreshManager endRefresh:self.mTableView];
-
- [_mTableView reloadData];
-
- } FailureBlock:^(NSError *error) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [BGMJRefreshManager endRefresh:self.mTableView];
- });
- }];
- }
- - (void)updateTableViewFrame
- {
- CGFloat tableViewHeight;
- if (!self.isHaveLive)
- {
- tableViewHeight = kScreenH - 64;
- }
- else
- {
- tableViewHeight = kScreenH / 2 - 44;
- }
- [self.mTableView setFrame:CGRectMake(0, 0, kScreenW, tableViewHeight)];
- }
- #pragma mrak-- ------------------------消息通知-- ------------------------
- - (void)IMChatMsgNotficationInList:(NSNotification *)notfication
- {
- if (![NSThread isMainThread])
- {
- [self performSelectorOnMainThread:@selector(IMChatMsgNotficationInList:) withObject:notfication waitUntilDone:NO];
- return;
- }
- SFriendObj *bfindone = nil;
- SIMMsgObj *thatmsg = notfication.object;
- for (SFriendObj *one in _conversationArr)
- {
- if (one.mUser_id == thatmsg.mSenderId)
- {
- bfindone = one;
- break;
- }
- }
- if (bfindone)
- {
- [bfindone setLMsg:thatmsg.mCoreTMsg];
- [self.mTableView reloadData];
- }
- }
- - (void)headerStartRefresh
- {
- [self requestPageWithIndex:1];
-
- }
- #pragma mark----------------------tableView的协议方法------------------------
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- // if (_conversationArr.count > 0) {
- return _conversationArr.count;
- // }
- // return 0;
- }
- - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return UITableViewAutomaticDimension;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return UITableViewAutomaticDimension;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
- BGSystemMsgModel *msgobj = nil;
- if (_conversationArr.count > 0) {
- msgobj = _conversationArr[indexPath.row];
- }
- MsgCellRight *retcell = [MsgCellRight new];
-
- if (msgobj.mMsgType == 1)
- { //文字消息
- retcell = [tableView dequeueReusableCellWithIdentifier:@"leftcell"];
-
- retcell.mheadimg.image = [UIImage imageNamed:@"bogo_news_top_system"];
- [retcell.mmsglabel dealFace:msgobj.content];
- CGSize ss = [retcell.mmsglabel sizeThatFits:CGSizeMake(tableView.bounds.size.width - 73 - 50, CGFLOAT_MAX)];
- retcell.mlabelconstH.constant = ss.height;
- retcell.mlabelconstW.constant = ss.width;
- retcell.backgroundColor = kClearColor;
- retcell.selectionStyle = UITableViewCellSelectionStyleNone;
- return retcell;
- }
- else
- { //其他什么鬼...其他所有消息都当真时间消息处理了....
- MsgTimeCell *timecell = [tableView dequeueReusableCellWithIdentifier:@"timecell"];
- timecell.mbgview.layer.borderWidth = 0.0f;
- timecell.mbgview.backgroundColor = kClearColor;
- timecell.mtimelabel.text = msgobj.addtime;
- timecell.mtimelabel.textColor = [UIColor colorWithHexString:@"#AAAAAA"];
- timecell.mtimelabel.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
- // [msgobj getTimeStr];
- timecell.selectionStyle = UITableViewCellSelectionStyleNone;
- return timecell;
- }
-
- retcell.selectionStyle = UITableViewCellSelectionStyleNone;
- retcell.backgroundColor = [UIColor clearColor];
- return retcell;
-
- }
- #pragma mark 点击单元格的方法
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- #pragma mark-----------------------删除单元格方法------------------------
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return NO;
- }
- - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return ASLocalizedString(@"删除");
- }
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // if (editingStyle == UITableViewCellEditingStyleDelete)
- // {
- // SFriendObj *oneobj = nil;
- // oneobj = [_conversationArr objectAtIndex:indexPath.row];
- // [SVProgressHUD showWithStatus:ASLocalizedString(@"操作中...")];
- //
- // [oneobj delThis:^(SResBase *resb) {
- //
- // if (resb.msuccess)
- // {
- // [SVProgressHUD dismiss];
- // [_conversationArr removeObjectAtIndex:indexPath.row];
- //
- // [self.mTableView beginUpdates];
- // [self.mTableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
- // [self.mTableView endUpdates];
- // //获取角标
- // [self reloadItem:_select];
- //
- // }
- // else
- // {
- // [SVProgressHUD showErrorWithStatus:resb.mmsg];
- // }
- //
- // }];
- // if (_conversationArr.count == 0) {
- // [self showNoContentView];
- // if (_isHaveLive)
- // {
- // self.noContentView.center = CGPointMake(self.view.frame.size.width/2, 87.5+40);
- // }
- // }
- // }
- }
- - (void)reloadItem:(int)selectItem
- {
- // if ([self.delegate respondsToSelector:@selector(reloadChatBadge:)])
- // {
- // [self.delegate reloadChatBadge:selectItem];
- // }
- }
- - (void)updateItem:(int)unReadNum
- {
- // if ([self.delegate respondsToSelector:@selector(updateChatFriendBadge:)])
- // {
- // [self.delegate updateChatFriendBadge:unReadNum];
- // }
- }
- - (void)itemBtnClick:(SFriendObj *)obj
- {
- // if ([self.delegate respondsToSelector:@selector(clickFriendItem:)])
- // {
- // [self.delegate clickFriendItem:obj];
- // }
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|