Commit b3ebe4bc cgx

社区列表UI

1 个父辈 7bd980b7
正在显示 34 个修改的文件 包含 740 行增加25 行删除
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; }; D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; }; D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; }; D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; };
D02B7E5C28E2A28500218EF7 /* ComDynamicCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D02B7E5B28E2A28500218EF7 /* ComDynamicCell.m */; };
D02B7E5F28E2C89600218EF7 /* ComDynModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D02B7E5E28E2C89600218EF7 /* ComDynModel.m */; };
D02B7E6128E2D33900218EF7 /* comList.plist in Resources */ = {isa = PBXBuildFile; fileRef = D02B7E6028E2D33900218EF7 /* comList.plist */; };
D02B7E6428E2D76D00218EF7 /* ComListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D02B7E6328E2D76D00218EF7 /* ComListViewModel.m */; };
D02D0827287BBEDE005C3A00 /* SleepReadyController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0826287BBEDE005C3A00 /* SleepReadyController.m */; }; D02D0827287BBEDE005C3A00 /* SleepReadyController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0826287BBEDE005C3A00 /* SleepReadyController.m */; };
D02D082A287BCEF3005C3A00 /* SRTipsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0829287BCEF3005C3A00 /* SRTipsView.m */; }; D02D082A287BCEF3005C3A00 /* SRTipsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D0829287BCEF3005C3A00 /* SRTipsView.m */; };
D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D082C287BD05D005C3A00 /* ReadyListController.m */; }; D02D082D287BD05D005C3A00 /* ReadyListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D02D082C287BD05D005C3A00 /* ReadyListController.m */; };
...@@ -361,6 +365,13 @@ ...@@ -361,6 +365,13 @@
D027EE2827FB51D0004BBA61 /* DSGifHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSGifHeader.m; sourceTree = "<group>"; }; D027EE2827FB51D0004BBA61 /* DSGifHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSGifHeader.m; sourceTree = "<group>"; };
D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+Extras.h"; sourceTree = "<group>"; }; D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+Extras.h"; sourceTree = "<group>"; };
D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Extras.m"; sourceTree = "<group>"; }; D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Extras.m"; sourceTree = "<group>"; };
D02B7E5A28E2A28500218EF7 /* ComDynamicCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComDynamicCell.h; sourceTree = "<group>"; };
D02B7E5B28E2A28500218EF7 /* ComDynamicCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComDynamicCell.m; sourceTree = "<group>"; };
D02B7E5D28E2C89600218EF7 /* ComDynModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComDynModel.h; sourceTree = "<group>"; };
D02B7E5E28E2C89600218EF7 /* ComDynModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComDynModel.m; sourceTree = "<group>"; };
D02B7E6028E2D33900218EF7 /* comList.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = comList.plist; sourceTree = "<group>"; };
D02B7E6228E2D76D00218EF7 /* ComListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComListViewModel.h; sourceTree = "<group>"; };
D02B7E6328E2D76D00218EF7 /* ComListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComListViewModel.m; sourceTree = "<group>"; };
D02D0825287BBEDE005C3A00 /* SleepReadyController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SleepReadyController.h; sourceTree = "<group>"; }; D02D0825287BBEDE005C3A00 /* SleepReadyController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SleepReadyController.h; sourceTree = "<group>"; };
D02D0826287BBEDE005C3A00 /* SleepReadyController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SleepReadyController.m; sourceTree = "<group>"; }; D02D0826287BBEDE005C3A00 /* SleepReadyController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SleepReadyController.m; sourceTree = "<group>"; };
D02D0828287BCEF3005C3A00 /* SRTipsView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SRTipsView.h; sourceTree = "<group>"; }; D02D0828287BCEF3005C3A00 /* SRTipsView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SRTipsView.h; sourceTree = "<group>"; };
...@@ -1438,6 +1449,8 @@ ...@@ -1438,6 +1449,8 @@
D0A3BB8D28D959F800F58781 /* View */ = { D0A3BB8D28D959F800F58781 /* View */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D02B7E5A28E2A28500218EF7 /* ComDynamicCell.h */,
D02B7E5B28E2A28500218EF7 /* ComDynamicCell.m */,
D0A3BB9028D95A2B00F58781 /* CommunityView.h */, D0A3BB9028D95A2B00F58781 /* CommunityView.h */,
D0A3BB9128D95A2B00F58781 /* CommunityView.m */, D0A3BB9128D95A2B00F58781 /* CommunityView.m */,
D070A78928DEF2D30039C5A7 /* DynamicView.h */, D070A78928DEF2D30039C5A7 /* DynamicView.h */,
...@@ -1473,6 +1486,7 @@ ...@@ -1473,6 +1486,7 @@
D070A78728DEED640039C5A7 /* DynamicController.m */, D070A78728DEED640039C5A7 /* DynamicController.m */,
D0078C5928E13D4C00054804 /* DynamicDetailController.h */, D0078C5928E13D4C00054804 /* DynamicDetailController.h */,
D0078C5A28E13D4C00054804 /* DynamicDetailController.m */, D0078C5A28E13D4C00054804 /* DynamicDetailController.m */,
D02B7E6028E2D33900218EF7 /* comList.plist */,
); );
path = Controller; path = Controller;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1480,6 +1494,8 @@ ...@@ -1480,6 +1494,8 @@
D0A3BB8F28D95A0C00F58781 /* Model */ = { D0A3BB8F28D95A0C00F58781 /* Model */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D02B7E5D28E2C89600218EF7 /* ComDynModel.h */,
D02B7E5E28E2C89600218EF7 /* ComDynModel.m */,
); );
path = Model; path = Model;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1493,6 +1509,8 @@ ...@@ -1493,6 +1509,8 @@
D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */, D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */,
D070A78C28DF02DE0039C5A7 /* DynamicViewModel.h */, D070A78C28DF02DE0039C5A7 /* DynamicViewModel.h */,
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */, D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
D02B7E6228E2D76D00218EF7 /* ComListViewModel.h */,
D02B7E6328E2D76D00218EF7 /* ComListViewModel.m */,
); );
path = ViewModel; path = ViewModel;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2250,6 +2268,7 @@ ...@@ -2250,6 +2268,7 @@
D0B5ECB127F2D9E0003EDFE3 /* Assets.xcassets in Resources */, D0B5ECB127F2D9E0003EDFE3 /* Assets.xcassets in Resources */,
D04B3DBD27F6F8090022F8DF /* Profile.storyboard in Resources */, D04B3DBD27F6F8090022F8DF /* Profile.storyboard in Resources */,
D051032F282A4E9200560A0D /* fse.mp3 in Resources */, D051032F282A4E9200560A0D /* fse.mp3 in Resources */,
D02B7E6128E2D33900218EF7 /* comList.plist in Resources */,
D0C09EDA28007D9100709D4C /* relax_lottie.json in Resources */, D0C09EDA28007D9100709D4C /* relax_lottie.json in Resources */,
D0F82D32285C7F8E0058DDB2 /* logo_start_classic@3x.png in Resources */, D0F82D32285C7F8E0058DDB2 /* logo_start_classic@3x.png in Resources */,
D051032E282A4E9200560A0D /* instant_eternity.mp3 in Resources */, D051032E282A4E9200560A0D /* instant_eternity.mp3 in Resources */,
...@@ -2376,6 +2395,7 @@ ...@@ -2376,6 +2395,7 @@
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */, D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */,
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */, D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */,
D0A3BB9628D9B43700F58781 /* ArticleController.m in Sources */, D0A3BB9628D9B43700F58781 /* ArticleController.m in Sources */,
D02B7E5F28E2C89600218EF7 /* ComDynModel.m in Sources */,
D01814D127FFCBAF00583D4E /* CWCarousel.m in Sources */, D01814D127FFCBAF00583D4E /* CWCarousel.m in Sources */,
D0D96FE22848493700461839 /* RelaxTrainModel.m in Sources */, D0D96FE22848493700461839 /* RelaxTrainModel.m in Sources */,
D0B5ECB727F2D9E0003EDFE3 /* main.m in Sources */, D0B5ECB727F2D9E0003EDFE3 /* main.m in Sources */,
...@@ -2501,6 +2521,7 @@ ...@@ -2501,6 +2521,7 @@
D091E66E283F29D100D3279E /* ScoreDetailController.m in Sources */, D091E66E283F29D100D3279E /* ScoreDetailController.m in Sources */,
D00A63572824C42300AFFEAA /* DSNetworkCache.m in Sources */, D00A63572824C42300AFFEAA /* DSNetworkCache.m in Sources */,
D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */, D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */,
D02B7E5C28E2A28500218EF7 /* ComDynamicCell.m in Sources */,
D0A72E39282B566200EED7BE /* HomeBasicCell.m in Sources */, D0A72E39282B566200EED7BE /* HomeBasicCell.m in Sources */,
D091E665283F0C4800D3279E /* ScoreTaskRequestModel.m in Sources */, D091E665283F0C4800D3279E /* ScoreTaskRequestModel.m in Sources */,
D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */, D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */,
...@@ -2508,6 +2529,7 @@ ...@@ -2508,6 +2529,7 @@
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */, D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */,
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */, D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */,
D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */, D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */,
D02B7E6428E2D76D00218EF7 /* ComListViewModel.m in Sources */,
D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */, D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */,
D0A1C48D28C1A42A000975DC /* TestFlutterController.m in Sources */, D0A1C48D28C1A42A000975DC /* TestFlutterController.m in Sources */,
D07DACA92810557D0067A1BF /* UIImage+RSKImageCropper.m in Sources */, D07DACA92810557D0067A1BF /* UIImage+RSKImageCropper.m in Sources */,
......
...@@ -10,11 +10,16 @@ ...@@ -10,11 +10,16 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface UIImage (Extras) @interface UIImage (Extras)
- (UIImage *)imageByScalingToSize:(CGSize)targetSize; - (UIImage *)imageByScalingToSize:(CGSize)targetSize;
/// UIImage转base64字符串 /// UIImage转base64字符串
/// @param image image /// @param image image
+ (NSString *)imageToBase64Str:(UIImage *)image; + (NSString *)imageToBase64Str:(UIImage *)image;
// 生成默认占位图
+ (UIImage *)defaultPlaceholderWithSize:(CGSize)size;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -192,4 +192,36 @@ ...@@ -192,4 +192,36 @@
return tempData; return tempData;
} }
+ (UIImage *)imgWithColor:(UIColor *)color size:(CGSize)size {
if (!color || size.width <= 0 || size.height <= 0) return nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
+ (UIImage *)addImage:(UIImage *)img1 withImg:(UIImage *)img2 {
CGFloat img2W = img2.size.width > img1.size.width ? img1.size.width - 10 : img2.size.width;
CGFloat img2H = (img2.size.height > img1.size.height) ? img1.size.height - 10 : img2.size.height;
UIGraphicsBeginImageContext(img1.size);
// 加上这句就不模糊了
UIGraphicsBeginImageContextWithOptions(img1.size, NO, [UIScreen mainScreen].scale);
[img1 drawInRect:CGRectMake(0, 0, img1.size.width, img1.size.height)];
[img2 drawInRect:CGRectMake((img1.size.width - img2W)/2, (img1.size.height - img2H)/2, img2W, img2H)];
UIImage *compoundImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return compoundImg;
}
+ (UIImage *)defaultPlaceholderWithSize:(CGSize)size {
UIImage *img1 = [self imgWithColor:ColorFromHex(0xE8E8E8) size:size];
UIImage *img2 = [UIImage imageNamed:@"basicPlaceholder"];
return [self addImage:img1 withImg:img2];
}
@end @end
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface UILabel (Extras) @interface UILabel (Extras)
#pragma mark - Create #pragma mark - Create
// 白天和黑夜模式下的UILabel // 白天和黑夜模式下的UILabel
+ (UILabel *)dkLabWithText:(NSString *)text font:(UIFont *)font; + (UILabel *)dkLabWithText:(NSString *)text font:(UIFont *)font;
...@@ -23,6 +24,10 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,6 +24,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (UILabel *)labWithText:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font; + (UILabel *)labWithText:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font;
+ (UILabel *)labWithText:(NSString *)text font:(UIFont *)font fit:(BOOL)fit; + (UILabel *)labWithText:(NSString *)text font:(UIFont *)font fit:(BOOL)fit;
// 根据文本及字体计算UILabel的高度
+ (CGFloat)getHeightByWidth:(CGFloat)width text:(NSString *)text font:(UIFont *)font;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -54,4 +54,24 @@ ...@@ -54,4 +54,24 @@
return lab; return lab;
} }
+ (CGFloat)getHeightByWidth:(CGFloat)width text:(NSString *)text font:(UIFont *)font
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, 0)];
label.text = text;
label.font = font;
label.numberOfLines = 0;
[label sizeToFit];
CGFloat height = label.frame.size.height;
return ceil(height);
}
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1000, 0)];
label.text = text;
label.font = font;
[label sizeToFit];
CGFloat width = label.frame.size.width;
return ceil(width);
}
@end @end
...@@ -57,7 +57,6 @@ FOUNDATION_EXTERN NSString * const RemoteCommandCenterDidClick; ...@@ -57,7 +57,6 @@ FOUNDATION_EXTERN NSString * const RemoteCommandCenterDidClick;
// 用户基础信息 // 用户基础信息
FOUNDATION_EXTERN NSString * const UserBasicInfo; FOUNDATION_EXTERN NSString * const UserBasicInfo;
FOUNDATION_EXTERN NSString * const IsBindMobile;
#pragma mark - 第三方平台配置 #pragma mark - 第三方平台配置
/** 微信开放平台AppID */ /** 微信开放平台AppID */
......
...@@ -36,14 +36,11 @@ NSString * const UnlockAudioSuccess = @"UnlockAudioSuccessNoti"; ...@@ -36,14 +36,11 @@ NSString * const UnlockAudioSuccess = @"UnlockAudioSuccessNoti";
NSString * const RemoteCommandCenterDidClick = @"RemoteCommandCenterDidClickNoti"; NSString * const RemoteCommandCenterDidClick = @"RemoteCommandCenterDidClickNoti";
NSString * const UserBasicInfo = @"UserBasicInfo"; NSString * const UserBasicInfo = @"UserBasicInfo";
NSString * const IsBindMobile = @"IsBindMobile";
NSString * const WeChatAppID = @"wx4cdd4760092cdfdf"; NSString * const WeChatAppID = @"wx4cdd4760092cdfdf";
NSString * const WeChatAppSecret = @"72c0a939b605b824d0c6d9dbde152ae0"; NSString * const WeChatAppSecret = @"72c0a939b605b824d0c6d9dbde152ae0";
// xinstall平台的 // xinstall平台的
NSString * const UNIVERSAL_LINK = @"https://ocusmp.xinstall.com.cn/tolink/"; NSString * const UNIVERSAL_LINK = @"https://ocusmp.xinstall.com.cn/tolink/";
// 友盟平台的
// NSString * const UNIVERSAL_LINK = @"https://8e0bcfb.umindex.com/";
NSString * const QQAppID = @"1111310949"; NSString * const QQAppID = @"1111310949";
NSString * const QQAppKey = @"CiiSZ3E04SlKKmVN"; NSString * const QQAppKey = @"CiiSZ3E04SlKKmVN";
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
[DSProgressHUD dissmissProgressHUD]; [DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
// 保存绑定手机号码标识 // 保存绑定手机号码标识
kSetUserDefaultsBOOL(YES, IsBindMobile); [LoginUtils updateUserInfo:requestModel.mobileDic];
kUserDefaultsSynchronize;
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} else { } else {
[DSProgressHUD showToast:requestModel.errMessage]; [DSProgressHUD showToast:requestModel.errMessage];
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
#import "CommunityController.h" #import "CommunityController.h"
#import "CommunityView.h" #import "CommunityView.h"
#import "TestFlutterController.h" #import "TestFlutterController.h"
#import "ComListViewModel.h"
@interface CommunityController () <CommunityViewDelegate> @interface CommunityController () <CommunityViewDelegate>
@property (nonatomic, strong) CommunityView *communityView; @property (nonatomic, strong) CommunityView *communityView;
@property (nonatomic, strong) TestFlutterController *flutterEngine; @property (nonatomic, strong) TestFlutterController *flutterEngine;
@property (nonatomic, strong) ComListViewModel *comListViewModel;
@end @end
@implementation CommunityController @implementation CommunityController
...@@ -24,6 +26,8 @@ ...@@ -24,6 +26,8 @@
[super viewDidLoad]; [super viewDidLoad];
[self setupUI]; [self setupUI];
self.comListViewModel = [ComListViewModel new];
} }
- (void)setupUI { - (void)setupUI {
...@@ -50,9 +54,11 @@ ...@@ -50,9 +54,11 @@
} }
- (void)getDynamicListRequest:(BOOL)loadMore { - (void)getDynamicListRequest:(BOOL)loadMore {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.comListViewModel getComListWithCompletion:^(ComListViewModel * _Nonnull requestModel) {
[self.communityView updateCommunityMoments:loadMore]; if (requestModel.resCode == DSResCodeSuccess) {
}); [self.communityView updateCommunityMoments:loadMore listArr:requestModel.listArr];
}
}];
} }
- (void)publishLogicDeal { - (void)publishLogicDeal {
...@@ -62,7 +68,7 @@ ...@@ -62,7 +68,7 @@
return; return;
} }
// 2、登录了,判断是否绑定了手机号 // 2、登录了,判断是否绑定了手机号
if (!kGetUserDefaultsBOOL(IsBindMobile)) { if (![LoginUtils getUserMobile]) {
UIViewController *bindVC = [[UIStoryboard storyboardWithName:@"BindMobileController" bundle:nil] instantiateViewControllerWithIdentifier:@"BindMobileController"]; UIViewController *bindVC = [[UIStoryboard storyboardWithName:@"BindMobileController" bundle:nil] instantiateViewControllerWithIdentifier:@"BindMobileController"];
[self.navigationController pushViewController:bindVC animated:YES]; [self.navigationController pushViewController:bindVC animated:YES];
return; return;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>error</key>
<string>&quot;&quot;</string>
<key>result</key>
<array>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>张三</string>
<key>time</key>
<string>1分钟前</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653288028602_1yFqHL.jpg</string>
</array>
<key>likeCount</key>
<integer>2</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>李四</string>
<key>time</key>
<string>半个小时前</string>
<key>content</key>
<string>长沙好好玩,各种美食应有尽有,吃喝玩乐嗨起来,周末约朋友喝茶颜去。。。</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653288005388_7wuK9n.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653277874846_BzEuFF.jpg</string>
</array>
<key>likeCount</key>
<integer>33</integer>
<key>remarkCount</key>
<integer>2</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>李四</string>
<key>time</key>
<string>半个小时前</string>
<key>content</key>
<string>长沙好好玩,各种美食应有尽有,吃喝玩乐嗨起来,周末约朋友喝茶颜去。。。</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653288005388_7wuK9n.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653277874846_BzEuFF.jpg</string>
</array>
<key>likeCount</key>
<integer>33</integer>
<key>remarkCount</key>
<integer>2</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>王五</string>
<key>time</key>
<string>昨天</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653302478340_liIqbO.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301114665_lwDNUG.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301150570_zfQ0jW.jpg</string>
</array>
<key>likeCount</key>
<integer>0</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>王五</string>
<key>time</key>
<string>昨天</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653302478340_liIqbO.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301114665_lwDNUG.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301150570_zfQ0jW.jpg</string>
</array>
<key>likeCount</key>
<integer>0</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>王五</string>
<key>time</key>
<string>昨天</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653302478340_liIqbO.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301114665_lwDNUG.jpg</string>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653301150570_zfQ0jW.jpg</string>
</array>
<key>likeCount</key>
<integer>0</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>异次元</string>
<key>time</key>
<string>3天前</string>
<key>content</key>
<string>觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系&quot;觉知当下,与家人建立和谐关系&quot;</string>
<key>likeCount</key>
<integer>2</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>张三</string>
<key>time</key>
<string>1分钟前</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653288028602_1yFqHL.jpg</string>
</array>
<key>likeCount</key>
<integer>2</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
<dict>
<key>userIcon</key>
<string>https://img2.ydniu.com/sleep_ssmain/face_img/1658215539163_ZsA0sm.jpg</string>
<key>userName</key>
<string>张三</string>
<key>time</key>
<string>1分钟前</string>
<key>content</key>
<string>国庆放假要好好计划下,健身打卡</string>
<key>imgUrls</key>
<array>
<string>https://img2.ydniu.com/sleep_ssmain/relax/1653288028602_1yFqHL.jpg</string>
</array>
<key>likeCount</key>
<integer>2</integer>
<key>remarkCount</key>
<integer>0</integer>
</dict>
</array>
<key>res_code</key>
<integer>1</integer>
</dict>
</plist>
//
// ComDynModel.h
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 社区动态列表数据model
@interface ComDynModel : NSObject
/// 用户头像URL
@property (nonatomic, copy) NSString *userIcon;
/// 用户名
@property (nonatomic, copy) NSString *userName;
/// 动态发布时间
@property (nonatomic, copy) NSString *time;
/// 动态内容
@property (nonatomic, copy) NSString *content;
/// 图片链接
@property (nonatomic, copy) NSArray *imgUrls;
/// 点赞数
@property (nonatomic, assign) int likeCount;
/// 评论数
@property (nonatomic, assign) int remarkCount;
/// 文本显示高度
- (CGFloat)contentHeight;
/// 图片高度
- (CGFloat)imgHeight;
/// 动态cell高度
- (CGFloat)cellHeight;
@end
NS_ASSUME_NONNULL_END
//
// ComDynModel.m
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import "ComDynModel.h"
@implementation ComDynModel
- (CGFloat)contentHeight {
CGFloat contentW = kScreenWidth - 60;
NSString *content = self.content;
CGFloat contentH = [UILabel getHeightByWidth:contentW text:content font:SysFont(14)];
return contentH > 100 ? 100 : contentH;
}
- (CGFloat)imgHeight {
if (self.imgUrls) {
if (iPhone5) {
return 100;
} else {
switch (self.imgUrls.count) {
case 1: case 2:
return 150;
break;
case 3:
return 95;
break;
default:
return 0;
break;
}
}
}
return 0;
}
- (CGFloat)cellHeight {
CGFloat topH = 67;
CGFloat bottomH = (self.imgUrls && self.imgUrls.count) ? 52 : 56;
CGFloat contentH = [self contentHeight];
CGFloat imgTextSpace = (self.imgUrls && self.imgUrls.count) ? 12 : 0;
CGFloat imgH = [self imgHeight];
return topH + bottomH + contentH + imgTextSpace + imgH;
}
@end
//
// ComDynamicCell.h
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import <UIKit/UIKit.h>
#import "ComDynModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 社区动态Cell
@interface ComDynamicCell : UITableViewCell
@property (nonatomic, strong) ComDynModel *model;
@end
NS_ASSUME_NONNULL_END
//
// ComDynamicCell.m
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import "ComDynamicCell.h"
#import "GKPhotoBrowser.h"
@interface ComDynamicCell ()
@property (nonatomic, strong) UIImageView *userIcon;
@property (nonatomic, strong) UILabel *userNameLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UIButton *informBtn;
@property (nonatomic, strong) UIView *imgContainerView;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIButton *likeBtn;
@property (nonatomic, strong) UIButton *remarkCountBtn;
@property (nonatomic, strong) NSMutableArray *photos;
@end
@implementation ComDynamicCell
#pragma mark - init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self cornerRadius:24.0];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, CornerViewDarkColor, DSWhite);
self.photos = [NSMutableArray array];
[self.contentView addSubview:self.userIcon];
[self.contentView addSubview:self.userNameLab];
[self.contentView addSubview:self.timeLab];
[self.contentView addSubview:self.informBtn];
[self.contentView addSubview:self.imgContainerView];
[self.contentView addSubview:self.contentLab];
[self.contentView addSubview:self.likeBtn];
[self.contentView addSubview:self.remarkCountBtn];
[self.userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.top.equalTo(self.contentView).offset(15);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.userNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userIcon.mas_right).offset(14);
make.top.equalTo(self.userIcon);
}];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userNameLab);
make.top.equalTo(self.contentView).offset(38);
}];
[self.informBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.size.mas_equalTo(CGSizeMake(30, 30));
}];
[self.remarkCountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-15);
make.bottom.equalTo(self.contentView).offset(-10);
make.size.mas_equalTo(CGSizeMake(100, 30));
}];
[self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.remarkCountBtn.mas_left);
make.size.bottom.equalTo(self.remarkCountBtn);
}];
}
return self;
}
#pragma mark - setter
- (void)setModel:(ComDynModel *)model {
_model = model;
[self.userIcon yy_setImageWithURL:[NSURL URLWithString:model.userIcon] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(40, 40)]];
self.userNameLab.text = model.userName;
self.timeLab.text = model.time;
self.contentLab.text = model.content;
[self.likeBtn setTitle:[NSString stringWithFormat:@"%d", model.likeCount] forState:UIControlStateNormal];
[self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", model.remarkCount] forState:UIControlStateNormal];
[self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.userIcon.mas_bottom).offset(12);
make.left.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.height.equalTo(@([model contentHeight]));
}];
// 先移除
[self.imgContainerView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj removeFromSuperview];
}];
[self.photos removeAllObjects];
// 再添加
CGFloat imgContainerViewH = [model imgHeight];
[self.imgContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentLab.mas_bottom).offset(12);
make.left.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.height.equalTo(@(imgContainerViewH));
}];
if (imgContainerViewH > 0) {
CGFloat itemCount = model.imgUrls.count;
CGFloat itemSpace = itemCount > 1 ? (kScreenWidth - 60 - imgContainerViewH * itemCount) / (itemCount - 1) : 0;
for (int index = 0; index < itemCount; index++) {
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(index*(imgContainerViewH + itemSpace), 0, imgContainerViewH, imgContainerViewH)];
[imgView cornerRadius:12];
imgView.tag = index;
imgView.userInteractionEnabled = YES;
[imgView yy_setImageWithURL:[NSURL URLWithString:model.imgUrls[index]] placeholder:[UIImage defaultPlaceholderWithSize:imgView.size]];
imgView.dk_alphaPicker = DKAlphaPickerWithAlphas(1.f, 0.5f, 0.1f);
[self.imgContainerView addSubview:imgView];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lookImg:)];
[imgView addGestureRecognizer:tapGR];
GKPhoto *photo = [GKPhoto new];
photo.url = [NSURL URLWithString:model.imgUrls[index]];
photo.sourceImageView = imgView;
[self.photos addObject:photo];
}
}
}
#pragma mark - private
- (void)lookImg:(UITapGestureRecognizer *)tapGR {
UIImageView *showIV = (UIImageView *)tapGR.view;
GKPhotoBrowser *browser = [GKPhotoBrowser photoBrowserWithPhotos:[_photos copy] currentIndex:showIV.tag];
browser.showStyle = GKPhotoBrowserShowStyleZoom;
browser.loadStyle = GKPhotoBrowserLoadStyleDeterminate;
[browser showFromVC:self.ds_viewController];
}
#pragma mark - lazy
- (UIImageView *)userIcon {
if (!_userIcon) {
_userIcon = [UIImageView new];
[_userIcon cornerRadius:20];
_userIcon.dk_alphaPicker = DKAlphaPickerWithAlphas(1.f, 0.5f, 0.1f);
}
return _userIcon;
}
- (UILabel *)userNameLab {
if (!_userNameLab) {
_userNameLab = [UILabel labWithFont:BoldFont(15)];
_userNameLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite);
}
return _userNameLab;
}
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12)];
_timeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
}
return _timeLab;
}
- (UIButton *)informBtn {
if (!_informBtn) {
_informBtn = [UIButton btnWithTitle:@"•••" font:BoldFont(15)];
[_informBtn dk_setTitleColorPicker:DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite) forState:UIControlStateNormal];
[_informBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
}
return _informBtn;
}
- (UIView *)imgContainerView {
if (!_imgContainerView) {
_imgContainerView = [UIView new];
}
return _imgContainerView;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite);
_contentLab.numberOfLines = 0;
}
return _contentLab;
}
- (UIButton *)likeBtn {
if (!_likeBtn) {
_likeBtn = [UIButton btnWithTitle:@"0" font:SysFont(12)];
[_likeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_likeBtn setImage:[UIImage imageNamed:@"ic_shequ_dianza"] forState:UIControlStateNormal];
_likeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 0);
}
return _likeBtn;
}
- (UIButton *)remarkCountBtn {
if (!_remarkCountBtn) {
_remarkCountBtn = [UIButton btnWithTitle:@"0" font:SysFont(12)];
[_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_remarkCountBtn setImage:[UIImage imageNamed:@"ic_shequ_pinlun"] forState:UIControlStateNormal];
_remarkCountBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 0);
}
return _remarkCountBtn;
}
@end
...@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<CommunityViewDelegate>)delegate; - (instancetype)initWithDelegate:(id<CommunityViewDelegate>)delegate;
/// 更新社区动态 /// 更新社区动态
- (void)updateCommunityMoments:(BOOL)loadMore; - (void)updateCommunityMoments:(BOOL)loadMore listArr:(NSArray *)listArr;
@end @end
......
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
// //
#import "CommunityView.h" #import "CommunityView.h"
#import "ComDynamicCell.h"
@interface CommunityView () <UITableViewDelegate, UITableViewDataSource> @interface CommunityView () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UIView *headView; @property (nonatomic, strong) UIView *headView;
@property (nonatomic, strong) UITableView *listView; @property (nonatomic, strong) UITableView *listView;
@property (nonatomic, strong) NSArray *listArr; @property (nonatomic, strong) NSMutableArray *listArr;
@end @end
@implementation CommunityView @implementation CommunityView
...@@ -19,7 +20,7 @@ ...@@ -19,7 +20,7 @@
- (instancetype)initWithDelegate:(id<CommunityViewDelegate>)delegate { - (instancetype)initWithDelegate:(id<CommunityViewDelegate>)delegate {
if (self = [super init]) { if (self = [super init]) {
self.delegate = delegate; self.delegate = delegate;
self.listArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"]; self.listArr = [NSMutableArray array];
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self addSubview:self.listView]; [self addSubview:self.listView];
...@@ -40,9 +41,10 @@ ...@@ -40,9 +41,10 @@
} }
#pragma mark - public #pragma mark - public
- (void)updateCommunityMoments:(BOOL)loadMore { - (void)updateCommunityMoments:(BOOL)loadMore listArr:(NSArray *)listArr {
self.listArr = [NSMutableArray arrayWithArray:listArr];
if (loadMore) { if (loadMore) {
self.listArr = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"8", @"9", @"10"]; [self.listArr addObjectsFromArray:listArr];
[self.listView.mj_footer endRefreshing]; [self.listView.mj_footer endRefreshing];
} else { } else {
[self.listView.mj_header endRefreshing]; [self.listView.mj_header endRefreshing];
...@@ -73,7 +75,8 @@ ...@@ -73,7 +75,8 @@
} }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 150; ComDynModel *model = self.listArr[indexPath.section];
return [model cellHeight];
} }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
...@@ -93,10 +96,8 @@ ...@@ -93,10 +96,8 @@
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])]; ComDynamicCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ComDynamicCell class])];
[cell cornerRadius:24.0]; cell.model = self.listArr[indexPath.section];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, CornerViewDarkColor, DSWhite);
return cell; return cell;
} }
...@@ -116,7 +117,7 @@ ...@@ -116,7 +117,7 @@
_listView.showsVerticalScrollIndicator = NO; _listView.showsVerticalScrollIndicator = NO;
_listView.separatorStyle = UITableViewCellSeparatorStyleNone; _listView.separatorStyle = UITableViewCellSeparatorStyleNone;
_listView.tableHeaderView = self.headView; _listView.tableHeaderView = self.headView;
[_listView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])]; [_listView registerClass:[ComDynamicCell class] forCellReuseIdentifier:NSStringFromClass([ComDynamicCell class])];
WS(weakSelf); WS(weakSelf);
_listView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{ _listView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
if (!_likeBtn) { if (!_likeBtn) {
_likeBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)]; _likeBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)];
[_likeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal]; [_likeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_likeBtn setImage:[UIImage imageNamed:@"community_selected"] forState:UIControlStateNormal]; [_likeBtn setImage:[UIImage imageNamed:@"ic_shequ_dianza"] forState:UIControlStateNormal];
_likeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0); _likeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0);
} }
return _likeBtn; return _likeBtn;
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
if (!_remarkCountBtn) { if (!_remarkCountBtn) {
_remarkCountBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)]; _remarkCountBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)];
[_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal]; [_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_remarkCountBtn setImage:[UIImage imageNamed:@"community_selected"] forState:UIControlStateNormal]; [_remarkCountBtn setImage:[UIImage imageNamed:@"ic_shequ_pinlun"] forState:UIControlStateNormal];
_remarkCountBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0); _remarkCountBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0);
} }
return _remarkCountBtn; return _remarkCountBtn;
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
[_textView cornerRadius:12]; [_textView cornerRadius:12];
_textView.textContainerInset = UIEdgeInsetsMake(15, 8, 33, 8); _textView.textContainerInset = UIEdgeInsetsMake(15, 8, 33, 8);
_textView.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite); _textView.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite);
_textView.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xF0F0F0), DarkColor, DSWhite); _textView.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xF0F0F0), CornerViewDarkColor, DSWhite);
} }
return _textView; return _textView;
} }
......
//
// ComListViewModel.h
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface ComListViewModel : DSNetworkTool
@property (nonatomic, strong) NSArray *listArr;
- (void)getComListWithCompletion:(void (^)(ComListViewModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// ComListViewModel.m
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import "ComListViewModel.h"
#import "ComDynModel.h"
@implementation ComListViewModel
- (void)getComListWithCompletion:(void (^)(ComListViewModel *requestModel))completion {
ComListViewModel * requestModel = [[ComListViewModel alloc] init];
NSDictionary *apiDic = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"comList" ofType:@"plist"]];
NSArray *resultArr = apiDic[@"result"];
requestModel.resCode = [apiDic[@"res_code"] integerValue];
requestModel.errMessage = apiDic[@"error"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
ComDynModel *model = [ComDynModel yy_modelWithDictionary:resultArr[i]];
[tmpArr addObject:model];
}
requestModel.listArr = [tmpArr copy];
DSLog(@"apiDic:%@", apiDic);
completion(requestModel);
// NSString *api = @"query_ssmian_knowledge_list";
// NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
// return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
// DSLog(@"文章咨询数据接口apiDic:%@", apiDic);
// requestModel.resCode = DSResCodeSuccess;
// NSDictionary *resultDic = apiDic[@"result"];
//
// completion(requestModel);
// } failure:^(id _Nonnull failureInfo) {
// requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
// requestModel.errMessage = failureInfo[@"errMessage"];
// completion(requestModel);
// }];
}
- (NSArray *)listArr {
if (!_listArr) {
_listArr = [NSArray array];
}
return _listArr;
}
@end
...@@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取用户生日 /// 获取用户生日
+ (NSString *)getBirthday; + (NSString *)getBirthday;
/// 获取用户手机号
+ (NSString *)getUserMobile;
/// 更新sid和token /// 更新sid和token
/// @param sid sid /// @param sid sid
/// @param token token /// @param token token
......
...@@ -42,6 +42,11 @@ ...@@ -42,6 +42,11 @@
return userModel.birthday; return userModel.birthday;
} }
+ (NSString *)getUserMobile {
UserModel *userModel = [self getUserLoginData];
return userModel.mobile;
}
+ (void)updateSid:(NSString *)sid token:(NSString *)token isAccess:(int)isAccess { + (void)updateSid:(NSString *)sid token:(NSString *)token isAccess:(int)isAccess {
UserModel *userModel = [self getUserLoginData]; UserModel *userModel = [self getUserLoginData];
userModel.sid = sid; userModel.sid = sid;
...@@ -66,6 +71,8 @@ ...@@ -66,6 +71,8 @@
userModel.gender = [value boolValue]; userModel.gender = [value boolValue];
} else if ([key isEqualToString:@"birthday"]) { } else if ([key isEqualToString:@"birthday"]) {
userModel.birthday = value; userModel.birthday = value;
} else if ([key isEqualToString:@"mobile"]) {
userModel.mobile = value;
} }
[self saveUserLoginData:userModel]; [self saveUserLoginData:userModel];
} }
...@@ -83,7 +90,7 @@ ...@@ -83,7 +90,7 @@
+ (void)clearUserLoginData { + (void)clearUserLoginData {
kUserDefaultsRemoveObj(UserBasicInfo); kUserDefaultsRemoveObj(UserBasicInfo);
kUserDefaultsSynchronize; kUserDefaultsSynchronize;
// 发送更新用户数据显示UI通知 // 发送更新用户数据显示UI通知
[[NSNotificationCenter defaultCenter] postNotificationName:HasUpdateUserDataNoti object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:HasUpdateUserDataNoti object:nil];
// 刷新主页数据 // 刷新主页数据
......
...@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *level_img; @property (nonatomic, copy) NSString *level_img;
/// 我的积分 /// 我的积分
@property (nonatomic, assign) int total_points; @property (nonatomic, assign) int total_points;
#pragma mark - 社区
@property (nonatomic, copy) NSString *mobile;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
[aCoder encodeObject:_level_img forKey:@"level_img"]; [aCoder encodeObject:_level_img forKey:@"level_img"];
[aCoder encodeObject:@(_total_points) forKey:@"total_points"]; [aCoder encodeObject:@(_total_points) forKey:@"total_points"];
[aCoder encodeObject:_user_name forKey:@"user_name"]; [aCoder encodeObject:_user_name forKey:@"user_name"];
[aCoder encodeObject:_mobile forKey:@"mobile"];
} }
- (id)initWithCoder:(NSCoder *)aDecoder { - (id)initWithCoder:(NSCoder *)aDecoder {
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
_level_img = [aDecoder decodeObjectForKey:@"level_img"]; _level_img = [aDecoder decodeObjectForKey:@"level_img"];
_total_points = [[aDecoder decodeObjectForKey:@"total_points"] intValue]; _total_points = [[aDecoder decodeObjectForKey:@"total_points"] intValue];
_user_name = [aDecoder decodeObjectForKey:@"user_name"]; _user_name = [aDecoder decodeObjectForKey:@"user_name"];
_mobile = [aDecoder decodeObjectForKey:@"mobile"];
return self; return self;
} }
......
...@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) UserModel *userModel; @property (nonatomic, strong) UserModel *userModel;
@property (nonatomic, strong) NSDictionary *mobileDic;
/// 微信登录请求 /// 微信登录请求
/// @param code 客户端微信授权用户code /// @param code 客户端微信授权用户code
/// @param isAccess isAccess /// @param isAccess isAccess
......
...@@ -187,6 +187,8 @@ ...@@ -187,6 +187,8 @@
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) { return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"验证手机号码接口apiDic:%@", apiDic); DSLog(@"验证手机号码接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess; requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
requestModel.mobileDic = @{@"mobile" : resultDic[@"mobile"]};
completion(requestModel); completion(requestModel);
} failure:^(id _Nonnull failureInfo) { } failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue]; requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
......
{
"images" : [
{
"filename" : "ic_shequ_dianza.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_shequ_dianza@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_shequ_dianza@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_shequ_pinlun.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_shequ_pinlun@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_shequ_pinlun@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!