YOUPAILCCallAttachment.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // YOUPAILCCallAttachment.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/11/27.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCallAttachment.h"
  9. @implementation YOUPAILCCallAttachment
  10. - (NSString *)encodeAttachment
  11. {
  12. NSDictionary *dict = @{
  13. CMType : @(CustomCall),
  14. CMData : @{
  15. CMCallTime: self.call_time?[NSNumber numberWithInteger:self.call_time]:@0,
  16. CMFrom: self.from_uid?[NSNumber numberWithInteger:self.from_uid]:@0,
  17. CMTo: self.to_uid?[NSNumber numberWithInteger:self.to_uid]:@0,
  18. CMLink_type: self.calltype?[NSNumber numberWithInteger:self.calltype]:@0,
  19. CMLink_url: self.status?[NSNumber numberWithInteger:self.calltype]:@0,
  20. }
  21. };
  22. NSData *data = [NSJSONSerialization dataWithJSONObject:dict
  23. options:0
  24. error:nil];
  25. NSString *content = nil;
  26. if (data) {
  27. content = [[NSString alloc] initWithData:data
  28. encoding:NSUTF8StringEncoding];
  29. }
  30. return content;
  31. }
  32. - (NSString *)cellContent:(NIMMessage *)message{
  33. return @"YOUPAILCCallContentView";//让礼物和贴图一样的形势发送
  34. }
  35. - (CGSize)contentSize:(NIMMessageModel *)model cellWidth:(CGFloat)width{
  36. NSString* txtStr = @"";
  37. if (self.status==3) {
  38. txtStr = @"超时未接听";
  39. }else if (self.status==4){
  40. txtStr = [NSString stringWithFormat:@"通话时长:%@",[ZCUtils getMinTimeStrFromSS:self.call_time]];
  41. }
  42. if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id integerValue] == self.from_uid) {//代表是自己发的
  43. if (self.status==1) {
  44. txtStr = @"已取消";
  45. }else if (self.status==2){
  46. txtStr = @"对方已拒绝";
  47. }
  48. }else{
  49. if (self.status==1) {
  50. txtStr = @"对方已取消";
  51. }else if (self.status==2){
  52. txtStr = @"已拒绝";
  53. }
  54. }
  55. CGFloat nameWidth =[txtStr widthWithFont:LCFont(14) constrainedToHeight:20];
  56. return CGSizeMake(nameWidth+50, 20);
  57. }
  58. - (UIEdgeInsets)contentViewInsets:(NIMMessage *)message
  59. {
  60. return [[NIMKit sharedKit].config setting:message].contentInsets;
  61. }
  62. @end