|
@@ -9,10 +9,12 @@
|
9
|
9
|
#import "KDPNoticeViewController.h"
|
10
|
10
|
#import "KDPNoticeModel.h"
|
11
|
11
|
#import "KDPMessageTableViewCell.h"
|
|
12
|
+#import "KDPForecastVC.h"
|
|
13
|
+#import "KDPAccountVC.h"
|
12
|
14
|
@interface KDPNoticeViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
|
13
|
15
|
|
14
|
16
|
@property (nonatomic, strong) UITableView *tableView;
|
15
|
|
-
|
|
17
|
+@property(nonatomic,strong)UIView *messageNoView;
|
16
|
18
|
@property (nonatomic, strong) NSMutableArray *dataSource;
|
17
|
19
|
|
18
|
20
|
@property (nonatomic, assign) NSInteger page;
|
|
@@ -32,6 +34,14 @@
|
32
|
34
|
[super viewDidLoad];
|
33
|
35
|
// Do any additional setup after loading the view.
|
34
|
36
|
[self setUpNav];
|
|
37
|
+ [self.view addSubview:self.messageNoView];
|
|
38
|
+ if (![self isOpenNotice]) {//是否开启通知
|
|
39
|
+ self.messageNoView.hidden=NO;
|
|
40
|
+ self.tableView.frame=CGRectMake(0, KDNavBarHeight+50, SCREEN_WIDTH, SCREEN_HEIGHT-KDNavBarHeight-50);
|
|
41
|
+ }else{
|
|
42
|
+ self.messageNoView.hidden=YES;
|
|
43
|
+ self.tableView.frame=CGRectMake(0, KDNavBarHeight+10, SCREEN_WIDTH, SCREEN_HEIGHT-KDNavBarHeight-10);
|
|
44
|
+ }
|
35
|
45
|
self.view.backgroundColor = [UIColor colorWithHex:0xF2F2F2];
|
36
|
46
|
[self.view addSubview:self.tableView];
|
37
|
47
|
}
|
|
@@ -159,6 +169,27 @@
|
159
|
169
|
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
|
160
|
170
|
return YES;
|
161
|
171
|
}
|
|
172
|
+-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
173
|
+{
|
|
174
|
+ KDPNoticeModel *model =self.dataSource[indexPath.row];
|
|
175
|
+ [self messageisreadLoad:model];
|
|
176
|
+ switch (model.message_type.integerValue) {
|
|
177
|
+ case 2://商品详情
|
|
178
|
+ [self goodDetailWithModel:model];
|
|
179
|
+ break;
|
|
180
|
+ case 3://版本更新
|
|
181
|
+ [self updataArrrapp];
|
|
182
|
+ break;
|
|
183
|
+ case 4://收入结算
|
|
184
|
+ [self ForecastVClist];
|
|
185
|
+ break;
|
|
186
|
+ case 5://提现通过
|
|
187
|
+ [self myAccountList];
|
|
188
|
+ break;
|
|
189
|
+ default:
|
|
190
|
+ break;
|
|
191
|
+ }
|
|
192
|
+}
|
162
|
193
|
|
163
|
194
|
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
|
164
|
195
|
return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
|
|
@@ -167,4 +198,113 @@
|
167
|
198
|
- (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
|
168
|
199
|
return 30;
|
169
|
200
|
}
|
|
201
|
+
|
|
202
|
+-(void)messageisreadLoad:(KDPNoticeModel *)model
|
|
203
|
+{
|
|
204
|
+ [LoadingView show];
|
|
205
|
+ [KDPNetworkRequestHTTP postURL:[NSString stringWithFormat:@"%@api/message_push/messageClick",KDURL] params:@{@"message_id":model.Id,@"person_group":model.person_group,@"is_view":model.is_view} success:^(id _Nonnull json) {
|
|
206
|
+ [LoadingView dismiss];
|
|
207
|
+
|
|
208
|
+ } failure:^(NSError * _Nonnull error) {
|
|
209
|
+ [LoadingView dismiss];
|
|
210
|
+
|
|
211
|
+ }];
|
|
212
|
+}
|
|
213
|
+
|
|
214
|
+#pragma mark----收入结算
|
|
215
|
+-(void)ForecastVClist
|
|
216
|
+{
|
|
217
|
+ KDPForecastVC *forecastV =[[KDPForecastVC alloc]init];
|
|
218
|
+ [self.navigationController pushViewController:forecastV animated:YES];
|
|
219
|
+}
|
|
220
|
+
|
|
221
|
+#pragma mark---商品详情
|
|
222
|
+-(void)goodDetailWithModel:(KDPNoticeModel *)model
|
|
223
|
+{
|
|
224
|
+ KDPGoodDetailVC *detailVC = [[KDPGoodDetailVC alloc] init];
|
|
225
|
+ KDPGoodsModel *goodM =[[KDPGoodsModel alloc]init];
|
|
226
|
+ goodM.goods_id=model.goods_id;
|
|
227
|
+ detailVC.model = goodM;
|
|
228
|
+ [self.navigationController pushViewController:detailVC animated:YES];
|
|
229
|
+}
|
|
230
|
+/**
|
|
231
|
+ 版本更新
|
|
232
|
+ */
|
|
233
|
+- (void)updataArrrapp {
|
|
234
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:APP_STORE_URL]];
|
|
235
|
+}
|
|
236
|
+
|
|
237
|
+#pragma mark---提现通过
|
|
238
|
+-(void)myAccountList
|
|
239
|
+{
|
|
240
|
+ KDPAccountVC *drawV =[[KDPAccountVC alloc]init];
|
|
241
|
+ [self.navigationController pushViewController:drawV animated:YES];
|
|
242
|
+}
|
|
243
|
+
|
|
244
|
+-(UIView *)messageNoView
|
|
245
|
+{
|
|
246
|
+ if (!_messageNoView) {
|
|
247
|
+ _messageNoView =[[UIView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, 50)];
|
|
248
|
+ _messageNoView.backgroundColor=[UIColor colorWithHexString:LineColor];
|
|
249
|
+
|
|
250
|
+ UIButton *backBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH,30)];
|
|
251
|
+ backBtn.backgroundColor =[UIColor whiteColor];
|
|
252
|
+ [self.messageNoView addSubview:backBtn];
|
|
253
|
+
|
|
254
|
+ UIButton *openButton =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-56, 6.5, 40,17)];
|
|
255
|
+ [openButton setTitle:@"开启" forState:UIControlStateNormal];
|
|
256
|
+ [openButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
|
|
257
|
+ openButton.layer.cornerRadius=8.5;
|
|
258
|
+ openButton.layer.masksToBounds=YES;
|
|
259
|
+ openButton.layer.borderColor =[UIColor colorWithHexString:ThemeColor].CGColor;
|
|
260
|
+ openButton.layer.borderWidth=0.5;
|
|
261
|
+
|
|
262
|
+ openButton.titleLabel.font =[UIFont systemFontOfSize:9];
|
|
263
|
+
|
|
264
|
+ [openButton addTarget:self action:@selector(openNotice) forControlEvents:UIControlEventTouchUpInside];
|
|
265
|
+ [backBtn addSubview:openButton];
|
|
266
|
+
|
|
267
|
+ UIImageView *messageIcon =[[UIImageView alloc]initWithFrame:CGRectMake(15, 7.5, 15, 15)];
|
|
268
|
+ messageIcon.image =[UIImage imageNamed:@"icon_message"];
|
|
269
|
+ [backBtn addSubview:messageIcon];
|
|
270
|
+
|
|
271
|
+ UILabel *tipL =[[UILabel alloc]initWithFrame:CGRectMake(40, 0, 300, 30)];
|
|
272
|
+ tipL.textColor=[UIColor colorWithHexString:ThemeColor];
|
|
273
|
+ tipL.font=[UIFont systemFontOfSize:12];
|
|
274
|
+ [backBtn addSubview:tipL];
|
|
275
|
+ tipL.text=@"您还未开启消息通知,开启获取最新通知";
|
|
276
|
+ tipL.tag = 1234;
|
|
277
|
+
|
|
278
|
+ }
|
|
279
|
+ return _messageNoView;
|
|
280
|
+}
|
|
281
|
+#pragma mark---开启通知
|
|
282
|
+-(void)openNotice
|
|
283
|
+{
|
|
284
|
+ UIApplication *application = [UIApplication sharedApplication];
|
|
285
|
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
286
|
+ if ([application canOpenURL:url]) {
|
|
287
|
+ if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
|
|
288
|
+ if (@available(iOS 10.0, *)) {
|
|
289
|
+ [application openURL:url options:@{} completionHandler:nil];
|
|
290
|
+ } else {
|
|
291
|
+ // Fallback on earlier versions
|
|
292
|
+ }
|
|
293
|
+ } else {
|
|
294
|
+ [application openURL:url];
|
|
295
|
+ }
|
|
296
|
+ }
|
|
297
|
+}
|
|
298
|
+//判断是否开启通知
|
|
299
|
+- (BOOL)isOpenNotice { // 判断用户是否允许接收通知
|
|
300
|
+ BOOL isEnable = NO;
|
|
301
|
+ if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0f) { // iOS版本 >=8.0 处理逻辑
|
|
302
|
+ UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
|
|
303
|
+ isEnable = (UIUserNotificationTypeNone == setting.types) ? NO : YES;
|
|
304
|
+ } else { // iOS版本 <8.0 处理逻辑
|
|
305
|
+ UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
|
|
306
|
+ isEnable = (UIRemoteNotificationTypeNone == type) ? NO : YES;
|
|
307
|
+ }
|
|
308
|
+ return isEnable;
|
|
309
|
+}
|
170
|
310
|
@end
|