MOTicketTimeView.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // MOTicketTimeView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/7/8.
  6. //
  7. #import "MOTicketTimeView.h"
  8. @interface MOTicketTimeView ()
  9. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  10. @property (weak, nonatomic) IBOutlet UILabel *timeLab;
  11. @property (nonatomic, assign) BOOL theTimeTag;
  12. @end
  13. @implementation MOTicketTimeView
  14. + (instancetype)moTicketTimeView{
  15. return [[[NSBundle mainBundle] loadNibNamed:@"MOTicketTimeView" owner:self options:nil] firstObject];
  16. }
  17. - (void)awakeFromNib{
  18. [super awakeFromNib];
  19. self.theTimeTag = NO;
  20. self.titleLab.font = [MOTextTools getTheFontWithSize:8.0 AndFontName:kTypeOneTitleFontStr];
  21. self.timeLab.font = [MOTextTools getTheFontWithSize:8.0 AndFontName:kNormalContentFontStr];
  22. }
  23. - (IBAction)viewClickAciton:(id)sender {
  24. self.ticketViewClickBlock ? self.ticketViewClickBlock() : nil;
  25. }
  26. - (void)resetAllProperty{
  27. self.theTimeTag = NO;
  28. self.timeLab.text = @"00:00";
  29. self.planConvertTime = 0;
  30. }
  31. - (void)oneSecondPassed{
  32. if(self.useTicket){
  33. return;
  34. }
  35. if(self.planConvertTime <= 0){
  36. return;
  37. }
  38. NSTimeInterval time = 0;
  39. NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000;
  40. if((self.planConvertTime - (round(currentTime) - GetRedSysTime)) < 0){
  41. //超过计算时间了
  42. self.timeLab.text = @"00:00";
  43. if(!self.theTimeTag){
  44. self.theTimeTag = YES;
  45. if(self.isCreatLive){
  46. [self changeTheRoomType];
  47. }
  48. else{
  49. self.ticketTimeOverBlock ? self.ticketTimeOverBlock() : nil;
  50. }
  51. }
  52. }
  53. else{
  54. //倒计时
  55. time = round((self.planConvertTime - (round(currentTime) - GetRedSysTime)) / 1000);
  56. NSString *timeStr = [NSDate formattedTimeStringFromTimeInterval:time AndFormatStr:@"mm:ss"];
  57. self.timeLab.text = timeStr;
  58. }
  59. }
  60. - (void)changeTheRoomType{
  61. if(self.roomId.length == 0){
  62. return;
  63. }
  64. WEAKSELF
  65. NSDictionary *dict = @{@"id":self.roomId};
  66. [kHttpManager toSubmitConvertAboutLiveRoomWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  67. if(kCode_Success){
  68. MORoomStatus *baseModel = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
  69. weakSelf.changeSuccessBlock ? weakSelf.changeSuccessBlock(baseModel) : nil;
  70. }
  71. else{
  72. MOLogV(@"toSettingConvertTheLiveRoomWithParams 接口报错了");
  73. kShowNetError(data)
  74. }
  75. }];
  76. }
  77. @end