《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRShopInfoView.m 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // DRShopInfoView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/13.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRShopInfoView.h"
  9. @interface DRShopInfoView ()
  10. {
  11. }
  12. @property (nonatomic, strong) UIImageView *icon;
  13. @property (nonatomic, strong) UILabel *shopName;
  14. @end
  15. @implementation DRShopInfoView
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = [UIColor whiteColor];
  20. [self initSubViews];
  21. self.layer.masksToBounds = YES;
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. self.icon = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(15), Fitsize(10), Fitsize(47), Fitsize(47))];
  27. self.icon.backgroundColor = [UIColor yhGrayColor];
  28. [self addSubview:self.icon];
  29. self.shopName = [[UILabel alloc] initWithFrame:CGRectMake(self.icon.right+10, Fitsize(13), Fitsize(230), Fitsize(20))];
  30. self.shopName.font = [UIFont systemFontOfSize:Fitsize(16)];
  31. self.shopName.textColor = [UIColor YHColorWithHex:0x333333];
  32. [self addSubview:self.shopName];
  33. CGFloat width = (self.width-self.icon.right-80)/3;
  34. CGFloat margin = self.icon.right+10;
  35. CGFloat space = 20;
  36. for (int i = 0; i < 3; i++) {
  37. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(margin+(width+space)*i, self.icon.bottom-Fitsize(14), width, Fitsize(14))];
  38. label.textColor = [UIColor YHColorWithHex:0x919090];
  39. label.font = [UIFont systemFontOfSize:Fitsize(12)];
  40. label.tag = 1000+i;
  41. [label sizeToFit];
  42. UILabel *level = [[UILabel alloc] initWithFrame:CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14))];
  43. level.centerY = label.centerY;
  44. level.backgroundColor = [UIColor YHColorWithHex:0xEEEEEE];
  45. level.font = [UIFont systemFontOfSize:FITSIZE(12)];
  46. level.textAlignment = NSTextAlignmentCenter;
  47. level.textColor = [UIColor YHColorWithHex:0x9B9B9B];
  48. level.tag = 2000+i;
  49. [self addSubview:label];
  50. [self addSubview:level];
  51. }
  52. }
  53. - (void)setShopInfo:(DRShopModel *)model {
  54. [self.icon sd_setImageWithURL:[NSURL URLWithString:model.pic_path] placeholderImage:Placehold_Img];
  55. self.shopName.text = model.title;
  56. NSArray *titles = @[[NSString stringWithFormat:@"商品描述:%.1f",model.item_score.floatValue],
  57. [NSString stringWithFormat:@"服务态度:%.1f",model.service_score.floatValue],
  58. [NSString stringWithFormat:@"发货速度:%.1f",model.delivery_score.floatValue],
  59. ];
  60. NSString *item_lev = model.item_score_pre?model.item_score_pre:@"";
  61. NSString *service_lev = model.service_score_pre?model.service_score_pre:@"";
  62. NSString *delivery_lev = model.delivery_score_pre?model.delivery_score_pre:@"";
  63. NSArray *levelArr = @[item_lev,service_lev,delivery_lev];
  64. for (int i = 0; i<3; i++ ) {
  65. UILabel *label = [self viewWithTag:1000+i];
  66. label.text = titles[i];
  67. [label sizeToFit];
  68. UILabel *level = [self viewWithTag:2000+i];
  69. level.frame = CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14));
  70. NSString *itemLev = levelArr[i];
  71. if ([itemLev isEqualToString:@"1"]) {
  72. level.text = @"低";
  73. }else if ([itemLev isEqualToString:@"2"]){
  74. level.text = @"平";
  75. }else if ([itemLev isEqualToString:@"3"]){
  76. level.text = @"高";
  77. }
  78. level.hidden = (itemLev.length==0);
  79. }
  80. }
  81. @end