96 lines
3.6 KiB
Objective-C
Executable File
96 lines
3.6 KiB
Objective-C
Executable File
//
|
|
// SPFocusFansCell.m
|
|
// SweetParty
|
|
//
|
|
// Created by bj_szd on 2022/6/8.
|
|
//
|
|
|
|
#import "SPFocusFansCell.h"
|
|
|
|
@interface SPFocusFansCell ()
|
|
|
|
@property(nonatomic, strong) SPFocusFansModel *model;
|
|
@property(nonatomic, assign) NSInteger type;
|
|
|
|
@end
|
|
|
|
@implementation SPFocusFansCell
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
|
|
}
|
|
|
|
- (void)onUpdateSPFocusFansCell:(SPFocusFansModel *)model type:(NSInteger)type {
|
|
self.model = model;
|
|
self.type = type;
|
|
|
|
if (model.is_online == 1) {
|
|
self.onlineStatus.image = ImageNamed(@"msg_online");
|
|
}else {
|
|
self.onlineStatus.image = ImageNamed(@"msg_offline");
|
|
}
|
|
|
|
if (type == 3) {
|
|
self.avatarImgV.layer.cornerRadius = 16;
|
|
[self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:model.room_cover] placeholderImage:kDefaultUserIcon];
|
|
self.nicknameLab.text = model.room_name;
|
|
self.IDLab.text = [NSString stringWithFormat:@"%@", model.room_number];
|
|
if (model.is_collect) {
|
|
[self.focusBtn setTitle:@"取消收藏" forState:UIControlStateNormal];
|
|
[self.focusBtn setTitleColor:HEXCOLOR(0x999999) forState:UIControlStateNormal];
|
|
self.focusBtn.backgroundColor = HEXCOLORA(0xFFFFFF,0.2);
|
|
self.focusBtn.layer.borderWidth = 1;
|
|
self.focusBtn.layer.borderColor = HEXCOLOR(0x999999).CGColor;
|
|
}else {
|
|
[self.focusBtn setTitle:@"收藏" forState:UIControlStateNormal];
|
|
[self.focusBtn setTitleColor:HEXCOLOR(0xFFFFFF) forState:UIControlStateNormal];
|
|
self.focusBtn.layer.borderWidth = 0;
|
|
[self.focusBtn styleGradiBlueColor];
|
|
}
|
|
}else {
|
|
[self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.nicknameLab.text = model.nick_name;
|
|
self.IDLab.text = [NSString stringWithFormat:@"%@", model.uid];
|
|
self.sexImgV.image = model.sex == 1 ? ImageNamed(@"sex_nan") : ImageNamed(@"sex_nv");
|
|
if (model.is_follow == 1) {
|
|
[self.focusBtn setImage:ImageNamed(@"mine_focus_sel_all") forState:UIControlStateNormal];
|
|
}else {
|
|
if (type == 2) {
|
|
[self.focusBtn setImage:ImageNamed(@"mine_focus_nor") forState:UIControlStateNormal];
|
|
}else {
|
|
[self.focusBtn setImage:ImageNamed(@"mine_focus_sel") forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- (IBAction)onFocus:(id)sender {
|
|
if (self.type == 3) {
|
|
NSDictionary *params = @{@"rid":C_string(self.model.rid)};
|
|
NSString *urlStr = self.model.is_collect ? @"api/room/un_collect_room" : @"api/room/collect_room";
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
SPFocusFansModel *model = self.model;
|
|
model.is_collect = !model.is_collect;
|
|
[self onUpdateSPFocusFansCell:model type:self.type];
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}else {
|
|
NSDictionary *params = @{@"follow_uid":C_string(self.model.uid)};
|
|
NSString *urlStr = @"api/user/unfollow_user";
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
// SPFocusFansModel *model = self.model;
|
|
// model.is_follow = model.is_follow==1 ? 2 : 1;
|
|
// [self onUpdateSPFocusFansCell:model type:self.type];
|
|
if (self.refreshAction) {
|
|
self.refreshAction();
|
|
}
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
}
|
|
|
|
@end
|