Commit 7facae2d cgx

我的反馈红点显示

1 个父辈 51fa6803
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
} }
#pragma mark - Swizzling #pragma mark - Swizzling
- (void)override_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL) animated completion:(void (^ __nullable)(void))completion{ - (void)override_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL) animated completion:(void (^ __nullable)(void))completion {
if(@available(iOS 13.0, *)){ if(@available(iOS 13.0, *)) {
if (viewControllerToPresent.modalPresentationStyle == UIModalPresentationPageSheet){ if (viewControllerToPresent.modalPresentationStyle == UIModalPresentationPageSheet) {
viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen; viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
} }
} }
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#import "FeedbackController.h" #import "FeedbackController.h"
#import "MyFeedListController.h" #import "MyFeedListController.h"
#import "FeedbackRequestModel.h"
@interface FeedbackController () @interface FeedbackController () <MyFeedListControllerDelegate, UITextViewDelegate>
@property (strong, nonatomic) UILabel *redLab;
@property (assign, nonatomic) int unreadCount;
@property (strong, nonatomic) UITextView *feedTV; @property (strong, nonatomic) UITextView *feedTV;
@property (strong, nonatomic) UICollectionView *imgCollectionView; @property (strong, nonatomic) UICollectionView *imgCollectionView;
@property (strong, nonatomic) UIButton *commitBtn; @property (strong, nonatomic) UIButton *commitBtn;
...@@ -22,35 +25,13 @@ ...@@ -22,35 +25,13 @@
self.navigationItem.title = @"意见反馈"; self.navigationItem.title = @"意见反馈";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UIButton *myFeedBtn = [UIButton btnWithTitle:@"我的反馈" titleColor:DSWhite font:SysFont(12)]; [self setNaviRightItem];
myFeedBtn.size = CGSizeMake(82, 26);
[myFeedBtn cornerRadius:13];
myFeedBtn.layer.borderColor = DSWhite.CGColor;
myFeedBtn.layer.borderWidth = 1;
[myFeedBtn addTarget:self action:@selector(myFeedAction) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myFeedBtn];
[self.view addSubview:self.feedTV]; [self.view addSubview:self.feedTV];
[self.view addSubview:self.imgCollectionView]; [self.view addSubview:self.imgCollectionView];
[self.view addSubview:self.commitBtn]; [self.view addSubview:self.commitBtn];
[self.feedTV mas_makeConstraints:^(MASConstraintMaker *make) { [self layoutUI];
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.top.equalTo(@15);
}];
[self.imgCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.feedTV.mas_bottom).offset(26);
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.height.equalTo(@77);
}];
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.imgCollectionView.mas_bottom).offset(60);
make.centerX.equalTo(self.view);
make.bottom.equalTo(self.view).offset(-91);
make.size.mas_equalTo(CGSizeMake(155, 40));
}];
} }
- (void)viewDidDisappear:(BOOL)animated { - (void)viewDidDisappear:(BOOL)animated {
...@@ -58,6 +39,19 @@ ...@@ -58,6 +39,19 @@
[self.feedTV endEditing:YES]; [self.feedTV endEditing:YES];
} }
#pragma mark - MyFeedListControllerDelegate
- (void)didClickMessage {
if (self.unreadCount == 0) { return; }
self.unreadCount--;
self.redLab.text = [NSString stringWithFormat:@"%d", self.unreadCount];
self.redLab.hidden = self.unreadCount == 0;
}
#pragma mark - UITextViewDelegate
- (void)textViewDidEndEditing:(UITextView *)textView {
textView.text = [NSString trimString:textView.text];
}
#pragma mark - 品牌模式 #pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle { - (NaviStyle)navigationBarStyle {
return NaviStyleDefault; return NaviStyleDefault;
...@@ -65,18 +59,40 @@ ...@@ -65,18 +59,40 @@
#pragma mark - Actions #pragma mark - Actions
- (void)myFeedAction { - (void)myFeedAction {
MyFeedListController *myFeedVC = [MyFeedListController new]; MyFeedListController *myFeedVC = [[MyFeedListController alloc] initWithDelegate:self];
[self.navigationController pushViewController:myFeedVC animated:YES]; [self.navigationController pushViewController:myFeedVC animated:YES];
} }
- (void)commitAction { - (void)commitAction {
if (self.feedTV.text.length == 0) {
[DSProgressHUD showDetailInfo:@"请输入遇到的问题或建议"];
return;
}
// 发送提交请求
[DSProgressHUD showProgressHUDWithInfo:@"提交中..."];
[FeedbackRequestModel adviceFeedbackRequestWithCompletion:^(FeedbackRequestModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
[DSProgressHUD showDetailInfo:@"已收到您的宝贵建议,谢谢!"];
[self.navigationController popViewControllerAnimated:YES];
}
}];
} }
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.feedTV endEditing:YES]; [self.feedTV endEditing:YES];
} }
- (void)getUnreadMessageRequest {
[FeedbackRequestModel queryUserTotalReplysRequest:^(FeedbackRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.unreadCount = requestModel.unreadCount;
self.redLab.text = [NSString stringWithFormat:@"%d", self.unreadCount];
self.redLab.hidden = self.unreadCount == 0;
}
}];
}
#pragma mark - lazy #pragma mark - lazy
- (UITextView *)feedTV { - (UITextView *)feedTV {
if (!_feedTV) { if (!_feedTV) {
...@@ -84,6 +100,7 @@ ...@@ -84,6 +100,7 @@
_feedTV.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xf0f0f0), CornerViewDarkColor, DSWhite); _feedTV.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xf0f0f0), CornerViewDarkColor, DSWhite);
_feedTV.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite); _feedTV.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite);
_feedTV.font = SysFont(14); _feedTV.font = SysFont(14);
_feedTV.delegate = self;
[_feedTV cornerRadius:12]; [_feedTV cornerRadius:12];
} }
return _feedTV; return _feedTV;
...@@ -106,4 +123,54 @@ ...@@ -106,4 +123,54 @@
return _commitBtn; return _commitBtn;
} }
- (void)setNaviRightItem {
UIView *cusView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 105, 32)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cusView];
UIButton *myFeedBtn = [UIButton btnWithTitle:@" 我的反馈 " titleColor:DSWhite font:SysFont(12)];
[myFeedBtn cornerRadius:13];
myFeedBtn.layer.borderColor = DSWhite.CGColor;
myFeedBtn.layer.borderWidth = 1;
[myFeedBtn addTarget:self action:@selector(myFeedAction) forControlEvents:UIControlEventTouchUpInside];
[cusView addSubview:myFeedBtn];
[myFeedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(cusView);
make.top.equalTo(cusView).offset(6);
}];
UILabel *lab = [UILabel labWithTextColor:DSWhite font:SysFont(12)];
lab.textAlignment = NSTextAlignmentCenter;
lab.backgroundColor = DSRed;
[lab cornerRadius:10];
lab.hidden = YES;
self.redLab = lab;
[cusView addSubview:lab];
[lab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(cusView);
make.top.equalTo(cusView);
make.width.height.equalTo(@20);
}];
}
- (void)layoutUI {
[self.feedTV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.top.equalTo(@15);
}];
[self.imgCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.feedTV.mas_bottom).offset(26);
make.left.equalTo(@15);
make.right.equalTo(@-15);
make.height.equalTo(@77);
}];
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.imgCollectionView.mas_bottom).offset(60);
make.centerX.equalTo(self.view);
make.bottom.equalTo(self.view).offset(-91);
make.size.mas_equalTo(CGSizeMake(155, 40));
}];
}
@end @end
...@@ -14,8 +14,10 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -14,8 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 反馈列表数据 /// 反馈列表数据
@property (nonatomic, strong) NSArray *adviceListArr; @property (nonatomic, strong) NSArray *adviceListArr;
/// 未读的回复数
@property (nonatomic, assign) int unreadCount;
/// 用户反馈接口请求 /// 用户提交反馈接口请求
/// @param completion completion /// @param completion completion
+ (NSURLSessionDataTask *)adviceFeedbackRequestWithCompletion:(void (^)(FeedbackRequestModel *requestModel))completion; + (NSURLSessionDataTask *)adviceFeedbackRequestWithCompletion:(void (^)(FeedbackRequestModel *requestModel))completion;
...@@ -33,8 +35,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -33,8 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion completion /// @param completion completion
+ (NSURLSessionDataTask *)queryAdviceDetailWithAdviceID:(int)adviceID completion:(void (^)(FeedbackRequestModel *requestModel))completion; + (NSURLSessionDataTask *)queryAdviceDetailWithAdviceID:(int)adviceID completion:(void (^)(FeedbackRequestModel *requestModel))completion;
// 我的反馈红点提醒接口(未找到) // 我的反馈红点提醒接口
+ (NSURLSessionDataTask *)queryAdviceAlertWithCompletion:(void (^)(FeedbackRequestModel *requestModel))completion; + (NSURLSessionDataTask *)queryUserTotalReplysRequest:(void (^)(FeedbackRequestModel *requestModel))completion;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -76,4 +76,22 @@ ...@@ -76,4 +76,22 @@
}]; }];
} }
+ (NSURLSessionDataTask *)queryUserTotalReplysRequest:(void (^)(FeedbackRequestModel *requestModel))completion {
FeedbackRequestModel * requestModel = [[FeedbackRequestModel alloc] init];
NSString *api = @"query_user_total_replys";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户反馈数接口apiDic:%@", apiDic);
// 未读的回复数
int unreadCount = [apiDic[@"result"] intValue];
requestModel.resCode = DSResCodeSuccess;
requestModel.unreadCount = unreadCount;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end @end
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "MyFeedModel.h"
#import "UITableViewCell+CardRadius.h" #import "UITableViewCell+CardRadius.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
......
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol MyFeedListControllerDelegate <NSObject>
/// 用户点击未读消息
- (void)didClickMessage;
@end
@interface MyFeedListController : UIViewController @interface MyFeedListController : UIViewController
@property (nonatomic, weak) id<MyFeedListControllerDelegate> delegate;
- (instancetype)initWithDelegate:(id<MyFeedListControllerDelegate>)delegate;
@end @end
...@@ -5,10 +5,19 @@ ...@@ -5,10 +5,19 @@
@interface MyFeedListController () <UITableViewDelegate, UITableViewDataSource> @interface MyFeedListController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *feedbackIV; @property (nonatomic, strong) UITableView *feedbackIV;
@property (nonatomic, strong) NSArray *listData;
@end @end
@implementation MyFeedListController @implementation MyFeedListController
- (instancetype)initWithDelegate:(id<MyFeedListControllerDelegate>)delegate {
if (self = [super init]) {
_delegate = delegate;
_listData = [NSArray array];
}
return self;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
...@@ -54,6 +63,14 @@ ...@@ -54,6 +63,14 @@
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// MyFeedModel *model = self.listData[indexPath.row];
// if (model.read_status == 0) {
// model.read_status = 1;
// if (self.delegate && [self.delegate respondsToSelector:@selector(didClickMessage)]) {
// [self.delegate didClickMessage];
// }
// }
FeedbackDetailController *detailVC = [FeedbackDetailController new]; FeedbackDetailController *detailVC = [FeedbackDetailController new];
[self.navigationController pushViewController:detailVC animated:YES]; [self.navigationController pushViewController:detailVC animated:YES];
} }
......
...@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *created_at; @property (nonatomic, copy) NSString *created_at;
// 是否回复 // 是否回复
@property (nonatomic, assign) int reply_status; @property (nonatomic, assign) int reply_status;
// 是否查阅 // 是否查阅(0:未查阅 1: 已查阅)
@property (nonatomic, assign) int read_status; @property (nonatomic, assign) int read_status;
@end @end
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!