GuWenDetailViewController.m 15 KB

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