Commit 2806b8a8 cgx

完成官方通知页面、优化消息中心及社区动态列表

1 个父辈 cccb0f4c
......@@ -134,6 +134,9 @@
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; };
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; };
D07827FC28FE424700C8D612 /* PraiseListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D07827FB28FE424700C8D612 /* PraiseListViewModel.m */; };
D078281628FE939400C8D612 /* OfficialNotiViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281528FE939400C8D612 /* OfficialNotiViewModel.m */; };
D078281C28FE94CA00C8D612 /* OfficialNotiCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281B28FE94CA00C8D612 /* OfficialNotiCell.m */; };
D078281F28FE953A00C8D612 /* OfficialNotiModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281E28FE953A00C8D612 /* OfficialNotiModel.m */; };
D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B26280E9BAA00BA0EC0 /* AccountController.m */; };
D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B29280EA6B600BA0EC0 /* UserInfoTableView.m */; };
D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */; };
......@@ -560,6 +563,12 @@
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; };
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PraiseListViewModel.h; sourceTree = "<group>"; };
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PraiseListViewModel.m; sourceTree = "<group>"; };
D078281428FE939400C8D612 /* OfficialNotiViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OfficialNotiViewModel.h; sourceTree = "<group>"; };
D078281528FE939400C8D612 /* OfficialNotiViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OfficialNotiViewModel.m; sourceTree = "<group>"; };
D078281A28FE94CA00C8D612 /* OfficialNotiCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OfficialNotiCell.h; sourceTree = "<group>"; };
D078281B28FE94CA00C8D612 /* OfficialNotiCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OfficialNotiCell.m; sourceTree = "<group>"; };
D078281D28FE953A00C8D612 /* OfficialNotiModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OfficialNotiModel.h; sourceTree = "<group>"; };
D078281E28FE953A00C8D612 /* OfficialNotiModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OfficialNotiModel.m; sourceTree = "<group>"; };
D07A4B25280E9BAA00BA0EC0 /* AccountController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountController.h; sourceTree = "<group>"; };
D07A4B26280E9BAA00BA0EC0 /* AccountController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountController.m; sourceTree = "<group>"; };
D07A4B28280EA6B600BA0EC0 /* UserInfoTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserInfoTableView.h; sourceTree = "<group>"; };
......@@ -1603,6 +1612,8 @@
D053D0E728F41FB300BB2B84 /* MessageComReplyCell.m */,
D0E3564A28F56181007190EE /* PraiseCell.h */,
D0E3564B28F56181007190EE /* PraiseCell.m */,
D078281A28FE94CA00C8D612 /* OfficialNotiCell.h */,
D078281B28FE94CA00C8D612 /* OfficialNotiCell.m */,
);
path = View;
sourceTree = "<group>";
......@@ -1616,6 +1627,8 @@
D003140828FD469B00E01A6A /* MessageComReplyModel.m */,
D0E3564D28F5651C007190EE /* PraiseModel.h */,
D0E3564E28F5651C007190EE /* PraiseModel.m */,
D078281D28FE953A00C8D612 /* OfficialNotiModel.h */,
D078281E28FE953A00C8D612 /* OfficialNotiModel.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -1625,6 +1638,8 @@
children = (
D003140428FD449E00E01A6A /* MessageCenterViewModel.h */,
D003140528FD449E00E01A6A /* MessageCenterViewModel.m */,
D078281428FE939400C8D612 /* OfficialNotiViewModel.h */,
D078281528FE939400C8D612 /* OfficialNotiViewModel.m */,
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */,
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */,
);
......@@ -2815,6 +2830,7 @@
D053D0DF28F40C6A00BB2B84 /* MessageController.m in Sources */,
D043A8B6287EBA4000226176 /* ReadyItemView.m in Sources */,
D09BF331280E570D00E5F06C /* UserModel.m in Sources */,
D078281C28FE94CA00C8D612 /* OfficialNotiCell.m in Sources */,
D0B8C39E28F935D000279AA6 /* ComDynListResultModel.m in Sources */,
D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */,
D091E674283F5B4200D3279E /* ScoreDetailModel.m in Sources */,
......@@ -2870,6 +2886,7 @@
D0F808F52803D4E70097899F /* Track.m in Sources */,
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */,
D0C50B3C27FD2EFD00DC68F0 /* PrivacyViewController.m in Sources */,
D078281628FE939400C8D612 /* OfficialNotiViewModel.m in Sources */,
D0E3563D28F55A27007190EE /* OfficialNoticeController.m in Sources */,
D0AE1E3528281B6F008CEF27 /* TimerProxy.m in Sources */,
D0498874286E95F2000ACF55 /* DsTaskManager.m in Sources */,
......@@ -2905,6 +2922,7 @@
D0E41B602851E0F6005A7DA4 /* ShareItem.m in Sources */,
D0506B1828054ECD00229278 /* SafeHelperCollectionView.m in Sources */,
D0E41B5D2851E0D1005A7DA4 /* ShareRequestModel.m in Sources */,
D078281F28FE953A00C8D612 /* OfficialNotiModel.m in Sources */,
D04B3DC327F6F9390022F8DF /* HomeViewController.m in Sources */,
D0F9AC5E282660CC00FD7A3B /* MusicPlayerView.m in Sources */,
D091E668283F0E8800D3279E /* MyPointController.m in Sources */,
......
......@@ -12,6 +12,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 基类控制器
@interface BaseViewController : UIViewController
- (void)dealErrorWithType:(ExceptionType)type errInfo:(NSString *)errInfo;
- (void)refreshHandle;
@end
NS_ASSUME_NONNULL_END
......@@ -6,9 +6,10 @@
//
#import "BaseViewController.h"
#import "ExceptionDefaultView.h"
@interface BaseViewController ()
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
@end
@implementation BaseViewController
......@@ -18,9 +19,33 @@
}
#pragma mark - public
- (void)dealErrorWithType:(ExceptionType)type errInfo:(NSString *)errInfo {
self.exceptionView.hidden = NO;
[self.exceptionView updateExceptionViewWithType:type];
if (type == ExceptionTypeNet) {
[self.exceptionView showServerErrInfo:errInfo];
}
}
- (void)refreshHandle {
self.exceptionView.hidden = YES;
}
#pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle {
return NaviStyleDefault;
}
#pragma mark - lazy
- (ExceptionDefaultView *)exceptionView {
if (!_exceptionView) {
WS(weakSelf);
_exceptionView = [[ExceptionDefaultView alloc] initWithType:ExceptionTypeNet block:^{
[weakSelf refreshHandle];
} superView:self.view];
}
return _exceptionView;
}
@end
......@@ -34,7 +34,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
......@@ -63,7 +63,7 @@
- (void)testDynDeleteAPI {
#warning - 测试删除接口
self.personDynViewModel = [PersonDynViewModel new];
self.personDynViewModel.oper_type = @"comment";
self.personDynViewModel.delete_id = 18;
......@@ -92,15 +92,16 @@
[self.comListViewModel querySleepDynamicListWithLoadMore:loadMore offset:self.offset completion:^(ComListViewModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
if (loadMore) {
if (self.offset > requestModel.totalCount) {
[DSProgressHUD showToast:@"无更多动态"];
[self.communityView updateCommunityMoments:loadMore];
return;
if (requestModel.latestDataList.count == 0) {
if (loadMore) {
[self.communityView endRefreshingWithNoMoreData];
} else {
[self.communityView endRefreshing:NO];
}
} else {
self.offset++;
[self.communityView updateCommunityMoments:loadMore];
}
self.offset++;
[self.communityView updateCommunityMoments:loadMore];
} else {
[DSProgressHUD showToast:requestModel.errMessage];
[self.communityView endRefreshing:loadMore];
......
......@@ -52,6 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 结束加载动画
- (void)endRefreshing:(BOOL)loadMore;
- (void)endRefreshingWithNoMoreData;
/// 显示举报、取消弹框
- (void)showInformCancelView;
......
......@@ -46,16 +46,21 @@
#pragma mark - public
- (void)updateCommunityMoments:(BOOL)loadMore {
[self endRefreshing:loadMore];
[self.listView reloadData];
}
- (void)endRefreshing:(BOOL)loadMore {
if (loadMore) {
[self.listView.mj_footer endRefreshing];
} else {
[self.listView.mj_header endRefreshing];
[self.listView.mj_footer resetNoMoreData];
}
[self.listView reloadData];
}
- (void)endRefreshing:(BOOL)loadMore {
loadMore ? [self.listView.mj_footer endRefreshing] : [self.listView.mj_header endRefreshing];
- (void)endRefreshingWithNoMoreData {
[self.listView.mj_footer endRefreshingWithNoMoreData];
}
- (void)showInformCancelView {
......
......@@ -14,8 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 社区动态列表、用户点赞
@interface ComListViewModel : DSNetworkTool
/// 对外提供总页数
@property (nonatomic, assign) int totalCount;
/// 服务器返回最新某一页的列表数据
@property (nonatomic, strong) NSArray *latestDataList;
/// 对外提供的社区动态列表数据
@property (nonatomic, strong) NSArray *listArr;
/// 自定义字段,用于标识是否是官方发布的动态
......
......@@ -36,15 +36,15 @@
self.resCode = DSResCodeSuccess;
self.resultModel = [ComDynListResultModel yy_modelWithDictionary:apiDic[@"result"]];
// 2、根据业务需要的数据结构对数据进行加工
NSArray *lastes_data_list = self.resultModel.data_list ?: @[];
NSArray *latest_data_list = self.resultModel.data_list ?: @[];
self.latestDataList = latest_data_list;
if (loadMore) {
NSMutableArray *tmp_list_arr = [NSMutableArray arrayWithArray:self.listArr];
[tmp_list_arr addObjectsFromArray:lastes_data_list.copy];
[tmp_list_arr addObjectsFromArray:latest_data_list.copy];
self.listArr = tmp_list_arr.copy;
} else {
self.listArr = lastes_data_list.copy;
self.listArr = latest_data_list.copy;
}
self.totalCount = self.resultModel.count;
// 3、如果是官方发布的动态,则放在第一位,并且只插入1次
NSMutableArray *newList = [NSMutableArray arrayWithArray:self.listArr];
__block BOOL hasOfficialModel = NO;
......
......@@ -6,9 +6,12 @@
//
#import "OfficialNoticeController.h"
#import "OfficialNotiCell.h"
#import "OfficialNotiViewModel.h"
@interface OfficialNoticeController ()
@interface OfficialNoticeController () <UITableViewDelegate>
@property (nonatomic, strong) DSDataSource *dataSource;
@property (nonatomic, strong) UITableView *listView;
@end
@implementation OfficialNoticeController
......@@ -18,6 +21,67 @@
self.navigationItem.title = @"官方通知";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.dataSource addDataArray:@[]];
[self.listView.mj_header beginRefreshing];
}
- (void)getListDataRequest {
[OfficialNotiViewModel queryUserOfficeMessagesWithCompletion:^(OfficialNotiViewModel * _Nonnull viewModel) {
[self.listView.mj_header endRefreshing];
if (viewModel.resCode == DSResCodeSuccess) {
if (viewModel.listArr.count == 0) {
[self dealErrorWithType:ExceptionTypeNoData errInfo:@""];
} else {
[self.dataSource addDataArray:viewModel.listArr];
[self.listView reloadData];
}
} else {
[self dealErrorWithType:ExceptionTypeNet errInfo:viewModel.errMessage];
}
}];
}
- (void)refreshHandle {
[super refreshHandle];
[self getListDataRequest];
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
OfficialNotiModel *model = self.dataSource.dataArray[indexPath.row];
return [model cellHeight];
}
#pragma mark - lazy
- (DSDataSource *)dataSource {
if (!_dataSource) {
CellConfigureBlock cellBlock = ^(OfficialNotiCell * cell, OfficialNotiModel * model, NSIndexPath * indexPath) {
cell.officialNotiModel = model;
};
_dataSource = [[DSDataSource alloc] initWithIdentifier:NSStringFromClass([OfficialNotiCell class]) datas:@[] isSection:NO configureBlock:cellBlock];
UITableView *listView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
listView.separatorStyle = UITableViewCellSeparatorStyleNone;
listView.delegate = self;
listView.dataSource = _dataSource;
listView.showsVerticalScrollIndicator = NO;
listView.backgroundColor = DSClearColor;
listView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[listView registerClass:[OfficialNotiCell class] forCellReuseIdentifier:NSStringFromClass([OfficialNotiCell class])];
[self.view addSubview:listView];
self.listView = listView;
WS(weakSelf);
self.listView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
[weakSelf getListDataRequest];
}];
[self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
}
return _dataSource;
}
@end
......@@ -61,6 +61,9 @@
}
if (loadMore) {
if (viewModel.resultArr.count == 0) {
[self.tableView.mj_footer endRefreshingWithNoMoreData];
}
[self.praiseList addObjectsFromArray:viewModel.resultArr];
} else {
self.offset++;
......@@ -70,7 +73,11 @@
[self.dataSource addDataArray:self.praiseList];
[self.tableView reloadData];
} else {
[self dealErrorWithType:ExceptionTypeNet errInfo:viewModel.errMessage];
if (self.praiseList.count) {
[DSProgressHUD showToast:viewModel.errMessage];
} else {
[self dealErrorWithType:ExceptionTypeNet errInfo:viewModel.errMessage];
}
}
}];
}
......
//
// OfficialNotiModel.h
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 官方通知数据model
@interface OfficialNotiModel : NSObject
@property (nonatomic, assign) NSInteger identifier;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *content;
@property (nonatomic, copy) NSString *imgs;
@property (nonatomic, assign) NSInteger status;
@property (nonatomic, copy) NSString *publishTime;
+ (CGFloat)leftMargin;
+ (UIFont *)contentFont;
- (CGFloat)cornerViewH;
- (CGFloat)cellHeight;
@end
NS_ASSUME_NONNULL_END
//
// OfficialNotiModel.m
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "OfficialNotiModel.h"
@implementation OfficialNotiModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"identifier" : @"id",
@"publishTime" : @"publish_time",
};
}
+ (CGFloat)leftMargin {
return 15;
}
+ (UIFont *)contentFont {
return SysFont(14);
}
- (CGFloat)cornerViewH {
CGFloat topH = 45;
CGFloat contentH = [UILabel getHeightByWidth:(kScreenWidth - 4 * [OfficialNotiModel leftMargin]) text:self.content font:[OfficialNotiModel contentFont]];
CGFloat bottomMargin = 15;
return topH + contentH + bottomMargin;
}
- (CGFloat)cellHeight {
return 47 + [self cornerViewH];
}
@end
//
// OfficialNotiCell.h
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "BaseTableViewCell.h"
#import "OfficialNotiModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 官方通知消息详情列表cell
@interface OfficialNotiCell : BaseTableViewCell
@property (nonatomic, strong) OfficialNotiModel *officialNotiModel;
@end
NS_ASSUME_NONNULL_END
//
// OfficialNotiCell.m
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "OfficialNotiCell.h"
@interface OfficialNotiCell ()
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UIView *cornerView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, assign) CGFloat margin;
@end
@implementation OfficialNotiCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.margin = [OfficialNotiModel leftMargin];
[self.contentView addSubview:self.timeLab];
[self.contentView addSubview:self.cornerView];
[self.cornerView addSubview:self.titleLab];
[self.cornerView addSubview:self.contentLab];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(self.margin);
make.centerX.equalTo(self.contentView);
}];
}
return self;
}
- (void)setOfficialNotiModel:(OfficialNotiModel *)officialNotiModel {
_officialNotiModel = officialNotiModel;
self.timeLab.text = officialNotiModel.publishTime;
self.titleLab.text = officialNotiModel.title;
self.contentLab.text = officialNotiModel.content;
[self.cornerView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(self.margin);
make.top.equalTo(self.contentView).offset(47);
make.right.equalTo(self.contentView).offset(-self.margin);
make.height.equalTo(@([officialNotiModel cornerViewH]));
}];
[self.titleLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self.cornerView).offset([OfficialNotiModel leftMargin]);
}];
[self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(45, self.margin, self.margin, self.margin));
}];
}
#pragma mark - lazy
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12)];
_timeLab.textAlignment = NSTextAlignmentCenter;
_timeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _timeLab;
}
- (UIView *)cornerView {
if (!_cornerView) {
_cornerView = [UIView new];
_cornerView.dk_backgroundColorPicker = DKColorPickerWithKey(CornerViewBG);
[_cornerView cornerRadius:24];
}
return _cornerView;
}
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [UILabel labWithFont:BoldFont(16)];
_titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
}
return _titleLab;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:[OfficialNotiModel contentFont]];
_contentLab.numberOfLines = 0;
_contentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
}
return _contentLab;
}
@end
......@@ -102,13 +102,22 @@
DSLog(@"社区动态消息中心官方和点赞统计未读通知接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resutDic = apiDic[@"result"];
NSDictionary *messageDic = resutDic[@"message"];
NSDictionary *praiseDic = resutDic[@"praise"];
NSString *officialContent = messageDic[@"content"];
NSString *praiseContent = praiseDic[@"nick_name"] ? [NSString stringWithFormat:@"%@赞了你的动态", praiseDic[@"nick_name"]] : @"";
NSString *officialIcon = messageDic[@"icon"] ?: @"";
NSString *praiseIcon = praiseDic[@"icon"] ?: @"";
NSArray *titleArr = @[@"官方通知", @"收到的赞"];
NSArray *detailArr = @[@"暂无消息", @"好高好高好高好高好高好"];
NSArray *messageCountArr = @[resutDic[@"message_count"], resutDic[@"praise_count"]];
NSArray *detailArr = @[officialContent, praiseContent];
NSArray *messageCountArr = @[messageDic[@"count"], praiseDic[@"count"]];
NSArray *iconArr = @[officialIcon, praiseIcon];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < 2; i++) {
MessageOfficialModel *officialModel = [MessageOfficialModel new];
officialModel.iconName = @"";
officialModel.iconName = iconArr[i];
officialModel.title = titleArr[i];
officialModel.detail = detailArr[i];
officialModel.messageCount = [messageCountArr[i] intValue];
......
//
// OfficialNotiViewModel.h
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface OfficialNotiViewModel : DSNetworkTool
@property (nonatomic, strong) NSArray *listArr;
/// 查询用户官方系统消息列表接口
/// @param completion completion
+ (NSURLSessionDataTask *)queryUserOfficeMessagesWithCompletion:(void (^)(OfficialNotiViewModel *viewModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// OfficialNotiViewModel.m
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "OfficialNotiViewModel.h"
#import "OfficialNotiModel.h"
@implementation OfficialNotiViewModel
+ (NSURLSessionDataTask *)queryUserOfficeMessagesWithCompletion:(void (^)(OfficialNotiViewModel *viewModel))completion {
OfficialNotiViewModel *viewModel = [OfficialNotiViewModel new];
NSString *api = @"query_user_office_messages";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [OfficialNotiViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"查询用户官方系统消息列表接口apiDic:%@", apiDic);
viewModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
OfficialNotiModel *model = [OfficialNotiModel yy_modelWithDictionary:resultArr[i]];
[tmpArr addObject:model];
}
viewModel.listArr = tmpArr.copy;
completion(viewModel);
} failure:^(id _Nonnull failureInfo) {
viewModel.resCode = [failureInfo[@"errorCode"] integerValue];
viewModel.errMessage = failureInfo[@"errMessage"];
completion(viewModel);
}];
}
@end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!