- 首页新增员工应急求助入口,接口改用 myParticipatedOrders,1条直接进群聊,多条弹窗选择 - ChatViewController 加急救员流程:isFromFirstAid、群成员面板、工单弹窗 - 急救员入口隐藏语音通话/档案/结束咨询,标题写死"应急求助" - XJDNetAPI 加 getMyParticipatedOrders/getActualGroupMemberList/getSearchEmployee/getSearchExpert/postAddGroupUser - 拷贝 XJSelectContactViewController、XJParticipatedOrderModel、checkbox/order 等图标资源 - IM断线静默重登,异地登录弹提示跳登录页 - 首页数量标签默认隐藏,非零才显示 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1169 lines
47 KiB
Objective-C
1169 lines
47 KiB
Objective-C
//
|
|
// ChatViewController.m
|
|
// DoctorXinjiang
|
|
//
|
|
// Created by 仁康信息 on 2023/2/13.
|
|
//
|
|
|
|
#import "ChatViewController.h"
|
|
#import "TUIC2CChatViewController.h"
|
|
#import "TUIMessageDataProvider.h"
|
|
#import "TUIChatDataProvider.h"
|
|
#import "XJDChatMapViewController.h"
|
|
#import <CommonCrypto/CommonDigest.h>
|
|
#import "TUIChatConfig.h"
|
|
#import "EndSystemSoSCell.h"
|
|
#import "XJDFileDataDetailViewController.h"
|
|
#import "DoctorIDCardMessageCell.h"
|
|
#import "XJDCurrentLocationViewController.h"
|
|
#import <TUICallEngine/TUICallEngine.h>
|
|
#import <TUICallEngine/TUICallObserver.h>
|
|
#import "TUIGroupChatViewController.h"
|
|
#import <TUICallKit/TUICallKit.h>
|
|
#import "TUICallingUserManager.h"
|
|
#import "TUICallingUserModel.h"
|
|
#import "XJParticipatedOrderModel.h"
|
|
#import "XJSelectContactViewController.h"
|
|
#import <MJRefresh/MJRefresh.h>
|
|
#import <TUICore/TUIDefine.h>
|
|
//自定义map
|
|
#define BussinessID_CustomMap @"TIMLocationElem"
|
|
//自定义评论
|
|
#define BussinessID_CustomReview @"CustomReview"
|
|
//自定义档案
|
|
#define BussinessID_CustomHealthData @"archives"
|
|
//自定义医生名片
|
|
#define BussinessID_CustomDoctorCard @"business_card"
|
|
|
|
|
|
@class TUIChatDataProvider;
|
|
|
|
@interface ChatViewController ()<V2TIMSimpleMsgListener,TUIChatBaseDataProviderDelegate,IMCustomDeleagte,TUIMessageCellDelegate,TUIBaseMessageControllerDelegate,TUICallObserver,V2TIMConversationListener,V2TIMGroupListener,UIGestureRecognizerDelegate,UITableViewDelegate,UITableViewDataSource>
|
|
|
|
@property (nonatomic, strong) TUIC2CChatViewController * vc;
|
|
@property (nonatomic, strong) TUIGroupChatViewController * groupvc;
|
|
|
|
@property (nonatomic, assign) CGFloat starNumber;
|
|
@property (nonatomic, strong) NSString * evlationConnte;
|
|
|
|
// 急救员相关
|
|
@property (nonatomic, strong) UIView *memberPanel;
|
|
@property (nonatomic, strong) UIView *memberOverlay;
|
|
@property (nonatomic, strong) UITableView *memberTableView;
|
|
@property (nonatomic, strong) UILabel *memberTitleLabel;
|
|
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *memberList;
|
|
@property (nonatomic, strong) UIImageView *refreshIcon;
|
|
@property (nonatomic, strong) NSMutableArray<XJParticipatedOrderModel *> *orderList;
|
|
@property (nonatomic, assign) NSInteger orderPage;
|
|
@property (nonatomic, strong) UITableView *orderPopupTable;
|
|
@property (nonatomic, assign) NSInteger selectedOrderIndex;
|
|
|
|
@end
|
|
|
|
@implementation ChatViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.title = self.navTitle;
|
|
// self 为 id<V2TIMSignalingListener>
|
|
self.view.backgroundColor = KWhiteColor;
|
|
|
|
[[V2TIMManager sharedInstance] addSimpleMsgListener:self];
|
|
[[TUICallEngine createInstance] addObserver:self];
|
|
[[V2TIMManager sharedInstance] addConversationListener:self];
|
|
[[V2TIMManager sharedInstance] addGroupListener:self];
|
|
// IMUserInfoModel * model = [XJDCommonUtils keyedUnarchiverWithKey:IMLoginUserInfo];
|
|
// [[TUICallEngine createInstance] init:[model.sdkAppId intValue] userId:model.userId userSig:model.userSig succ:^{
|
|
//
|
|
// } fail:^(int code, NSString * _Nullable errMsg) {
|
|
//
|
|
// }];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowAction:) name:UIKeyboardWillShowNotification object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHideAction:) name:UIKeyboardWillHideNotification object:nil];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendReportMessage:) name:@"sendReport" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendHealthMessage:) name:@"sendHealth" object:nil];
|
|
|
|
|
|
// [ESCTUIManager createUITUIChatViewControllerisGroup:self.isGroupID chatConnetID:self.chatID isAudio:false isVideo:false];
|
|
XJDUserInfo * user = [XJDCommonUtils keyedUnarchiverWithKey:LoginUserInfo];
|
|
|
|
TUIChatConversationModel *data = [[TUIChatConversationModel alloc] init];
|
|
//显示对方正在输入状态
|
|
data.otherSideTyping = true;
|
|
// 显示翻译按钮
|
|
// TUIChatConfig.defaultConfig.enableTextTranslation = YES;
|
|
//不显示视频和语音
|
|
[TUIChatConfig defaultConfig].enableVideoCall = self.isVideo;
|
|
[TUIChatConfig defaultConfig].enableAudioCall = self.isFromFirstAid ? NO : self.isVideo;
|
|
[TUIChatConfig defaultConfig].backgroudColor = UIColorHex(#EEEEEE);
|
|
[TUIConfig defaultConfig].defaultAvatarImage = [UIImage imageNamed:@"heard_man"];
|
|
[TUIConfig defaultConfig].avatarType = TAvatarTypeRounded;
|
|
TUIChatConfig.defaultConfig.enableTypingStatus = NO;
|
|
//是否显示发送报告
|
|
[TUIChatConfig defaultConfig].enableSendReportCall = true;
|
|
[TUIChatConfig defaultConfig].enableSendHealthDataCall = self.eablehaveHelathData;
|
|
[TUIChatConfig defaultConfig].enableMapCall = self.eableMapTools;
|
|
|
|
// 急救员入口隐藏结束咨询、档案、语音通话
|
|
if (self.isFromFirstAid) {
|
|
[TUIChatConfig defaultConfig].enableEndConsultation = NO;
|
|
[TUIChatConfig defaultConfig].enableSendHealthDataCall = YES;
|
|
}
|
|
TUIConfig *config = [TUIConfig defaultConfig];
|
|
config.avatarType = TAvatarTypeRounded;
|
|
// 修改默认头像
|
|
if ([user.sex integerValue] == 1) { //女[]
|
|
config.defaultAvatarImage = [UIImage imageNamed:@"heard_woman"];
|
|
}else
|
|
{
|
|
config.defaultAvatarImage = [UIImage imageNamed:@"heard_man"];
|
|
}
|
|
// 设置发送文字消息的字体和颜色
|
|
// [TUITextMessageCellData setOutgoingTextFont:[UIFont systemFontOfSize:20]];
|
|
// [TUITextMessageCellData setOutgoingTextColor:[UIColor blueColor]];
|
|
// // 设置接收文字消息的字体和颜色
|
|
// [TUITextMessageCellData setIncommingTextFont:[UIFont systemFontOfSize:20]];
|
|
// [TUITextMessageCellData setIncommingTextColor:[UIColor purpleColor]];
|
|
// 设置发送气泡,包括普通状态和选中状态
|
|
[TUIBubbleMessageCellData setOutgoingBubble:[UIImage imageWithColor:KWhiteColor]];
|
|
[TUIBubbleMessageCellData setOutgoingHighlightedBubble:[UIImage imageWithColor:KWhiteColor]];
|
|
// 设置接收气泡,包括普通状态和选中状态
|
|
[TUIBubbleMessageCellData setIncommingBubble:[UIImage imageWithColor:KWhiteColor]];
|
|
|
|
if( self.isGroupID == false) {
|
|
data.groupID = self.chatID;
|
|
TUIC2CChatViewController *vc = [[TUIC2CChatViewController alloc] init];
|
|
self.vc = vc;
|
|
vc.messageController.delegate = self;
|
|
[vc setConversationData:data];
|
|
[self addChildViewController:vc];
|
|
self.view.backgroundColor = UIColorHex(#EEEEEE);
|
|
[self.view addSubview:vc.view];
|
|
vc.customDelegate = self;
|
|
}
|
|
else
|
|
{
|
|
data.groupID = self.chatID;
|
|
TUIGroupChatViewController * vc = [[TUIGroupChatViewController alloc] init];
|
|
self.groupvc = vc;
|
|
vc.messageController.delegate = self;
|
|
[vc setConversationData:data];
|
|
[self addChildViewController:vc];
|
|
self.view.backgroundColor = UIColorHex(#EEEEEE);
|
|
[self.view addSubview:vc.view];
|
|
vc.customDelegate = self;
|
|
}
|
|
// TUIC2CChatViewController
|
|
|
|
//发送
|
|
|
|
|
|
|
|
// 把 TUIC2CChatViewController 添加到自己的 ViewController
|
|
|
|
// 右上角三个点(仅急救员入口显示)
|
|
if (self.isFromFirstAid) {
|
|
UIButton *moreBtn = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
[moreBtn setTitle:@"···" forState:UIControlStateNormal];
|
|
moreBtn.titleLabel.font = [UIFont boldSystemFontOfSize:22];
|
|
[moreBtn setTitleColor:KWhiteColor forState:UIControlStateNormal];
|
|
[moreBtn addTarget:self action:@selector(moreAction) forControlEvents:UIControlEventTouchUpInside];
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:moreBtn];
|
|
}
|
|
|
|
if ([self.tfNew integerValue] == 1) {
|
|
|
|
[ESCTUIManager sendGroupVideo:self.chatID withUserIdList:self.member];
|
|
}
|
|
//主动发送一条消息
|
|
//如果点击跳过进入 不操作 非跳过 发送健康档案 2=非跳过
|
|
if (self.JumpType == 2 && self.questionType == 2) {
|
|
|
|
[self sendQuestionInfoMessage];
|
|
}
|
|
|
|
// [self ChatsendReview];
|
|
//调整聊天界面
|
|
if (self.isHideKeyBord == true) {
|
|
if( self.isGroupID == false) {
|
|
|
|
self.vc.inputController.view.hidden = YES;
|
|
}else
|
|
{
|
|
self.groupvc.inputController.view.hidden = YES;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark:跳转到地图选择页
|
|
- (void)jumpChatMapView {
|
|
|
|
XJDChatMapViewController * mapVC = [[XJDChatMapViewController alloc] init];
|
|
MJWeakSelf
|
|
mapVC.mapBlcok = ^(CLLocationCoordinate2D coordinate) {
|
|
V2TIMMessage * message = [[V2TIMManager sharedInstance] createLocationMessage:@"位置" longitude:coordinate.longitude latitude:coordinate.latitude];
|
|
if( self.isGroupID == false) {
|
|
[weakSelf.vc sendMessage:message];
|
|
}else
|
|
{
|
|
[weakSelf.groupvc sendMessage:message];
|
|
}
|
|
};
|
|
[self.navigationController pushViewController:mapVC animated:YES];
|
|
}
|
|
|
|
#pragma mark:结束咨询
|
|
|
|
- (void)sendChatEndQuestionAction {
|
|
|
|
// NSDictionary * parmdic = @{BussinessID:BussinessID_CustomReview};
|
|
// NSData * messagedata = [NSJSONSerialization dataWithJSONObject:parmdic options:0 error:nil];
|
|
// V2TIMMessage * message = [[V2TIMManager sharedInstance] createCustomMessage:messagedata];
|
|
// [self.vc sendMessage:message];
|
|
////1 应急 2 图文咨询 3 音视频咨询 smallHelp_id小助手
|
|
if (self.questionType == 1) {
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
[parmDic setObject:self.sosEnd_id forKey:@"id"];
|
|
XJDNetAPI * endApi = [[XJDNetAPI alloc] init:self tag:@"ENDSOSAPI" NeedToken:@""];
|
|
[endApi PostEndSoSIMQuestion:parmDic];
|
|
}
|
|
if (self.questionType == 2) {
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
[parmDic setObject:self.pictureEnd_id forKey:@"id"];
|
|
XJDNetAPI * endApi = [[XJDNetAPI alloc] init:self tag:@"ENDPICTUREAPI" NeedToken:@""];
|
|
[endApi GetEndPictureEndIMQuestion:parmDic];
|
|
}
|
|
if (!ValidStr(self.smallHelp_id)) {
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
[parmDic setObject:self.smallHelp_id forKey:@"id"];
|
|
XJDNetAPI * endApi = [[XJDNetAPI alloc] init:self tag:@"ENDPICTUREAPI" NeedToken:@""];
|
|
[endApi GetEndPictureEndIMQuestion:parmDic];
|
|
}
|
|
}
|
|
|
|
#pragma mark:发送健康档案
|
|
|
|
//主动发一条消息:健康档案 带联系人数据
|
|
- (void)sendQuestionInfoMessage {
|
|
if (self.disModel) {
|
|
//性别
|
|
NSString * sexString = [self.disModel.gender integerValue] == 1 ?@"女":@"男";
|
|
//年龄
|
|
NSString * ageString = [NSString stringWithFormat:@"%@",self.disModel.age];
|
|
//姓名
|
|
NSString * nameString = [NSString stringWithFormat:@"%@",self.disModel.name];
|
|
//id
|
|
NSString * memberId = [NSString stringWithFormat:@"%@",self.dangan_id];
|
|
|
|
//症状描述
|
|
NSString * siksDesString = @"";
|
|
//图片数组
|
|
|
|
NSMutableArray * imageArray = [[NSMutableArray alloc] init];
|
|
for ( diseaseModel * listMode in self.disModel.list) {
|
|
|
|
if (listMode.isSelected == true) {
|
|
NSArray * listImageArray = [listMode.image componentsSeparatedByString:@","];
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
for (NSString * imageString in listImageArray) {
|
|
|
|
NSString * photo = [NSString stringWithFormat:@"%@%@",ResourceAddress,imageString];
|
|
|
|
NSString * str1 = @"\\";
|
|
|
|
photo = [photo stringByReplacingOccurrencesOfString:str1 withString:@"/"];
|
|
|
|
NSString *encodedString3 = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)photo, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL, kCFStringEncodingUTF8));
|
|
|
|
[parmDic setObject:encodedString3 forKey:@"bigImageUrl"];
|
|
[parmDic setObject:encodedString3 forKey:@"thumbnailUrl"];
|
|
|
|
[imageArray addObject:parmDic];
|
|
}
|
|
siksDesString = listMode.medicalDescribe;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
NSDictionary * parmdic = @{BussinessID:BussinessID_CustomHealthData,@"gender":sexString,@"age":ageString,@"name":nameString,@"symptomDescription":siksDesString,@"imageList":imageArray,@"archivesId":memberId};
|
|
NSData * messagedata = [NSJSONSerialization dataWithJSONObject:parmdic options:0 error:nil];
|
|
V2TIMMessage * message = [[V2TIMManager sharedInstance] createCustomMessage:messagedata];
|
|
|
|
if( self.isGroupID == false) {
|
|
[self.vc sendMessage:message];
|
|
}else
|
|
{
|
|
[self.groupvc sendMessage:message];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)questionChatSendHealthData {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)onCallEnd:(TUIRoomId *)roomId callMediaType:(TUICallMediaType)callMediaType callRole:(TUICallRole)callRole totalTime:(float)totalTime {
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark:发送个人名片
|
|
- (void)ChatsendDoctorIDCard {
|
|
NSDictionary * parmdic = @{BussinessID:BussinessID_CustomDoctorCard};
|
|
NSData * messagedata = [NSJSONSerialization dataWithJSONObject:parmdic options:0 error:nil];
|
|
V2TIMMessage * message = [[V2TIMManager sharedInstance] createCustomMessage:messagedata];
|
|
|
|
if( self.isGroupID == false) {
|
|
[self.vc sendMessage:message];
|
|
}else
|
|
{
|
|
[self.groupvc sendMessage:message];
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark:发送体检报告
|
|
- (void)ChatsendReview {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)onRecvC2CCustomMessage:(NSString *)msgID sender:(V2TIMUserInfo *)info customData:(NSData *)data
|
|
{
|
|
id myResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSLog(@"onRecvGroupCustomMessage, msgID: %@, info: %@, customData: %@", msgID, info, myResult);
|
|
}
|
|
|
|
- (void)onRecvGroupCustomMessage:(NSString *)msgID groupID:(NSString *)groupID sender:(V2TIMGroupMemberInfo *)info customData:(NSData *)data {
|
|
|
|
id myResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSLog(@"onRecvGroupCustomMessage, msgID: %@, info: %@, customData: %@", msgID, info, myResult);
|
|
|
|
}
|
|
/// 收到 C2C 文本消息
|
|
- (void)onRecvC2CTextMessage:(NSString *)msgID sender:(V2TIMUserInfo *)info text:(NSString *)text{
|
|
|
|
|
|
NSLog(@"onRecvGroupCustomMessage, msgID: %@, info: %@", msgID, info);
|
|
|
|
}
|
|
#pragma mark:发起评价
|
|
- (void)chatevlationDoctorStarView:(TUIMessageCell *)cell{
|
|
// DLog(@"-----------%@",@"我是评价");
|
|
|
|
if ([cell isKindOfClass:EndSystemSoSCell.class]) {
|
|
|
|
|
|
}
|
|
|
|
if ([cell isKindOfClass:DoctorIDCardMessageCell.class]) {
|
|
|
|
|
|
|
|
}
|
|
|
|
if ([cell isKindOfClass:healthDataCustomCell.class]) {
|
|
healthDataCustomCell * healthCell = cell;
|
|
XJDFileDataDetailViewController * experVC= [[XJDFileDataDetailViewController alloc] init];
|
|
experVC.record_id = healthCell.fileId;
|
|
[self.navigationController pushViewController:experVC animated:YES];
|
|
}
|
|
|
|
}
|
|
|
|
- (void)lookLocationDetail:(TUIMessageCell *)cel {
|
|
|
|
// DLog(@"%@",cel.messageData.innerMessage.locationElem.longitude);
|
|
|
|
XJDCurrentLocationViewController * currVC = [[XJDCurrentLocationViewController alloc] init];
|
|
currVC.longitude = cel.messageData.innerMessage.locationElem.longitude;
|
|
currVC.latitude = cel.messageData.innerMessage.locationElem.latitude;
|
|
[self.navigationController pushViewController:currVC animated:YES];
|
|
|
|
}
|
|
- (void)doctorSourceWithStarNumaber:(CGFloat)starNumer withContext:(NSString *)connet isKnow:(NSString *)isNiming{
|
|
|
|
// NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
// [parmDic setObject:@(starNumer) forKey:@"score"];
|
|
// [parmDic setObject:connet forKey:@"context"];
|
|
// [parmDic setObject:self.pictureEnd_id forKey:@"sessionId"];
|
|
// [parmDic setObject:isNiming forKey:@"tfUnknow"];
|
|
//
|
|
// XMAPI * endApi = [[XMAPI alloc] init:self tag:@"DoctorSource" NeedToken:@""];
|
|
// [endApi PostQustionDoctorScore:parmDic];
|
|
|
|
}
|
|
- (void)sendReportMessage:(NSNotification *)note {
|
|
|
|
|
|
}
|
|
|
|
- (void)sendHealthMessage:(NSNotification *)note {
|
|
|
|
diseaseModel * model = note.object;
|
|
if (model) {
|
|
//性别
|
|
NSString * sexString = [self.disModel.gender integerValue] == 1 ?@"女":@"男";
|
|
//年龄
|
|
NSString * ageString = [NSString stringWithFormat:@"%@",model.age];
|
|
//姓名
|
|
NSString * nameString = [NSString stringWithFormat:@"%@",model.name];
|
|
//id
|
|
NSString * memberId = [NSString stringWithFormat:@"%@",model.tfper_id];
|
|
|
|
//症状描述
|
|
NSString * siksDesString = @"";
|
|
//图片数组
|
|
NSMutableArray * imageArray = [[NSMutableArray alloc] init];
|
|
|
|
NSArray * listImageArray = [model.image componentsSeparatedByString:@","];
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
for (NSString * imageString in listImageArray) {
|
|
|
|
NSString * photo = [NSString stringWithFormat:@"%@%@",ResourceAddress,imageString];
|
|
|
|
NSString * str1 = @"\\";
|
|
|
|
photo = [photo stringByReplacingOccurrencesOfString:str1 withString:@"/"];
|
|
|
|
NSString *encodedString3 = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)photo, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL, kCFStringEncodingUTF8));
|
|
|
|
[parmDic setObject:encodedString3 forKey:@"bigImageUrl"];
|
|
[parmDic setObject:encodedString3 forKey:@"thumbnailUrl"];
|
|
|
|
[imageArray addObject:parmDic];
|
|
}
|
|
|
|
siksDesString = model.medicalDescribe;
|
|
|
|
NSDictionary * parmdic = @{BussinessID:BussinessID_CustomHealthData,@"gender":sexString,@"age":ageString,@"name":nameString,@"symptomDescription":siksDesString,@"imageList":imageArray,@"archivesId":memberId};
|
|
NSData * messagedata = [NSJSONSerialization dataWithJSONObject:parmdic options:0 error:nil];
|
|
V2TIMMessage * message = [[V2TIMManager sharedInstance] createCustomMessage:messagedata];
|
|
if( self.isGroupID == false) {
|
|
[self.vc sendMessage:message];
|
|
}else
|
|
{
|
|
[self.groupvc sendMessage:message];
|
|
}
|
|
}
|
|
}
|
|
#pragma mark - 键盘处理
|
|
|
|
/**
|
|
* 键盘即将隐藏
|
|
*/
|
|
- (void)keyboardWillHideAction:(NSNotification *)note
|
|
{
|
|
|
|
// 1.键盘弹出需要的时间
|
|
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
|
|
// 2.动画
|
|
[UIView animateWithDuration:duration animations:^{
|
|
}];
|
|
}
|
|
|
|
/**
|
|
* 键盘即将弹出
|
|
*/
|
|
- (void)keyboardWillShowAction:(NSNotification *)note
|
|
{
|
|
|
|
// 1.键盘弹出需要的时间
|
|
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
|
|
// 2.动画
|
|
[UIView animateWithDuration:duration animations:^{
|
|
// 取出键盘高度
|
|
CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
|
CGFloat keyboardH = keyboardF.size.height - 40;
|
|
// if (_ThreeInch) {
|
|
// self.view.transform = CGAffineTransformMakeTranslation(0, - keyboardH);
|
|
// } else {
|
|
// self.view.transform = CGAffineTransformMakeTranslation(0, - 50);
|
|
// }
|
|
|
|
}];
|
|
}
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
if( self.isGroupID == false) {
|
|
self.vc.needScrollToBottom = true;
|
|
}
|
|
else
|
|
{
|
|
|
|
self.groupvc .needScrollToBottom = true;
|
|
}
|
|
}
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
|
|
#pragma mark - ————— 急救员 —————
|
|
|
|
- (void)enterChatWithSessionId:(NSString *)sessionId title:(NSString *)title {
|
|
if (!sessionId.length) return;
|
|
ChatViewController *chatVC = [[ChatViewController alloc] init];
|
|
chatVC.isGroupID = YES;
|
|
chatVC.isFromFirstAid = YES;
|
|
chatVC.isVideo = YES;
|
|
chatVC.chatID = sessionId;
|
|
chatVC.navTitle = title ?: @"应急求助";
|
|
[self.navigationController pushViewController:chatVC animated:YES];
|
|
}
|
|
|
|
- (void)callFirstAiderAction {
|
|
[self showMBProgressHUDWithString:@"加载中..." autoHidden:false];
|
|
self.orderPage = 1;
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
params[@"pageNo"] = @(self.orderPage);
|
|
params[@"pageSize"] = @(10);
|
|
XJDNetAPI *api = [[XJDNetAPI alloc] init:self tag:@"myParticipatedOrders" NeedToken:@""];
|
|
[api getMyParticipatedOrders:params];
|
|
}
|
|
|
|
#pragma mark - 工单列表弹窗
|
|
|
|
- (void)showOrderListPopup:(NSArray<XJParticipatedOrderModel *> *)models {
|
|
self.selectedOrderIndex = -1;
|
|
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
|
|
UIView *mask = [[UIView alloc] initWithFrame:keyWindow.bounds];
|
|
mask.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
|
|
mask.tag = 9001;
|
|
[keyWindow addSubview:mask];
|
|
|
|
CGFloat panelW = kScreenWidth - 46;
|
|
CGFloat panelH = 490;
|
|
CGFloat panelX = 23;
|
|
CGFloat panelY = (kScreenHeight - panelH) * 0.45;
|
|
|
|
UIView *panel = [[UIView alloc] initWithFrame:CGRectMake(panelX, panelY, panelW, panelH)];
|
|
panel.backgroundColor = KWhiteColor;
|
|
panel.layer.cornerRadius = 23;
|
|
panel.layer.masksToBounds = YES;
|
|
panel.tag = 9002;
|
|
[keyWindow addSubview:panel];
|
|
|
|
UILabel *titleLbl = [[UILabel alloc] init];
|
|
titleLbl.text = @"请选择正在应急的工单";
|
|
titleLbl.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
|
|
titleLbl.textColor = UIColorHex(0x252535);
|
|
[titleLbl sizeToFit];
|
|
titleLbl.top = 24;
|
|
titleLbl.centerX = panelW / 2;
|
|
[panel addSubview:titleLbl];
|
|
|
|
UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(panelW - 20 - 24, 21, 24, 24)];
|
|
closeBtn.backgroundColor = UIColorHex(0xF1F5F9);
|
|
closeBtn.layer.cornerRadius = 12;
|
|
UILabel *xLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
|
|
xLbl.text = @"✕"; xLbl.font = [UIFont systemFontOfSize:13];
|
|
xLbl.textColor = UIColorHex(0x77849E); xLbl.textAlignment = NSTextAlignmentCenter;
|
|
[closeBtn addSubview:xLbl];
|
|
[closeBtn addTarget:self action:@selector(dismissOrderPopup) forControlEvents:UIControlEventTouchUpInside];
|
|
[panel addSubview:closeBtn];
|
|
|
|
CGFloat sep1Y = titleLbl.bottom + 16;
|
|
UIView *sep1 = [[UIView alloc] initWithFrame:CGRectMake(0, sep1Y, panelW, 1)];
|
|
sep1.backgroundColor = UIColorHex(0xEAECFA);
|
|
[panel addSubview:sep1];
|
|
|
|
CGFloat btnH = 44;
|
|
UIButton *confirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, panelH - 12 - btnH, panelW - 40, btnH)];
|
|
confirmBtn.backgroundColor = UIColorHex(0x2EB8B2);
|
|
confirmBtn.layer.cornerRadius = 12;
|
|
[confirmBtn setTitle:@"确认选择" forState:UIControlStateNormal];
|
|
[confirmBtn setTitleColor:KWhiteColor forState:UIControlStateNormal];
|
|
confirmBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
|
|
[confirmBtn addTarget:self action:@selector(onConfirmOrderSelection) forControlEvents:UIControlEventTouchUpInside];
|
|
[panel addSubview:confirmBtn];
|
|
|
|
CGFloat sep2Y = confirmBtn.top - 12;
|
|
UIView *sep2 = [[UIView alloc] initWithFrame:CGRectMake(0, sep2Y, panelW, 1)];
|
|
sep2.backgroundColor = UIColorHex(0xEAECFA);
|
|
[panel addSubview:sep2];
|
|
|
|
CGFloat tableY = sep1Y + 1, tableH = sep2Y - tableY;
|
|
self.orderPopupTable = [[UITableView alloc] initWithFrame:CGRectMake(0, tableY, panelW, tableH) style:UITableViewStylePlain];
|
|
self.orderPopupTable.delegate = self;
|
|
self.orderPopupTable.dataSource = self;
|
|
self.orderPopupTable.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.orderPopupTable.showsVerticalScrollIndicator = NO;
|
|
self.orderPopupTable.backgroundColor = KWhiteColor;
|
|
self.orderPopupTable.rowHeight = UITableViewAutomaticDimension;
|
|
self.orderPopupTable.estimatedRowHeight = 160;
|
|
if (@available(iOS 15.0, *)) { self.orderPopupTable.sectionHeaderTopPadding = 0; }
|
|
self.orderPopupTable.contentInset = UIEdgeInsetsZero;
|
|
|
|
__weak typeof(self) wk = self;
|
|
self.orderPopupTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
wk.orderPage = 1; NSMutableDictionary *p = [NSMutableDictionary dictionary];
|
|
p[@"pageNo"] = @(1); p[@"pageSize"] = @(10);
|
|
[[[XJDNetAPI alloc] init:wk tag:@"myParticipatedOrders" NeedToken:@""] getMyParticipatedOrders:p];
|
|
}];
|
|
self.orderPopupTable.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
|
|
wk.orderPage++; NSMutableDictionary *p = [NSMutableDictionary dictionary];
|
|
p[@"pageNo"] = @(wk.orderPage); p[@"pageSize"] = @(10);
|
|
[[[XJDNetAPI alloc] init:wk tag:@"myParticipatedOrders" NeedToken:@""] getMyParticipatedOrders:p];
|
|
}];
|
|
|
|
[panel addSubview:self.orderPopupTable];
|
|
panel.alpha = 0;
|
|
[UIView animateWithDuration:0.25 animations:^{ panel.alpha = 1; }];
|
|
}
|
|
|
|
- (void)dismissOrderPopup {
|
|
[[UIApplication.sharedApplication.keyWindow viewWithTag:9001] removeFromSuperview];
|
|
[[UIApplication.sharedApplication.keyWindow viewWithTag:9002] removeFromSuperview];
|
|
}
|
|
|
|
- (void)onConfirmOrderSelection {
|
|
if (self.selectedOrderIndex < 0 || self.selectedOrderIndex >= self.orderList.count) return;
|
|
XJParticipatedOrderModel *m = self.orderList[self.selectedOrderIndex];
|
|
[self dismissOrderPopup];
|
|
[self enterChatWithSessionId:m.sessionId title:m.salvageUserName];
|
|
}
|
|
|
|
#pragma mark - 群成员侧滑面板
|
|
|
|
- (void)moreAction {
|
|
if (!self.isGroupID) return;
|
|
if (self.memberPanel) { [self hideMemberPanel]; return; }
|
|
|
|
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
CGFloat panelW = kScreenWidth - 94;
|
|
|
|
self.memberOverlay = [[UIView alloc] initWithFrame:keyWindow.bounds];
|
|
self.memberOverlay.backgroundColor = RGBA(0, 0, 0, 0.4);
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideMemberPanel)];
|
|
[self.memberOverlay addGestureRecognizer:tap];
|
|
[keyWindow addSubview:self.memberOverlay];
|
|
|
|
self.memberPanel = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, panelW, kScreenHeight)];
|
|
self.memberPanel.backgroundColor = KWhiteColor;
|
|
[keyWindow addSubview:self.memberPanel];
|
|
|
|
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, panelW, kStatusBarHeight + 44)];
|
|
headerView.backgroundColor = KWhiteColor;
|
|
[self.memberPanel addSubview:headerView];
|
|
|
|
self.memberTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, kStatusBarHeight, panelW - 56, 44)];
|
|
self.memberTitleLabel.text = @"群成员";
|
|
self.memberTitleLabel.textAlignment = NSTextAlignmentLeft;
|
|
self.memberTitleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
|
self.memberTitleLabel.textColor = UIColorHex(0x070809);
|
|
[headerView addSubview:self.memberTitleLabel];
|
|
|
|
UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(panelW - 44, kStatusBarHeight, 44, 44)];
|
|
[closeBtn setTitle:@"✕" forState:UIControlStateNormal];
|
|
[closeBtn setTitleColor:UIColorHex(0x070809) forState:UIControlStateNormal];
|
|
[closeBtn addTarget:self action:@selector(hideMemberPanel) forControlEvents:UIControlEventTouchUpInside];
|
|
[headerView addSubview:closeBtn];
|
|
|
|
UIView *headerLine = [[UIView alloc] initWithFrame:CGRectMake(12, headerView.bounds.size.height - 1, panelW - 12, 1)];
|
|
headerLine.backgroundColor = UIColorHex(0xEAECF1);
|
|
[headerView addSubview:headerLine];
|
|
|
|
CGFloat tableY = kStatusBarHeight + 44;
|
|
self.memberTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, tableY, panelW, kScreenHeight - tableY) style:UITableViewStylePlain];
|
|
self.memberTableView.delegate = self;
|
|
self.memberTableView.dataSource = self;
|
|
self.memberTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.memberTableView.rowHeight = 68;
|
|
self.memberTableView.tableFooterView = [self makeAddMemberFooterView:panelW];
|
|
[self.memberPanel addSubview:self.memberTableView];
|
|
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
self.memberPanel.frame = CGRectMake(kScreenWidth - panelW, 0, panelW, kScreenHeight);
|
|
}];
|
|
|
|
[self loadGroupMembers];
|
|
}
|
|
|
|
- (UIView *)makeAddMemberFooterView:(CGFloat)panelW {
|
|
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, panelW, 20 + 49 + 57)];
|
|
footer.backgroundColor = KWhiteColor;
|
|
|
|
UIButton *refreshBtn = [[UIButton alloc] initWithFrame:CGRectMake(11, 12, panelW - 22, 49)];
|
|
refreshBtn.backgroundColor = KWhiteColor;
|
|
refreshBtn.layer.cornerRadius = 8;
|
|
refreshBtn.layer.borderWidth = 1;
|
|
refreshBtn.layer.borderColor = UIColorHex(0xCCCCCC).CGColor;
|
|
[refreshBtn setTitle:@" 更新群成员" forState:UIControlStateNormal];
|
|
[refreshBtn setTitleColor:UIColorHex(0x070809) forState:UIControlStateNormal];
|
|
refreshBtn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
[refreshBtn addTarget:self action:@selector(refreshMemberList) forControlEvents:UIControlEventTouchUpInside];
|
|
[footer addSubview:refreshBtn];
|
|
|
|
self.refreshIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
|
|
self.refreshIcon.image = [UIImage imageNamed:@"yuanxunhuan"];
|
|
self.refreshIcon.contentMode = UIViewContentModeScaleAspectFit;
|
|
CGFloat rTitleW = [refreshBtn.titleLabel.text sizeWithAttributes:@{NSFontAttributeName: refreshBtn.titleLabel.font}].width;
|
|
CGFloat rIconX = (panelW - 22 - rTitleW) / 2;
|
|
self.refreshIcon.center = CGPointMake(rIconX, 49 / 2);
|
|
[refreshBtn addSubview:self.refreshIcon];
|
|
|
|
UIButton *addBtn = [[UIButton alloc] initWithFrame:CGRectMake(11, 12 + 49 + 8, panelW - 22, 49)];
|
|
addBtn.backgroundColor = [UIColorHex(0x2EB8B2) colorWithAlphaComponent:0.12];
|
|
addBtn.layer.cornerRadius = 8;
|
|
addBtn.layer.borderWidth = 1;
|
|
addBtn.layer.borderColor = UIColorHex(0x2EB8B2).CGColor;
|
|
[addBtn addTarget:self action:@selector(addMemberAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, (49 - 18) / 2, 18, 18)];
|
|
icon.image = [UIImage imageNamed:@"firstAid_add_icon"];
|
|
icon.contentMode = UIViewContentModeScaleAspectFit;
|
|
[addBtn addSubview:icon];
|
|
|
|
UILabel *btnTitle = [[UILabel alloc] init];
|
|
btnTitle.text = @"添加成员";
|
|
btnTitle.textColor = UIColorHex(0x2EB8B2);
|
|
btnTitle.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
[btnTitle sizeToFit];
|
|
CGFloat totalW = 18 + 6 + btnTitle.bounds.size.width;
|
|
icon.frame = CGRectMake((addBtn.bounds.size.width - totalW) / 2, (49 - 18) / 2, 18, 18);
|
|
btnTitle.frame = CGRectMake(icon.frame.origin.x + 18 + 6, (49 - btnTitle.bounds.size.height) / 2, btnTitle.bounds.size.width, btnTitle.bounds.size.height);
|
|
[addBtn addSubview:btnTitle];
|
|
|
|
[footer addSubview:addBtn];
|
|
return footer;
|
|
}
|
|
|
|
- (void)hideMemberPanel {
|
|
CGFloat panelW = kScreenWidth - 94;
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
self.memberPanel.frame = CGRectMake(kScreenWidth, 0, panelW, kScreenHeight);
|
|
} completion:^(BOOL finished) {
|
|
[self.memberOverlay removeFromSuperview];
|
|
[self.memberPanel removeFromSuperview];
|
|
self.memberOverlay = nil;
|
|
self.memberPanel = nil;
|
|
self.memberTableView = nil;
|
|
self.memberList = nil;
|
|
}];
|
|
}
|
|
|
|
- (void)refreshMemberList {
|
|
CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
|
|
rotation.toValue = @(M_PI * 2);
|
|
rotation.duration = 0.6;
|
|
rotation.repeatCount = HUGE_VALF;
|
|
[self.refreshIcon.layer addAnimation:rotation forKey:@"refreshRotation"];
|
|
[self loadGroupMembers];
|
|
}
|
|
|
|
- (void)loadGroupMembers {
|
|
[self showMBProgressHUDWithString:@"加载中..." autoHidden:NO];
|
|
self.memberList = [NSMutableArray array];
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
[params setObject:self.chatID forKey:@"sessionId"];
|
|
XJDNetAPI *api = [[XJDNetAPI alloc] init:self tag:@"GROUPMEMBERLIST" NeedToken:@""];
|
|
[api getActualGroupMemberList:params];
|
|
}
|
|
|
|
- (NSString *)memberTypeNameFromValue:(NSInteger)memberType {
|
|
switch (memberType) {
|
|
case -1: return @"发起人";
|
|
case 0: return @"操作人员";
|
|
case 1: return @"专业人员";
|
|
case 2: return @"员工";
|
|
default: return @"";
|
|
}
|
|
}
|
|
|
|
- (void)addMemberAction {
|
|
[self hideMemberPanel];
|
|
XJSelectContactViewController *selectVC = [[XJSelectContactViewController alloc] init];
|
|
selectVC.chatID = self.chatID;
|
|
selectVC.groupId = self.chatID;
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:selectVC];
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
[keyWindow.rootViewController presentViewController:nav animated:YES completion:nil];
|
|
}
|
|
|
|
- (void)callMemberAction:(UIButton *)sender {
|
|
UITableViewCell *cell = (UITableViewCell *)sender.superview.superview;
|
|
NSIndexPath *indexPath = [self.memberTableView indexPathForCell:cell];
|
|
if (!indexPath || indexPath.row >= self.memberList.count) return;
|
|
NSDictionary *member = self.memberList[indexPath.row];
|
|
NSString *phone = member[@"phone"];
|
|
if (phone.length == 0) {
|
|
[EasyTextView showErrorText:@"暂无手机号"];
|
|
return;
|
|
}
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", phone]] options:nil completionHandler:nil];
|
|
}
|
|
|
|
- (void)loginImAccount {
|
|
XJDNetAPI *api = [[XJDNetAPI alloc] init:self tag:@"loginIMAPI" NeedToken:nil];
|
|
[api GetIMLoginAccount:nil];
|
|
}
|
|
|
|
#pragma mark - V2TIMConversationListener
|
|
|
|
- (void)onConversationChanged:(NSArray<V2TIMConversation *> *)conversationList {}
|
|
|
|
- (void)onKickedOffline {
|
|
[XJDCommonUtils keyedArchiverWithData:nil key:LoginUserInfo];
|
|
[ESCTUIManager outLoginTUISDK];
|
|
KPostNotification(KNotificationLoginStateChange, @NO);
|
|
}
|
|
|
|
#pragma mark - V2TIMGroupListener
|
|
|
|
- (void)onMemberEnter:(NSString *)groupID memberList:(NSArray<V2TIMGroupMemberInfo *> *)memberList {
|
|
if ([groupID isEqualToString:self.chatID] && self.memberPanel) {
|
|
[self loadGroupMembers];
|
|
}
|
|
}
|
|
|
|
#pragma mark - ————— Network —————
|
|
|
|
- (void)Failed:(NSString*)message tag:(NSString*)tag
|
|
{
|
|
if ([tag isEqualToString:@"myParticipatedOrders"]) {
|
|
[self hiddenAllMBProgressHUD];
|
|
if (self.orderPage == 1) [EasyTextView showErrorText:message];
|
|
return;
|
|
}
|
|
[self showMBProgressHUDOnlyWithString:message];
|
|
[self hiddenAllMBProgressHUD];
|
|
}
|
|
- (void)Sucess:(id)response tag:(NSString*)tag
|
|
{
|
|
if ([tag isEqualToString:@"ENDSOSAPI"])
|
|
{
|
|
NSDictionary * parmDic = response;
|
|
if( self.isGroupID == false) {
|
|
|
|
self.vc.inputController.view.hidden = YES;
|
|
}else
|
|
{
|
|
self.groupvc.inputController.view.hidden = YES;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if ([tag isEqualToString:@"ENDPICTUREAPI"]) {
|
|
|
|
if( self.isGroupID == false) {
|
|
|
|
self.vc.inputController.view.hidden = YES;
|
|
}else
|
|
{
|
|
self.groupvc.inputController.view.hidden = YES;
|
|
}
|
|
|
|
}
|
|
if ([tag isEqualToString:@"DoctorSource"]) {
|
|
|
|
}
|
|
if ([tag isEqualToString:@"myParticipatedOrders"]) {
|
|
[self hiddenAllMBProgressHUD];
|
|
NSDictionary *dic = [response isKindOfClass:[NSDictionary class]] ? response : nil;
|
|
NSArray *records = dic[@"records"];
|
|
if (![records isKindOfClass:[NSArray class]] || records.count == 0) {
|
|
if (self.orderPage == 1) [EasyTextView showErrorText:@"暂无进行中的应急工单"];
|
|
return;
|
|
}
|
|
NSMutableArray *models = [NSMutableArray array];
|
|
for (NSDictionary *d in records) {
|
|
[models addObject:[XJParticipatedOrderModel modelWithDictionary:d]];
|
|
}
|
|
if (models.count == 1 && self.orderPage == 1 && [dic[@"total"] integerValue] == 1) {
|
|
XJParticipatedOrderModel *m = models.firstObject;
|
|
[self enterChatWithSessionId:m.sessionId title:m.salvageUserName];
|
|
return;
|
|
}
|
|
if (self.orderPage == 1) {
|
|
self.orderList = models;
|
|
[self showOrderListPopup:self.orderList];
|
|
} else {
|
|
[self.orderList addObjectsFromArray:models];
|
|
[self.orderPopupTable reloadData];
|
|
}
|
|
[self.orderPopupTable.mj_header endRefreshing];
|
|
[self.orderPopupTable.mj_footer endRefreshing];
|
|
if (records.count < 10) [self.orderPopupTable.mj_footer endRefreshingWithNoMoreData];
|
|
return;
|
|
}
|
|
if ([tag isEqualToString:@"GROUPMEMBERLIST"]) {
|
|
[self hiddenAllMBProgressHUD];
|
|
[self.memberList removeAllObjects];
|
|
NSArray *list = [response isKindOfClass:[NSDictionary class]] ? response[@"result"] : response;
|
|
if ([list isKindOfClass:[NSArray class]]) {
|
|
[self.memberList addObjectsFromArray:list];
|
|
}
|
|
self.memberTitleLabel.text = [NSString stringWithFormat:@"群成员(%lu)", (unsigned long)self.memberList.count];
|
|
[self.memberTableView reloadData];
|
|
[self.refreshIcon.layer removeAnimationForKey:@"refreshRotation"];
|
|
return;
|
|
}
|
|
if ([tag isEqualToString:@"loginIMAPI"]) {
|
|
[self hiddenAllMBProgressHUD];
|
|
NSDictionary *pamrDic = response;
|
|
NSInteger sdkAppId = [[pamrDic objectForKey:@"sdkAppId"] intValue];
|
|
NSString *userId = [pamrDic objectForKey:@"userId"];
|
|
NSString *userSig = [pamrDic objectForKey:@"userSig"];
|
|
[ESCTUIManager loginInitTUISDKAppidWith:sdkAppId UserID:userId userSig:userSig];
|
|
[self callFirstAiderAction];
|
|
return;
|
|
}
|
|
}
|
|
|
|
#pragma mark - ————— UITableView —————
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
if (tableView == self.memberTableView) return self.memberList.count;
|
|
if (tableView == self.orderPopupTable) return self.orderList.count;
|
|
return 0;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (tableView == self.memberTableView) return 68;
|
|
if (tableView == self.orderPopupTable) return 160;
|
|
return 44;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (tableView == self.memberTableView) return [self memberCellForRowAtIndexPath:indexPath];
|
|
if (tableView == self.orderPopupTable) return [self orderCellForRowAtIndexPath:indexPath];
|
|
return [UITableViewCell new];
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (tableView == self.orderPopupTable) {
|
|
self.selectedOrderIndex = indexPath.row;
|
|
[tableView reloadData];
|
|
}
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
}
|
|
|
|
#pragma mark - 群成员 Cell
|
|
|
|
- (UITableViewCell *)memberCellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
static NSString *cellId = @"MemberCell";
|
|
NSDictionary *member = self.memberList[indexPath.row];
|
|
CGFloat panelW = kScreenWidth - 94;
|
|
|
|
UITableViewCell *cell = [self.memberTableView dequeueReusableCellWithIdentifier:cellId];
|
|
if (!cell) {
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
UIImageView *avatar = [[UIImageView alloc] initWithFrame:CGRectMake(12, 11, 45, 45)];
|
|
avatar.tag = 100;
|
|
avatar.layer.cornerRadius = 8;
|
|
avatar.layer.masksToBounds = YES;
|
|
[cell.contentView addSubview:avatar];
|
|
|
|
UILabel *nameLabel = [[UILabel alloc] init];
|
|
nameLabel.tag = 101;
|
|
nameLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
|
nameLabel.textColor = UIColorHex(0x070809);
|
|
[cell.contentView addSubview:nameLabel];
|
|
|
|
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 42, panelW - 132, 14)];
|
|
titleLabel.tag = 102;
|
|
titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
|
|
titleLabel.textColor = UIColorHex(0x808080);
|
|
[cell.contentView addSubview:titleLabel];
|
|
|
|
UIButton *phoneBtn = [[UIButton alloc] initWithFrame:CGRectMake(panelW - 47, 20, 32, 32)];
|
|
phoneBtn.tag = 103;
|
|
[phoneBtn setImage:[UIImage imageNamed:@"firstAid_phone_icon"] forState:UIControlStateNormal];
|
|
[phoneBtn addTarget:self action:@selector(callMemberAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[cell.contentView addSubview:phoneBtn];
|
|
|
|
UIView *line = [[UIView alloc] initWithFrame:CGRectMake(70, 67, panelW - 70, 1)];
|
|
line.tag = 104;
|
|
line.backgroundColor = UIColorHex(0xEAECF1);
|
|
[cell.contentView addSubview:line];
|
|
}
|
|
|
|
UIImageView *avatar = [cell.contentView viewWithTag:100];
|
|
UILabel *nameLabel = [cell.contentView viewWithTag:101];
|
|
UILabel *titleLabel = [cell.contentView viewWithTag:102];
|
|
|
|
NSString *userName = member[@"userName"] ?: @"";
|
|
nameLabel.text = userName;
|
|
CGSize nameSize = [userName sizeWithAttributes:@{NSFontAttributeName: nameLabel.font}];
|
|
nameLabel.frame = CGRectMake(70, 15, nameSize.width, 17);
|
|
|
|
titleLabel.text = [self memberTypeNameFromValue:[member[@"memberType"] integerValue]];
|
|
|
|
NSString *avatarPath = member[@"avatar"];
|
|
if (avatarPath.length > 0) {
|
|
NSString *fullUrl = [avatarPath hasPrefix:@"http"] ? avatarPath : [NSString stringWithFormat:@"%@%@", ResourceAddress, avatarPath];
|
|
[avatar sd_setImageWithURL:[NSURL URLWithString:fullUrl] placeholderImage:[UIImage imageNamed:@"heard_man"]];
|
|
} else {
|
|
avatar.image = [UIImage imageNamed:@"heard_man"];
|
|
}
|
|
|
|
return cell;
|
|
}
|
|
|
|
#pragma mark - 工单 Cell
|
|
|
|
- (UITableViewCell *)orderCellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
static NSString *cid = @"OrderCell";
|
|
XJParticipatedOrderModel *m = self.orderList[indexPath.row];
|
|
BOOL selected = (indexPath.row == self.selectedOrderIndex);
|
|
CGFloat panelW = kScreenWidth - 46;
|
|
|
|
UITableViewCell *cell = [self.orderPopupTable dequeueReusableCellWithIdentifier:cid];
|
|
if (!cell) {
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cid];
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
cell.backgroundColor = KWhiteColor;
|
|
|
|
UIView *container = [[UIView alloc] init];
|
|
container.tag = 200;
|
|
container.layer.cornerRadius = 8;
|
|
container.layer.borderWidth = 1;
|
|
[cell.contentView addSubview:container];
|
|
[container mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.equalTo(cell.contentView).offset(12);
|
|
make.right.equalTo(cell.contentView).offset(-12);
|
|
make.bottom.equalTo(cell.contentView);
|
|
}];
|
|
|
|
UILabel *nameLbl = [[UILabel alloc] init];
|
|
nameLbl.tag = 201;
|
|
nameLbl.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
|
|
[container addSubview:nameLbl];
|
|
[nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.equalTo(container).offset(16);
|
|
}];
|
|
|
|
UIImageView *indicator = [[UIImageView alloc] init];
|
|
indicator.tag = 202;
|
|
indicator.contentMode = UIViewContentModeScaleAspectFit;
|
|
[container addSubview:indicator];
|
|
[indicator mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(container).offset(-16);
|
|
make.top.equalTo(container).offset(14);
|
|
make.size.mas_equalTo(CGSizeMake(18, 18));
|
|
}];
|
|
|
|
UIView *line = [[UIView alloc] init];
|
|
line.tag = 204;
|
|
line.backgroundColor = UIColorHex(0xEAECFA);
|
|
[container addSubview:line];
|
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(container).offset(16);
|
|
make.right.equalTo(container).offset(-16);
|
|
make.top.equalTo(nameLbl.mas_bottom).offset(12);
|
|
make.height.mas_equalTo(1);
|
|
}];
|
|
|
|
UIImageView *orgIcon = [[UIImageView alloc] init];
|
|
orgIcon.tag = 205;
|
|
orgIcon.contentMode = UIViewContentModeScaleAspectFit;
|
|
[container addSubview:orgIcon];
|
|
[orgIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(container).offset(16);
|
|
make.top.equalTo(line.mas_bottom).offset(12);
|
|
make.size.mas_equalTo(CGSizeMake(16, 16));
|
|
}];
|
|
|
|
UILabel *orgLbl = [[UILabel alloc] init];
|
|
orgLbl.tag = 206;
|
|
orgLbl.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
|
orgLbl.numberOfLines = 0;
|
|
[container addSubview:orgLbl];
|
|
[orgLbl mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(orgIcon.mas_right).offset(8);
|
|
make.top.equalTo(line.mas_bottom).offset(12);
|
|
make.right.equalTo(container).offset(-16);
|
|
}];
|
|
|
|
UIImageView *timeIcon = [[UIImageView alloc] init];
|
|
timeIcon.tag = 207;
|
|
timeIcon.contentMode = UIViewContentModeScaleAspectFit;
|
|
[container addSubview:timeIcon];
|
|
[timeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(container).offset(16);
|
|
make.top.equalTo(orgLbl.mas_bottom).offset(15);
|
|
make.size.mas_equalTo(CGSizeMake(16, 16));
|
|
}];
|
|
|
|
UILabel *timeLbl = [[UILabel alloc] init];
|
|
timeLbl.tag = 208;
|
|
timeLbl.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
|
[container addSubview:timeLbl];
|
|
[timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(timeIcon.mas_right).offset(8);
|
|
make.centerY.equalTo(timeIcon);
|
|
make.right.equalTo(container).offset(-16);
|
|
make.bottom.equalTo(container).offset(-16);
|
|
}];
|
|
}
|
|
|
|
UIView *container = [cell.contentView viewWithTag:200];
|
|
UILabel *nameLbl = [container viewWithTag:201];
|
|
UIImageView *indicator = [container viewWithTag:202];
|
|
UIImageView *orgIcon = [container viewWithTag:205];
|
|
UILabel *orgLbl = [container viewWithTag:206];
|
|
UIImageView *timeIcon = [container viewWithTag:207];
|
|
UILabel *timeLbl = [container viewWithTag:208];
|
|
|
|
if (selected) {
|
|
container.layer.borderColor = UIColorHex(0x2EB8B280).CGColor;
|
|
container.backgroundColor = UIColorHex(0x2EB8B20F);
|
|
orgLbl.textColor = UIColorHex(0x2EB8B2);
|
|
timeLbl.textColor = UIColorHex(0x2EB8B2);
|
|
} else {
|
|
container.layer.borderColor = UIColorHex(0xE6E6EA).CGColor;
|
|
container.backgroundColor = KWhiteColor;
|
|
orgLbl.textColor = UIColorHex(0x77849E);
|
|
timeLbl.textColor = UIColorHex(0x77849E);
|
|
}
|
|
nameLbl.textColor = UIColorHex(0x252535);
|
|
|
|
nameLbl.text = m.salvageUserName ?: @"--";
|
|
indicator.image = [UIImage imageNamed:selected ? @"order_selected" : @"order_unselected"];
|
|
orgIcon.image = [UIImage imageNamed:selected ? @"org_selected" : @"org_unselected"];
|
|
orgLbl.text = m.orgName ?: @"";
|
|
timeIcon.image = [UIImage imageNamed:selected ? @"time_selected" : @"time_unselected"];
|
|
timeLbl.text = m.createTime.length > 0 ? [NSString stringWithFormat:@"求助时间:%@", m.createTime] : @"";
|
|
|
|
return cell;
|
|
}
|
|
|
|
@end
|