123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // LDShopInfoView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/13.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDShopInfoView.h"
- @interface LDShopInfoView ()
- {
-
- }
- @property (nonatomic, strong) UIImageView *icon;
- @property (nonatomic, strong) UILabel *shopName;
- @end
- @implementation LDShopInfoView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
-
- self.backgroundColor = [UIColor whiteColor];
- [self initSubViews];
- self.layer.masksToBounds = YES;
- }
- return self;
- }
- - (void)initSubViews {
- self.icon = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(15), Fitsize(10), Fitsize(47), Fitsize(47))];
- self.icon.backgroundColor = [UIColor yhGrayColor];
- [self addSubview:self.icon];
-
- self.shopName = [[UILabel alloc] initWithFrame:CGRectMake(self.icon.right+10, Fitsize(13), Fitsize(230), Fitsize(20))];
- self.shopName.font = [UIFont systemFontOfSize:Fitsize(16)];
- self.shopName.textColor = [UIColor YHColorWithHex:0x333333];
- [self addSubview:self.shopName];
-
- CGFloat width = (self.width-self.icon.right-80)/3;
- CGFloat margin = self.icon.right+10;
- CGFloat space = 20;
-
- UIButton *shopabtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-70, FITSIZE(13), 60, FITSIZE(20))];
- [shopabtn setTitle:@"进入店铺" forState:UIControlStateNormal];
- [shopabtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
- shopabtn.titleLabel.font=[UIFont systemFontOfSize:11];
- [shopabtn setImage:[UIImage imageNamed:@"shop_info"] forState:UIControlStateNormal];
- [shopabtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
- // [self addSubview:shopabtn];
- shopabtn.userInteractionEnabled=NO;
-
- for (int i = 0; i < 3; i++) {
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(margin+(width+space)*i, self.icon.bottom-Fitsize(14), width, Fitsize(14))];
- label.textColor = [UIColor YHColorWithHex:0x919090];
- label.font = [UIFont systemFontOfSize:Fitsize(12)];
- label.tag = 1000+i;
- [label sizeToFit];
-
- UILabel *level = [[UILabel alloc] initWithFrame:CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14))];
- level.centerY = label.centerY;
- level.backgroundColor = [UIColor YHColorWithHex:0xEEEEEE];
- level.font = [UIFont systemFontOfSize:FITSIZE(12)];
- level.textAlignment = NSTextAlignmentCenter;
- level.textColor = [UIColor YHColorWithHex:0x9B9B9B];
- level.tag = 2000+i;
-
-
- [self addSubview:label];
- [self addSubview:level];
- }
-
- }
- - (void)setShopInfo:(LDShopModel *)model {
- [self.icon sd_setImageWithURL:[NSURL URLWithString:model.pic_path] placeholderImage:Placehold_Img];
- self.shopName.text = model.title;
- NSArray *titles = @[[NSString stringWithFormat:@"商品描述:%.1f",model.item_score.floatValue],
- [NSString stringWithFormat:@"服务态度:%.1f",model.service_score.floatValue],
- [NSString stringWithFormat:@"发货速度:%.1f",model.delivery_score.floatValue],
- ];
-
- NSString *item_lev = model.item_score_pre?model.item_score_pre:@"";
- NSString *service_lev = model.service_score_pre?model.service_score_pre:@"";
- NSString *delivery_lev = model.delivery_score_pre?model.delivery_score_pre:@"";
- NSArray *levelArr = @[item_lev,service_lev,delivery_lev];
- for (int i = 0; i<3; i++ ) {
- UILabel *label = [self viewWithTag:1000+i];
- label.text = titles[i];
- [label sizeToFit];
-
- UILabel *level = [self viewWithTag:2000+i];
- level.frame = CGRectMake(label.right+2, label.top, FITSIZE(16), FITSIZE(14));
- NSString *itemLev = levelArr[i];
- if ([itemLev isEqualToString:@"1"]) {
- level.text = @"低";
- }else if ([itemLev isEqualToString:@"2"]){
- level.text = @"平";
- }else if ([itemLev isEqualToString:@"3"]){
- level.text = @"高";
- }
- level.hidden = (itemLev.length==0);
- }
-
- }
- @end
|