ZJdetailViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. //
  2. // ZJdetailViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/17.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "ZJdetailViewController.h"
  9. #import "MainTouchTableTableView.h"
  10. #import "WMPageController.h"
  11. #import "ParentClassScrollViewController.h"
  12. #import "ZJJJViewController.h"
  13. #import "YHPJzqViewController.h"
  14. #import "GuwenDetaiModel.h"
  15. #import "placeorderViewController.h"
  16. #define Main_Screen_Height [[UIScreen mainScreen] bounds].size.height
  17. #define Main_Screen_Width [[UIScreen mainScreen] bounds].size.width
  18. static CGFloat const headViewHeight = 256;
  19. @interface ZJdetailViewController ()<UITableViewDelegate,UITableViewDataSource,scrollDelegate,WMPageControllerDelegate>{
  20. NSMutableArray *dataArray;
  21. UIButton *scBT;
  22. NSString *guanzhutype;
  23. }
  24. @property(nonatomic ,strong)MainTouchTableTableView * mainTableView;
  25. @property(nonatomic,strong) UIScrollView * parentScrollView;
  26. @property(nonatomic,strong)UIImageView *headImageView;//头部图片
  27. @property(nonatomic,strong)UIView *CommodityinformationView;//商品信息
  28. @property(nonatomic,strong)UIImageView * avatarImage;
  29. @property(nonatomic,strong)UILabel *countentLabel;
  30. @end
  31. @implementation ZJdetailViewController
  32. @synthesize mainTableView;
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. [self setNavTitle:@"专家详情"];
  36. dataArray = NewMutableArrayInit;
  37. [self.view addSubview:self.mainTableView];
  38. [self networkRequest:nil];
  39. // [self.mainTableView addSubview:self.headImageView];
  40. [self.mainTableView addSubview:self.CommodityinformationView];
  41. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-45, SCREEN_WIDTH, 45)];
  42. view.backgroundColor = [UIColor colorWithString:@"#E3E3E3"];
  43. [self.view addSubview:view];
  44. UIButton *bianjiBT = [UIButton new];
  45. bianjiBT.frame = CGRectMake(SCREEN_WIDTH-fitScreenWidth(150), 0, fitScreenWidth(150), 45);
  46. [bianjiBT setTitle:@"立即咨询" forState:UIControlStateNormal];
  47. bianjiBT.titleLabel.font = NewFont(fitScreenWidth(18));
  48. [bianjiBT setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  49. [bianjiBT setBackgroundColor:NewButtonColor];
  50. NewTouchUpInside(bianjiBT, bianjiBTlick:);
  51. [view addSubview:bianjiBT];
  52. scBT = [UIButton new];
  53. NewTouchUpInside(scBT, scBTclick:);
  54. [view addSubview:scBT];
  55. scBT.sd_layout
  56. .centerYEqualToView(view)
  57. .widthIs(15)
  58. .heightIs(15)
  59. .leftSpaceToView(view, 15);
  60. UIButton *scBTff = [UIButton new];
  61. [scBTff setTitle:@"关注" forState:UIControlStateNormal];
  62. NewTouchUpInside(scBTff, scBTclick:);
  63. scBTff.titleLabel.font = NewFont(14);
  64. [scBTff setTitleColor:[UIColor colorWithString:@"#6C6C6C"] forState:UIControlStateNormal];
  65. [view addSubview:scBTff];
  66. scBTff.sd_layout
  67. .centerYEqualToView(view)
  68. .widthIs(30)
  69. .heightIs(15)
  70. .leftSpaceToView(scBT, 10);
  71. if (@available(iOS 11.0, *)) {
  72. self.mainTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  73. }else {
  74. self.automaticallyAdjustsScrollViewInsets = NO;
  75. }
  76. // Do any additional setup after loading the view.
  77. }
  78. - (void)networkRequest:(id)object
  79. {
  80. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  81. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  82. [parameters safeSetObject:self.ID forKey:@"id"];
  83. [NetworkRequestManager requestGetWithInterfacePrefix:JT_NewexpertsDetail parameters:parameters onSuccess:^(id requestData) {
  84. [MBProgressHUD hideHUDForView:self.view];
  85. if ([requestData[@"error"] count] !=0) {
  86. for (NSDictionary *dic in requestData[@"error"]) {
  87. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  88. }
  89. }else{
  90. GuwenDetaiModel *model = [[GuwenDetaiModel alloc] initWithDictionary:requestData[@"data"] error:nil];
  91. [dataArray addObject:model];
  92. if ([model.interested isEqualToString:@"0"]) {
  93. [scBT setImage:NewImageNamed(@"wsc") forState:UIControlStateNormal];
  94. guanzhutype = @"0";//未关注
  95. }else{
  96. [scBT setImage:NewImageNamed(@"sc") forState:UIControlStateNormal];
  97. guanzhutype = @"1";//已关注
  98. }
  99. [self loadCommodityinformationView];
  100. [mainTableView reloadData];
  101. }
  102. } onFailure:^{
  103. [MBProgressHUD hideHUDForView:self.view];
  104. }];
  105. }
  106. - (void)scBTclick:(UIButton *)sender {
  107. if ([UserHelper isLogin]) {
  108. NSLog(@"%@",@"已登录");
  109. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  110. [parameters safeSetObject:@"2" forKey:@"type"];//类型(0-成果,1-需求,2-专家,3-项目,4-活动,5-政策,6-其他)
  111. [parameters safeSetObject:self.ID forKey:@"objectId"];
  112. [parameters safeSetObject:guanzhutype forKey:@"interest"];//是否标记兴趣(0则标记,1则去处)
  113. [NetworkRequestManager requestPostWithInterfacePrefix:JT_NewinterestAdd parameters:parameters onSuccess:^(id requestData) {
  114. if ([requestData[@"error"] count] !=0) {
  115. for (NSDictionary *dic in requestData[@"error"]) {
  116. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  117. }
  118. }else{
  119. if ([guanzhutype isEqualToString:@"0"]) {
  120. [MBProgressHUD showSuccess:@"关注成功" toView:self.view];
  121. guanzhutype = @"1";
  122. [scBT setImage:NewImageNamed(@"sc") forState:UIControlStateNormal];
  123. }else{
  124. [MBProgressHUD showSuccess:@"您已取消关注" toView:self.view];
  125. guanzhutype = @"0";
  126. [scBT setImage:NewImageNamed(@"wsc") forState:UIControlStateNormal];
  127. }
  128. }
  129. } onFailure:^{
  130. }];
  131. }else{
  132. NSLog(@"%@",@"未登录");
  133. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  134. [vc setLoginSuccess:^(NSString *string) {
  135. NewPopViewController;
  136. }];
  137. NewPushViewController(vc);
  138. }
  139. }
  140. #pragma scrollDelegate
  141. -(void)scrollViewLeaveAtTheTop:(UIScrollView *)scrollView
  142. {
  143. self.parentScrollView = scrollView;
  144. //离开顶部 主View 可以滑动
  145. self.parentScrollView.scrollEnabled = NO;
  146. }
  147. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  148. //获取滚动视图y值的偏移量
  149. CGFloat tabOffsetY = [mainTableView rectForSection:0].origin.y;
  150. CGFloat offsetY = scrollView.contentOffset.y;
  151. if (offsetY>=tabOffsetY) {
  152. scrollView.contentOffset = CGPointMake(0, tabOffsetY);
  153. self.parentScrollView.scrollEnabled = YES;
  154. }else{
  155. }
  156. /**
  157. * 处理头部视图
  158. */
  159. // CGFloat yOffset = scrollView.contentOffset.y;
  160. // if(yOffset < -headViewHeight) {
  161. //
  162. // CGRect f = self.headImageView.frame;
  163. // f.origin.y= yOffset ;
  164. // f.size.height= -yOffset;
  165. // f.origin.y= yOffset;
  166. //
  167. // //改变头部视图的fram
  168. // self.headImageView.frame= f;
  169. // CGRect avatarF = CGRectMake(f.size.width/2-40, (f.size.height-headViewHeight)+56, 80, 80);
  170. // _avatarImage.frame = avatarF;
  171. // _countentLabel.frame = CGRectMake((f.size.width-Main_Screen_Width)/2+40, (f.size.height-headViewHeight)+172, Main_Screen_Width-80, 36);
  172. // }
  173. }
  174. #pragma mark --tableDelegate
  175. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  176. return 1;
  177. }
  178. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  179. return 1;
  180. }
  181. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  182. return Main_Screen_Height-64;
  183. }
  184. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  185. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
  186. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  187. /* 添加pageView
  188. * 这里可以任意替换你喜欢的pageView
  189. *作者这里使用一款github较多人使用的 WMPageController 地址https://github.com/wangmchn/WMPageController
  190. */
  191. [cell.contentView addSubview:self.setPageViewControllers];
  192. return cell;
  193. }
  194. #pragma mark -- setter/getter
  195. -(UIView *)setPageViewControllers
  196. {
  197. WMPageController *pageController = [self p_defaultController];
  198. pageController.title = @"Line";
  199. pageController.menuViewStyle = WMMenuViewStyleLine;
  200. pageController.titleSizeSelected = 15;
  201. [self addChildViewController:pageController];
  202. [pageController didMoveToParentViewController:self];
  203. return pageController.view;
  204. }
  205. - (WMPageController *)p_defaultController {
  206. ZJJJViewController * oneVc = [ZJJJViewController new];
  207. oneVc.delegate = self;
  208. YHPJzqViewController * twoVc = [YHPJzqViewController new];
  209. twoVc.delegate = self;
  210. if (dataArray.count>0) {
  211. GuwenDetaiModel *model = dataArray[0];
  212. oneVc.neirong = model.introduction;
  213. twoVc.ID = self.ID;
  214. }
  215. NSArray *viewControllers = @[oneVc,twoVc];
  216. NSArray *titles = @[@"专家简介",@"用户评价"];
  217. WMPageController *pageVC = [[WMPageController alloc] initWithViewControllerClasses:viewControllers andTheirTitles:titles];
  218. [pageVC setViewFrame:CGRectMake(0, 0, Main_Screen_Width, Main_Screen_Height)];
  219. pageVC.delegate = self;
  220. pageVC.menuItemWidth = 100;
  221. pageVC.menuHeight = 44;
  222. pageVC.postNotification = YES;
  223. pageVC.bounces = YES;
  224. pageVC.menuBGColor = NewWhiteColor;
  225. return pageVC;
  226. }
  227. - (void)pageController:(WMPageController *)pageController willEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info {
  228. NSLog(@"%@",viewController);
  229. }
  230. -(UIImageView *)headImageView
  231. {
  232. if (_headImageView == nil)
  233. {
  234. _headImageView= [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"项目默认.jpg"]];
  235. _headImageView.frame=CGRectMake(0, -headViewHeight-126 ,Main_Screen_Width,headViewHeight);
  236. _headImageView.userInteractionEnabled = YES;
  237. }
  238. return _headImageView;
  239. }
  240. - (void)loadCommodityinformationView{
  241. GuwenDetaiModel *model = dataArray[0];
  242. _CommodityinformationView = [[UIView alloc] initWithFrame:CGRectMake(0, -175, SCREEN_WIDTH, 175)];
  243. [_CommodityinformationView setBackgroundColor:NewWhiteColor];
  244. [self.mainTableView addSubview:self.CommodityinformationView];
  245. UILabel *title = [UILabel new];
  246. [title setText:model.username];
  247. title.font = NewFont(fitScreenWidth(17));
  248. [title setTextAlignment:NSTextAlignmentLeft];
  249. [_CommodityinformationView addSubview:title];
  250. title.sd_layout
  251. .leftSpaceToView(_CommodityinformationView, 20)
  252. .heightIs(fitScreenWidth(16))
  253. .rightSpaceToView(_CommodityinformationView, 15)
  254. .topSpaceToView(_CommodityinformationView, 40);
  255. UILabel *titledetail = [UILabel new];
  256. if (model.workUnit == NULL && model.professionalTitle == NULL) {
  257. titledetail.text = @"位置职业";
  258. }else{
  259. [titledetail setText:[NSString stringWithFormat:@"%@ %@",model.workUnit,model.professionalTitle]];
  260. }
  261. titledetail.font = NewFont(fitScreenWidth(13));
  262. [titledetail setTextColor:[UIColor colorWithString:@"#0779D5"]];
  263. [titledetail setTextAlignment:NSTextAlignmentLeft];
  264. [_CommodityinformationView addSubview:titledetail];
  265. titledetail.sd_layout
  266. .leftSpaceToView(_CommodityinformationView, 20)
  267. .heightIs(fitScreenWidth(13))
  268. .rightSpaceToView(_CommodityinformationView, 90)
  269. .topSpaceToView(title, 20);
  270. UIImageView *headimage = [UIImageView new];
  271. [headimage sd_setImageWithURL:NewURL([model.personPortraitUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"专家-6")];
  272. ViewRadius(headimage, 73/2);
  273. [_CommodityinformationView addSubview:headimage];
  274. headimage.sd_layout
  275. .rightSpaceToView(_CommodityinformationView, 15)
  276. .heightIs(73)
  277. .widthIs(73)
  278. .topSpaceToView(_CommodityinformationView, 25);
  279. UILabel *line1 = [UILabel new];
  280. line1.backgroundColor = NewLineGrayColor;
  281. [_CommodityinformationView addSubview:line1];
  282. line1.sd_layout
  283. .leftSpaceToView(_CommodityinformationView, 20)
  284. .heightIs(0.8)
  285. .rightSpaceToView(_CommodityinformationView, 15)
  286. .topSpaceToView(titledetail, 15);
  287. UILabel *jiage = [UILabel new];
  288. jiage.text = [NSString stringWithFormat:@"好评率:%@",model.favorableRate];
  289. jiage.font = NewFont(fitScreenWidth(12));
  290. jiage.textColor = [UIColor colorWithString:@"#FF9350"];
  291. [jiage setSingleLineAutoResizeWithMaxWidth:0];
  292. [_CommodityinformationView addSubview:jiage];
  293. jiage.sd_layout
  294. .leftSpaceToView(_CommodityinformationView, 20)
  295. .heightIs(fitScreenWidth(12))
  296. .bottomSpaceToView(_CommodityinformationView, 40);
  297. UILabel *line = [UILabel new];
  298. line.backgroundColor = NewLineGrayColor;
  299. [_CommodityinformationView addSubview:line];
  300. line.sd_layout
  301. .leftEqualToView(_CommodityinformationView)
  302. .rightEqualToView(_CommodityinformationView)
  303. .heightIs(10)
  304. .bottomEqualToView(_CommodityinformationView);
  305. UIButton *followBT = [UIButton new];
  306. [followBT setBackgroundColor:NewClearColor];
  307. [followBT setImage:NewImageNamed(@"pj") forState:UIControlStateNormal];
  308. [_CommodityinformationView addSubview:followBT];
  309. followBT.sd_layout
  310. .centerYEqualToView(jiage)
  311. .heightIs(15)
  312. .widthIs(15)
  313. .rightSpaceToView(_CommodityinformationView, 15);
  314. UILabel *followNumber = [UILabel new];
  315. [followNumber setText:model.countInterest];
  316. [followNumber setFont:NewFont(fitScreenWidth(13))];
  317. [followNumber setTextColor:[UIColor colorWithString:@"#AEAEAE"]];
  318. [followNumber setSingleLineAutoResizeWithMaxWidth:0];
  319. [_CommodityinformationView addSubview:followNumber];
  320. followNumber.sd_layout
  321. .rightSpaceToView(followBT, 3)
  322. .heightIs(fitScreenWidth(11))
  323. .centerYEqualToView(followBT);
  324. }
  325. -(MainTouchTableTableView *)mainTableView
  326. {
  327. if (mainTableView == nil)
  328. {
  329. mainTableView= [[MainTouchTableTableView alloc]initWithFrame:CGRectMake(0,NavHeader,Main_Screen_Width,Main_Screen_Height-NavHeader-45)];
  330. mainTableView.delegate=self;
  331. mainTableView.dataSource=self;
  332. mainTableView.showsVerticalScrollIndicator = NO;
  333. mainTableView.contentInset = UIEdgeInsetsMake(175,0, 0, 0);
  334. mainTableView.backgroundColor = [UIColor clearColor];
  335. }
  336. return mainTableView;
  337. }
  338. - (void)bianjiBTlick:(UIButton *)sender {
  339. if ([UserHelper isLogin]) {
  340. NSLog(@"%@",@"已登录");
  341. if (dataArray.count>0) {
  342. GuwenDetaiModel *model = dataArray[0];
  343. placeorderViewController *vc = [[placeorderViewController alloc] init];
  344. vc.jiage = @"0";
  345. vc.goumaititle = model.username;
  346. vc.ID = model.uid;
  347. vc.type = @"专家";
  348. NewPushViewController(vc);
  349. }
  350. }else{
  351. NSLog(@"%@",@"未登录");
  352. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  353. [vc setLoginSuccess:^(NSString *string) {
  354. NewPopViewController;
  355. }];
  356. NewPushViewController(vc);
  357. }
  358. }
  359. - (void)didReceiveMemoryWarning {
  360. [super didReceiveMemoryWarning];
  361. // Dispose of any resources that can be recreated.
  362. }
  363. /*
  364. #pragma mark - Navigation
  365. // In a storyboard-based application, you will often want to do a little preparation before navigation
  366. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  367. // Get the new view controller using [segue destinationViewController].
  368. // Pass the selected object to the new view controller.
  369. }
  370. */
  371. @end