XYVoiceMatchOrderDetailsViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // XYVoiceMatchOrderDetailsViewController.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/11/20.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYVoiceMatchOrderDetailsViewController.h"
  9. #import "XYVoiceMatchOrderDetailsViewModel.h"
  10. #import "XYVoiceMatchOrderDetailsUserView.h"
  11. #import "XYVoiceMatchOrderDetailsStatusView.h"
  12. #import "XYVoiceMatchOrderDetailsInfoView.h"
  13. #import "XYSkillOrderDetailsTimeView.h"
  14. @interface XYVoiceMatchOrderDetailsViewController ()
  15. @property (nonatomic, strong) XYVoiceMatchOrderDetailsViewModel *viewModel;
  16. @property (nonatomic, strong) UIScrollView *scrollView;
  17. @property (nonatomic, strong) XYVoiceMatchOrderDetailsUserView *userView;
  18. @property (nonatomic, strong) XYVoiceMatchOrderDetailsStatusView *statusView;
  19. @property (nonatomic, strong) XYVoiceMatchOrderDetailsInfoView *infoView;
  20. @property (nonatomic, strong) XYSkillOrderDetailsTimeView *timeView;
  21. @end
  22. @implementation XYVoiceMatchOrderDetailsViewController
  23. - (instancetype)init
  24. {
  25. self = [super init];
  26. if (self) {
  27. }
  28. return self;
  29. }
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. // Do any additional setup after loading the view.
  33. [self setupUI];
  34. }
  35. #pragma mark — Override
  36. - (void)bindViewModel {
  37. self.viewModel = XYVoiceMatchOrderDetailsViewModel.new;
  38. self.viewModel.hisId = self.orderId;
  39. }
  40. - (void)requestRemoteData {
  41. [self.viewModel loadData:^(id _Nullable responseModel) {
  42. dispatch_async(dispatch_get_main_queue(), ^{
  43. [self updateView];
  44. });
  45. } failure:^(ZYLNetworkError * _Nullable error) {
  46. [SVProgressHUD showInfoWithStatus:error.domain];
  47. }];
  48. }
  49. - (void)updateView {
  50. // 更新数据
  51. [self.userView setupViewModel:self.viewModel];
  52. [self.statusView setupViewModel:self.viewModel];
  53. [self.infoView setupViewDataWithModel:self.viewModel.orderInfoModel];
  54. [self.timeView setupViewDataWithModel:self.viewModel.orderInfoModel];
  55. }
  56. - (void)setupUI {
  57. self.title = kLocalizedString(@"订单详情");
  58. [self.view addSubview:self.scrollView];
  59. [self.scrollView addSubview:self.userView];
  60. [self.scrollView addSubview:self.statusView];
  61. [self.scrollView addSubview:self.infoView];
  62. [self.scrollView addSubview:self.timeView];
  63. [self.scrollView setContentSize:CGSizeMake(0, self.timeView.f_top + 20.0f)];
  64. }
  65. #pragma mark — Action
  66. - (void)followAction {
  67. if (self.viewModel.isCurretTarget) {
  68. // 接收者
  69. if (self.viewModel.orderInfoModel.followStatus) {
  70. [[XYSocialApiManager new] unFollowUserWithTargetId:self.viewModel.orderInfoModel.userId successHandler:^(ZYLResponseModel *responseModel) {
  71. self.viewModel.orderInfoModel.followStatus = 0;
  72. [self.userView setupFollowStatus:self.viewModel.orderInfoModel.followStatus];
  73. } failureHandler:^(ZYLNetworkError *error) {
  74. [SVProgressHUD showInfoWithStatus:error.domain];
  75. }];
  76. }else {
  77. [[XYSocialApiManager new] followUserWithTargetId:self.viewModel.orderInfoModel.userId successHandler:^(ZYLResponseModel *responseModel) {
  78. self.viewModel.orderInfoModel.followStatus = 1;
  79. [self.userView setupFollowStatus:self.viewModel.orderInfoModel.followStatus];
  80. } failureHandler:^(ZYLNetworkError *error) {
  81. [SVProgressHUD showInfoWithStatus:error.domain];
  82. }];
  83. }
  84. }else {
  85. // 发起者
  86. if (self.viewModel.orderInfoModel.targetFollowStatus) {
  87. [[XYSocialApiManager new] unFollowUserWithTargetId:self.viewModel.orderInfoModel.targetUserId successHandler:^(ZYLResponseModel *responseModel) {
  88. self.viewModel.orderInfoModel.targetFollowStatus = 0;
  89. [self.userView setupFollowStatus:self.viewModel.orderInfoModel.targetFollowStatus];
  90. } failureHandler:^(ZYLNetworkError *error) {
  91. [SVProgressHUD showInfoWithStatus:error.domain];
  92. }];
  93. }else {
  94. [[XYSocialApiManager new] followUserWithTargetId:self.viewModel.orderInfoModel.targetUserId successHandler:^(ZYLResponseModel *responseModel) {
  95. self.viewModel.orderInfoModel.followStatus = 1;
  96. [self.userView setupFollowStatus:self.viewModel.orderInfoModel.targetFollowStatus];
  97. } failureHandler:^(ZYLNetworkError *error) {
  98. [SVProgressHUD showInfoWithStatus:error.domain];
  99. }];
  100. }
  101. }
  102. }
  103. - (void)chatAction {
  104. NSString *convId = @"";
  105. if (self.viewModel.isCurretTarget) {
  106. // 接收者
  107. convId = self.viewModel.orderInfoModel.userId;
  108. }else {
  109. // 发起者
  110. convId = self.viewModel.orderInfoModel.targetUserId;
  111. }
  112. [self.navigationController pushViewController:[XYNewChatViewController createPrivateChatControllerWithConvId:convId] animated:YES];
  113. }
  114. #pragma mark — Getter
  115. - (UIScrollView *)scrollView {
  116. if (!_scrollView) {
  117. _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NAVGATION_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAVGATION_HEIGHT)];
  118. _scrollView.backgroundColor = Color_Clear;
  119. }
  120. return _scrollView;
  121. }
  122. - (XYVoiceMatchOrderDetailsUserView *)userView {
  123. if (!_userView) {
  124. _userView = [[XYVoiceMatchOrderDetailsUserView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150.0f)];
  125. _userView.backgroundColor = Color_White;
  126. WeakSelf
  127. [_userView setFollowClickBlock:^{
  128. [weakSelf followAction];
  129. }];
  130. [_userView setChatClickBlock:^{
  131. [weakSelf chatAction];
  132. }];
  133. }
  134. return _userView;
  135. }
  136. - (XYVoiceMatchOrderDetailsStatusView *)statusView {
  137. if (!_statusView) {
  138. _statusView = [[XYVoiceMatchOrderDetailsStatusView alloc] initWithFrame:CGRectMake(10.0f, self.userView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 130.0f)];
  139. _statusView.backgroundColor = Color_White;
  140. [_statusView addViewBorder:Color_Clear redian:8];
  141. }
  142. return _statusView;
  143. }
  144. - (XYVoiceMatchOrderDetailsInfoView *)infoView {
  145. if (!_infoView) {
  146. _infoView = [[XYVoiceMatchOrderDetailsInfoView alloc] initWithFrame:CGRectMake(10.0f, self.statusView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 152.0f + 54.0f)];
  147. _infoView.backgroundColor = Color_White;
  148. [_infoView addViewBorder:Color_Clear redian:8];
  149. }
  150. return _infoView;
  151. }
  152. - (XYSkillOrderDetailsTimeView *)timeView {
  153. if (!_timeView) {
  154. _timeView = [[XYSkillOrderDetailsTimeView alloc] initWithFrame:CGRectMake(10.0f, self.infoView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 122.0f)];
  155. _timeView.backgroundColor = Color_White;
  156. [_timeView addViewBorder:Color_Clear redian:8];
  157. }
  158. return _timeView;
  159. }
  160. @end