Commit 761ba49d authored by admin's avatar admin

完成公告大部分

parent 0ef0fbc5
This diff is collapsed.
No preview for this file type
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "横幅背景@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "横幅背景@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
redstar/Assets.xcassets/anno_banner.imageset/横幅背景@2x.png

4.47 KB

redstar/Assets.xcassets/anno_banner.imageset/横幅背景@3x.png

6.31 KB

{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "灰色园背景@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "灰色园背景@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
redstar/Assets.xcassets/gray_back.imageset/灰色园背景@2x.png

2.12 KB

redstar/Assets.xcassets/gray_back.imageset/灰色园背景@3x.png

2.87 KB

{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "绿色圆@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "绿色圆@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
redstar/Assets.xcassets/green_back.imageset/绿色圆@2x.png

2.12 KB

redstar/Assets.xcassets/green_back.imageset/绿色圆@3x.png

2.9 KB

{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "红色圆@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "红色圆@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
redstar/Assets.xcassets/red_back.imageset/红色圆@2x.png

2.12 KB

redstar/Assets.xcassets/red_back.imageset/红色圆@3x.png

2.86 KB

{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "黄色圆@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "黄色圆@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
redstar/Assets.xcassets/yellow_back.imageset/黄色圆@2x.png

2.12 KB

redstar/Assets.xcassets/yellow_back.imageset/黄色圆@3x.png

2.87 KB

......@@ -126,6 +126,10 @@
// #444444
#define kLightBlack [UIColor colorWithRed:68 / 255.0 green:68 / 255.0 blue:68 / 255.0 alpha:1.0]
#define kAnnounceHeaderColor [UIColor colorWithRed:236 / 255.0 green:238 / 255.0 blue:250 / 255.0 alpha:1.0]
#define kCommentViewHeight 300
#define kTaxisViewHeight 150
......
......@@ -50,4 +50,13 @@
// 上报巡检结果
#define kUpLoadInspectResult @"redstar-server/rest/praise/report/"
// 公告
#define kAnnounceListURL @"redstar-server/rest/affiche/download/"
// 单个公告详情
#define kAnnounceDetailURL @"redstar-server/rest/affiche/get/"
// 提交公告
#define kAnnounceYetReadURL @"redstar-server/rest/affiche/read/"
#endif /* Url_h */
//
// AnnoContentTableViewCell.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AnnoContentTableViewCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@end
//
// AnnoContentTableViewCell.m
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnoContentTableViewCell.h"
@implementation AnnoContentTableViewCell
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = kNavigationBarColor;
_titleLabel.font = [UIFont systemFontOfSize:13.0];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_titleLabel];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
[self.contentView addConstraint:contentHeight];
}
return _titleLabel;
}
- (UILabel *)contentLabel
{
if (!_contentLabel) {
_contentLabel = [[UILabel alloc] init];
_contentLabel.textColor = kLightBlack;
_contentLabel.font = [UIFont systemFontOfSize:13.0];
_contentLabel.numberOfLines = 0;
_contentLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_contentLabel];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_contentLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
[self.contentView addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_contentLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_contentLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:contentRight];
NSLayoutConstraint *contentBottom = [NSLayoutConstraint constraintWithItem:_contentLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-10];
[self.contentView addConstraint:contentBottom];
}
return _contentLabel;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AnnounceDetailModel.h
// redstar
//
// Created by admin on 15/12/1.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AnnounceDetailModel : NSObject
@property (nonatomic, copy) NSString *attachmentId;
@property (nonatomic, strong) NSArray *attachmentUrls;
@property (nonatomic, copy) NSString *content;
@property (nonatomic, copy) NSString *create_id;
@property (nonatomic, copy) NSString *create_operName;
@property (nonatomic, copy) NSString *create_time;
@property (nonatomic, copy) NSString *enterprise;
@property (nonatomic, copy) NSString *lastModify_id;
@property (nonatomic, copy) NSString *lastModify_operName;
@property (nonatomic, copy) NSString *lastModify_time;
@property (nonatomic, assign) int priority;
@property (nonatomic, strong) NSArray *publishes;
@property (nonatomic, assign) int state;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *version;
+ (instancetype)announceDetailModelWithDict:(NSDictionary *)dict;
- (instancetype)initWithDict:(NSDictionary *)dict;
@end
//
// AnnounceDetailModel.m
// redstar
//
// Created by admin on 15/12/1.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnounceDetailModel.h"
@implementation AnnounceDetailModel
+ (instancetype)announceDetailModelWithDict:(NSDictionary *)dict
{
return [[self alloc] initWithDict:dict];
}
- (instancetype)initWithDict:(NSDictionary *)dict
{
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dict];
}
return self;
}
@end
//
// AnnounceDetailFootView.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AnnounceDetailModel.h"
@interface AnnounceDetailFootView : UIView
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) AnnounceDetailModel *annoDetail;
@end
//
// AnnounceDetailFootView.m
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnounceDetailFootView.h"
@implementation AnnounceDetailFootView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
self.titleLabel.text = @"附件";
}
- (void)setAnnoDetail:(AnnounceDetailModel *)annoDetail
{
_annoDetail = annoDetail;
}
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = kNavigationBarColor;
_titleLabel.font = [UIFont systemFontOfSize:13.0];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_titleLabel];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:20];
[self addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
[self addConstraint:contentHeight];
}
return _titleLabel;
}
@end
//
// AnnounceDetailHeadView.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AnnounceDetailModel.h"
@interface AnnounceDetailHeadView : UIView
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) AnnounceDetailModel *annoDetail;
@end
//
// AnnoDetailViewController.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AnnoDetailViewController : UIViewController
@property (nonatomic, copy) NSString *affiche_uuid;
@end
//
// AnnoDetailViewController.m
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnoDetailViewController.h"
#import "AnnounceDetailHeadView.h"
#import "AnnoContentTableViewCell.h"
#import "AnnounceDetailFootView.h"
#import "HttpClient.h"
#import "AnnounceDetailModel.h"
#define kAnnounceContentCell @"AnnoContentTableViewCell"
@interface AnnoDetailViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) AnnounceDetailHeadView *headerView;
@property (nonatomic, strong) AnnounceDetailFootView *footerView;
@property (nonatomic, strong) AnnounceDetailModel *annoDetail;
@end
@implementation AnnoDetailViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self setNav];
[self requestAnnoDetail];
[self settingYetRead];
}
- (void)requestAnnoDetail
{
NSString *url = [NSString stringWithFormat:@"%@%@%@", kRedStarURL, kAnnounceDetailURL, self.affiche_uuid];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
[httpCilent getAnnounceDetailWithCompletion:^(id response, NSError *error) {
NSLog(@"anno详情 = %@", response);
NSDictionary *dict = response[@"data"];
AnnounceDetailModel *annoDetail = [AnnounceDetailModel announceDetailModelWithDict:dict];
_annoDetail = annoDetail;
self.tableView.delegate = self;
self.tableView.dataSource = self;
}];
}
- (void)settingYetRead
{
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:date];
NSString *url = [NSString stringWithFormat:@"%@%@%@?user_uuid=%@&read_time=%@", kRedStarURL, kAnnounceYetReadURL, self.affiche_uuid, user_uuid, dateString];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSLog(@"uuurl = %@", url);
[httpCilent settingAnnounceYetReadWithCompletion:^(id response, NSError *error) {
NSLog(@"已读 response = %@", response);
}];
}
// 返回上一页面
- (void)doBack:(UIBarButtonItem *)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)setNav
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"公告"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AnnoContentTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kAnnounceContentCell];
if (!cell) {
cell = [[AnnoContentTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAnnounceContentCell];
}
cell.titleLabel.text = @"内容";
cell.contentLabel.text = [NSString stringWithFormat:@"%@",_annoDetail.content];
cell.backgroundColor = kAnnounceHeaderColor;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.tableFooterView = [[UIView alloc] init];
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100.0;
_tableView.tableHeaderView = self.headerView;
_tableView.tableFooterView = self.footerView;
[_tableView registerClass:[AnnoContentTableViewCell class] forCellReuseIdentifier:kAnnounceContentCell];
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
- (AnnounceDetailHeadView *)headerView
{
if (!_headerView) {
_headerView = [[AnnounceDetailHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 120)];
_headerView.backgroundColor = kAnnounceHeaderColor;
_headerView.annoDetail = _annoDetail;
}
return _headerView;
}
- (AnnounceDetailFootView *)footerView
{
if (!_footerView) {
_footerView = [[AnnounceDetailFootView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 120)];
_footerView.backgroundColor = [UIColor whiteColor];
}
return _footerView;
}
@end
//
// AnnoTableViewCell.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AnnounceModel.h"
@interface AnnoTableViewCell : UITableViewCell
@property (nonatomic, strong) UILabel *stateLabel;
@property (nonatomic, strong) UIImageView *bgImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *peopleLabel;
@property (nonatomic, strong) AnnounceModel *announce;
@property (nonatomic, copy) NSString *currentState;
@end
//
// AnnoTableViewCell.m
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnoTableViewCell.h"
@implementation AnnoTableViewCell
- (void)setAnnounce:(AnnounceModel *)announce
{
_announce = announce;
self.titleLabel.text = [NSString stringWithFormat:@"%@", announce.content];
self.peopleLabel.text = [NSString stringWithFormat:@"发布人:%@ 发布日期:%@", announce.lastModify_operName ,announce.lastModify_time];
if ([self.currentState isEqualToString:@"false"]) {
if (announce.priority == 0) {
self.stateLabel.text = @"低";
self.bgImageView.image = [UIImage imageNamed:@"green_back"];
} else if (announce.priority == 1) {
self.stateLabel.text = @"中";
self.bgImageView.image = [UIImage imageNamed:@"yellow_back"];
} else {
self.stateLabel.text = @"高";
self.bgImageView.image = [UIImage imageNamed:@"red_back"];
}
} else if ([self.currentState isEqualToString:@"true"]) {
self.bgImageView.image = [UIImage imageNamed:@"gray_back"];
if (announce.priority == 0) {
self.stateLabel.text = @"低";
} else if (announce.priority == 1) {
self.stateLabel.text = @"中";
} else {
self.stateLabel.text = @"高";
}
} else {
if (announce.priority == 0) {
self.stateLabel.text = @"低";
self.bgImageView.image = [UIImage imageNamed:@"green_back"];
} else if (announce.priority == 1) {
self.stateLabel.text = @"中";
self.bgImageView.image = [UIImage imageNamed:@"yellow_back"];
} else {
self.stateLabel.text = @"高";
self.bgImageView.image = [UIImage imageNamed:@"red_back"];
}
}
}
- (UIImageView *)bgImageView
{
if (!_bgImageView) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_bgImageView];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:22];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:overDateWidth];
NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:overDateHeight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-22];
[self.contentView addConstraint:overDateBottom];
}
return _bgImageView;
}
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
_titleLabel.textColor = kLightBlack;
_titleLabel.font = [UIFont systemFontOfSize:15.0];
[self.contentView addSubview:_titleLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:17];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:55];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateHeight];
}
return _titleLabel;
}
- (UILabel *)peopleLabel
{
if (!_peopleLabel) {
_peopleLabel = [[UILabel alloc] init];
_peopleLabel.translatesAutoresizingMaskIntoConstraints = NO;
_peopleLabel.textColor = kLightGray;
_peopleLabel.font = [UIFont systemFontOfSize:13.0];
[self.contentView addSubview:_peopleLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:2];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:55];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_peopleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateHeight];
}
return _peopleLabel;
}
- (UILabel *)stateLabel
{
if (!_stateLabel) {
_stateLabel = [[UILabel alloc] init];
_stateLabel.translatesAutoresizingMaskIntoConstraints = NO;
_stateLabel.textAlignment = NSTextAlignmentCenter;
_stateLabel.textColor = [UIColor whiteColor];
_stateLabel.font = [UIFont systemFontOfSize:14.0];
[self.bgImageView addSubview:_stateLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.bgImageView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.bgImageView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.bgImageView addConstraint:overDateRight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.bgImageView addConstraint:overDateBottom];
}
return _stateLabel;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AnnounceModel.h
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AnnounceModel : NSObject
@property (nonatomic, copy) NSString *attachmentId;
@property (nonatomic, strong) NSArray *attachmentUrls;
@property (nonatomic, copy) NSString *content;
@property (nonatomic, copy) NSString *create_id;
@property (nonatomic, copy) NSString *create_operName;
@property (nonatomic, copy) NSString *create_time;
@property (nonatomic, copy) NSString *enterprise;
@property (nonatomic, copy) NSString *lastModify_id;
@property (nonatomic, copy) NSString *lastModify_operName;
@property (nonatomic, copy) NSString *lastModify_time;
@property (nonatomic, assign) int priority;
@property (nonatomic, strong) NSArray *publishes;
@property (nonatomic, assign) int state;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *version;
+ (instancetype)announceModelWithDict:(NSDictionary *)dict;
- (instancetype)initWithDict:(NSDictionary *)dict;
@end
//
// AnnounceModel.m
// redstar
//
// Created by admin on 15/11/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AnnounceModel.h"
@implementation AnnounceModel
+ (instancetype)announceModelWithDict:(NSDictionary *)dict
{
return [[self alloc] initWithDict:dict];
}
- (instancetype)initWithDict:(NSDictionary *)dict
{
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dict];
}
return self;
}
@end
......@@ -7,13 +7,23 @@
//
#import "AnnounceViewController.h"
#import "AnnoTableViewCell.h"
#import "HttpClient.h"
#import "AnnounceModel.h"
#import "AnnoDetailViewController.h"
#import <MBProgressHUD.h>
#define kAnnoTableViewCell @"AnnoTableViewCell"
@interface AnnounceViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UIView *bgBar;
@property (nonatomic, strong) UISegmentedControl *segmentedControl;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSString *stateStr;
@property (nonatomic, assign) BOOL isRead;
@property (nonatomic, strong) NSMutableArray *allAnnoArray;
@end
@implementation AnnounceViewController
......@@ -30,13 +40,17 @@
self.navigationController.navigationBar.translucent = NO;
}
self.stateStr = @"未读";
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.allAnnoArray = [NSMutableArray array];
self.isRead = NO;
self.stateStr = @"false";
[self setNav];
[self setup];
[self requestAnnoList];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -49,6 +63,30 @@
}
#pragma mark - Prative Methods
- (void)requestAnnoList
{
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
int page_number = 0;
int page_size = 10;
NSString *url = [NSString stringWithFormat:@"%@%@%@?read=%@&page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid ,_stateStr, page_number, page_size];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getAnnounceListWithCompletion:^(id response, NSError *error) {
if (response[@"success"]) {
NSDictionary *dict = response[@"data"];
NSArray *array = dict[@"records"];
for (NSDictionary *annoDict in array) {
AnnounceModel *anno = [AnnounceModel announceModelWithDict:annoDict];
[_allAnnoArray addObject:anno];
self.tableView.delegate = self;
self.tableView.dataSource = self;
}
}
}];
}
// 返回上一页面
- (void)doBack:(UIBarButtonItem *)sender
{
......@@ -79,42 +117,70 @@
}
- (void)segmentChangedValue:(id)sender
- (void)segmentChangedValue:(UISegmentedControl *)sender
{
NSString *url;
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
int page_number = 0;
int page_size = 10;
if (sender.selectedSegmentIndex == 0) {
self.stateStr = @"false";
url = [NSString stringWithFormat:@"%@%@%@?read=%@&page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid ,_stateStr, page_number, page_size];
} else if (sender.selectedSegmentIndex == 1) {
self.stateStr = @"true";
url = [NSString stringWithFormat:@"%@%@%@?read=%@&page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid ,_stateStr, page_number, page_size];
} else {
self.stateStr = @"";
url = [NSString stringWithFormat:@"%@%@%@?page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid , page_number, page_size];
}
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getAnnounceListWithCompletion:^(id response, NSError *error) {
if (response[@"success"]) {
NSDictionary *dict = response[@"data"];
NSArray *array = dict[@"records"];
NSMutableArray *annoArray = [NSMutableArray array];
for (NSDictionary *annoDict in array) {
AnnounceModel *anno = [AnnounceModel announceModelWithDict:annoDict];
[annoArray addObject:anno];
}
_allAnnoArray = annoArray;
[self.tableView reloadData];
}
}];
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
return _allAnnoArray.count;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%ld%ld", (long)[indexPath section], (long)[indexPath row]];
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
AnnoTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kAnnoTableViewCell];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell = [[AnnoTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAnnoTableViewCell];
}
if ([self.stateStr isEqualToString:@"未读"]) {
cell.textLabel.text = [NSString stringWithFormat:@"未读%@", CellIdentifier];
} else if ([self.stateStr isEqualToString:@"已读"]) {
cell.textLabel.text = [NSString stringWithFormat:@"已读%@", CellIdentifier];
} else {
cell.textLabel.text = [NSString stringWithFormat:@"历史%@", CellIdentifier];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.currentState = self.stateStr;
cell.announce = _allAnnoArray[indexPath.row];
return cell;
}
// cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AnnounceModel *announce = _allAnnoArray[indexPath.row];
AnnoDetailViewController *detailVC = [[AnnoDetailViewController alloc] init];
detailVC.affiche_uuid = announce.uuid;
[self.navigationController pushViewController:detailVC animated:YES];
}
......@@ -124,6 +190,8 @@
if (!_bgBar) {
_bgBar = [[UIView alloc] init];
_bgBar.translatesAutoresizingMaskIntoConstraints = NO;
_bgBar.layer.borderColor = kSeparateLineCGColor;
_bgBar.layer.borderWidth = 0.5;
[self.view addSubview:_bgBar];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_bgBar attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
......@@ -177,7 +245,9 @@
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.tableFooterView = [[UIView alloc] init];
// [_tableView registerClass:[InspectListCell class] forCellReuseIdentifier:kInspectListCell];
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100.0;
[_tableView registerClass:[AnnoTableViewCell class] forCellReuseIdentifier:kAnnoTableViewCell];
[self.view addSubview:_tableView];
......
......@@ -208,7 +208,6 @@
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSLog(@"useruuid= %@", user_uuid);
// 请求参数
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
......
......@@ -55,4 +55,12 @@ typedef void (^completionBlock) (id response, NSError *error);
// 上传新检查点
- (void)uploadInspectResultWithParameters:(id)parameters completion:(completionBlock)completion;
// 获取公告列表
- (void)getAnnounceListWithCompletion:(completionBlock)completion;
// 获取公告详情
- (void)getAnnounceDetailWithCompletion:(completionBlock)completion;
// 提交公告已读状态
- (void)settingAnnounceYetReadWithCompletion:(completionBlock)completion;
@end
......@@ -211,4 +211,32 @@
}];
}
- (void)getAnnounceListWithCompletion:(completionBlock)completion
{
[self postParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
- (void)getAnnounceDetailWithCompletion:(completionBlock)completion
{
[self getParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
// 提交公告已读状态
- (void)settingAnnounceYetReadWithCompletion:(completionBlock)completion
{
[self postParameters:nil completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment