Commit 9ca5e7e9 authored by admin's avatar admin

问题与知识接口 除提交以及筛选 完成

parent 4ab42698
......@@ -77,6 +77,8 @@
84E420411BE849FC00689976 /* QuestionDescribeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E420401BE849FC00689976 /* QuestionDescribeCell.m */; };
84E420441BE84A2300689976 /* QuestionCommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E420431BE84A2300689976 /* QuestionCommentCell.m */; };
84E420471BE88AE000689976 /* RootTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E420461BE88AE000689976 /* RootTabBarController.m */; };
84ECCF181C01FA2600EA4960 /* QuestionDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ECCF171C01FA2600EA4960 /* QuestionDetailModel.m */; };
84ECCF1B1C0210F000EA4960 /* CommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ECCF1A1C0210F000EA4960 /* CommentModel.m */; };
84ED5DD81BF2E64300A1BB6D /* ScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ED5DD71BF2E64300A1BB6D /* ScreenView.m */; };
84F1669B1BE715E40061D350 /* ZanButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F1669A1BE715E40061D350 /* ZanButton.m */; };
84F30DA41BFC19F200CBAD13 /* RankListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F30DA31BFC19F200CBAD13 /* RankListModel.m */; };
......@@ -251,6 +253,10 @@
84E420431BE84A2300689976 /* QuestionCommentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuestionCommentCell.m; sourceTree = "<group>"; };
84E420451BE88AE000689976 /* RootTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootTabBarController.h; sourceTree = "<group>"; };
84E420461BE88AE000689976 /* RootTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootTabBarController.m; sourceTree = "<group>"; };
84ECCF161C01FA2600EA4960 /* QuestionDetailModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuestionDetailModel.h; sourceTree = "<group>"; };
84ECCF171C01FA2600EA4960 /* QuestionDetailModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuestionDetailModel.m; sourceTree = "<group>"; };
84ECCF191C0210F000EA4960 /* CommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentModel.h; sourceTree = "<group>"; };
84ECCF1A1C0210F000EA4960 /* CommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentModel.m; sourceTree = "<group>"; };
84ED5DD61BF2E64300A1BB6D /* ScreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenView.h; sourceTree = "<group>"; };
84ED5DD71BF2E64300A1BB6D /* ScreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenView.m; sourceTree = "<group>"; };
84F166991BE715E40061D350 /* ZanButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZanButton.h; sourceTree = "<group>"; };
......@@ -526,6 +532,7 @@
8474C5861BE78A85007DCF19 /* QuestionDetail */ = {
isa = PBXGroup;
children = (
84ECCF151C01FA0E00EA4960 /* Model */,
8474C5961BE78BA3007DCF19 /* Cell */,
8474C5871BE78A85007DCF19 /* View */,
8474C5881BE78A85007DCF19 /* ViewController */,
......@@ -1143,6 +1150,17 @@
path = Model;
sourceTree = "<group>";
};
84ECCF151C01FA0E00EA4960 /* Model */ = {
isa = PBXGroup;
children = (
84ECCF161C01FA2600EA4960 /* QuestionDetailModel.h */,
84ECCF171C01FA2600EA4960 /* QuestionDetailModel.m */,
84ECCF191C0210F000EA4960 /* CommentModel.h */,
84ECCF1A1C0210F000EA4960 /* CommentModel.m */,
);
path = Model;
sourceTree = "<group>";
};
84F166981BE715D20061D350 /* ZanButton */ = {
isa = PBXGroup;
children = (
......@@ -1540,11 +1558,13 @@
84C9574D1BDB344900083584 /* UIBarButtonItem+Create.m in Sources */,
84AD4F3D1BF4894D00BFB37C /* RankDetailView.m in Sources */,
84AD4F431BF4A66F00BFB37C /* WorkModel.m in Sources */,
84ECCF1B1C0210F000EA4960 /* CommentModel.m in Sources */,
84E0ABCD1BFB082E001C8F45 /* TaskDetailModel.m in Sources */,
8490C4D31BF9DEF0006B6569 /* PictureTableCell.m in Sources */,
84970E391BD8E0B300C1728A /* LoginView.m in Sources */,
84DB9BC41BDCD4B600822CC4 /* CustomDropMenuView.m in Sources */,
84CF0ED81BE9AC7E00C855CE /* InspectSettleViewController.m in Sources */,
84ECCF181C01FA2600EA4960 /* QuestionDetailModel.m in Sources */,
84846E9A1BE07CDF0010550A /* RankingListCell.m in Sources */,
848699B61BDF812F00859DFE /* RankingListViewController.m in Sources */,
84D825821BDD35E000CC61F7 /* HomeHeaderView.m in Sources */,
......
......@@ -14,4 +14,6 @@
@property (nonatomic, strong) TakePhotoView *takePhotoView;
@property (nonatomic, strong) UIButton *reportBtn;
@end
......@@ -71,6 +71,8 @@
self.placeholderLabel1.text = @"请输入文字...";
self.takePhotoView.backgroundColor = kSectionBackGroundColor;
[self.reportBtn setTitle:@"上报问题" forState:UIControlStateNormal];
}
#pragma mark - UITextView Delegate
......@@ -176,6 +178,33 @@
return _takePhotoView;
}
- (UIButton *)reportBtn
{
if (!_reportBtn) {
_reportBtn = [[UIButton alloc] init];
_reportBtn.translatesAutoresizingMaskIntoConstraints = NO;
_reportBtn.titleLabel.font = [UIFont systemFontOfSize:20.0];
_reportBtn.backgroundColor = kNavigationBarColor;
_reportBtn.layer.cornerRadius = 5.0;
[_reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self addSubview:_reportBtn];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.takePhotoView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10];
[self addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:tableRight];
NSLayoutConstraint *tableHeight = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
[self addConstraint:tableHeight];
}
return _reportBtn;
}
@end
......@@ -14,7 +14,7 @@
#define kAddQuestionCell @"addQuestionTableViewCell"
@interface AddQuestionViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoDelegate>
@interface AddQuestionViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) AddQuestionFooterView *footerView;
......@@ -28,6 +28,8 @@
{
[super viewDidLoad];
self.view.backgroundColor = kFootViewBackGroundColor;
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"新问题提报"];
......@@ -48,8 +50,7 @@
[self addTableView];
// takePhoto按钮点击事件
[self.footerView.takePhotoView.btn addTarget:self action:@selector(addNew:) forControlEvents:UIControlEventTouchUpInside];
// takePhoto代理
self.footerView.takePhotoView.delegate = self;
}
......@@ -73,26 +74,41 @@
self.tableView.tableFooterView = self.footerView;
}
- (void)addNew:(UIButton *)sender
#pragma mark - TakePhoto Delegate
- (void)deletePhoto:(UIButton *)button
{
if (![self.footerView.takePhotoView deleClose:sender]) {
self.footerView.takePhotoView.editTag = -1;
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Unable to find the camera" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
} else {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self.footerView.takePhotoView;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
picker.videoQuality = UIImagePickerControllerQualityTypeLow;
[self presentViewController:picker animated:YES completion:nil];
}
// 从存放所有Image的数组里移除当前点击的Image
[self.footerView.takePhotoView.allImages removeObject:[(UIButton *)button.superview imageForState:UIControlStateNormal]];
// 移除显示Image的Button
[button.superview removeFromSuperview];
CGFloat btnH = 110;
CGFloat marginY = 10;
int count = (int)self.footerView.takePhotoView.allImages.count + 1;
int k ;
if (count % 2 == 0) {
k = count / 2;
} else {
k = (count + 1) / 2;
}
self.footerView.takePhotoView.frame = CGRectMake(0, 170, kScreenWidth, k * btnH + (k + 1) * marginY);
self.footerView.height = self.footerView.takePhotoView.frame.size.height + 220;
}
- (void)createImagePicker
{
// 创建相册
UIImagePickerController *pc = [[UIImagePickerController alloc] init];
pc.allowsEditing = YES;
pc.delegate = self;
// 推出
[self presentViewController:pc animated:YES completion:nil];
}
#pragma mark - TakePhoto Delegate
- (void)takePhotoShowPicture:(UIButton *)btn
{
CheckPicViewController *checkVC = [[CheckPicViewController alloc] init];
......@@ -100,6 +116,33 @@
[self.navigationController pushViewController:checkVC animated:YES];
}
#pragma mark - UIImagePickerController 代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
// 创建一个新的控件
UIButton *newButton = [self.footerView.takePhotoView createButtonWithImage:image selector:@selector(takePhotoShowPicture:)];
[self.footerView.takePhotoView insertSubview:newButton atIndex:self.footerView.takePhotoView.subviews.count - 1];
[self.footerView.takePhotoView.allImages addObject:image];
int count = (int)self.footerView.takePhotoView.allImages.count + 1;
int k ;
if (count % 2 == 0) {
k = count / 2;
} else {
k = (count + 1) / 2;
}
CGFloat btnH = 110;
CGFloat marginY = 10;
self.footerView.takePhotoView.frame = CGRectMake(0, 170, kScreenWidth, k * btnH + (k + 1) * marginY);
self.footerView.height = self.footerView.takePhotoView.frame.size.height + 220;
// 退出图片选择控制器
[picker dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - TableView Delegate/DateSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
......
......@@ -7,7 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "QuestionModel.h"
#import "CommentModel.h"
@interface QuestionCommentCell : UITableViewCell
......@@ -16,6 +16,6 @@
@property (nonatomic, strong) UILabel *positionLabel; // 职位
@property (nonatomic, strong) UILabel *dateLabel; // 时间
@property (nonatomic, strong) QuestionModel *question;
@property (nonatomic, strong) CommentModel *commentModel;
@end
......@@ -24,6 +24,16 @@
}
- (void)setCommentModel:(CommentModel *)commentModel
{
_commentModel = commentModel;
self.suggestLabel.text = [NSString stringWithFormat:@"%@", commentModel.comment];
self.peopleLabel.text = [NSString stringWithFormat:@"%@", commentModel.commentor_name];
self.dateLabel.text = [NSString stringWithFormat:@"%@", commentModel.commentTime];
}
#pragma mark - lazy loading
- (UILabel *)suggestLabel
{
......
......@@ -7,7 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "QuestionModel.h"
#import "QuestionDetailModel.h"
@interface QuestionDescribeCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel; // 标题
......@@ -22,6 +22,6 @@
@property (nonatomic, strong) UILabel *peopleLabel; // 解决人
@property (nonatomic, strong) UILabel *dateLabel; // 时间
@property (nonatomic, strong) QuestionModel *question;
@property (nonatomic, strong) QuestionDetailModel *questionDetail;
@end
......@@ -7,6 +7,11 @@
//
#import "QuestionDescribeCell.h"
#import <UIImageView+WebCache.h>
@interface QuestionDescribeCell ()
@property (nonatomic, strong) NSLayoutConstraint *picConstraint;
@end
@implementation QuestionDescribeCell
#pragma mark - System Methods
......@@ -27,18 +32,19 @@
self.pictureLabel.textColor = kDetailCellDescribeTextColor;
_pictureLabel.text = @"照片";
self.pictureView.backgroundColor = kSectionBackGroundColor;
self.pictureView.backgroundColor = [UIColor whiteColor];
self.feedbackLabel.textColor = kDetailCellDescribeTextColor;
self.feedbackBackView.backgroundColor = kQuestionFeedBackColor;
}
- (void)setQuestion:(QuestionModel *)question
- (void)setQuestionDetail:(QuestionDetailModel *)questionDetail
{
_question = question;
_questionDetail = questionDetail;
// 问题与描述
NSString *describeStr = [NSString stringWithFormat:@"%@", question.content];
NSString *describeStr = [NSString stringWithFormat:@"%@", questionDetail.content];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:describeStr];
NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
paragraphStyle1.alignment = NSTextAlignmentLeft;
......@@ -46,8 +52,64 @@
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [describeStr length])];
self.describeLabel.attributedText = attributedString;
self.pictureView.backgroundColor = [UIColor whiteColor];
CGFloat imageMaginX = 20;
CGFloat imageMaginY = 10;
CGFloat imageW = (kScreenWidth - imageMaginX * 3) / 2;
CGFloat imageH = 110;
int count = (int)questionDetail.attachments.count;
int k ;
if (count % 2 == 0) {
k = count / 2;
} else {
k = (count + 1) / 2;
}
self.picConstraint.constant = imageMaginY + (imageMaginY + imageH) * k;
[self.pictureView setNeedsUpdateConstraints];
for (int i = 0; i < count; i++) {
UIImageView *imageView = [[UIImageView alloc] init];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
NSDictionary *imageDict = questionDetail.attachments[i];
NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kRedStarURL, imageDict[@"fileUrl"]]];
[imageView sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"default_pic"]];
[self.pictureView addSubview:imageView];
int j = 0;
if ((i + 1) % 2 == 0) {
j = count / 2;
} else {
j = (count + 1) / 2;
}
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.pictureView attribute:NSLayoutAttributeTop multiplier:1.0 constant:imageMaginY + (j - 1) * (imageH + imageMaginY)];
[self.pictureView addConstraint:titleTop];
if ((i + 1) % 2 == 0) {
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.pictureView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:imageMaginX + imageW + imageMaginX];
[self.pictureView addConstraint:titleLeft];
} else {
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.pictureView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:imageMaginX];
[self.pictureView addConstraint:titleLeft];
}
// 右边
NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:imageW];
[self.pictureView addConstraint:titleWidth];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:imageH];
[self.pictureView addConstraint:titleHeight];
}
// 反馈
NSString *answerStr = [NSString stringWithFormat:@"%@", question.feedback];
NSString *answerStr = [NSString stringWithFormat:@"%@", questionDetail.feedback];
NSMutableAttributedString *answerAttrStr = [[NSMutableAttributedString alloc] initWithString:answerStr];
NSMutableParagraphStyle *paragraphStyle2 = [[NSMutableParagraphStyle alloc] init];
paragraphStyle2.alignment = NSTextAlignmentLeft;
......@@ -56,8 +118,8 @@
self.answerLabel.attributedText = answerAttrStr;
// 解决人
self.peopleLabel.text = [NSString stringWithFormat:@"问题解决负责人:%@", question.responsiblePersonName];
self.dateLabel.text = [NSString stringWithFormat:@"反馈时间:%@", question.lastModify_time];
self.peopleLabel.text = [NSString stringWithFormat:@"问题解决负责人:%@", questionDetail.resolveUser_name];
self.dateLabel.text = [NSString stringWithFormat:@"反馈时间:%@", questionDetail.lastModify_time];
}
#pragma mark - lazy loading
......@@ -156,16 +218,16 @@
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:120];
[self.contentView addConstraint:titleHeight];
self.picConstraint = [NSLayoutConstraint constraintWithItem:_pictureView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:130];
[self.contentView addConstraint:_picConstraint];
}
return _pictureView;
......
......@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import "ZanButton.h"
#import "QuestionModel.h"
#import "QuestionDetailModel.h"
@interface QuestionDetailCell : UITableViewCell
@property (nonatomic, strong) UILabel *stateLabel; // 状态
......@@ -18,5 +18,5 @@
@property (nonatomic, strong) UILabel *peopleLabel; // 提报人
@property (nonatomic, strong) UILabel *dateLabel; // 提报时间
@property (nonatomic, strong) QuestionModel *question;
@property (nonatomic, strong) QuestionDetailModel *questionDetail;
@end
......@@ -28,12 +28,12 @@
}
- (void)setQuestion:(QuestionModel *)question
- (void)setQuestionDetail:(QuestionDetailModel *)questionDetail
{
_question = question;
_questionDetail = questionDetail;
// 状态
if ([question.state isEqualToString:@"resolved"]) {
if ([questionDetail.state isEqualToString:@"resolved"]) {
NSString *stateText = [NSString stringWithFormat:@"状态:已解决"];
NSMutableAttributedString *stateAttr = [[NSMutableAttributedString alloc] initWithString:stateText];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,3)];
......@@ -48,32 +48,31 @@
}
// 点赞数
[self.thumbBtn setTitle:[NSString stringWithFormat:@"%d",question.likeCount] forState:UIControlStateNormal];
[self.thumbBtn setTitle:[NSString stringWithFormat:@"%d",questionDetail.likeCount] forState:UIControlStateNormal];
// 分类
NSString *sortText = [NSString stringWithFormat:@"分类:%@", question.categoryName];
NSString *sortText = [NSString stringWithFormat:@"分类:%@", questionDetail.category];
NSMutableAttributedString *sortAttr = [[NSMutableAttributedString alloc] initWithString:sortText];
[sortAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,3)];
[sortAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(3,sortText.length - 3)];
[self.sortLabel setAttributedText:sortAttr];
// 商场
NSString *shopText = [NSString stringWithFormat:@"商场:%@", question.projectPath];
NSString *shopText = [NSString stringWithFormat:@"商场:%@", questionDetail.storePath];
NSMutableAttributedString *shopAttr = [[NSMutableAttributedString alloc] initWithString:shopText];
[shopAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,3)];
[shopAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(3,shopText.length - 3)];
[self.shopLabel setAttributedText:shopAttr];
// 问题提报人
NSDictionary *submitPersonDict = question.submitPerson;
NSString *peopleText = [NSString stringWithFormat:@"问题提报人:%@", submitPersonDict[@"name"]];
NSString *peopleText = [NSString stringWithFormat:@"问题提报人:%@", questionDetail.submitUser_name];
NSMutableAttributedString *peopleAttr = [[NSMutableAttributedString alloc] initWithString:peopleText];
[peopleAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,6)];
[peopleAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(6,peopleText.length - 6)];
[self.peopleLabel setAttributedText:peopleAttr];
// 提报时间
NSString *dateText = [NSString stringWithFormat:@"提报时间:%@", question.submitTime];
NSString *dateText = [NSString stringWithFormat:@"提报时间:%@", questionDetail.submitTime];
NSMutableAttributedString *dateAttr = [[NSMutableAttributedString alloc] initWithString:dateText];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,5)];
[dateAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(5,dateText.length - 5)];
......
//
// CommentModel.h
// redstar
//
// Created by admin on 15/11/22.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface CommentModel : NSObject
@property (nonatomic, copy) NSString *comment;
@property (nonatomic, copy) NSString *commentTime;
@property (nonatomic, copy) NSString *commentor_code;
@property (nonatomic, copy) NSString *commentor_name;
@property (nonatomic, copy) NSString *commentor_uuid;
@property (nonatomic, copy) NSString *entityType;
@property (nonatomic, copy) NSString *entityUuid;
@property (nonatomic, copy) NSString *star;
@property (nonatomic, copy) NSString *uuid;
@end
//
// CommentModel.m
// redstar
//
// Created by admin on 15/11/22.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "CommentModel.h"
@implementation CommentModel
@end
//
// QuestionDetailModel.h
//
//
// Created by admin on 15/11/22.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface QuestionDetailModel : NSObject
@property (nonatomic, strong) NSArray *attachments;
@property (nonatomic, copy) NSString *category;
@property (nonatomic, strong) NSArray *comments;
@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 *feedback;
@property (nonatomic, copy) NSString *group;
@property (nonatomic, copy) NSString *hotspot;
@property (nonatomic, copy) NSString *lastModify_id;
@property (nonatomic, copy) NSString *lastModify_operName;
@property (nonatomic, copy) NSString *lastModify_time;
@property (nonatomic, assign) int likeCount;
@property (nonatomic, assign) BOOL myLike;
@property (nonatomic, copy) NSString *resolveTime;
@property (nonatomic, copy) NSString *resolveUser_code;
@property (nonatomic, copy) NSString *resolveUser_name;
@property (nonatomic, copy) NSString *resolveUser_uuid;
@property (nonatomic, copy) NSString *solutionType;
@property (nonatomic, copy) NSString *state;
@property (nonatomic, copy) NSString *storePath;
@property (nonatomic, copy) NSString *submitTime;
@property (nonatomic, copy) NSString *submitUser_code;
@property (nonatomic, copy) NSString *submitUser_name;
@property (nonatomic, copy) NSString *submitUser_uuid;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *version;
@end
//
// QuestionDetailModel.m
// redstar
//
// Created by admin on 15/11/22.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "QuestionDetailModel.h"
@implementation QuestionDetailModel
@end
......@@ -7,10 +7,9 @@
//
#import <UIKit/UIKit.h>
#import "QuestionModel.h"
@interface QuestionDetailViewController : UIViewController
@property (nonatomic,strong) QuestionModel *question;
@property (nonatomic, assign) NSInteger row;
@property (nonatomic, copy) NSString *questionUuid;
@end
......@@ -16,19 +16,20 @@
#import "HttpClient.h"
#import <MBProgressHUD.h>
#import "QuestionDetailModel.h"
#import "CommentModel.h"
#define kQuestionDetailCell @"QuestionDetailCell" // 问题详情
#define kQuestionCommentCell @"QuestionCommentCell" // 评论
#define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述
@interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) QuestionDetailFooterView *footerView;
@property (nonatomic, strong) NSArray *test1Array;
@property (nonatomic, strong) NSArray *test2Array;
@property (nonatomic, strong) NSArray *test3Array;
@property (nonatomic, strong) UIView *backGroundView;
@property (nonatomic, strong) CommentView *commentView;
@property (nonatomic, strong) QuestionDetailModel *questionDetailModel;
@property (nonatomic, strong) NSMutableArray *allCommentArray;
@end
@implementation QuestionDetailViewController
......@@ -37,18 +38,23 @@
{
[super viewDidLoad];
self.tableView.tableFooterView = self.footerView;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.navigationController.navigationBar.translucent = NO;
}
[self.footerView.addButon addTarget:self action:@selector(addComment:) forControlEvents:UIControlEventTouchUpInside];
[self setupNav];
self.test1Array = [NSArray arrayWithObjects:@"该建议很好", @"有效提高了用户体验,减少不必要的工作,还符合了上级提出的四个现代化,建议多提类似建议!", nil];
self.test2Array = [NSArray arrayWithObjects:@"李XX 集团XX总", @"王XX 某大区经理", nil];
self.test3Array = [NSArray arrayWithObjects:@"2015-09-10 10:21:43", @"2015-10-27 11:21:43", nil];
// 问题详情
[self requestQestionDetail];
self.view.backgroundColor = kSectionBackGroundColor;
}
- (void)viewWillAppear:(BOOL)animated
......@@ -68,15 +74,28 @@
#pragma mark - Private Methods
- (void)requestQestionDetail
{
self.allCommentArray = [NSMutableArray array];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *user_uuid = dict[@"user_uuid"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kQuestionListURL, _question.uuid,user_uuid];
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kQuestionDetailURL, _questionUuid ,user_uuid];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getQuestionDetailWithParameters:nil completion:^(id response, NSError *error) {
NSLog(@"response = %@", response);
NSDictionary *dict = response[@"data"];
NSLog(@"问题详情 = %@", dict);
QuestionDetailModel *quesDetail = [[QuestionDetailModel alloc] init];
[quesDetail setValuesForKeysWithDictionary:dict];
_questionDetailModel = quesDetail;
NSArray *commentArray = _questionDetailModel.comments;
for (NSDictionary *dict in commentArray) {
CommentModel *comment = [[CommentModel alloc] init];
[comment setValuesForKeysWithDictionary:dict];
[_allCommentArray addObject:comment];
}
self.tableView.tableFooterView = self.footerView;
}];
}
......@@ -160,7 +179,7 @@
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"entityType":@"question",
@"entityUuid":_question.uuid,
@"entityUuid":_questionUuid,
@"star":count,
@"comment":_commentView.contentTextView.text};
NSLog(@"parameters = %@", parameters);
......@@ -210,7 +229,7 @@
NSString *operId = dict[@"user_code"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, _question.uuid, dateString, operId, operName];
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, _questionUuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
......@@ -241,7 +260,7 @@
} else if (section == 1) {
return 1;
} else {
return _test1Array.count;
return _allCommentArray.count;
}
}
......@@ -253,7 +272,7 @@
if (!cell) {
cell = [[QuestionDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDetailCell];
}
cell.question = self.question;
cell.questionDetail = self.questionDetailModel;
[cell.thumbBtn addTarget:self action:@selector(addZan:) forControlEvents:UIControlEventTouchUpInside];
return cell;
......@@ -262,7 +281,7 @@
if (!cell) {
cell = [[QuestionDescribeCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDescribeCell];
}
cell.question = self.question;
cell.questionDetail = self.questionDetailModel;
return cell;
} else {
......@@ -270,13 +289,9 @@
if (!cell) {
cell = [[QuestionCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionCommentCell];
}
cell.suggestLabel.text = _test1Array[indexPath.row];
cell.peopleLabel.text = _test2Array[indexPath.row];
cell.dateLabel.text = _test3Array[indexPath.row];
cell.commentModel = _allCommentArray[indexPath.row];
return cell;
}
}
// section高度
......@@ -368,12 +383,12 @@
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 200.0;
_tableView.estimatedRowHeight = 400.0;
[_tableView registerClass:[QuestionDetailCell class] forCellReuseIdentifier:kQuestionDetailCell];
[_tableView registerClass:[QuestionCommentCell class] forCellReuseIdentifier:kQuestionCommentCell];
[_tableView registerClass:[QuestionDescribeCell class] forCellReuseIdentifier:kQuestionDescribeCell];
......
......@@ -30,14 +30,13 @@
_question = question;
// 标题
self.titleLabel.text = [NSString stringWithFormat:@"%@",question.content];
self.titleLabel.text = [NSString stringWithFormat:@"%@",question.title];
// 反馈(副标题)
self.detailsLabel.text = [NSString stringWithFormat:@"%@", question.feedback];
self.detailsLabel.text = [NSString stringWithFormat:@"%@", question.content];
// 服务类型
self.stateLabel.text = [NSString stringWithFormat:@"%@", question.categoryName];
self.stateLabel.text = [NSString stringWithFormat:@"%@", question.category];
// 提报时间
self.dateLabel.text = [NSString stringWithFormat:@"提报时间:%@", question.submitTime];
// 点赞数
[self.thumbBtn setTitle:[NSString stringWithFormat:@"%d", question.likeCount] forState:UIControlStateNormal];
......@@ -46,6 +45,12 @@
} else {
self.hotLabel.hidden = YES;
}
if (question.myLike) {
self.thumbBtn.selected = YES;
} else {
self.thumbBtn.selected = NO;
}
}
#pragma mark - lazy laoding
......@@ -201,6 +206,7 @@
_thumbBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
[_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
[_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal];
[_thumbBtn setImage:[UIImage imageNamed:@"commend_after"] forState:UIControlStateSelected];
[self.contentView addSubview:_thumbBtn];
// 顶端
......
......@@ -10,33 +10,38 @@
@interface QuestionModel : NSObject
@property (nonatomic, strong) NSString *uuid;//唯一标识
@property (nonatomic, strong) NSString *categoryName;//问题分类名称
@property (nonatomic, strong) NSString *categoryUuid;//问题分类Uuid
@property (nonatomic, strong) NSArray *attachments;
@property (nonatomic, strong) NSString *category;//唯一标识
@property (nonatomic, strong) NSArray *comments;//问题分类名称
@property (nonatomic, strong) NSString *content; //问题内容
@property (nonatomic, strong) NSString *create_id; //
@property (nonatomic, strong) NSString *create_operName; //
@property (nonatomic, strong) NSString *create_time;//
@property (nonatomic, strong) NSString *enterprise;//
@property (nonatomic, strong) NSString *feedback;//问题反馈
@property (nonatomic, strong) NSString *groupName;//专业组名称
@property (nonatomic, strong) NSString *groupUuid;//专业组Uuid
@property (nonatomic, strong) NSString *group;//专业组名称
@property (nonatomic, assign) BOOL hotspot; // 热点问题
@property (nonatomic, strong) NSString *lastModify_id;//
@property (nonatomic, strong) NSString *lastModify_operName;//
@property (nonatomic, strong) NSString *lastModify_time;//
@property (nonatomic, strong) NSArray *pictureIds;//pictureIds
@property (nonatomic, strong) NSString *projectName;//商场名称
@property (nonatomic, strong) NSString *projectPath;//组织路径
@property (nonatomic, strong) NSString *projectUuid;//商场Uuid
@property (nonatomic, strong) NSDictionary *resolvePerson;//问题解决人Uuid
@property (nonatomic, strong) NSString *responsiblePersonName;//责任人姓名
@property (nonatomic, strong) NSString *responsiblePersonUuid;//责任人Uuid
@property (nonatomic, strong) NSString *state;//问题状态
@property (nonatomic, strong) NSDictionary *submitPerson;//
@property (nonatomic, assign) int likeCount; // 点赞数
@property (nonatomic, assign) BOOL myLike;
@property (nonatomic, strong) NSString *resolveTime;//pictureIds
@property (nonatomic, strong) NSString *resolveUser_code;
@property (nonatomic, strong) NSString *resolveUser_name;
@property (nonatomic, strong) NSString *resolveUser_uuid;//商场名称
@property (nonatomic, strong) NSString *solutionType;//问题解决人Uuid
@property (nonatomic, strong) NSString *state;//责任人姓名
@property (nonatomic, strong) NSString *storePath;//责任人Uuid
@property (nonatomic, strong) NSString *submitTime;//
@property (nonatomic, strong) NSString *type;//问题处理分类
@property (nonatomic, strong) NSString *submitUser_code;
@property (nonatomic, strong) NSString *submitUser_name;//
@property (nonatomic, strong) NSString *submitUser_uuid;//
@property (nonatomic, strong) NSString *title;//问题处理分类
@property (nonatomic, strong) NSString *uuid;//
@property (nonatomic, strong) NSString *version;//
@property (nonatomic, assign) BOOL hotspot; // 热点问题
@property (nonatomic, assign) int likeCount; // 点赞数
@end
......@@ -94,20 +94,13 @@
self.allQuestionArray = [NSMutableArray array];
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *user_uuid = dict[@"user_uuid"];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// 请求参数
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
@"group":@"",
@"category":@"",
@"contentLike":@"",
@"keyword":@"",
@"state":@"created",
@"submitTimeFrom":@"",
@"submitTimeTo":@"",
@"pageNumber":@(1),
@"pageSize":@(10)
@"pageNumber":@(0),
@"pageSize":@(20)
};
// 发起请求
......@@ -120,7 +113,7 @@
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"问题与知识列表recods = %@", recordsDict);
NSLog(@"问题与知识列表recods = %@", response);
NSLog(@"error = %@", error);
for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init];
......@@ -191,28 +184,43 @@
NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"];
NSString *operId = dict[@"user_code"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount + 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
NSString *operId = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_code"];
NSString *operName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"];
if (sender.selected) {
// 点赞
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount + 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
} else {
// 取消点赞
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kCancelLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
NSLog(@"取消点赞response = %@", response);
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount - 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"取消点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
}
}
- (void)addClick:(UIButton *)sender
{
AddQuestionViewController *addQuestionVC = [[AddQuestionViewController alloc] init];
......@@ -415,7 +423,8 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
questionDetailVC.question = (QuestionModel *)_allQuestionArray[indexPath.row];
QuestionModel *question = (QuestionModel *)_allQuestionArray[indexPath.row];
questionDetailVC.questionUuid = question.uuid;
questionDetailVC.row = indexPath.row;
[self.navigationController pushViewController:questionDetailVC animated:YES];
}
......
//
// TakePhotoView.h
// redstar
// test
//
// Created by admin on 15/11/4.
// Created by admin on 15/11/21.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol TakePhotoViewDelegate <NSObject>
@protocol TakePhotoDelegate <NSObject>
@optional
- (void)takePhotoShowPicture:(UIButton *)btn;
- (void)deletePhoto:(UIButton *)button;
- (void)createImagePicker;
@end
@interface TakePhotoView : UIView <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
// 标识被编辑的按钮 -1 为添加新的按钮
NSInteger editTag;
}
@property (nonatomic, strong) UIButton *btn;
@property (nonatomic, assign) NSInteger editTag;
@interface TakePhotoView : UIView
@property (nonatomic, strong) NSMutableArray *allImages;
@property (nonatomic, strong) id <TakePhotoDelegate>delegate;
@property (nonatomic, strong) UIViewController *viewController;
@property (nonatomic, assign) id <TakePhotoViewDelegate>delegate;
- (BOOL)deleClose:(UIButton *)btn;
- (UIButton *)createButtonWithImage:(id)imageNameOrImage andSeletor : (SEL)selector;
- (void)changeOld:(UIButton *)btn;
- (UIButton *)createButtonWithImage:(UIImage *)image selector:(SEL)selector;
@end
......@@ -15,7 +15,7 @@
#import "HttpClient.h"
#define kInspectSettleCell @"InspectSettleCell"
@interface InspectSettleViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoDelegate>
@interface InspectSettleViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) InspectDetailFooterView *footerView;
......@@ -47,7 +47,6 @@
self.tableView.tableFooterView = self.footerView;
self.footerView.takePhotoView.delegate = self;
[self.footerView.takePhotoView.btn addTarget:self action:@selector(addNew:) forControlEvents:UIControlEventTouchUpInside];
}
......@@ -57,7 +56,6 @@
}
#pragma mark - private Methods
// 返回上一页面
- (void)doBack:(UIBarButtonItem *)sender
{
......@@ -65,6 +63,26 @@
}
#pragma mark - TakePhoto Delegate
- (void)deletePhoto:(UIButton *)button
{
// 从存放所有Image的数组里移除当前点击的Image
[self.footerView.takePhotoView.allImages removeObject:[(UIButton *)button.superview imageForState:UIControlStateNormal]];
// 移除显示Image的Button
[button.superview removeFromSuperview];
}
- (void)createImagePicker
{
// 创建相册
UIImagePickerController *pc = [[UIImagePickerController alloc] init];
pc.allowsEditing = YES;
pc.delegate = self;
// 推出
[self presentViewController:pc animated:YES completion:nil];
}
- (void)takePhotoShowPicture:(UIButton *)btn
{
CheckPicViewController *checkVC = [[CheckPicViewController alloc] init];
......@@ -72,27 +90,33 @@
[self.navigationController pushViewController:checkVC animated:YES];
}
#pragma mark - Private Methods
- (void)addNew:(UIButton *)sender
#pragma mark - UIImagePickerController 代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if (![self.footerView.takePhotoView deleClose:sender]) {
self.footerView.takePhotoView.editTag = -1;
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Unable to find the camera" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
} else {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self.footerView.takePhotoView;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
picker.videoQuality = UIImagePickerControllerQualityTypeLow;
[self presentViewController:picker animated:YES completion:nil];
}
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
// 创建一个新的控件
UIButton *newButton = [self.footerView.takePhotoView createButtonWithImage:image selector:@selector(takePhotoShowPicture:)];
[self.footerView.takePhotoView insertSubview:newButton atIndex:self.footerView.takePhotoView.subviews.count - 1];
[self.footerView.takePhotoView.allImages addObject:image];
int count = (int)self.footerView.takePhotoView.allImages.count + 1;
int k ;
if (count % 2 == 0) {
k = count / 2;
} else {
k = (count + 1) / 2;
}
CGFloat btnH = 110;
CGFloat marginY = 10;
self.footerView.takePhotoView.frame = CGRectMake(0, 40, kScreenWidth, k * btnH + (k + 1) * marginY);
self.footerView.height = self.footerView.takePhotoView.frame.size.height + 220;
NSLog(@"self.footerView = %f", self.footerView.frame.size.height);
// 退出图片选择控制器
[picker dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
......
......@@ -32,12 +32,16 @@
#define kHomeQuestionListTableCell @"homeQuestionListTableCell"
#import "QuestionModel.h"
#import "QuestionDetailViewController.h"
#define kQuestionTag 387428
#import "InspectListCell.h"
#define kHomeInspectListCell @"homeInspectListsCell"
#import "InspectTaskViewController.h"
#import "TaskListModel.h"
#import "HttpClient.h"
#import <MBProgressHUD.h>
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate>
@property (nonatomic, strong) UIImageView *bgImageView; // 背景
@property (nonatomic, strong) UITextField *searchTextField; // 搜索框
......@@ -67,6 +71,8 @@
// rank cell
@property (nonatomic, strong) NSMutableDictionary *selectedIndexes;
@property (nonatomic, strong) NSMutableArray *allQuestionArray; // 问题与知识
@end
@implementation HomeViewController
......@@ -105,6 +111,9 @@
// 初始化容器
self.selectedIndexes = [[NSMutableDictionary alloc] init];
// 问题与知识
[self requestQuestionList];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -119,6 +128,44 @@
[super didReceiveMemoryWarning];
}
#pragma mark - 请求
- (void)requestQuestionList
{
// 初始化数组
self.allQuestionArray = [NSMutableArray array];
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// 请求参数
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
@"pageNumber":@(0),
@"pageSize":@(2)
};
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
//
__block HomeViewController *weakSelf = self;
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
// 请求问题列表
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"问题与知识列表recods = %@", response);
NSLog(@"error = %@", error);
for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init];
[question setValuesForKeysWithDictionary:questionDict];
[weakSelf.allQuestionArray addObject:question];
}
self.tableView.tableHeaderView = self.headView;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
#pragma mark - Private Methods
- (void)setupNav
{
......@@ -151,13 +198,9 @@
[item addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchUpInside];
[self.headView.scrollView addSubview:item];
}
self.tableView.tableHeaderView = self.headView;
}
// 更多按钮点击事件
- (void)moreButtonClick:(UIButton *)sender
{
UIButton *button = (UIButton *)sender;
......@@ -212,6 +255,59 @@
[self presentViewController:nav animated:YES completion:nil];
}
- (void)addZan:(ZanButton *)sender
{
sender.selected = !sender.selected;
NSInteger key = sender.tag - kQuestionTag;
QuestionModel *question = _allQuestionArray[key];
NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:date];
NSDate *localeDate = [date dateByAddingTimeInterval:interval];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSString *operId = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_code"];
NSString *operName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"];
if (sender.selected) {
// 点赞
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount + 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
} else {
// 取消点赞
NSString *url = [NSString stringWithFormat:@"%@%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kCancelLikeURL, question.uuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient likeCountWithParameters:nil completion:^(id response, NSError *error) {
NSLog(@"取消点赞response = %@", response);
if (response[@"success"]) {
int likeCount = [sender.titleLabel.text intValue];
[sender setTitle:[NSString stringWithFormat:@"%d", likeCount - 1] forState:UIControlStateNormal];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"取消点赞失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}];
}
}
// rank Cell
- (BOOL)cellIsSelected:(NSIndexPath *)indexPath {
......@@ -396,17 +492,16 @@
return cell;
}
} else if (indexPath.section == 2) {
// 问题与知识
QuestionListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeQuestionListTableCell];
if (!cell) {
cell = [[QuestionListTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeQuestionListTableCell];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
QuestionModel *question = [[QuestionModel alloc] init];
question.content = @"OMS系统不能执行15分钟退货程序处理,应该添加";
question.feedback = @"启动线下“30天无理由退货”程序处理OMS系统的相关问题";
question.categoryName = @"送货跟单-送货跟单";
question.submitTime = @"2015-09-11 10:23:12";
QuestionModel *question = _allQuestionArray[indexPath.row];
cell.question = question;
[cell.thumbBtn addTarget:self action:@selector(addZan:) forControlEvents:UIControlEventTouchUpInside];
cell.thumbBtn.tag = kQuestionTag + indexPath.row;
return cell;
} else {
......@@ -448,12 +543,8 @@
}
} else if (indexPath.section == 2) {
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
QuestionModel *question = [[QuestionModel alloc] init];
question.content = @"OMS系统不能执行15分钟退货程序处理,应该添加";
question.feedback = @"启动线下“30天无理由退货”程序处理OMS系统的相关问题";
question.categoryName = @"送货跟单-送货跟单";
question.submitTime = @"2015-09-11 10:23:12";
questionDetailVC.question = question;
QuestionModel *question = _allQuestionArray[indexPath.row];
questionDetailVC.questionUuid = question.uuid;
[self.navigationController pushViewController:questionDetailVC animated:YES];
} else {
......@@ -718,7 +809,7 @@
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
[_tableView registerClass:[PictureTableCell class] forCellReuseIdentifier:kHomePictureListCell];
[_tableView registerClass:[HomeTitleTableCell class] forCellReuseIdentifier:kHomeTitleTableCell];
[_tableView registerClass:[RankingListCell class] forCellReuseIdentifier:kHomeRankingListCell];
......@@ -735,7 +826,7 @@
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:-40];
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;
......
......@@ -84,8 +84,15 @@
[userDefault setObject:username forKey:@"username"];
[userDefault setObject:password forKey:@"password"];
[userDefault setObject:response[@"message"] forKey:@"loginMessage"];
[userDefault setObject:(NSDictionary *)response[@"data"] forKey:@"loginData"];
NSDictionary *dict = response[@"data"];
NSString *user_code = dict[@"user_code"];
NSString *user_name = dict[@"user_name"];
NSString *user_uuid = dict[@"user_uuid"];
[userDefault setObject:user_code forKey:@"user_code"];
[userDefault setObject:user_name forKey:@"user_name"];
[userDefault setObject:user_uuid forKey:@"user_uuid"];
self.rootTBC = [[RootTabBarController alloc] init];
[MBProgressHUD hideHUDForView:window animated:YES];
[self presentViewController:_rootTBC animated:YES completion:nil];
......@@ -113,9 +120,6 @@
*/
- (void)loginButtonClick:(UIButton *)sender
{
// // 进入RootTabBar
// self.rootTBC = [[RootTabBarController alloc] init];
// [self presentViewController:_rootTBC animated:YES completion:nil];
if (self.loginView.usernameTextFiled.text.length == 0 || self.loginView.passwordTextFiled.text.length == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"账号、密码不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
......@@ -135,8 +139,13 @@
[[NSUserDefaults standardUserDefaults] setObject:self.loginView.usernameTextFiled.text forKey:@"username"];
[[NSUserDefaults standardUserDefaults] setObject:self.loginView.passwordTextFiled.text forKey:@"password"];
[[NSUserDefaults standardUserDefaults] setObject:response[@"message"] forKey:@"loginMessage"];
[[NSUserDefaults standardUserDefaults] setObject:response[@"data"] forKey:@"loginData"];
NSDictionary *dict = response[@"data"];
NSString *user_code = dict[@"user_code"];
NSString *user_name = dict[@"user_name"];
NSString *user_uuid = dict[@"user_uuid"];
[[NSUserDefaults standardUserDefaults] setObject:user_code forKey:@"user_code"];
[[NSUserDefaults standardUserDefaults] setObject:user_name forKey:@"user_name"];
[[NSUserDefaults standardUserDefaults] setObject:user_uuid forKey:@"user_uuid"];
// 进入RootTabBar
self.rootTBC = [[RootTabBarController alloc] init];
[MBProgressHUD hideHUDForView:window animated:YES];
......
......@@ -108,7 +108,7 @@
// 获取问题列表
- (void)getQuestionListWithParameters:(id)parameters completion:(completionBlock)completion
{
[self getParameters:parameters completion:^(id response, NSError *error) {
[self postParameters:parameters completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
......
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