You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

134 lines
4.7 KiB

//
// EditDeviceHeadTableViewCell.m
// tongxin
//
// Created by WeiChaoZheng on 2018/6/21.
// Copyright © 2018年 xTT. All rights reserved.
//
#import "EditDeviceHeadTableViewCell.h"
#import "QRcodeViewController.h"
@implementation EditDeviceHeadTableViewCell
-(UIImageView *)deviceHeadImageView{
if(!_deviceHeadImageView){
_deviceHeadImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
}
return _deviceHeadImageView;
}
- (void)awakeFromNib {
[super awakeFromNib];
_ATitleLabel.font = DefineFontSize;
self.selectionStyle = 0;
}
-(void)setDevice:(Device*)device WithStatus:(BOOL)isAdd isEdting:(BOOL)isEdit{
self.device = device;
NSString *headImageUrl = device.avator;
self.deviceHeadImageView.layer.cornerRadius = self.deviceHeadImageView.frame.size.height/2;
self.deviceHeadImageView.layer.masksToBounds = YES;
if (device.image){
self.deviceHeadImageView.image = device.image;
}else{
if(headImageUrl && ![headImageUrl containsString:@"default.jpg"]){
[self.deviceHeadImageView sd_setImageWithURL:[NSURL URLWithString:headImageUrl]];
}else{
//判断性别
NSString *sexImageName = [device.sex isEqualToString:@"girl"] ? @"icon_girl_head_portrait" : @"icon_boy_head_portrait";
self.deviceHeadImageView.image = [UIImage imageNamed:sexImageName];
}
}
self.accessoryView = self.deviceHeadImageView;
// if(isAdd || isEdit){
// [self.batteryLabel setHidden:YES];
// [self.batteryLeveImage setHidden:YES];
// [self.QRCodeBtn setHidden:YES];
// }else{
// [self.batteryLabel setHidden:NO];
// [self.batteryLeveImage setHidden:NO];
// [self.QRCodeBtn setHidden:NO];
// self.batteryLabel.text = [NSString stringWithFormat:@"%d%%",[device.battery intValue]];
// NSString *imageName = @"";
// if([device.max_level intValue] == 0){ //旧设备
// if([device.battery intValue] == 0){
// imageName = @"电空";
// }else if ([device.battery intValue] < 25) {
// imageName = @"电量1";
// }else if ([device.battery intValue] < 50) {
// imageName = @"电量2";
// }else if ([device.battery intValue] < 75) {
// imageName = @"电量3";
// }else{
// imageName = @"电量4";
// }
// }else{ //新的设备 有3格 有4格
// if([device.max_level intValue] == 3){
// int currLevel = [device.curr_level intValue];
// switch (currLevel) {
// case 0:
// imageName = @"电空";
// break;
// case 1:
// imageName = @"电池1";
// break;
// case 2:
// imageName = @"电池2";
// break;
// case 3:
// imageName = @"电池3";
// break;
// default:
// imageName = @"电池故障";
// break;
// }
//
// self.batteryLeveImage.image = [myHelper getImageWithName:imageName];
// }else if([device.max_level intValue] == 4){
// int currLevel = [device.curr_level intValue];
//
// switch (currLevel) {
// case 0:
// imageName = @"电空";
// break;
// case 1:
// imageName = @"电量1";
// break;
// case 2:
// imageName = @"电量2";
// break;
// case 3:
// imageName = @"电量3";
// break;
// case 4:
// imageName = @"电量4";
// break;
// default:
// imageName = @"电池故障";
// break;
// }
//
// }
// }
// self.batteryLeveImage.image = [myHelper getImageWithName:imageName];
// }
}
- (IBAction)QRcodeAction:(UIButton *)sender {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
QRcodeViewController *vc = [sb instantiateViewControllerWithIdentifier:@"QRcodeViewController"];
[[self getViewController].navigationController pushViewController:vc animated:YES];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end