//
// MyDocViewController_zhen.m
// Patient
//
// Created by wangjian on 15/12/4.
// Copyright © 2015年 ShangYu. All rights reserved.
//
#import "MyDocViewController_zhen.h"
#import "MyDocViewController_zhen.h"
#import "Doccell.h"
#import "DocDetailViewController.h"
#import "NearbyViewController.h"
#import "SweepViewController.h"
#import "SearchDocviewcontroller.h"
#import "Dlpontlerexple.h"
#import "ChatViewCell.h"
#import "LoginViewController.h"
//924
#import "ContactListViewController.h"
#import "ContactListViewCell.h"
#import "ContactDetailViewController.h"
#import "ChatViewController.h"
@interface MyDocViewController_zhen ()<UITableViewDelegate,UITableViewDataSource>
{
BOOL isbool;
UILabel *redDotLab;
NSUserDefaults *DocUserdeful;
NSMutableArray *doccuuidarr;
UIImageView *imagershuju;
UILabel *tiwuxianLab;
//gzz2016
BOOL isEmpty;
}
//右边加号view
@property(nonatomic,strong)UIView *Wholeview;
@property(nonatomic,strong)UITableView *tableView;
@property (nonatomic,weak)Doccell *docCell;
//专家信息
@property (nonatomic,strong) NSMutableArray *SpecialistMutarr;
//gzz2016
@property(nonatomic,strong) NSMutableArray *dataSpcialMutarr;
@end
//2016 gzz
static FMDatabase *_dataBaseDoc;
@implementation MyDocViewController_zhen
+ (MyDocViewController_zhen *)sharedManager
{
static MyDocViewController_zhen * sharedHomeViewController = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
sharedHomeViewController = [[self alloc] init];
[sharedHomeViewController AddNotifications];
});
return sharedHomeViewController;
}
- (void)AddNotifications
{
NSLog(@"");
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(notifer) name:@"EXPERTDOCTOR" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mylinkSuccess:) name:@"YIDIDENGLUGDXZ" object:nil];
}
- (void)notifer
{
NSLog(@"我的专家有新消息");
doccuuidarr =[[NSMutableArray alloc]initWithArray:[DocUserdeful objectForKey:@"FLLOWDOCEXPERT"]];
[self.tableView reloadData];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
isbool = NO;
_Wholeview.hidden = YES;
doccuuidarr =[[NSMutableArray alloc]initWithArray:[DocUserdeful objectForKey:@"FLLOWDOCEXPERT"]];
_SpecialistMutarr = [NSMutableArray array];
[self MyRequest];
}
- (void)mylinkSuccess:(NSNotification *)text
{
NSLog(@"mydocvicer--%@",text);
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
LoginViewController *loage = [[LoginViewController alloc]init];
[self.navigationController pushViewController:loage animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self DocNavbar];
[self Rightaddview];
[self Downrefresh];
self.view.backgroundColor = [UIColor whiteColor];
isbool = NO;
isEmpty=NO;
_dataSpcialMutarr=[NSMutableArray array];
imagershuju = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2, ImagerWuWidth, ImagerWuheight)];
imagershuju.image = [UIImage imageNamed:@"zanwushuju1"];
imagershuju.hidden = YES;
[self.view addSubview:imagershuju];
tiwuxianLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-TishiLabwidth/2, CGRectGetMaxY(imagershuju.frame), TishiLabwidth, 30)];
tiwuxianLab.text = @"暂无数据";
tiwuxianLab.textAlignment = YES;
tiwuxianLab.textColor = RGB(188, 188, 188);
tiwuxianLab.hidden = YES;
tiwuxianLab.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLab];
//除去下面的多余的横线
DocUserdeful = [NSUserDefaults standardUserDefaults];
//gzz2016
//1.创建数据库 指定数据库的路径
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"DocData11.sqlite"];
_dataBaseDoc = [FMDatabase databaseWithPath:path];
NSLog(@"==path=dddddd=%@",path);
BOOL success = [_dataBaseDoc open];
if (success) {
NSLog(@"创建数据库成功!");
//2.创建表 字段 ()
// sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo
//1-5 id 主键 sex = 0;(性别) state = 6;(状态) type = 1(类型); uuid = 7L08qJnuVO3AJnFXHEy(uuid);
//6-10 positionUuid = "位置uuid"; provId = 1;(省) qrcode = "二维码"; realName = "真实姓名" ;realatoinType = 1(关系);
//11-15 nation = 0(民族); officeName = "办公室名字"; officePhone = "办公室电话"; officeUuid = "办公司uuid"; photo = "expert/2015-12-31/c229790e93d1404aae65b21e43854e2c.jpg"; (头像图像)
//16-20 hospitalUuid = "医院uuid"; intro = "介绍";isStar = 0;(是否有星星) mobile = 18039678870(手机号); monthIsEnable = 0;(是否包月服务)
//21-25 cityId = 2;市 clinicIsEnable = 1; 是否包月服务 countyId = 0; (区) email = "<null>"; (邮箱)hospitalName = "<null>"(医院名字);
//26-30 birthDate = "<null>";(生日 ) callIsEnable = 1(是否开通电话服务);certificate = "<null>"(证书);
// certificateImg = "<null>"(证书图片);
// checkInfo = "<null>"(检查信息) ;
// // 删除语句 删除表中所有数据
// NSString * delete=@"delete from t_DocDetail";
// BOOL dflag= [_dataBaseDoc executeUpdate:delete];
// if(dflag){
// NSLog(@"删除成功");
// }
//[_dataBaseDoc executeUpdate:@"DROP TABLE IF EXISTS t_DocDetail;"];//删除表
2.创建表
NSString *str = @"CREATE TABLE IF NOT EXISTS t_DocDetail(id integer PRIMARY KEY AUTOINCREMENT , sex text NOT NULL,state text NOT NULL, type text NOT NULL,uuid text NOT NULL,positionUuid text NOT NULL,provId text NOT NULL, qrcode text NOT NULL,realName text NOT NULL,realatoinType text NOT NULL,nation text NOT NULL,officeName text NOT NULL, officePhone text NOT NULL,officeUuid text NOT NULL,photo text NOT NULL,hospitalUuid text NOT NULL,intro text NOT NULL, isStar text NOT NULL,mobile text NOT NULL,monthIsEnable text NOT NULL,cityId text NOT NULL,clinicIsEnable text NOT NULL, countyId text NOT NULL,email text NOT NULL,hospitalName text NOT NULL,birthDate text NOT NULL,callIsEnable text NOT NULL, certificate text NOT NULL,certificateImg text NOT NULL,checkInfo text NOT NULL,_id text NOT NULL);";
if ([_dataBaseDoc executeUpdate:str]) {
NSLog(@"表创建成功!");
}else{
NSLog(@"创建表失败!");
}
}else{
NSLog(@"创建数据库失败!");
}
[self selectDoc];
}
//保存到数据库数据
-(void)saveDataDoc{
// 删除语句
NSString * delete=@"delete from t_DocDetail";
BOOL dflag= [_dataBaseDoc executeUpdate:delete];
if(dflag){
NSLog(@"删除成功");
}
for (int i=0; i<_SpecialistMutarr.count; i++) {
// sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo
NSString *callIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"callIsEnable"]];
NSString *certificate=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"certificate"]];
NSString *certificateImg=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"certificateImg"]];
NSString *checkInfo=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"checkInfo"]];
NSString *cityId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"cityId"]];
NSString *clinicIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"clinicIsEnable"]];
NSString *countyId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"countyId"]];
NSString *email=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"email"]];
NSLog(@"email ===%@",email);
NSString *hospitalName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"hospitalName"]];
NSString *hospitalUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"hospitalUuid"]];
NSString *intro=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"intro"]];
NSString *isStar=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"isStar"]];
NSString *mobile=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"mobile"]];
NSString *monthIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"monthIsEnable"]];
NSString *nation=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"nation"]];
NSString *officeName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officeName"]];
NSString *officePhone=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officePhone"]];
NSString *officeUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officeUuid"]];
NSString *photo=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"photo"]];
NSString *positionUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"positionUuid"]];
NSString *provId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"provId"]];
NSString *qrcode=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"qrcode"]];
NSString *realName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"realName"]];
NSString *realatoinType=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"realatoinType"]];
NSString *sex=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"sex"]];
NSString *birthDate=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"birthDate"]];
NSString *state=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"state"]];
NSString *type=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"type"]];
NSString *uuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"uuid"]];
NSString *IDD=[NSString stringWithFormat:@"%zd",(i+1)];
//
BOOL success = [_dataBaseDoc executeUpdate:@"INSERT INTO t_DocDetail(sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo,_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo,IDD];
if (success) {
// NSLog(@"添加成功!");
}else{
NSLog(@"添加失败!");
}
}
[self selectDoc];
}
-(void)selectDoc{
if (isEmpty) {
[_dataSpcialMutarr removeAllObjects];
NSInteger count=_SpecialistMutarr.count;
for (int i=1; i<count+1; i++) {
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail where _id='%zd';",i];
//查询语句 执行的方法
FMResultSet *set = [_dataBaseDoc executeQuery:sql];
while ([set next]) {
NSString *sex=[set stringForColumn:@"sex"];
NSString *state=[set stringForColumn:@"state"];
NSString *type=[set stringForColumn:@"type"];
NSString *uuid=[set stringForColumn:@"uuid"];
NSString *positionUuid=[set stringForColumn:@"positionUuid"];
NSString *provId=[set stringForColumn:@"provId"];
NSString *qrcode=[set stringForColumn:@"qrcode"];
NSString *realName=[set stringForColumn:@"realName"];
NSString *realatoinType=[set stringForColumn:@"realatoinType"];
NSString *nation=[set stringForColumn:@"nation"];
NSString *officeName=[set stringForColumn:@"officeName"];
NSString *officePhone=[set stringForColumn:@"officePhone"];
NSString *officeUuid=[set stringForColumn:@"officeUuid"];
NSString *photo=[set stringForColumn:@"photo"];
NSString *hospitalUuid=[set stringForColumn:@"hospitalUuid"];
NSString *intro=[set stringForColumn:@"intro"];
NSString *isStar=[set stringForColumn:@"isStar"];
NSString *mobile=[set stringForColumn:@"mobile"];
NSString *monthIsEnable=[set stringForColumn:@"monthIsEnable"];
NSString *cityId=[set stringForColumn:@"cityId"];
NSString *clinicIsEnable=[set stringForColumn:@"clinicIsEnable"];
NSString *countyId=[set stringForColumn:@"countyId"];
NSString *email=[set stringForColumn:@"email"];
NSLog(@"emial --set-%@",email);
NSString *hospitalName=[set stringForColumn:@"hospitalName"];
NSString *birthDate=[set stringForColumn:@"birthDate"];
NSString *callIsEnable=[set stringForColumn:@"callIsEnable"];
NSString *certificate=[set stringForColumn:@"certificate"];
NSString *certificateImg=[set stringForColumn:@"certificateImg"];
NSString *checkInfo=[set stringForColumn:@"checkInfo"];
NSMutableDictionary *dic0 = [NSMutableDictionary dictionaryWithObjectsAndKeys:sex,@"sex",state,@"state",type,@"type",uuid,@"uuid",positionUuid,@"positionUuid",provId,@"provId",qrcode,@"qrcode",realName,@"realName",realatoinType,@"realatoinType",nation,@"nation",officeName,@"officeName",officePhone,@"officePhone",officeUuid,@"officeUuid",photo,@"photo",hospitalUuid,@"hospitalUuid",intro,@"intro",isStar,@"isStar",mobile,@"mobile",monthIsEnable,@"monthIsEnable",cityId,@"cityId",clinicIsEnable,@"clinicIsEnable",countyId,@"countyId",email,@"email",hospitalName,@"hospitalName",birthDate,@"birthDate",callIsEnable,@"callIsEnable",certificate,@"certificate",certificateImg,@"certificateImg",checkInfo,@"checkInfo",nil];
[_dataSpcialMutarr addObject:dic0];
NSLog(@"data ==%zd success",i);
}
}
}else{
// NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail where _id='%zd';",i];
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail "];
//查询语句 执行的方法
FMResultSet *set = [_dataBaseDoc executeQuery:sql];
while ([set next]) {
NSString *sex=[set stringForColumn:@"sex"];
NSString *state=[set stringForColumn:@"state"];
NSString *type=[set stringForColumn:@"type"];
NSString *uuid=[set stringForColumn:@"uuid"];
NSString *positionUuid=[set stringForColumn:@"positionUuid"];
NSString *provId=[set stringForColumn:@"provId"];
NSString *qrcode=[set stringForColumn:@"qrcode"];
NSString *realName=[set stringForColumn:@"realName"];
NSString *realatoinType=[set stringForColumn:@"realatoinType"];
NSString *nation=[set stringForColumn:@"nation"];
NSString *officeName=[set stringForColumn:@"officeName"];
NSString *officePhone=[set stringForColumn:@"officePhone"];
NSString *officeUuid=[set stringForColumn:@"officeUuid"];
NSString *photo=[set stringForColumn:@"photo"];
NSString *hospitalUuid=[set stringForColumn:@"hospitalUuid"];
NSString *intro=[set stringForColumn:@"intro"];
NSString *isStar=[set stringForColumn:@"isStar"];
NSString *mobile=[set stringForColumn:@"mobile"];
NSString *monthIsEnable=[set stringForColumn:@"monthIsEnable"];
NSString *cityId=[set stringForColumn:@"cityId"];
NSString *clinicIsEnable=[set stringForColumn:@"clinicIsEnable"];
NSString *countyId=[set stringForColumn:@"countyId"];
NSString *email=[set stringForColumn:@"email"];
NSLog(@"emial --set-%@",email);
NSString *hospitalName=[set stringForColumn:@"hospitalName"];
NSString *birthDate=[set stringForColumn:@"birthDate"];
NSString *callIsEnable=[set stringForColumn:@"callIsEnable"];
NSString *certificate=[set stringForColumn:@"certificate"];
NSString *certificateImg=[set stringForColumn:@"certificateImg"];
NSString *checkInfo=[set stringForColumn:@"checkInfo"];
NSMutableDictionary *dic0 = [NSMutableDictionary dictionaryWithObjectsAndKeys:sex,@"sex",state,@"state",type,@"type",uuid,@"uuid",positionUuid,@"positionUuid",provId,@"provId",qrcode,@"qrcode",realName,@"realName",realatoinType,@"realatoinType",nation,@"nation",officeName,@"officeName",officePhone,@"officePhone",officeUuid,@"officeUuid",photo,@"photo",hospitalUuid,@"hospitalUuid",intro,@"intro",isStar,@"isStar",mobile,@"mobile",monthIsEnable,@"monthIsEnable",cityId,@"cityId",clinicIsEnable,@"clinicIsEnable",countyId,@"countyId",email,@"email",hospitalName,@"hospitalName",birthDate,@"birthDate",callIsEnable,@"callIsEnable",certificate,@"certificate",certificateImg,@"certificateImg",checkInfo,@"checkInfo",nil];
[_dataSpcialMutarr addObject:dic0];
NSLog(@"first come in or failed in get request");
}
_SpecialistMutarr=_dataSpcialMutarr;
[self.tableView reloadData];
}
}
//navgationbar
-(void)DocNavbar{
self.title=@"我的专家";
//字体大小
// [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],
//
// NSForegroundColorAttributeName:[UIColor redColor]}];
// 自定义后退按钮
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
self.navigationItem.leftBarButtonItem=backItem;
// 右侧加号按钮
UIBarButtonItem *add= [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"addjiahao32"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(addClick)];
self.navigationItem.rightBarButtonItem=add;
//自定义后退按钮后,手势返回上一级控制器的功能恢复
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled =NO;
self.tableView.tableFooterView=[[UIView alloc]init];
// self.tableView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.tableView];
}
//下拉刷新
- (void)Downrefresh
{
__weak MyDocViewController_zhen *puad = self;
[puad.tableView addHeaderWithCallback:^{
[puad.SpecialistMutarr removeAllObjects];
_SpecialistMutarr = [NSMutableArray array];
[puad MyRequest];
[puad.tableView headerEndRefreshing];
}];
}
#pragma mark 请求
-(void)MyRequest
{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
Dlpontlerexple *dlop = [Dlpontlerexple shareIndence];
AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];
manger.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *str = [NSString stringWithFormat:@"%@expertList",Public_URL];
NSMutableDictionary *dice = [NSMutableDictionary dictionary];
dice[@"patientUuid"] =dlop.uuidstring;
[manger POST:str parameters:dice success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];
[_SpecialistMutarr removeAllObjects];
NSString *stracode =[NSString stringWithFormat:@"%@",dic[@"code"]];
if ([stracode isEqualToString:@"1"]) {
NSArray *Arrinter = dic[@"data"];
for (int i=0;i<Arrinter.count; i++) {
NSString *realatoinType = [NSString stringWithFormat:@"%@",[Arrinter[i] objectForKey:@"realatoinType"]];
if ([realatoinType isEqualToString:@"1"]) {
[_SpecialistMutarr addObject:Arrinter[i]];
}
}
if (_SpecialistMutarr.count>0) {
//gzz
isEmpty=YES;
[self saveDataDoc];
}else{
_SpecialistMutarr=_dataSpcialMutarr;
}
}else{
UIAlertView *alviec = [[UIAlertView alloc]initWithTitle:@"提示" message:dic[@"message"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alviec show];
}
// [_SpecialistMutarr addObjectsFromArray:dic[@"data"]];
if (_SpecialistMutarr.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
// imagershuju.hidden = NO;
// tiwuxianLab.hidden = NO;
}
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
// NSLog(@"----%@----dfsf s--00",dic);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.tableView reloadData];
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"数据请求失败,请重新尝试" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
// [alert show];
if (_SpecialistMutarr.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
// imagershuju.hidden = NO;
// tiwuxianLab.hidden = NO;
_SpecialistMutarr=_dataSpcialMutarr;
[self.tableView reloadData];
}
}];
}
//返回
- (void)backClick{
[self.navigationController popViewControllerAnimated:YES];
}
//右侧加号view
- (void)Rightaddview
{
_Wholeview=[[UIView alloc]init];
_Wholeview.hidden = YES;
_Wholeview.frame=CGRectMake(SCREEN_WIDTH-113,66,108,106);
[self.view addSubview:_Wholeview];
UIImageView *backerimage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _Wholeview.frame.size.width, _Wholeview.frame.size.height)];
backerimage.image = [UIImage imageNamed:@"xingzhuang1"];
[_Wholeview addSubview:backerimage];
NSArray *imagearr = [NSArray arrayWithObjects:@"sousuofangda",@"fujindeyisheng",@"saoyisaoww", nil];
NSArray *namearr = [NSArray arrayWithObjects:@"找医生",@"附近医生",@"扫一扫", nil];
for (int i=0; i<3; i++) {
UIImageView *imagertlift = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imagearr[i]]];
imagertlift.frame = CGRectMake(10, 34*i+15, 14,14);
[_Wholeview addSubview:imagertlift];
UILabel *labnemar = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imagertlift.frame)+5, 34*i+12, 80, 20)];
labnemar.text = namearr[i];
labnemar.font = SYSTEMFONT(15);
labnemar.textColor = [UIColor whiteColor];
[_Wholeview addSubview:labnemar];
UIButton *Seekbutton = [UIButton buttonWithType:0];
Seekbutton.frame = CGRectMake(5, 34*i+5, 108,35);
Seekbutton.tag = i;
[Seekbutton addTarget:self action:@selector(buttoseek:) forControlEvents:UIControlEventTouchUpInside];
[_Wholeview addSubview:Seekbutton];
if (i<2) {
UIImageView *imageci = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"baixian"]];
imageci.frame = CGRectMake(10,CGRectGetMaxY(Seekbutton.frame), _Wholeview.frame.size.width-20, 1) ;
[_Wholeview addSubview:imageci];
}
}
}
//右侧加号
-(void)addClick{
// NSLog(@"右上侧++add");
if (isbool==NO) {
_Wholeview.hidden = NO;
isbool=YES;
}
else{
_Wholeview.hidden = YES;
isbool = NO;
}
}
#pragma delegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (_SpecialistMutarr.count>0) {
NSLog(@"选中 cell");
_Wholeview.hidden = YES;
isbool = NO;
// // self.docCell.selectedBackgroundView.backgroundColor = [UIColor redColor];
// DocDetailViewController *docD=[[DocDetailViewController alloc]init];
// // docD.DoterSter = [_SpecialistMutarr[indexPath.row]objectForKey:@"type"];
// docD.strDocuuid = [[_SpecialistMutarr objectAtIndex:indexPath.row] objectForKey:@"uuid"];
// // docD.DoterSter = [[_SpecialistMutarr objectAtIndex:representative.tag] objectForKey:@"type"];
// [self.navigationController pushViewController:docD animated:YES];
NSLog(@"随访聊天修改扩展字段");
//send_type(发送方类型 1.患者 2.专家),receiver_type(接收方类型 1.患者 2.专家),chat_from(来源1.公益咨询 2.随访 3.vip),chat_from_uuid(如果是公益咨询,则存uuid,否则0)
NSString *UserData =@"1,2,2,0";
if (_SpecialistMutarr.count>0) {
NSDictionary *dicer = [self clearErrorData:[_SpecialistMutarr objectAtIndex:indexPath.row]];
NSUserDefaults * userdefaults =[NSUserDefaults standardUserDefaults];
[userdefaults setValue:UserData forKey:@"TypeFrom"];
[userdefaults synchronize];
// ChatViewController * cvc = [[ChatViewController alloc] initWithSessionId:_dict[phoneKey]]; // 容联的
NSString *strc = [dicer objectForKey:@"uuid"];
ChatViewController * cvc = [[ChatViewController alloc] initWithSessionId:strc];
[doccuuidarr removeObject:strc];
cvc.experDocuuid =strc;
cvc.DocNameChat = dicer[@"realName"];
cvc.hidesBottomBarWhenPushed=YES;
cvc.HearImage = [dicer objectForKey:@"photo"];
// [self.navigationController setViewControllers:[NSArray arrayWithObjects:[self.navigationController.viewControllers objectAtIndex:0],cvc, nil] animated:YES];
// ChatViewController *cvc=[[ChatViewController alloc]init];
// cvc.hidesBottomBarWhenPushed=YES;18039678870
[self.navigationController pushViewController:cvc animated:YES];
}
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 68;
}
#pragma datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _SpecialistMutarr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cstt = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cstt];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cstt];
}
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
if (_SpecialistMutarr.count>0) {
NSDictionary *dicel = [self clearErrorData:[_SpecialistMutarr objectAtIndex:indexPath.row]];
NSString *hearImagecell = [NSString stringWithFormat:@"%@%@",ImageUrl,dicel[@"photo"]];
UIImageView *lifimageherar = [[UIImageView alloc]initWithFrame:CGRectMake(14, 7, 54, 54)];
[lifimageherar sd_setImageWithURL:[NSURL URLWithString:hearImagecell] placeholderImage:[UIImage imageNamed:@"01300000556468126412516695160"]];
lifimageherar.layer.masksToBounds = YES;
lifimageherar.layer.cornerRadius = 27;
lifimageherar.layer.borderWidth = 2;
lifimageherar.layer.borderColor = RGB(175, 174, 174).CGColor;
[cell.contentView addSubview:lifimageherar];
UIButton *lightButt = [UIButton buttonWithType:UIButtonTypeCustom];
lightButt.frame = CGRectMake(0, 0, 68, 68);
[lightButt addTarget:self action:@selector(headIconTouch:) forControlEvents:UIControlEventTouchUpInside];
lightButt.tag = indexPath.row;
[cell.contentView addSubview:lightButt];
UILabel *laname = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lifimageherar.frame)+10, 26, 140, 20)];
laname.text=[NSString stringWithFormat:@"%@专家工作室",[dicel objectForKey:@"realName"]];
laname.font = SYSTEMFONT(14);
[cell.contentView addSubview:laname];
UIImageView *duiHa = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"椭圆-1"]];
duiHa.frame = CGRectMake(SCREEN_WIDTH-40, 25, 26, 17);
[cell.contentView addSubview:duiHa];
UIButton *DurightButt = [UIButton buttonWithType:UIButtonTypeCustom];
DurightButt.frame = CGRectMake(SCREEN_WIDTH-70, 0, 70, cell.frame.size.height);
[DurightButt addTarget:self action:@selector(chatTouch:) forControlEvents:UIControlEventTouchUpInside];
DurightButt.tag = indexPath.row;
// [cell.contentView addSubview:DurightButt];
redDotLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-20, 5, 15, 15)];
redDotLab.backgroundColor = [UIColor redColor];
redDotLab.layer.masksToBounds = YES;
redDotLab.layer.cornerRadius = 8;
NSMutableArray *nofitmutrr = [NSMutableArray array];
for (int i=0; i<doccuuidarr.count; i++) {
NSString *measeguuid = [NSString stringWithFormat:@"%@",[Dlpontlerexple shareIndence].uuidstring];
NSString *messageforms = [NSString stringWithFormat:@"%@",[[doccuuidarr objectAtIndex:i] objectForKey:@"messageuuid"]];
if ([messageforms isEqualToString:measeguuid]) {
[nofitmutrr addObject:[[doccuuidarr objectAtIndex:i] objectForKey:@"messagefroms"]];
}
}
// NSArray *doccuuid = [DocUserdeful objectForKey:@"FLLOWDOCEXPERT"];
NSString *struuid =[NSString stringWithFormat:@"8a48b5514fba2f87014fca72dec021e4#%@",[dicel objectForKey:@"uuid"]];
if ([nofitmutrr containsObject:struuid]) {
[cell.contentView addSubview:redDotLab];
}
}
// self.docCell=cell;
return cell;
}
//头像点击
-(void)headIconTouch:(UIButton *)representative{
// NSLog(@"我的专家中的_专家头像点击");
DocDetailViewController *docD=[[DocDetailViewController alloc]init];
// docD.DoterSter = [_SpecialistMutarr[representative.tag]objectForKey:@"type"];
docD.strDocuuid = [[_SpecialistMutarr objectAtIndex:representative.tag] objectForKey:@"uuid"];
// docD.DoterSter = [[_SpecialistMutarr objectAtIndex:representative.tag] objectForKey:@"type"];
[self.navigationController pushViewController:docD animated:YES];
}
//chat点击
-(void)chatTouch:(UIButton *)sender{
NSLog(@"随访聊天修改扩展字段");
//send_type(发送方类型 1.患者 2.专家),receiver_type(接收方类型 1.患者 2.专家),chat_from(来源1.公益咨询 2.随访 3.vip),chat_from_uuid(如果是公益咨询,则存uuid,否则0)
NSString *UserData =@"1,2,2,0";
if (_SpecialistMutarr.count>0) {
NSDictionary *dicer = [self clearErrorData:[_SpecialistMutarr objectAtIndex:sender.tag]];
NSUserDefaults * userdefaults =[NSUserDefaults standardUserDefaults];
[userdefaults setValue:UserData forKey:@"TypeFrom"];
[userdefaults synchronize];
// ChatViewController * cvc = [[ChatViewController alloc] initWithSessionId:_dict[phoneKey]]; // 容联的
NSString *strc = [dicer objectForKey:@"uuid"];
ChatViewController * cvc = [[ChatViewController alloc] initWithSessionId:strc];
[doccuuidarr removeObject:strc];
cvc.experDocuuid =strc;
cvc.DocNameChat = dicer[@"realName"];
cvc.hidesBottomBarWhenPushed=YES;
cvc.HearImage = [dicer objectForKey:@"photo"];
// [self.navigationController setViewControllers:[NSArray arrayWithObjects:[self.navigationController.viewControllers objectAtIndex:0],cvc, nil] animated:YES];
// ChatViewController *cvc=[[ChatViewController alloc]init];
// cvc.hidesBottomBarWhenPushed=YES;18039678870
[self.navigationController pushViewController:cvc animated:YES];
}
}
- (void)buttoseek:(UIButton *)sender
{
self.Wholeview.hidden = YES;
switch (sender.tag) {
case 0:
{
SearchDocviewcontroller *searchDoc=[[SearchDocviewcontroller alloc]init];
[self.navigationController pushViewController:searchDoc animated:YES];
}
break;
case 1:
{
NearbyViewController *aearview = [[NearbyViewController alloc]init];
[self.navigationController pushViewController:aearview animated:YES];
}
break;
case 2:
{
SweepViewController *sweed = [[SweepViewController alloc]init];
[self.navigationController pushViewController:sweed animated:YES];
}
default:
break;
}
}
-(NSDictionary *)clearErrorData:(NSMutableDictionary *)dictionary{
NSMutableDictionary *newDict = [[NSMutableDictionary alloc] initWithDictionary:dictionary]
;
NSArray * allkeys = [newDict allKeys];
for (int i = 0; i < [allkeys count]; i ++) {
// 获取下标对应的key
NSString * key = [allkeys objectAtIndex:i];
// 根据key获取value
NSString * value = [newDict objectForKey:key];
if (value == [NSNull null]) {
newDict[key] = @"";
}
}
return newDict;
}
@end