AuctionResultView.m 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // AuctionResultView.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 16/10/26.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "AuctionResultView.h"
  9. @interface AuctionResultView()
  10. @property (nonatomic, strong) UIView * backView;//用来装竞拍图片下方的显示内容
  11. @property (nonatomic, strong) UIImageView * resultImage;//竞拍结果图片,显示为竞拍成功,竞拍失败,付款成功
  12. @property (nonatomic, strong) UIImageView * diamondView;//钻石图片
  13. @property (nonatomic, strong) UILabel * nameLabel; //竞拍成功人的名字
  14. @property (nonatomic, strong) UILabel * lastLabel; //最终价
  15. @property (nonatomic, strong) UILabel * priceLabel; //最终价格Label
  16. @property (nonatomic, strong) UIView * titleView; //如果竞拍成功且付款人在付款中
  17. @property (nonatomic, strong) UIButton * payButton; //立即付款按钮
  18. @end
  19. @implementation AuctionResultView
  20. - (instancetype)initWithFrame:(CGRect)frame
  21. {
  22. if (self = [super initWithFrame:frame])
  23. {
  24. _resultImage = [[UIImageView alloc] init];
  25. [self addSubview:_resultImage];
  26. _backView = [[UIView alloc] init];
  27. [self addSubview:_backView];
  28. _titleView = [[UIView alloc] init];
  29. [_backView addSubview:_titleView];
  30. _nameLabel = [[UILabel alloc] init];
  31. [_backView addSubview:_nameLabel];
  32. _lastLabel = [[UILabel alloc] init];
  33. [_titleView addSubview:_lastLabel];
  34. _diamondView = [[UIImageView alloc] init];
  35. [_titleView addSubview:_diamondView];
  36. _priceLabel = [[UILabel alloc] init];
  37. [_titleView addSubview:_priceLabel];
  38. _payButton = [UIButton buttonWithType:UIButtonTypeCustom];
  39. [_backView addSubview:_payButton];
  40. }
  41. return self;
  42. }
  43. - (void)createWithType:(NSInteger )type andResult:(NSString *)result andName:(NSString *) name andPrice:(NSString *)price
  44. {
  45. CGFloat scaleW = [[UIScreen mainScreen] bounds].size.width/375.0;
  46. //如果是竞拍成功状态
  47. if ([result isEqualToString:@"ac_auction_success"])
  48. {
  49. _resultImage.frame = CGRectMake(0, 0, 250*scaleW, 170*scaleW);
  50. _resultImage.image = [UIImage imageNamed:result];
  51. _backView.frame = CGRectMake(0, 170*scaleW, 250*scaleW, 70*scaleW);
  52. if (type==0)
  53. {
  54. _backView.backgroundColor = kGrayTransparentColor2;
  55. _nameLabel.frame= CGRectMake(0, 5*scaleW, 250*scaleW, 30*scaleW);
  56. _nameLabel.text = name;
  57. _nameLabel.textColor = [UIColor whiteColor];
  58. _nameLabel.font = [UIFont systemFontOfSize:18.0];
  59. _nameLabel.textAlignment = NSTextAlignmentCenter;
  60. NSString * priceStr = [NSString stringWithFormat:@"%@",price];
  61. CGSize priceSize = [priceStr boundingRectWithSize:CGSizeMake(MAXFLOAT, 25*scaleW) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
  62. CGFloat length = priceSize.width+60*scaleW+33*scaleW;
  63. _titleView.frame = CGRectMake((250*scaleW-length)/2, 40*scaleW, length, 25*scaleW);
  64. _lastLabel.frame = CGRectMake(0, 0, 60*scaleW, 25*scaleW);
  65. _lastLabel.text = ASLocalizedString(@"最终价");
  66. _lastLabel.textColor = [UIColor whiteColor];
  67. _lastLabel.font = [UIFont systemFontOfSize:15.0];
  68. _diamondView.image = [UIImage imageNamed:@"com_diamond_1"];
  69. _diamondView.frame = CGRectMake(CGRectGetMaxX(_lastLabel.frame),0, 33*scaleW, 25*scaleW);
  70. _priceLabel.frame = CGRectMake(CGRectGetMaxX(_diamondView.frame), 0, priceSize.width, 25*scaleW);
  71. _priceLabel.text =priceStr;
  72. _priceLabel.textColor = [UIColor whiteColor];
  73. _priceLabel.font = [UIFont systemFontOfSize:15.0];
  74. }
  75. else if (type==1)
  76. {
  77. _payButton.frame = CGRectMake(75*scaleW, 5*scaleW, 100*scaleW, 30*scaleW);
  78. _payButton.backgroundColor = kAuctionBtnColor;
  79. _payButton.layer.cornerRadius = 12;
  80. [_payButton setTitle:ASLocalizedString(@"立即付款")forState:UIControlStateNormal];
  81. [_payButton addTarget:self action:@selector(clickBtnToPay) forControlEvents:UIControlEventTouchUpInside];
  82. }
  83. }
  84. else if ([result isEqualToString:@"ac_pay_success"])
  85. {
  86. _resultImage.frame = CGRectMake(0, 0, 250*scaleW, 170*scaleW);
  87. _resultImage.image = [UIImage imageNamed:result];
  88. _backView.frame = CGRectMake(0, 170*scaleW, 250*scaleW, 70*scaleW);
  89. if (type==0)
  90. {
  91. _backView.backgroundColor = kGrayTransparentColor2;
  92. _nameLabel.frame = CGRectMake(0, 5*scaleW, 250*scaleW, 30*scaleW);
  93. _nameLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@付款成功"),name];
  94. _nameLabel.textColor = [UIColor whiteColor];
  95. _nameLabel.font = [UIFont systemFontOfSize:18.0];
  96. _nameLabel.textAlignment = NSTextAlignmentCenter;
  97. NSString * priceStr = [NSString stringWithFormat:@"%@",price];
  98. CGSize priceSize = [priceStr boundingRectWithSize:CGSizeMake(MAXFLOAT, 25*scaleW) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
  99. CGFloat length = priceSize.width+60*scaleW+33*scaleW;
  100. _titleView.frame = CGRectMake((250*scaleW-length)/2, 40*scaleW, length, 25*scaleW);
  101. _lastLabel.frame= CGRectMake(0, 0, 60*scaleW, 25*scaleW);
  102. _lastLabel.text = ASLocalizedString(@"最终价");
  103. _lastLabel.textColor = [UIColor whiteColor];
  104. _lastLabel.font = [UIFont systemFontOfSize:15.0];
  105. _diamondView.image =[UIImage imageNamed:@"com_diamond_1"];
  106. _diamondView.frame = CGRectMake(CGRectGetMaxX(_lastLabel.frame),0, 33*scaleW, 25*scaleW);
  107. _priceLabel.frame = CGRectMake(CGRectGetMaxX(_diamondView.frame), 0, priceSize.width, 25*scaleW);
  108. _priceLabel.text =priceStr;
  109. _priceLabel.textColor = [UIColor whiteColor];
  110. _priceLabel.font = [UIFont systemFontOfSize:15.0];
  111. }
  112. else if (type==1)
  113. {
  114. _lastLabel.frame = CGRectMake(0, 5*scaleW, 250*scaleW, 30*scaleW);
  115. _lastLabel.text = ASLocalizedString(@"恭喜你付款成功");
  116. _lastLabel.backgroundColor = kGrayTransparentColor2;
  117. _lastLabel.textColor = [UIColor whiteColor];
  118. _lastLabel.font = [UIFont systemFontOfSize:18.0];
  119. _lastLabel.textAlignment = NSTextAlignmentCenter;
  120. }
  121. }
  122. else if ([result isEqualToString:@"ac_auction_fail"])
  123. {
  124. _resultImage.frame = CGRectMake(0, 0, 250*scaleW, 165*scaleW);
  125. _resultImage.image = [UIImage imageNamed:result];
  126. _backView.frame = CGRectMake(0, 165*scaleW, 250*scaleW, 40*scaleW);
  127. _backView.backgroundColor = kGrayTransparentColor2;
  128. _lastLabel.frame= CGRectMake(0, 5*scaleW, 250*scaleW, 30*scaleW);
  129. if (type==0) {
  130. _lastLabel.text = ASLocalizedString(@"无人参拍");
  131. }
  132. else if (type==1)
  133. {
  134. _lastLabel.text = ASLocalizedString(@"中拍者超时未付款");
  135. }
  136. else if (type==2)
  137. {
  138. _lastLabel.text = ASLocalizedString(@"您参与的竞拍超时未付款");
  139. }
  140. _lastLabel.textColor = [UIColor whiteColor];
  141. _lastLabel.font = [UIFont systemFontOfSize:18.0];
  142. _lastLabel.textAlignment = NSTextAlignmentCenter;
  143. }
  144. }
  145. //点击付款按钮
  146. - (void)clickBtnToPay
  147. {
  148. if (_delegate && [_delegate respondsToSelector:@selector(toPay)])
  149. {
  150. [_delegate toPay];
  151. }
  152. }
  153. @end