猎豆优选

LDShopInfoView.m 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // LDShopInfoView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/13.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDShopInfoView.h"
  9. @interface LDShopInfoView ()
  10. {
  11. }
  12. @property (nonatomic, strong) UIImageView *icon;
  13. @property (nonatomic, strong) UILabel *shopName;
  14. @end
  15. @implementation LDShopInfoView
  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. UIButton *shopabtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-70, FITSIZE(13), 60, FITSIZE(20))];
  37. [shopabtn setTitle:@"进入店铺" forState:UIControlStateNormal];
  38. [shopabtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  39. shopabtn.titleLabel.font=[UIFont systemFontOfSize:11];
  40. [shopabtn setImage:[UIImage imageNamed:@"shop_info"] forState:UIControlStateNormal];
  41. [shopabtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
  42. // [self addSubview:shopabtn];
  43. shopabtn.userInteractionEnabled=NO;
  44. for (int i = 0; i < 3; i++) {
  45. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(margin+(width+space)*i, self.icon.bottom-Fitsize(14), width, Fitsize(14))];
  46. label.textColor = [UIColor YHColorWithHex:0x919090];
  47. label.font = [UIFont systemFontOfSize:Fitsize(12)];
  48. label.tag = 1000+i;
  49. [label sizeToFit];
  50. UILabel *level = [[UILabel alloc] initWithFrame:CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14))];
  51. level.centerY = label.centerY;
  52. level.backgroundColor = [UIColor YHColorWithHex:0xEEEEEE];
  53. level.font = [UIFont systemFontOfSize:FITSIZE(12)];
  54. level.textAlignment = NSTextAlignmentCenter;
  55. level.textColor = [UIColor YHColorWithHex:0x9B9B9B];
  56. level.tag = 2000+i;
  57. [self addSubview:label];
  58. [self addSubview:level];
  59. }
  60. }
  61. - (void)setShopInfo:(LDShopModel *)model {
  62. [self.icon sd_setImageWithURL:[NSURL URLWithString:model.pic_path] placeholderImage:Placehold_Img];
  63. self.shopName.text = model.title;
  64. NSArray *titles = @[[NSString stringWithFormat:@"商品描述:%.1f",model.item_score.floatValue],
  65. [NSString stringWithFormat:@"服务态度:%.1f",model.service_score.floatValue],
  66. [NSString stringWithFormat:@"发货速度:%.1f",model.delivery_score.floatValue],
  67. ];
  68. NSString *item_lev = model.item_score_pre?model.item_score_pre:@"";
  69. NSString *service_lev = model.service_score_pre?model.service_score_pre:@"";
  70. NSString *delivery_lev = model.delivery_score_pre?model.delivery_score_pre:@"";
  71. NSArray *levelArr = @[item_lev,service_lev,delivery_lev];
  72. for (int i = 0; i<3; i++ ) {
  73. UILabel *label = [self viewWithTag:1000+i];
  74. label.text = titles[i];
  75. [label sizeToFit];
  76. UILabel *level = [self viewWithTag:2000+i];
  77. level.frame = CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14));
  78. NSString *itemLev = levelArr[i];
  79. if ([itemLev isEqualToString:@"1"]) {
  80. level.text = @"低";
  81. }else if ([itemLev isEqualToString:@"2"]){
  82. level.text = @"平";
  83. }else if ([itemLev isEqualToString:@"3"]){
  84. level.text = @"高";
  85. }
  86. level.hidden = (itemLev.length==0);
  87. }
  88. }
  89. @end