Initial commit
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// MemberDetailViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/4/11.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WhiteNavBaseViewController.h"
|
||||
#import "MemberNanageListData.h"
|
||||
@interface MemberDetailViewController : WhiteNavBaseViewController
|
||||
@property (nonatomic,strong) MemberNanageListData *userData;
|
||||
@property (nonatomic,strong) NSString *shopId;
|
||||
|
||||
@end
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
//
|
||||
// MemberDetailViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/4/11.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MemberDetailViewController.h"
|
||||
#import "ShopMemberDetailViewInfoCell.h"
|
||||
#import "EditeMemberTitleViewCell.h"
|
||||
#import "MemeberEditeViewCustomCell.h"
|
||||
#import "MemberEditeViewLocationCell.h"
|
||||
#import "MemberDetailMarkViewCell.h"
|
||||
#import "MemberDetailMarkDetailViewCell.h"
|
||||
#import "MemberEditeCommitBtnViewCell.h"
|
||||
#import "ShopUserDatailData.h"
|
||||
#import "UIControl+YT.h"
|
||||
#import "MBProgressHUD.h"
|
||||
#define CELLTAGATINDEX 9990111
|
||||
#import "ChinaPlckerView.h"
|
||||
#import "KebordExternAddTextInputView.h"
|
||||
#import "IfishSessionViewController.h"
|
||||
@interface MemberDetailViewController ()<UITableViewDelegate,UITableViewDataSource,MBProgressHUDDelegate,ChinaPlckerViewDelegate,UIActionSheetDelegate>
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
@property (nonatomic,strong) ShopUserDatailData *userInfo;
|
||||
@property(nonatomic,strong) MBProgressHUD *progressHud;
|
||||
@property(nonatomic,strong) UIActionSheet *levelSheet;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MemberDetailViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[self addTitleViewWithTitle:@"会员详情"];
|
||||
self.userInfo =[[ShopUserDatailData alloc] init];
|
||||
|
||||
|
||||
[self creatTab];
|
||||
[self loadShopUserInfos];
|
||||
|
||||
}
|
||||
|
||||
-(void)creatTab{
|
||||
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
self.tableView.showsVerticalScrollIndicator = NO;
|
||||
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
|
||||
[self.view addSubview:self.tableView];
|
||||
self.automaticallyAdjustsScrollViewInsets = YES;
|
||||
|
||||
}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
|
||||
if (section ==0) {
|
||||
return 1;
|
||||
}else if (section ==1){
|
||||
return 6;
|
||||
|
||||
}
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.section ==0) {
|
||||
ShopMemberDetailViewInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopMemberDetailViewInfoCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopMemberDetailViewInfoCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
[cell loadataWith:self.userData andUserInfo:self.userInfo];
|
||||
[cell.chatBtn addTarget:self action:@selector(chatBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section ==1&&indexPath.row ==0){
|
||||
|
||||
EditeMemberTitleViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EditeMemberTitleViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"EditeMemberTitleViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}else if (indexPath.section ==1&&indexPath.row >0&&indexPath.row<5){
|
||||
MemeberEditeViewCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemeberEditeViewCustomCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemeberEditeViewCustomCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
NSArray *titles = @[@"会员等级",@"备注名称",@"手机号码",@"所在地址"];
|
||||
[cell initTitles:titles AtRowIndex:indexPath.row userDatailData:self.userInfo];
|
||||
cell.tag =CELLTAGATINDEX + indexPath.row;
|
||||
if (indexPath.row==1||indexPath.row==4) {
|
||||
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section ==1&&indexPath.row ==5){
|
||||
MemberEditeViewLocationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemberEditeViewLocationCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemberEditeViewLocationCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
cell.tag =CELLTAGATINDEX + 20;
|
||||
|
||||
if ([self.userInfo.address isKindOfClass:[NSNull class]]||!self.userInfo.address) {
|
||||
self.userInfo.address = @"用户详情地址";
|
||||
}
|
||||
cell.locationDetail.text = self.userInfo.address;
|
||||
cell.locationDetail.userInteractionEnabled = NO;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section ==2&&indexPath.row ==0){
|
||||
MemberDetailMarkViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemberDetailMarkViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemberDetailMarkViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section ==2&&indexPath.row ==1){
|
||||
MemberDetailMarkDetailViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemberDetailMarkDetailViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemberDetailMarkDetailViewCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
cell.tag =CELLTAGATINDEX + 40;
|
||||
if ([self.userInfo.remark isKindOfClass:[NSNull class]]||!self.userInfo.remark) {
|
||||
self.userInfo.remark = @"可在此备注品牌/型号/日期/鱼种类/数量/价格等信息";
|
||||
}
|
||||
cell.markTexView.text = self.userInfo.remark;
|
||||
cell.markTexView.userInteractionEnabled = NO;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section ==2&&indexPath.row ==2){
|
||||
MemberEditeCommitBtnViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemberEditeCommitBtnViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemberEditeCommitBtnViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
[cell.sureBtn addTarget:self action:@selector(upDateUserInfo) forControlEvents:UIControlEventTouchUpInside];
|
||||
cell.sureBtn.yt_acceptEventInterval = 2;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.section==0) {
|
||||
return 90.0f;
|
||||
}else if (indexPath.section ==1&&indexPath.row >=0&&indexPath.row<5){
|
||||
|
||||
return 44.0f;
|
||||
}else if (indexPath.section ==1&&indexPath.row ==5){
|
||||
return 88.0f;
|
||||
|
||||
}else if (indexPath.section ==2&&indexPath.row ==0){
|
||||
return 35.0f;
|
||||
|
||||
}else if (indexPath.section ==2&&indexPath.row ==1){
|
||||
return 76.0f;
|
||||
|
||||
}
|
||||
return 90.0f;
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||||
|
||||
return 0.1f;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
if (section==1) {
|
||||
return 10.0f;
|
||||
}
|
||||
return 5.0f;
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
if (indexPath.row==1&&indexPath.section==1) {
|
||||
//等级
|
||||
[self creatLevelSheet];
|
||||
}else if (indexPath.row==2&&indexPath.section==1){
|
||||
//备注名
|
||||
NSString *name = _userInfo.userName;
|
||||
|
||||
[self creatExternKeyBordWith:name AtIndex:indexPath];
|
||||
}else if (indexPath.row==3&&indexPath.section==1){
|
||||
//手机号
|
||||
NSString *phone = _userInfo.phoneNumber;
|
||||
[self creatExternKeyBordWith:phone AtIndex:indexPath];
|
||||
}else if (indexPath.row==4&&indexPath.section==1){
|
||||
//省市区
|
||||
[self showChinaPic];
|
||||
}else if (indexPath.row==5&&indexPath.section==1){
|
||||
//详细地址
|
||||
[self creatExternKeyBordWith:self.userInfo.address AtIndex:indexPath];
|
||||
}else if (indexPath.row==1&&indexPath.section==2){
|
||||
//详细备注
|
||||
[self creatExternKeyBordWith:self.userInfo.remark AtIndex:indexPath];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)creatExternKeyBordWith:(NSString*)holdText AtIndex:(NSIndexPath *)indexPath{
|
||||
__weak typeof (self)weskSelf=self;
|
||||
KebordExternAddTextInputView *commentView =[[KebordExternAddTextInputView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.bounds];
|
||||
//commentView.palceholderText = holdText;
|
||||
commentView.customText = holdText;
|
||||
[[UIApplication sharedApplication].keyWindow addSubview:commentView];
|
||||
commentView.doneTextInfoHandler = ^(NSString *conttent){
|
||||
|
||||
NSArray *pathArr = @[indexPath];
|
||||
if (indexPath.row==2&&indexPath.section==1) {
|
||||
weskSelf.userInfo.userName=conttent;
|
||||
}else if (indexPath.row==3&&indexPath.section==1){
|
||||
weskSelf.userInfo.phoneNumber=conttent;
|
||||
}else if (indexPath.row==5&&indexPath.section==1){
|
||||
weskSelf.userInfo.address=conttent;
|
||||
}else if (indexPath.row==1&&indexPath.section==2){
|
||||
weskSelf.userInfo.remark=conttent;
|
||||
}
|
||||
|
||||
[weskSelf.tableView reloadRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationNone];
|
||||
NSLog(@"conttent:%@",conttent);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
#pragma mark - 获取会员详情
|
||||
|
||||
-(void)loadShopUserInfos{
|
||||
__weak typeof (self)weskSelf=self;
|
||||
[AFHttpTool getShopsUserInfo:weskSelf.userData.userID shopId:weskSelf.shopId success:^(id response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSDictionary *dataDic=reDic[@"data"];
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
ShopUserDatailData *data = [[ShopUserDatailData alloc] initWithDict:dataDic];
|
||||
weskSelf.userInfo = data;
|
||||
}
|
||||
[weskSelf.tableView reloadData];
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - upDateUserInfo 更新会员信息
|
||||
-(void)upDateUserInfo{
|
||||
|
||||
[self showProgress];
|
||||
__weak typeof (self)weskSelf=self;
|
||||
|
||||
if ([_userInfo.province isKindOfClass:[NSNull class]]||!_userInfo.province) {
|
||||
_userInfo.province = @"";
|
||||
}
|
||||
if ([_userInfo.city isKindOfClass:[NSNull class]]||!_userInfo.city) {
|
||||
_userInfo.city = @"";
|
||||
}
|
||||
if ([_userInfo.area isKindOfClass:[NSNull class]]||!_userInfo.city) {
|
||||
_userInfo.area = @"";
|
||||
}
|
||||
|
||||
|
||||
[AFHttpTool updateShopsUserInfo:_userData.userID shopId:weskSelf.shopId memberLevel:_userInfo.memberLevel userName:_userInfo.userName phoneNumber:_userInfo.phoneNumber province:_userInfo.province city:_userInfo.city area:_userInfo.area address:_userInfo.address remark:_userInfo.remark success:^(id response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
//NSDictionary *dataDic=reDic[@"data"];
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
[weskSelf.view makeToast:@"修改成功"];
|
||||
|
||||
}else{
|
||||
[weskSelf.view makeToast:@"请求异常"];
|
||||
}
|
||||
[weskSelf.progressHud hide:YES];
|
||||
} failure:^(NSError *err) {
|
||||
[self.view makeToast:@"请求异常"];
|
||||
[weskSelf.progressHud hide:YES];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)showProgress{
|
||||
|
||||
self.progressHud = [[MBProgressHUD alloc] initWithView:self.view];
|
||||
[self.view addSubview:self.progressHud];
|
||||
self.progressHud.mode=MBProgressHUDModeCustomView;
|
||||
self.progressHud.customView = [[UIView alloc] init];
|
||||
self.progressHud.delegate = self;
|
||||
self.progressHud.labelText = @"更新中...";
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - chatBtnClick和会员聊天
|
||||
-(void)chatBtnClick{
|
||||
|
||||
|
||||
UserModel*model=[dataContorl getUserInfo];
|
||||
|
||||
NSString *myAcount = [NSString stringWithFormat:@"%@",model.userId];
|
||||
|
||||
NSString *tarGetAcount = [NSString stringWithFormat:@"%@",self.userInfo.userId];
|
||||
if ([myAcount isEqualToString:tarGetAcount]) {
|
||||
|
||||
[self.view makeToast:@"不能和自己聊天哦"];
|
||||
return;
|
||||
}
|
||||
|
||||
[[NIMSDK sharedSDK].loginManager login:myAcount token:model.neteaseToken completion:^(NSError *error) {
|
||||
if (!error) {
|
||||
NSLog(@"登录成功");
|
||||
//创建session
|
||||
NIMSession *session = [NIMSession session:tarGetAcount type:NIMSessionTypeP2P];
|
||||
//创建聊天页,这个页面继承自 NIMKit 中的组件 NIMSessionViewController
|
||||
|
||||
IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session];
|
||||
//导航颜色
|
||||
vc.navState = 1;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
|
||||
}else{
|
||||
NSLog(@"登录失败");
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 等级sheet
|
||||
-(void)creatLevelSheet{
|
||||
_levelSheet = [[UIActionSheet alloc] initWithTitle:@"等级选择" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"1级",@"2级",@"3级", nil];
|
||||
[_levelSheet showInView:self.view];
|
||||
}
|
||||
|
||||
#pragma mark--UIActionSheetDelegate
|
||||
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
|
||||
|
||||
if (actionSheet==self.levelSheet) {
|
||||
if (buttonIndex==actionSheet.cancelButtonIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (buttonIndex) {
|
||||
case 0:
|
||||
{
|
||||
self.userInfo.memberLevel= @"1";
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
self.userInfo.memberLevel= @"2";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
self.userInfo.memberLevel= @"3";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:1];
|
||||
NSArray *pathArr = @[indexPath];
|
||||
[self.tableView reloadRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationNone];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 选择省市区
|
||||
-(void)showChinaPic
|
||||
{
|
||||
[ChinaPlckerView customChinaPicker:self superView:self.view];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - ChinaPlckerViewDelegate
|
||||
- (void)chinaPlckerViewDelegateChinaModel:(ChinaArea *)chinaModel{
|
||||
|
||||
|
||||
self.userInfo.province = chinaModel.provinceModel.NAME;
|
||||
self.userInfo.city = chinaModel.cityModel.NAME;
|
||||
self.userInfo.area = chinaModel.areaModel.NAME;
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:4 inSection:1];
|
||||
NSArray *pathArr = @[indexPath];
|
||||
[self.tableView reloadRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationNone];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// MemberManageViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/4/11.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WhiteNavBaseViewController.h"
|
||||
|
||||
@interface MemberManageViewController : WhiteNavBaseViewController
|
||||
@property(nonatomic,strong) NSString *shopId;
|
||||
|
||||
@end
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// MemberManageViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/4/11.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MemberManageViewController.h"
|
||||
#import "MemberManageListViewCell.h"
|
||||
#import "JHRefresh.h"
|
||||
#import "MemberNanageListData.h"
|
||||
#import "MemberDetailViewController.h"
|
||||
@interface MemberManageViewController ()<UITableViewDelegate,UITableViewDataSource>
|
||||
{
|
||||
BOOL _isLoadMore;
|
||||
}
|
||||
@property(nonatomic)BOOL isLoadMore;
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
@property (nonatomic,strong) NSMutableArray *listDataArr;
|
||||
@property (nonatomic) NSInteger firstResult;
|
||||
@property(nonatomic,copy) NSString *total;
|
||||
@property(nonatomic) int page;
|
||||
@end
|
||||
|
||||
@implementation MemberManageViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
//商家会员列表
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
_listDataArr = [[NSMutableArray alloc] init];
|
||||
_firstResult =0;
|
||||
_total =@"0";
|
||||
_page = 0;
|
||||
[self addTitleViewWithTitle:@"会员管理"];
|
||||
[self creatTab];
|
||||
[self initData];
|
||||
[self creatReatRefreshView];
|
||||
}
|
||||
|
||||
-(void)initData{
|
||||
|
||||
[self loadPageDataWith:_firstResult];
|
||||
}
|
||||
|
||||
-(void)loadPageDataWith:(NSInteger)first
|
||||
{
|
||||
__weak typeof (self)weskSelf=self;
|
||||
NSInteger pagesize = 20;
|
||||
NSString *userId =[dataContorl dataControlGetUserIdInfo];
|
||||
|
||||
[AFHttpTool getPageShopsUserInfo:first pageSize:pagesize userId:userId shopsId:self.shopId success:^(id response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
|
||||
NSArray *dataArr=reDic[@"data"];
|
||||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||||
|
||||
NSString *firstResult=reDic[@"firstResult"];
|
||||
_firstResult = [firstResult integerValue];
|
||||
NSString *total=reDic[@"total"];
|
||||
_total = total;
|
||||
for (NSDictionary *dict in dataArr) {
|
||||
MemberNanageListData *data = [[MemberNanageListData alloc] initWithDict:dict];
|
||||
[_listDataArr addObject:data];
|
||||
|
||||
}
|
||||
if (dataArr&&![dataArr isKindOfClass:[NSNull class]]) {
|
||||
//dataArr = [[NSArray alloc] init];
|
||||
if ([dataArr count]!=0) {
|
||||
[weskSelf.tableView reloadData];
|
||||
}else{
|
||||
[weskSelf resetNoDataView];
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
[weskSelf.view makeToast:@"请求异常"];
|
||||
}
|
||||
[weskSelf endRefreshing];
|
||||
} failure:^(NSError *err) {
|
||||
[weskSelf endRefreshing];
|
||||
[weskSelf.view makeToast:@"请求异常"];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)creatReatRefreshView{
|
||||
|
||||
//上拉加载更多
|
||||
__weak typeof (self)weskSelf=self;
|
||||
[_tableView addRefreshFooterViewWithAniViewClass:[JHRefreshCommonAniView class] beginRefresh:^{
|
||||
|
||||
if (weskSelf.isLoadMore) {
|
||||
return ;
|
||||
}
|
||||
weskSelf.isLoadMore=YES;
|
||||
|
||||
NSInteger pagecount =[_total integerValue]/20+1;
|
||||
if (weskSelf.page<pagecount-1) {
|
||||
weskSelf.page++;
|
||||
|
||||
NSInteger first=(NSInteger)weskSelf.page*20;
|
||||
|
||||
[weskSelf loadPageDataWith:first];
|
||||
}else{
|
||||
|
||||
[weskSelf endRefreshing];
|
||||
[weskSelf.view makeToast:@"已无更多数据"];
|
||||
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)endRefreshing{
|
||||
|
||||
if (_isLoadMore) {
|
||||
_isLoadMore=NO;
|
||||
[_tableView footerEndRefreshing];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)creatTab{
|
||||
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
self.tableView.showsVerticalScrollIndicator = NO;
|
||||
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
|
||||
[self.view addSubview:self.tableView];
|
||||
self.automaticallyAdjustsScrollViewInsets = YES;
|
||||
|
||||
}
|
||||
|
||||
-(void)resetNoDataView{
|
||||
|
||||
[self.tableView removeFromSuperview];
|
||||
self.view.backgroundColor =TABLE_BACKGROUD_COLOR;
|
||||
UIImageView *backImg = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 98/2 ,self.view.frame.size.height/4, 108, 98)];
|
||||
backImg.image = [UIImage imageNamed:@"nurse_empty_picture"];
|
||||
[self.view addSubview:backImg];
|
||||
|
||||
UILabel *title=[[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(backImg.frame) + 30, self.view.frame.size.width,20)];
|
||||
title.text = @"还里空空如也";
|
||||
title.textAlignment = NSTextAlignmentCenter;
|
||||
title.font =[UIFont systemFontOfSize:15];
|
||||
title.textColor = RGB(51, 51, 51);
|
||||
[self.view addSubview:title];
|
||||
|
||||
UILabel *title2=[[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(title.frame) + 7, self.view.frame.size.width,20)];
|
||||
|
||||
title2.text = @"您还木有会员~";
|
||||
title2.font =[UIFont systemFontOfSize:12];
|
||||
title2.textAlignment = NSTextAlignmentCenter;
|
||||
title2.textColor = RGB(153, 153, 153);
|
||||
[self.view addSubview:title2];
|
||||
|
||||
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
|
||||
return self.listDataArr.count;
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
MemberManageListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MemberManageListViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"MemberManageListViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
MemberNanageListData *data = _listDataArr[indexPath.row];
|
||||
[cell loadList:data];
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
return 70.0f;
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||||
|
||||
return 0.1f;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
|
||||
return 10.0f;
|
||||
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
MemberDetailViewController *detailVC = [[MemberDetailViewController alloc] init];
|
||||
MemberNanageListData *data = _listDataArr[indexPath.row];
|
||||
detailVC.userData =data;
|
||||
detailVC.shopId= self.shopId;
|
||||
[self.navigationController pushViewController:detailVC animated:YES];
|
||||
|
||||
}
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user