// // YYKTVCenterView.m // SweetParty // // Created by bj_szd on 2024/1/5. // #import "YYKTVCenterView.h" #import "ZWTimer.h" @interface YYKTVCenterView () @property (nonatomic, strong) ZWTimer *timer; @property (nonatomic, assign) NSInteger leftSecond; @end @implementation YYKTVCenterView - (void)awakeFromNib { [super awakeFromNib]; [self.hostEndBtn styleGradiBlueColor]; WEAK_SELF [self.singAvatarImgV dg_Tapped:^{ }]; [self.zhizuoAvatarImgV dg_Tapped:^{ }]; } - (void)onUpdateUIWith:(NSDictionary *)dataDict isHost:(BOOL)isHost { //K歌房状态 1未开始 2唱歌阶段 3签约阶段 NSInteger status = [dataDict safeIntForKey:@"room_song_status"]; NSDictionary *singInfo = dataDict[@"room_song_info"][@"user_info"]; if (status == 2) { _timeBgView.hidden = NO; _chujiaBtn.hidden = _hostChujiaBtn.hidden = _hostEndBtn.hidden = YES; _qipaiPriceViewTopCon.constant = 178; }else if (status == 3) { _timeBgView.hidden = YES; _qipaiPriceViewTopCon.constant = 49; if (isHost) { _chujiaBtn.hidden = YES; _hostChujiaBtn.hidden = YES; _hostEndBtn.hidden = NO; }else { _chujiaBtn.hidden = YES; _hostChujiaBtn.hidden = _hostEndBtn.hidden = YES; } } //制作人信息 NSDictionary *zhizuoInfo = dataDict[@"room_song_info"][@"producer_info"]; NSInteger is_producer = [dataDict[@"room_song_info"] safeIntForKey:@"is_producer"]; if (is_producer == 1) { _zhizuoAvatarImgV.hidden = _zhizuoBorderImgV.hidden = NO; _singAvatarCenterCon.constant = -10; [self.zhizuoAvatarImgV sd_setImageWithURL:[NSURL URLWithString:[zhizuoInfo safeStringForKey:@"head_pic"]] placeholderImage:kDefaultUserIcon]; }else { _zhizuoAvatarImgV.hidden = _zhizuoBorderImgV.hidden = YES; _singAvatarCenterCon.constant = 0; } [self.singAvatarImgV sd_setImageWithURL:[NSURL URLWithString:[singInfo safeStringForKey:@"head_pic"]] placeholderImage:kDefaultUserIcon]; self.singCharmLab.text = [singInfo safeStringForKey:@"charm_value"]; self.qipaiPriceLab.text = [singInfo safeStringForKey:@"auction_price"]; self.leftSecond = [dataDict[@"room_song_info"] safeIntForKey:@"surplus_time"]; [self.timer startGCDTimer:1 delegate:self]; } - (void)onTimerFired:(ZWTimer *)timer { self.leftSecond -= 1; if (self.leftSecond < 0) { self.leftSecond = 0; [self.timer stopTimer]; } self.timeLab.text = [NSString stringWithFormat:@"%02ld:%02ld", self.leftSecond/60%60, self.leftSecond%60]; } - (ZWTimer *)timer { if (!_timer) { _timer = [[ZWTimer alloc] init]; } return _timer; } @end