// // YOUPAILCCallAttachment.m // LiveChat // // Created by 张灿 on 2018/11/27. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCCallAttachment.h" @implementation YOUPAILCCallAttachment - (NSString *)encodeAttachment { NSDictionary *dict = @{ CMType : @(CustomCall), CMData : @{ CMCallTime: self.call_time?[NSNumber numberWithInteger:self.call_time]:@0, CMFrom: self.from_uid?[NSNumber numberWithInteger:self.from_uid]:@0, CMTo: self.to_uid?[NSNumber numberWithInteger:self.to_uid]:@0, CMLink_type: self.calltype?[NSNumber numberWithInteger:self.calltype]:@0, CMLink_url: self.status?[NSNumber numberWithInteger:self.calltype]:@0, } }; NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil]; NSString *content = nil; if (data) { content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; } return content; } - (NSString *)cellContent:(NIMMessage *)message{ return @"YOUPAILCCallContentView";//让礼物和贴图一样的形势发送 } - (CGSize)contentSize:(NIMMessageModel *)model cellWidth:(CGFloat)width{ NSString* txtStr = @""; if (self.status==3) { txtStr = @"超时未接听"; }else if (self.status==4){ txtStr = [NSString stringWithFormat:@"通话时长:%@",[ZCUtils getMinTimeStrFromSS:self.call_time]]; } if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id integerValue] == self.from_uid) {//代表是自己发的 if (self.status==1) { txtStr = @"已取消"; }else if (self.status==2){ txtStr = @"对方已拒绝"; } }else{ if (self.status==1) { txtStr = @"对方已取消"; }else if (self.status==2){ txtStr = @"已拒绝"; } } CGFloat nameWidth =[txtStr widthWithFont:LCFont(14) constrainedToHeight:20]; return CGSizeMake(nameWidth+50, 20); } - (UIEdgeInsets)contentViewInsets:(NIMMessage *)message { return [[NIMKit sharedKit].config setting:message].contentInsets; } @end