1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // YMFriendsListCellViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/1.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMFriendsListCellViewModel.h"
- #import "YMRelationModel.h"
- @interface YMFriendsListCellViewModel ()
- /// 是否隐藏提醒
- @property (nonatomic, assign, readwrite) BOOL isHideReminder;
- /// 用户Id
- @property (nonatomic, assign, readwrite) NSInteger userId;
- /// 用户头像
- @property (nonatomic, copy, readwrite) NSString *userAvatar;
- /// 用户名称
- @property (nonatomic, copy, readwrite) NSString *userNickname;
- /// 用户描述
- @property (nonatomic, copy, readwrite) NSString *userDesc;
- /// 是否关注
- @property (nonatomic, assign, readwrite) BOOL isFollow;
- /// 是否互相关注
- @property (nonatomic, assign, readwrite) BOOL isMutualConcerns;
- @end
- @implementation YMFriendsListCellViewModel
- - (void)ym_initialize{
- [super ym_initialize];
- if ([self.params[ParamsModel] isKindOfClass:[YMRelationModel class]]) {
- YMRelationModel *model = self.params[ParamsModel];
- self.isHideReminder = model.is_watch > 0 ? YES : NO;
- self.userId = model.userid;
- self.userAvatar = model.avatar;
- self.userNickname = model.nickname;
- NSMutableString *desc = [NSMutableString string];
- if (model.gender == 1) {
- [desc appendFormat:@"女 | "];
- }else{
- [desc appendFormat:@"男 | "];
- }
-
- if (model.age != 0) {
- [desc appendFormat:@"%ld岁 | ",model.age];
- }
-
- self.userDesc = [desc substringToIndex:desc.length - 2];
-
- self.isFollow = model.is_follow;
- self.isMutualConcerns = model.is_fans;
- }
-
- }
- - (void)followUser{
- [LCHttpHelper requestWithURLString:UserFollow parameters:@{
- @"follow_uid":@(self.userId),
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
-
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
- NSString *action = [data stringValueForKey:@"action" defaultValue:@""];
- if ([action isEqualToString:@"add"]) {
- [ZCHUDHelper showTitle:@"已关注"];
- self.isFollow = YES;
- }else if ([action isEqualToString:@"delete"]){
- [ZCHUDHelper showTitle:@"已取消关注"];
- self.isFollow = NO;
- }
- if (self.changeFollowStatusBlock) {
- self.changeFollowStatusBlock();
- }
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- @end
|