123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //
- // XYVoiceMatchOrderDetailsViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/11/20.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYVoiceMatchOrderDetailsViewController.h"
- #import "XYVoiceMatchOrderDetailsViewModel.h"
- #import "XYVoiceMatchOrderDetailsUserView.h"
- #import "XYVoiceMatchOrderDetailsStatusView.h"
- #import "XYVoiceMatchOrderDetailsInfoView.h"
- #import "XYSkillOrderDetailsTimeView.h"
- @interface XYVoiceMatchOrderDetailsViewController ()
- @property (nonatomic, strong) XYVoiceMatchOrderDetailsViewModel *viewModel;
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic, strong) XYVoiceMatchOrderDetailsUserView *userView;
- @property (nonatomic, strong) XYVoiceMatchOrderDetailsStatusView *statusView;
- @property (nonatomic, strong) XYVoiceMatchOrderDetailsInfoView *infoView;
- @property (nonatomic, strong) XYSkillOrderDetailsTimeView *timeView;
- @end
- @implementation XYVoiceMatchOrderDetailsViewController
- - (instancetype)init
- {
- self = [super init];
- if (self) {
-
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self setupUI];
- }
- #pragma mark — Override
- - (void)bindViewModel {
- self.viewModel = XYVoiceMatchOrderDetailsViewModel.new;
- self.viewModel.hisId = self.orderId;
- }
- - (void)requestRemoteData {
- [self.viewModel loadData:^(id _Nullable responseModel) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self updateView];
- });
- } failure:^(ZYLNetworkError * _Nullable error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }
- - (void)updateView {
- // 更新数据
- [self.userView setupViewModel:self.viewModel];
- [self.statusView setupViewModel:self.viewModel];
- [self.infoView setupViewDataWithModel:self.viewModel.orderInfoModel];
- [self.timeView setupViewDataWithModel:self.viewModel.orderInfoModel];
- }
- - (void)setupUI {
-
- self.title = kLocalizedString(@"订单详情");
-
- [self.view addSubview:self.scrollView];
- [self.scrollView addSubview:self.userView];
- [self.scrollView addSubview:self.statusView];
- [self.scrollView addSubview:self.infoView];
- [self.scrollView addSubview:self.timeView];
-
- [self.scrollView setContentSize:CGSizeMake(0, self.timeView.f_top + 20.0f)];
- }
- #pragma mark — Action
- - (void)followAction {
- if (self.viewModel.isCurretTarget) {
- // 接收者
- if (self.viewModel.orderInfoModel.followStatus) {
- [[XYSocialApiManager new] unFollowUserWithTargetId:self.viewModel.orderInfoModel.userId successHandler:^(ZYLResponseModel *responseModel) {
- self.viewModel.orderInfoModel.followStatus = 0;
- [self.userView setupFollowStatus:self.viewModel.orderInfoModel.followStatus];
- } failureHandler:^(ZYLNetworkError *error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }else {
- [[XYSocialApiManager new] followUserWithTargetId:self.viewModel.orderInfoModel.userId successHandler:^(ZYLResponseModel *responseModel) {
- self.viewModel.orderInfoModel.followStatus = 1;
- [self.userView setupFollowStatus:self.viewModel.orderInfoModel.followStatus];
- } failureHandler:^(ZYLNetworkError *error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }
- }else {
- // 发起者
- if (self.viewModel.orderInfoModel.targetFollowStatus) {
- [[XYSocialApiManager new] unFollowUserWithTargetId:self.viewModel.orderInfoModel.targetUserId successHandler:^(ZYLResponseModel *responseModel) {
- self.viewModel.orderInfoModel.targetFollowStatus = 0;
- [self.userView setupFollowStatus:self.viewModel.orderInfoModel.targetFollowStatus];
- } failureHandler:^(ZYLNetworkError *error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }else {
- [[XYSocialApiManager new] followUserWithTargetId:self.viewModel.orderInfoModel.targetUserId successHandler:^(ZYLResponseModel *responseModel) {
- self.viewModel.orderInfoModel.followStatus = 1;
- [self.userView setupFollowStatus:self.viewModel.orderInfoModel.targetFollowStatus];
- } failureHandler:^(ZYLNetworkError *error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }
- }
- }
- - (void)chatAction {
- NSString *convId = @"";
- if (self.viewModel.isCurretTarget) {
- // 接收者
- convId = self.viewModel.orderInfoModel.userId;
- }else {
- // 发起者
- convId = self.viewModel.orderInfoModel.targetUserId;
- }
- [self.navigationController pushViewController:[XYNewChatViewController createPrivateChatControllerWithConvId:convId] animated:YES];
- }
- #pragma mark — Getter
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NAVGATION_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAVGATION_HEIGHT)];
- _scrollView.backgroundColor = Color_Clear;
- }
- return _scrollView;
- }
- - (XYVoiceMatchOrderDetailsUserView *)userView {
- if (!_userView) {
- _userView = [[XYVoiceMatchOrderDetailsUserView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150.0f)];
- _userView.backgroundColor = Color_White;
- WeakSelf
- [_userView setFollowClickBlock:^{
- [weakSelf followAction];
- }];
- [_userView setChatClickBlock:^{
- [weakSelf chatAction];
- }];
- }
- return _userView;
- }
- - (XYVoiceMatchOrderDetailsStatusView *)statusView {
- if (!_statusView) {
- _statusView = [[XYVoiceMatchOrderDetailsStatusView alloc] initWithFrame:CGRectMake(10.0f, self.userView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 130.0f)];
- _statusView.backgroundColor = Color_White;
- [_statusView addViewBorder:Color_Clear redian:8];
- }
- return _statusView;
- }
- - (XYVoiceMatchOrderDetailsInfoView *)infoView {
- if (!_infoView) {
- _infoView = [[XYVoiceMatchOrderDetailsInfoView alloc] initWithFrame:CGRectMake(10.0f, self.statusView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 152.0f + 54.0f)];
- _infoView.backgroundColor = Color_White;
- [_infoView addViewBorder:Color_Clear redian:8];
- }
- return _infoView;
- }
- - (XYSkillOrderDetailsTimeView *)timeView {
- if (!_timeView) {
- _timeView = [[XYSkillOrderDetailsTimeView alloc] initWithFrame:CGRectMake(10.0f, self.infoView.f_top + 10.0f, SCREEN_WIDTH - 20.0f, 122.0f)];
- _timeView.backgroundColor = Color_White;
- [_timeView addViewBorder:Color_Clear redian:8];
- }
- return _timeView;
- }
- @end
|