123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- //
- // YOUPAILCCallRecordCell.m
- // LiveChat
- //
- // Created by 张灿 on 2018/10/13.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCCallRecordCell.h"
- #import "YOUPAILZLevelView.h"
- #import "ZCUtils.h"
- @interface YOUPAILCCallRecordCell()
- @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
- @property(nonatomic,strong)UILabel *youpaipnicknameL;
- //@property (nonatomic,strong)UIImageView *sexImgV;
- @property (nonatomic, weak) UIImageView *youpaipvipImgV;
- @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
- @property (nonatomic, strong) UILabel *youpaipdayL;
- @property (nonatomic, strong) UILabel *youpaiptimerL;
- @property (nonatomic, strong) UILabel *youpaipdescL;
- //@property(nonatomic,strong)UILabel* moneyLabel;
- //@property(nonatomic,strong)UILabel* otherLabel;
- ////@property(nonatomic,strong)UILabel* skillLabel;
- //@property(nonatomic,strong)UILabel* timeLabel;
- ////@property(nonatomic,strong)UILabel* createTLabel;
- @end
- @implementation YOUPAILCCallRecordCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- [self youpaifinitUI];
- }
- return self;
- }
- - (void)youpaifinitUI{
-
-
- self.youpaipavatarImgV = [[UIImageView alloc]init];
- self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- self.youpaipavatarImgV.layer.cornerRadius = 22.0f;
- self.youpaipavatarImgV.layer.masksToBounds = YES;
- [self.contentView addSubview:self.youpaipavatarImgV];
- [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.centerY.equalTo(self.contentView.centerY);
- make.size.mas_equalTo(CGSizeMake(44.0f, 44.0f));
- }];
-
- self.youpaipnicknameL = [[UILabel alloc] init];
- self.youpaipnicknameL.font = LCFont(14);
- self.youpaipnicknameL.textColor = LZ273145Color;
- [self.contentView addSubview:self.youpaipnicknameL];
- [self.youpaipnicknameL makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
- make.top.equalTo(self.youpaipavatarImgV.top).offset(5.5f);
- }];
-
- // UIImageView *sexImgV = [[UIImageView alloc] init];
- // [sexImgV setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_woman"]];
- // [self.contentView addSubview:sexImgV];
- // self.sexImgV = sexImgV;
- // [sexImgV makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(self.nicknameL.right).offset(@3);
- // make.centerY.equalTo(self.nicknameL);
- // make.size.mas_equalTo(CGSizeMake(14, 14));
- // }];
-
- UIImageView *vipImgV = [[UIImageView alloc] init];
- [self.contentView addSubview:vipImgV];
- self.youpaipvipImgV = vipImgV;
- [vipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
- make.centerY.equalTo(self.youpaipnicknameL);
- }];
-
- YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init];
- [self.contentView addSubview:levelView];
- self.youpaiplevelView = levelView;
- [levelView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
- make.centerY.equalTo(self.youpaipnicknameL);
- }];
-
- UILabel *dayL = [[UILabel alloc] init];
- dayL.font = LCFont(11.0f);
- dayL.textColor = HexColorFromRGB(0x9F9DA5);
- dayL.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:dayL];
- self.youpaipdayL = dayL;
- [dayL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-14.0f);
- make.top.equalTo(self.youpaipnicknameL.mas_top);
- }];
-
- UILabel *timerL = [[UILabel alloc] init];
- timerL.font = LCFont(11.0f);
- timerL.textColor = HexColorFromRGB(0x9F9DA5);
- timerL.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:timerL];
- self.youpaiptimerL = timerL;
- [timerL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-14.0f);
- make.top.equalTo(self.youpaipdayL.mas_bottom).offset(12.0f);
- }];
-
- UILabel *descL = [[UILabel alloc] init];
- descL.font = LCFont(12.0f);
- descL.textColor = LZA3AABEColor;
- descL.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:descL];
- self.youpaipdescL = descL;
- [descL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
- make.top.equalTo(self.youpaipnicknameL.mas_bottom).offset(8.0f);
- }];
-
- [self.contentView addLineWithColor:LZF5F4F7Color lineRect:CGRectMake(14.0f, 77.5f, KScreenWidth - 28.0f, 0.5f)];
- }
- - (void)setYoupaiprecordModel:(YOUPAILCCallRecordModel *)recordModel{
- _youpaiprecordModel = recordModel;
- [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:recordModel.youpaipavatar]];
- self.youpaipnicknameL.text = recordModel.youpaipnickname;
- if (recordModel.youpaipstatus==1) {
- if (recordModel.youpaiptype==1) {
- self.youpaipdescL.text = @"自己取消了呼叫";
- }else{
- self.youpaipdescL.text = @"对方取消了通话";
- }
- }else if (recordModel.youpaipstatus==2){
- if (recordModel.youpaiptype==1) {
- self.youpaipdescL.text = @"对方拒绝了通话";
- }else{
- self.youpaipdescL.text = @"自己拒绝接听";
- }
- }else if (recordModel.youpaipstatus==3){
- self.youpaipdescL.text = @"超时未接听";
- }else if (recordModel.youpaipstatus==4){
- if (recordModel.youpaiptype==1) {
- self.youpaipdescL.text = [NSString stringWithFormat:@"通话时长%@(支出%@钻石)",[self getMMSSFromSS:[NSString stringWithFormat:@"%ld",recordModel.youpaipcall_time]],recordModel.youpaipcall_amount];
- }else{
- self.youpaipdescL.text = [NSString stringWithFormat:@"通话时长%@(收入%@钻石)",[self getMMSSFromSS:[NSString stringWithFormat:@"%ld",recordModel.youpaipcall_time]],recordModel.youpaipcall_income];
- }
- }
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- //需要设置为和字符串相同的格式
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *localDate = [dateFormatter dateFromString:recordModel.youpaipcreate_time];
- NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
- NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
-
- NSDate *now = [NSDate date];
- NSDateComponents *comps = [[NSDateComponents alloc] init];
- comps = [calendar components:unitFlags fromDate:now];
-
- NSDateComponents *create_comps = [[NSDateComponents alloc] init];
- create_comps = [calendar components:unitFlags fromDate:localDate];
- // NSLog(@"%ld年%ld月%ld日",(long)[comps year],(long)[comps month],(long)[comps day]);
- // NSLog(@"%ld",(long)[comps weekday]);
-
- NSString *day = @"";
- if ([comps year] == [create_comps year] && [comps month] == [create_comps month] && [comps day] == [create_comps day]) {
- day = @"今天";
- }else{
- day = [NSString stringWithFormat:@"%@月%@日",@([create_comps month]),@([create_comps day])];
- }
-
- self.youpaipdayL.text = day;
- self.youpaiptimerL.text = [NSString stringWithFormat:@"%02ld:%02ld",[create_comps hour],[create_comps minute]];
-
- // if (recordModel.gender == 1) {//0未知 1女 2男
- // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
- // }else{
- // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
- // }
-
- self.youpaipvipImgV.hidden = YES;
- self.youpaiplevelView.hidden = YES;
-
- UIView *frontV;
- if (recordModel.youpaipvip_icon.length != 0) {
- self.youpaipvipImgV.hidden = NO;
- [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:recordModel.youpaipvip_icon]];
- [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- if (frontV == nil) {
- make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
- }else{
- make.left.equalTo(frontV.mas_right).offset(3.0f);
- }
- make.centerY.equalTo(self.youpaipnicknameL);
- make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
- }];
- frontV = self.youpaipvipImgV;
- }
- self.youpaiplevelView.hidden = NO;
- [self.youpaiplevelView youpaifreloadWithIcon:recordModel.youpaipgrade.youpaipimg1 iconWidth:recordModel.youpaipgrade.youpaipicon_width bgImg:recordModel.youpaipgrade.youpaipimg2 bgImgWidth:recordModel.youpaipgrade.youpaipicon1_width levelName:recordModel.youpaipgrade.youpaipgrade_name level:recordModel.youpaipgrade.youpaipgrade];
- [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
- if (frontV == nil) {
- make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
- }else{
- make.left.equalTo(frontV.mas_right).offset(3.0f);
- }
- make.centerY.equalTo(self.youpaipnicknameL);
- make.size.mas_offset(self.youpaiplevelView.mj_size);
- }];
-
-
- // [self.levelView youpaifreloadWithIcon:recordModel.grade.img1 iconWidth:recordModel.grade.icon_width bgImg:recordModel.grade.img2 bgImgWidth:recordModel.grade.icon1_width levelName:recordModel.grade.grade_name level:recordModel.grade.grade];
- // [self.levelView mas_updateConstraints:^(MASConstraintMaker *make) {
- // make.size.mas_offset(self.levelView.mj_size);
- // }];
- }
- -(NSString *)getMMSSFromSS:(NSString *)totalTime{
- NSInteger seconds = [totalTime integerValue];
- //format of hour
- NSString *str_hour = [NSString stringWithFormat:@"%02ld",seconds/3600];
- //format of minute
- NSString *str_minute = [NSString stringWithFormat:@"%02ld",(seconds%3600)/60];
- //format of second
- NSString *str_second = [NSString stringWithFormat:@"%02ld",seconds%60];
- //format of time
- NSString *format_time = [NSString stringWithFormat:@"%@:%@:%@",str_hour,str_minute,str_second];
- return format_time;
- }
- @end
|