241 lines
7.8 KiB
Objective-C
241 lines
7.8 KiB
Objective-C
//
|
|
// CustomMapMessageCell.m
|
|
// XinjiangProject
|
|
//
|
|
// Created by Apple on 2024/6/12.
|
|
//
|
|
|
|
#import "CustomMapMessageCell.h"
|
|
#import<CommonCrypto/CommonDigest.h>
|
|
|
|
@interface CustomMapMessageCell ()
|
|
|
|
@property (nonatomic, strong) UIImageView * heardImage;
|
|
|
|
@property (nonatomic, strong) UILabel * nickNameLabel;
|
|
|
|
@property (nonatomic, strong) UILabel * myTextLabel; // 展示文本
|
|
|
|
@property (nonatomic, strong) UIImageView * mapImage; //
|
|
|
|
@property (nonatomic, strong) UIView * backView;
|
|
|
|
@end
|
|
|
|
@implementation CustomMapMessageCell
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
// Initialization code
|
|
}
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
[super setSelected:selected animated:animated];
|
|
|
|
// Configure the view for the selected state
|
|
}
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
|
{
|
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
if (self) {
|
|
|
|
[self createUI];
|
|
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)createUI {
|
|
|
|
self.heardImage = [[UIImageView alloc] init];
|
|
self.heardImage.backgroundColor = KWhiteColor;
|
|
self.heardImage.image = [UIImage imageNamed:@"heard_man"];
|
|
[self.contentView addSubview:self.heardImage];
|
|
self.heardImage.layer.cornerRadius = 20;
|
|
self.heardImage.layer.masksToBounds = true;
|
|
[self.heardImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(@15);
|
|
make.top.mas_equalTo(@8);
|
|
make.height.width.mas_equalTo(@30);
|
|
}];
|
|
|
|
self.nickNameLabel = [[UILabel alloc] init];
|
|
self.nickNameLabel.text = @"全科医生";
|
|
[self.contentView addSubview:self.nickNameLabel];
|
|
self.nickNameLabel.font = SYSTEMFONT(12);
|
|
[self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.heardImage.mas_right).offset(10);
|
|
make.top.mas_equalTo(@10);
|
|
make.width.mas_equalTo(@300.0);
|
|
make.height.mas_offset(13);
|
|
}];
|
|
|
|
//姓名
|
|
self.backView = [[UIView alloc] init];
|
|
self.backView.layer.cornerRadius = 10;
|
|
self.backView.backgroundColor = KWhiteColor;
|
|
[self.contentView addSubview:self.backView];
|
|
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.heardImage.mas_right).offset(10);
|
|
make.width.mas_offset(245);
|
|
make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(8);
|
|
make.height.mas_offset(170);
|
|
}];
|
|
|
|
|
|
self.myTextLabel = [[UILabel alloc] init];
|
|
self.myTextLabel.font = SYSTEMFONT(15);
|
|
self.myTextLabel.textColor = CFontColor1;
|
|
self.myTextLabel.text = @"我的位置";
|
|
[self.backView addSubview:self.myTextLabel];
|
|
|
|
[self.myTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_offset(10);
|
|
make.top.mas_offset(0);
|
|
make.right.mas_offset(-10);
|
|
make.height.mas_offset(25);
|
|
}];
|
|
|
|
|
|
self.mapImage = [[UIImageView alloc] init];
|
|
self.mapImage.backgroundColor = KRedColor;
|
|
[self.backView addSubview:self.mapImage];
|
|
[self.mapImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.bottom.mas_offset(0);
|
|
make.top.mas_equalTo(self.myTextLabel.mas_bottom);
|
|
}];
|
|
}
|
|
|
|
- (void)setModel:(CustomTUIHistoryModel *)model {
|
|
_model = model;
|
|
|
|
// self.nickNameLabel.text = _model.fromAccountName;
|
|
|
|
if (_model.isSelf == true) { //头像在右
|
|
|
|
[self.heardImage mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.height.width.mas_offset(40);
|
|
make.top.mas_equalTo(@10);
|
|
make.right.mas_equalTo(self.contentView.mas_right).offset(-10);
|
|
|
|
}];
|
|
self.nickNameLabel.textAlignment = NSTextAlignmentRight;
|
|
[self.nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.right.mas_equalTo(self.heardImage.mas_left).offset(-10);
|
|
make.top.mas_equalTo(@10);
|
|
make.width.mas_equalTo(@245.0);
|
|
make.height.mas_offset(13);
|
|
}];
|
|
|
|
[self.backView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(8);
|
|
make.width.mas_offset(245);
|
|
make.right.mas_equalTo(self.heardImage.mas_left).offset(-10);
|
|
make.height.mas_equalTo(@170);
|
|
}];
|
|
|
|
|
|
}else
|
|
{
|
|
[self.heardImage mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(@15);
|
|
make.top.mas_equalTo(@8);
|
|
make.height.width.mas_equalTo(@40);
|
|
}];
|
|
self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
|
[self.nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.heardImage.mas_right).offset(10);
|
|
make.top.mas_equalTo(@10);
|
|
make.width.mas_equalTo(@300.0);
|
|
make.height.mas_offset(13);
|
|
}];
|
|
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.heardImage.mas_right).offset(10);
|
|
make.width.mas_offset(245);
|
|
make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(8);
|
|
make.height.mas_offset(170);
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
[self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.left.right.mas_equalTo(@0);
|
|
make.bottom.mas_equalTo(self.backView.mas_bottom).offset(10);
|
|
}];
|
|
|
|
|
|
NSString * MapPictureImg = [self mapLocationImage:_model.Longitude Withlation:_model.Latitude];
|
|
|
|
[self.mapImage sd_setImageWithURL:[NSURL URLWithString:MapPictureImg] placeholderImage:nil];
|
|
|
|
NSString * photo = [NSString stringWithFormat:@"%@%@",ResourceAddress,_model.avatar];
|
|
|
|
NSString * str1 = @"\\";
|
|
|
|
photo = [photo stringByReplacingOccurrencesOfString:str1 withString:@"/"];
|
|
|
|
NSString *encodedString3 = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)photo, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL, kCFStringEncodingUTF8));
|
|
|
|
[self.heardImage sd_setImageWithURL:[NSURL URLWithString:encodedString3] placeholderImage:PLACEHOLD_IMG];
|
|
}
|
|
|
|
|
|
- (NSString *)mapLocationImage:(CGFloat)longLation Withlation:(CGFloat)lation {
|
|
// 0: self.longLation,self.lation
|
|
//https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png
|
|
NSString * staciUrl = @"https://restapi.amap.com/v3/staticmap?key=e9926badd26aaa766d13439c88a83f2d";
|
|
NSString * mapKey = @"e9926badd26aaa766d13439c88a83f2d";
|
|
NSString * loctaionUrl = @"https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png";
|
|
|
|
NSString * needMdString = [NSString stringWithFormat:@"key=%@&location=%f,%f&markers=-1,%@,0:%f,%f&size=700*500&zoom=15124d58f7223ac9738312a8d187a21f2b",mapKey,longLation,lation,loctaionUrl,longLation,lation];
|
|
|
|
|
|
NSString * mapUrl = [NSString stringWithFormat:@"%@&location=%f,%f&markers=-1,%@,0:%f,%f&size=700*500&zoom=15&sig=%@",staciUrl,longLation,lation,loctaionUrl,longLation,lation,[self md5:needMdString]];
|
|
|
|
return mapUrl;
|
|
|
|
|
|
|
|
}
|
|
//md加密
|
|
- (NSString *)md5:(NSString *)str
|
|
{
|
|
const char *cStr = [str UTF8String];
|
|
unsigned char result[16];
|
|
CC_MD5(cStr, strlen(cStr), result); // This is the md5 call
|
|
return [NSString stringWithFormat:
|
|
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
|
result[0], result[1], result[2], result[3],
|
|
result[4], result[5], result[6], result[7],
|
|
result[8], result[9], result[10], result[11],
|
|
result[12], result[13], result[14], result[15]
|
|
];
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|