| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- //
- // DemanddetailViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2017/12/16.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "DemanddetailViewController.h"
- #import "DemandCell.h"
- #import "RequirementdescriptionCell.h"
- #import "OrdertakingViewController.h"
- #import "DemanddetailModel.h"
- #import "CGPurchaseintentionViewController.h"
- #import "XuqiuImageCell.h"
- #import "YBPopupMenu.h"
- #import "MyattentionViewController.h"
- #import "MyOrderViewController.h"
- #import "AchievementsReleaseViewController.h"
- #import "ReleaserequirementsViewController.h"
- #define TITLES @[@"我的关注", @"我的订单",@"发布成果",@"发布需求"]
- #define ICONS @[@"wdgz",@"wddd",@"fbcg",@"fbxq"]
- @interface DemanddetailViewController ()<UITableViewDelegate,UITableViewDataSource,YBPopupMenuDelegate>{
- UITableView *newtableView;
- NSMutableArray *dataArray;
- NSMutableArray *DemanddetailArray;
- UIButton *followBT;
- }
- @property (strong ,nonatomic) UIButton * registerAccount;
- @end
- @implementation DemanddetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"需求详情"];
- [self dataInitialization];
- [self demandDetailsNetworkrequest];
- [self loadsView];
- // Do any additional setup after loading the view.
- }
- #pragma mark ---------需求详情关注网络请求-------
- - (void)followBTclick:(UIButton *)sender {
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- NSMutableDictionary *parameters = NewMutableDictionaryInit;
- // [parameters safeSetObject:[UserEntity sharedInstance].token forKey:@"uid"];
- /*
- 0-成果 1-需求 2-专家 3-政策 4-活动 5-其他
- */
- [parameters safeSetObject:@"1" forKey:@"type"];
- DemanddetailModel *model = DemanddetailArray[0];
- [parameters safeSetObject:model.ID forKey:@"objectId"];
- [parameters safeSetObject:model.interest forKey:@"interest"];
- [NetworkRequestManager requestGetWithInterfacePrefix:JT_interestAdd parameters:parameters onSuccess:^(id requestData) {
- NSLog(@"服务器返回数据:%@",requestData);
- if ([requestData[@"error"] count] !=0) {
- for (NSDictionary *dic in requestData[@"error"]) {
- [MBProgressHUD showError:dic[@"message"] toView:self.view];
- }
- }else{
- if ([requestData[@"data"] isEqualToString:@"取消关注成功"]) {
- DemanddetailModel *model = DemanddetailArray[0];
- NSInteger follownumber = [model.countInterest integerValue]-1;
- model.countInterest = [NSString stringWithFormat:@"%ld",follownumber];
- model.interest = @"0";
- [DemanddetailArray removeAllObjects];
- [DemanddetailArray addObject:model];
- [followBT setImage:[UIImage imageNamed:@"未关注"] forState:UIControlStateNormal];
- [MBProgressHUD showSuccess:@"哎呀,您取消关注啦!" toView:self.view];
- [newtableView reloadData];
- }else{
- ResultsDetailsModel *model = DemanddetailArray[0];
- NSInteger follownumber = [model.countInterest integerValue]+1;
- model.countInterest = [NSString stringWithFormat:@"%ld",follownumber];
- model.interest = @"1";
- [DemanddetailArray removeAllObjects];
- [DemanddetailArray addObject:model];
- [followBT setImage:[UIImage imageNamed:@"已关注"] forState:UIControlStateNormal];
- [MBProgressHUD showSuccess:@"哎呀,您关注成功啦!" toView:self.view];
- [newtableView reloadData];
- }
- }
- } onFailure:^{
-
- }];
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }
- #pragma mark -------需求详情网络请求--------
- - (void)demandDetailsNetworkrequest {
- [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
- NSMutableDictionary *parameters = NewMutableDictionaryInit;
- [parameters safeSetObject:_ID forKey:@"id"];
- [NetworkRequestManager requestGetWithInterfacePrefix:JT_demandDetail parameters:parameters onSuccess:^(id requestData) {
- [MBProgressHUD hideHUDForView:self.view];
- NSLog(@"服务器返回数据:%@",requestData);
- if ([requestData[@"error"] count] !=0) {
- for (NSDictionary *dic in requestData[@"error"]) {
- [MBProgressHUD showError:dic[@"message"] toView:self.view];
- }
- }else{
- DemanddetailModel *model = [[DemanddetailModel alloc] initWithDictionary:requestData[@"data"] error:nil];
- [DemanddetailArray addObject:model];
- if ([model.interest isEqualToString:@"0"]) {
- [followBT setImage:[UIImage imageNamed:@"未关注"] forState:UIControlStateNormal];
- }else{
- [followBT setImage:[UIImage imageNamed:@"已关注"] forState:UIControlStateNormal];
- }
- [newtableView reloadData];
- }
- } onFailure:^{
- [MBProgressHUD hideHUDForView:self.view];
- }];
- }
- - (void)dataInitialization {
- dataArray = NewMutableArrayInit;
- [dataArray addObject:@"1"];
- [dataArray addObject:@"1"];
- DemanddetailArray = NewMutableArrayInit;
- }
- #pragma mark ----加载界面
- - (void)loadsView{
- [self.navgationBar addSubview:self.registerAccount];
- _registerAccount.sd_layout
- .widthIs(30)
- .rightSpaceToView(self.navgationBar, 10)
- .heightIs(44)
- .topSpaceToView(self.navgationBar, 18);
- [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeader) backgroundColor:NewGroupTableViewBackgroundColor style:1 delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
- newtableView.separatorStyle = NO;
- UIView *view = [UIView new];
- view.backgroundColor = NewWhiteColor;
- [self.view addSubview:view];
-
- view.sd_layout
- .bottomEqualToView(self.view)
- .heightIs(44)
- .widthIs(SCREEN_WIDTH);
-
- followBT = [UIButton new];
- followBT.backgroundColor = NewClearColor;
- NewTouchUpInside(followBT, followBTclick:);
- [view addSubview:followBT];
-
- followBT.sd_layout
- .leftEqualToView(view)
- .heightIs(44)
- .topEqualToView(view)
- .widthIs(44);
-
- UIButton *submissionpurchase = [UIButton new];
- [submissionpurchase setTitle:@"接 单" forState:UIControlStateNormal];
- [submissionpurchase setTitleColor:NewWhiteColor forState:UIControlStateNormal];
- submissionpurchase.titleLabel.font = NewFont(15);
- submissionpurchase.titleLabel.textAlignment = NSTextAlignmentCenter;
- submissionpurchase.backgroundColor = NewRGBColor(252, 133, 52, 1);
- NewTouchUpInside(submissionpurchase, submissionpurchaseclick:);
- [view addSubview:submissionpurchase];
-
- submissionpurchase.sd_layout
- .rightEqualToView(view)
- .heightIs(44)
- .widthIs(fitScreenWidth(121));
-
- UIButton *negotiate = [UIButton new];
- [negotiate setTitle:@"洽 谈" forState:UIControlStateNormal];
- [negotiate setTitleColor:NewWhiteColor forState:UIControlStateNormal];
- negotiate.titleLabel.font = NewFont(15);
- negotiate.titleLabel.textAlignment = NSTextAlignmentCenter;
- negotiate.backgroundColor = NewButtonColor;
- NewTouchUpInside(negotiate, negotiateclick:);
- [view addSubview:negotiate];
-
- negotiate.sd_layout
- .rightSpaceToView(submissionpurchase, 1)
- .heightIs(44)
- .widthIs(fitScreenWidth(121));
-
- }
- #pragma mark-------------------------UITableView------------------------------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- //返回每段行数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return dataArray.count+1;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *Cell = @"Cell";
- static NSString *Cell1 = @"Cell1";
- static NSString *Cell2 = @"Cell2";
- if (indexPath.row == 0) {
- DemandCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
- if (cell == nil) {
- cell = [[DemandCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (DemanddetailArray.count>0) {
- [cell assignment:DemanddetailArray[indexPath.row]];
- }
- return cell;
- }else if (indexPath.row == 1){
- RequirementdescriptionCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1];
- if (cell == nil) {
- cell = [[RequirementdescriptionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (DemanddetailArray.count>0) {
- cell.title.text = @"需求描述";
- DemanddetailModel *model = DemanddetailArray[0];
- if (model.problemDes == NULL) {
- cell.content.text = @"暂无需求描述";
- }else{
- cell.content.text = model.problemDes;
- }
- }
- return cell;
- }else if (indexPath.row == 2){
- XuqiuImageCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell2];
- if (cell == nil) {
- cell = [[XuqiuImageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell2];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (DemanddetailArray.count>0) {
- DemanddetailModel *model = DemanddetailArray[0];
- UIImageView *image = [UIImageView new];
- image.backgroundColor = NewClearColor;
- image.frame = CGRectMake(15, 0, SCREEN_WIDTH-30, 188);
- if (model.pictureUrls.count>0) {
- [image sd_setImageWithURL:NewURL([model.pictureUrls[0] mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"")];
- }
- [cell.contentView addSubview:image];
- }
- return cell;
- }
- return [[UITableViewCell alloc] init];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 0) {
- return 220;
- }else if(indexPath.row == 1){
- if (DemanddetailArray.count>0) {
- DemanddetailModel *model = DemanddetailArray[0];
- if (model.problemDes == NULL) {
- CGFloat height = [NewUtils heightforString:@"暂无需求描述" andWidth:SCREEN_WIDTH-30 fontSize:fitScreenWidth(13)];
- return height+70;
- }else{
- CGFloat height = [NewUtils heightforString:model.problemDes andWidth:SCREEN_WIDTH-30 fontSize:fitScreenWidth(13)];
- return height+70;
- }
- }
- }else if (indexPath.row == 2){
- if (DemanddetailArray.count>0) {
- DemanddetailModel *model = DemanddetailArray[0];
- if (model.pictureUrls.count>0) {
- return 188;
- }else{
- return 0;
- }
- }
- }
- return 0;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- #pragma mark ------接单------
- - (void)submissionpurchaseclick:(UIButton *)sender {
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- DemanddetailModel *model = DemanddetailArray[0];
- CGPurchaseintentionViewController *vc = [[CGPurchaseintentionViewController alloc] init];
- vc.ID = model.ID;
- vc.commodityType = @"2";
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }
- - (void)negotiateclick:(UIButton *)sender {
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- if (DemanddetailArray.count>0) {
- DemanddetailModel *model = DemanddetailArray[0];
- if (model.easemobName == NULL) {
- model.easemobName = HXKF;
- }
- EaseMessageViewController *viewController = [[EaseMessageViewController alloc] initWithConversationChatter:model.easemobName conversationType:0];
- if ([model.easemobName isEqualToString:HXKF]) {
- viewController.title = @"客服在线";
- }else{
- viewController.title = model.easemobName;
- }
- viewController.hidesBottomBarWhenPushed = YES;
- [[NSNotificationCenter defaultCenter]postNotificationName:@"环信登录成功" object:nil];
- [self.navigationController pushViewController:viewController animated:YES];
- }
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }
- - (UIButton *)registerAccount
- {
- if (!_registerAccount)
- {
- _registerAccount = [UIButton buttonWithType:UIButtonTypeCustom];
- // [_registerAccount setTitle:@"" forState:UIControlStateNormal];
- [_registerAccount setTitleColor:[UIColor colorWithString:@"#9A9A9A"] forState:UIControlStateNormal];
- [_registerAccount setBackgroundColor:[UIColor clearColor]];
- [_registerAccount setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
- [_registerAccount.titleLabel setFont:[UIFont systemFontOfSize:fitScreenWidth(14)]];
- [_registerAccount addTarget:self action:@selector(touchRegister:) forControlEvents:UIControlEventTouchUpInside];
- // [_registerAccount setupAutoSizeWithHorizontalPadding:5 buttonHeight:44];
- [_registerAccount setImage:NewImageNamed(@"gd") forState:UIControlStateNormal];
- }
- return _registerAccount;
- }
- - (void)touchRegister:(UIButton *)sender{
- [YBPopupMenu showRelyOnView:sender titles:TITLES icons:ICONS menuWidth:140 delegate:self];
-
- }
- #pragma mark - YBPopupMenuDelegate
- - (void)ybPopupMenuDidSelectedAtIndex:(NSInteger)index ybPopupMenu:(YBPopupMenu *)ybPopupMenu
- {
- NSLog(@"点击了 %@ 选项",TITLES[index]);
- if (index == 0) {
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- MyattentionViewController *vc = [[MyattentionViewController alloc] init];
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }else if (index == 1){
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- MyOrderViewController*vc = [[MyOrderViewController alloc] init];
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }else if (index == 2) {
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- AchievementsReleaseViewController *vc = [[AchievementsReleaseViewController alloc] init];
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }else if (index == 3){
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- ReleaserequirementsViewController *vc = [[ReleaserequirementsViewController alloc] init];
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- [self demandDetailsNetworkrequest];
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|