| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // MOTicketTimeView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/7/8.
- //
- #import "MOTicketTimeView.h"
- @interface MOTicketTimeView ()
- @property (weak, nonatomic) IBOutlet UILabel *titleLab;
- @property (weak, nonatomic) IBOutlet UILabel *timeLab;
- @property (nonatomic, assign) BOOL theTimeTag;
- @end
- @implementation MOTicketTimeView
- + (instancetype)moTicketTimeView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOTicketTimeView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
- self.theTimeTag = NO;
- self.titleLab.font = [MOTextTools getTheFontWithSize:8.0 AndFontName:kTypeOneTitleFontStr];
- self.timeLab.font = [MOTextTools getTheFontWithSize:8.0 AndFontName:kNormalContentFontStr];
- }
- - (IBAction)viewClickAciton:(id)sender {
- self.ticketViewClickBlock ? self.ticketViewClickBlock() : nil;
- }
- - (void)resetAllProperty{
- self.theTimeTag = NO;
- self.timeLab.text = @"00:00";
- self.planConvertTime = 0;
- }
- - (void)oneSecondPassed{
-
- if(self.useTicket){
- return;
- }
-
- if(self.planConvertTime <= 0){
- return;
- }
-
- NSTimeInterval time = 0;
- NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000;
-
- if((self.planConvertTime - (round(currentTime) - GetRedSysTime)) < 0){
- //超过计算时间了
- self.timeLab.text = @"00:00";
-
- if(!self.theTimeTag){
- self.theTimeTag = YES;
-
- if(self.isCreatLive){
- [self changeTheRoomType];
- }
- else{
- self.ticketTimeOverBlock ? self.ticketTimeOverBlock() : nil;
- }
- }
- }
- else{
- //倒计时
- time = round((self.planConvertTime - (round(currentTime) - GetRedSysTime)) / 1000);
- NSString *timeStr = [NSDate formattedTimeStringFromTimeInterval:time AndFormatStr:@"mm:ss"];
- self.timeLab.text = timeStr;
- }
- }
- - (void)changeTheRoomType{
- if(self.roomId.length == 0){
- return;
- }
-
- WEAKSELF
- NSDictionary *dict = @{@"id":self.roomId};
-
- [kHttpManager toSubmitConvertAboutLiveRoomWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
-
- MORoomStatus *baseModel = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
- weakSelf.changeSuccessBlock ? weakSelf.changeSuccessBlock(baseModel) : nil;
- }
- else{
- MOLogV(@"toSettingConvertTheLiveRoomWithParams 接口报错了");
- kShowNetError(data)
- }
- }];
- }
- @end
|