123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- //
- // YOUPAIHRChatRoomContributeDetailVC.m
- // VQU
- //
- // Created by xiaohaoran on 2021/11/3.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIHRChatRoomContributeDetailVC.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAILZChatRoomInviationUpSeatCell.h"
- #import "YOUPAILZChatRoomCurrentMemberView.h"
- @interface YOUPAIHRChatRoomContributeDetailVC () <UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, weak) UITableView *youpaiptableView;
- @property (nonatomic, assign) NSInteger youpaippage;
- @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomMemberModel *>*youpaipdataSource;
- @property (nonatomic, weak) YOUPAILZChatRoomCurrentMemberView *youpaipfooterView;
- @end
- @implementation YOUPAIHRChatRoomContributeDetailVC
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self youpaifinitUI];
-
- /// 关注状态改变,接收通知
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifchangeFollowStateNotification:) name:@"ChangeFollowState" object:nil];
- [self youpaifrequestRankListWithStatus:kRefreshNormal];
- }
- - (void)youpaifchangeFollowStateNotification:(NSNotification *)notification{
- NSDictionary *dict = [notification userInfo];
- NSString *idStr = dict[@"follow_uid"];
- NSInteger isfollow = [dict[@"is_follow"] intValue];
- NSArray *arr = self.youpaipdataSource;
- NSMutableArray *arrM = [NSMutableArray new];
- if (arr.count>0) {
- for (int i = 0; i<arr.count; i++) {
- YOUPAILZChatRoomMemberModel *model = arr[i];
- if ([model.youpaipid isEqualToString:idStr]) {
- model.youpaipis_follow = isfollow;
- }
- [arrM addObject:model];
- }
- [self.youpaipdataSource removeAllObjects];
- self.youpaipdataSource = arrM;
- [self.youpaiptableView reloadData];
- }
- }
- - (void)youpaifinitUI{
-
- YOUPAILZChatRoomCurrentMemberView *youpaipfooterView = [[YOUPAILZChatRoomCurrentMemberView alloc] init];
- youpaipfooterView.backgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(KScreenWidth, 60.0f + SafeHeight) FromColors:@[HexColorFromRGB(0xE41E84),HexColorFromRGB(0xEE6942)] ByGradientType:GradientLeftToRight]];
- [self.view addSubview:youpaipfooterView];
- self.youpaipfooterView = youpaipfooterView;
- [youpaipfooterView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.offset(0.0f);
- make.height.offset(60.0f + SafeHeight);
- }];
- UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- tableView.delegate = self;
- tableView.dataSource = self;
- tableView.rowHeight = 60.0f;
- tableView.estimatedRowHeight = 60.0f;
- tableView.estimatedSectionHeaderHeight = 0.0f;
- tableView.estimatedSectionFooterHeight = 0.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
- @weakify(self);
- [tableView setRefreshHeaderWithBlock:^{
- @strongify(self);
- [self youpaifrequestRankListWithStatus:kRefreshHeader];
- }];
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.offset(0.0f);
- make.bottom.equalTo(self.youpaipfooterView.mas_top);
- }];
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *cellID = @"YOUPAILZChatRoomInviationUpSeatCell";
- YOUPAILZChatRoomInviationUpSeatCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[YOUPAILZChatRoomInviationUpSeatCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- NSString *contributionName = @"贡献值";
- if (self.youpaiptype == 1) {
- contributionName = @"魅力值";
- }
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] index:indexPath.row buttonType:LZChatRoomInviationUpSeatCellButtonTypeWithFollow rankType:LZChatRoomInviationUpSeatCellRankTypeWithTopThree contributionName:contributionName];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.youpaiptouchUserBlock != nil) {
- self.youpaiptouchUserBlock(self.youpaipdataSource[indexPath.row].youpaipid);
- }
- }
- /// 设置加载更多
- - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
- @weakify(self);
- [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
- @strongify(self);
- [self youpaifrequestRankListWithStatus:kRefreshFooter];
- }];
- }
- - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{
- if (status == kRefreshFooter) {
- self.youpaippage ++;
- }else{
- self.youpaippage = 1;
- }
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetTalkUserRank parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"page":@(self.youpaippage),@"type":@(self.youpaiptype)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- if (status != kRefreshFooter) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSDictionary *data = [dict objectForKey:@"data"];
- NSArray <YOUPAILZChatRoomMemberModel *>*list = [YOUPAILZChatRoomMemberModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
- YOUPAILZChatRoomMemberModel *youpaipmemberModel = [YOUPAILZChatRoomMemberModel mj_objectWithKeyValues:[data objectForKey:@"current"]];
- NSString *contributionName = @"贡献值";
- if (self.youpaiptype == 1) {
- contributionName = @"魅力值";
- }
- [self.youpaipfooterView youpaifreloadWithModel:youpaipmemberModel contributionName:contributionName];
- NSInteger youpaiptotalPage = [[data objectForKey:@"total_page"] integerValue];
- [self youpaifrefreshFooterWithHidden:self.youpaippage >= youpaiptotalPage];
- }
- } failure:^(NSError *error) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- }];
- }
- - (NSMutableArray<YOUPAILZChatRoomMemberModel *> *)youpaipdataSource{
- if (!_youpaipdataSource) {
- _youpaipdataSource = [NSMutableArray array];
- }
- return _youpaipdataSource;
- }
- #pragma mark - JXCategoryListContentViewDelegate
- - (UIView *)listView{
- return self.view;
- }
- @end
|