466 lines
16 KiB
Objective-C
466 lines
16 KiB
Objective-C
//
|
||
// WoShiShangJiaViewController.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 17/2/9.
|
||
// Copyright © 2017年 lianlian. All rights reserved.
|
||
//
|
||
|
||
#import "WoShiShangJiaViewController.h"
|
||
#import "ShopServiceListData.h"
|
||
#import "ShopNotCertifyViewCell.h"
|
||
#import "ShopAlreadyCertifyViewCell.h"
|
||
#import "ShopServiceListCell.h"
|
||
#import "UINavigationBar+Background.h"
|
||
#import "ShopCertificationViewController.h"
|
||
#import "ShopCertifyFailViewController.h"
|
||
#import "IfishShopDetailViewController.h"
|
||
#import "ShopEditViewController.h"
|
||
#import "IfishShopEditeNewViewController.h"
|
||
#import "WorkbechViewController.h"
|
||
#import "IfishKanHuGuanLiViewController.h"
|
||
#import "ShopCertificationIntroduceController.h"
|
||
#import "MemberManageViewController.h"
|
||
#import "ShopErWeiMaViewController.h"
|
||
#import "IfishGoodsManageViewController.h"
|
||
#import "ShopGoodsManageViewController.h"
|
||
@interface WoShiShangJiaViewController ()<UITableViewDelegate,UITableViewDataSource>
|
||
|
||
@property(nonatomic,strong)UITableView *tableView;
|
||
@property(nonatomic,strong) NSMutableArray *dataArr;
|
||
@property(nonatomic,strong) CertificationShopModel *ShopsInfo;
|
||
@end
|
||
|
||
@implementation WoShiShangJiaViewController
|
||
|
||
- (void)viewDidLoad {
|
||
|
||
[super viewDidLoad];
|
||
[self getData];
|
||
// Do any additional setup after loading the view.
|
||
//self.title = @"我是商家";
|
||
[self addTitleViewWithTitle:@"我是商家"];
|
||
[self creatTab];
|
||
self.view.backgroundColor =[UIColor whiteColor];
|
||
}
|
||
|
||
-(void)viewWillAppear:(BOOL)animated{
|
||
[super viewWillAppear:animated];
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"1"]) {
|
||
self.ShopsInfo= [[DataCenter defaultDtacenter] valueForKey:@"ShopsInfo"];
|
||
NSIndexPath *path =[NSIndexPath indexPathForRow:0 inSection:0];
|
||
NSArray *pathArr =@[path];
|
||
[self.tableView reloadRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationNone];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
-(void)goBackAction{
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
|
||
}
|
||
|
||
-(void)viewWillDisappear:(BOOL)animated{
|
||
[super viewWillDisappear:animated];
|
||
[self.navigationController.navigationBar resetBackgroundImage];
|
||
|
||
}
|
||
|
||
-(void)getData{
|
||
|
||
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"ShopService" ofType:@"plist"];
|
||
if (!_dataArr) {
|
||
|
||
_dataArr = [[NSMutableArray alloc] init];
|
||
|
||
NSArray *data = [[NSArray alloc] initWithContentsOfFile:plistPath];
|
||
|
||
|
||
for (NSDictionary *listDic in data) {
|
||
ShopServiceListData *model=[[ShopServiceListData alloc] init];
|
||
model.serviceIcon = listDic[@"serviceIcon"];
|
||
model.serviceName= listDic[@"title"];
|
||
model.serviceDt = listDic [@"dsc"];
|
||
[_dataArr addObject:model];
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
-(void)creatTab{
|
||
|
||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStylePlain];
|
||
|
||
self.tableView.delegate = self;
|
||
self.tableView.dataSource = self;
|
||
self.tableView.scrollEnabled = YES;
|
||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
self.tableView.showsVerticalScrollIndicator = NO;
|
||
self.tableView.backgroundColor = [UIColor whiteColor];
|
||
[self.view addSubview:self.tableView];
|
||
|
||
}
|
||
|
||
#pragma mark - Table view data source
|
||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
|
||
return 2;
|
||
}
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
if (section ==0) {
|
||
|
||
return 1;
|
||
|
||
}else{
|
||
|
||
return 5;
|
||
}
|
||
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
if (indexPath.section ==0) {
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"1"]) {
|
||
|
||
return 186.0f;
|
||
|
||
}else{
|
||
return self.view.frame.size.width*0.21;
|
||
}
|
||
}else{
|
||
return self.view.frame.size.width*0.16;
|
||
}
|
||
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
|
||
if (section ==0) {
|
||
|
||
return 5.0f;
|
||
|
||
}else{
|
||
|
||
CGFloat ViewH =self.view.frame.size.width * 0.093;
|
||
return ViewH + 10.0f;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
if (section ==1) {
|
||
CGFloat ViewH =self.view.frame.size.width * 0.093;
|
||
UIView *HoldView=[[UIView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, ViewH + 10)];
|
||
HoldView.backgroundColor = JWUIColorFromRGB(0xf2f2f2);
|
||
//CGFloat whiteH = ViewH - 10;
|
||
UIView *whiteHoldView=[[UIView alloc] initWithFrame:CGRectMake(0, 10, self.view.frame.size.width,ViewH)];
|
||
whiteHoldView.backgroundColor = [UIColor whiteColor];
|
||
[HoldView addSubview:whiteHoldView];
|
||
|
||
CGFloat pointW = 6.0f;
|
||
UIView *headpoint=[[UIView alloc] initWithFrame:CGRectMake(15, ViewH/2 -pointW/2, pointW, pointW)];
|
||
headpoint.layer.masksToBounds = YES;
|
||
headpoint.layer.cornerRadius = pointW/2;
|
||
[whiteHoldView addSubview:headpoint];
|
||
|
||
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(headpoint.frame) + 5, ViewH/2 - 30/2, 280, 30)];
|
||
title.textColor = RGB(102, 102, 102);
|
||
title.font = [UIFont systemFontOfSize:12.0];
|
||
[whiteHoldView addSubview:title];
|
||
|
||
UIView *lineView=[[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetHeight(whiteHoldView.frame) -1, self.view.frame.size.width, 1)];
|
||
lineView.backgroundColor = RGB(221, 221, 221);
|
||
[whiteHoldView addSubview:lineView];
|
||
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"1"]) {
|
||
headpoint.backgroundColor = RGB(50,184, 254);
|
||
title.text = @"您已通过爱鱼奇商家认证,可以使用以下服务";
|
||
|
||
}else{
|
||
|
||
headpoint.backgroundColor = RGB(221, 221, 221);
|
||
title.text = @"完成商家认证,即可使用以下服务";
|
||
}
|
||
|
||
return HoldView;
|
||
|
||
}else if (section ==1){
|
||
UIView *Footerback=[[UIView alloc] init];
|
||
Footerback.backgroundColor = JWUIColorFromRGB(0xf2f2f2);
|
||
return Footerback;
|
||
}
|
||
return nil;
|
||
}
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
if (indexPath.section==0) {
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"1"]) {
|
||
//商家
|
||
ShopAlreadyCertifyViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopAlreadyCertifyViewCell"];
|
||
if (!cell) {
|
||
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopAlreadyCertifyViewCell" owner:self options:nil]lastObject];
|
||
|
||
}
|
||
CertificationShopModel *ShopsInfo= [[DataCenter defaultDtacenter] valueForKey:@"ShopsInfo"];
|
||
[cell loadDataWith:ShopsInfo];
|
||
[cell.shopDetailBtn addTarget:self action:@selector(shopDetailBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
[cell.saomaBtn addTarget:self action:@selector(saomaBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
return cell;
|
||
|
||
}else{
|
||
|
||
ShopNotCertifyViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopNotCertifyViewCell"];
|
||
if (!cell) {
|
||
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopNotCertifyViewCell" owner:self options:nil]lastObject];
|
||
|
||
}
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
||
return cell;
|
||
}
|
||
|
||
}else{
|
||
ShopServiceListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopServiceListCell"];
|
||
|
||
if (!cell) {
|
||
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopServiceListCell" owner:self options:nil]lastObject];
|
||
|
||
}
|
||
ShopServiceListData *mode =self.dataArr[indexPath.row];
|
||
[cell setCellDataWith:mode];
|
||
return cell;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"1"]) {
|
||
if (indexPath.section ==0) {
|
||
|
||
return;
|
||
}
|
||
|
||
switch (indexPath.row) {
|
||
case 0:
|
||
{
|
||
//店铺管理
|
||
|
||
// ShopEditViewController *shopeditVC= [[ShopEditViewController alloc] init];
|
||
IfishShopEditeNewViewController *shopeditVC= [[IfishShopEditeNewViewController alloc] init];
|
||
shopeditVC.shopInfo = self.ShopsInfo;
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:shopeditVC animated:YES];
|
||
}
|
||
break;
|
||
case 1:
|
||
{//看护管理
|
||
//看护工作 台
|
||
if ([self.ShopsInfo.status isEqualToString:@"3"]) {
|
||
|
||
[self.view makeToast:@"此商户已被禁用"];
|
||
return;
|
||
}
|
||
// WorkbechViewController *workVC=[[WorkbechViewController alloc] init];
|
||
IfishKanHuGuanLiViewController *workVC = [[IfishKanHuGuanLiViewController alloc] init];
|
||
workVC.shopsInfo = self.ShopsInfo;
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:workVC animated:YES];
|
||
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
//会员管理
|
||
MemberManageViewController *memberManageVC = [[MemberManageViewController alloc] init];
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
memberManageVC.shopId = self.ShopsInfo.shopsId;
|
||
[self.navigationController pushViewController:memberManageVC animated:YES];
|
||
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
//进货管理
|
||
IfishGoodsManageViewController *goodsVC=[[IfishGoodsManageViewController alloc] init];
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:goodsVC animated:YES];
|
||
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
if ([self.ShopsInfo.shopsId isKindOfClass:[NSNull class]]||!self.ShopsInfo.shopsId) {
|
||
return;
|
||
}
|
||
|
||
//商品管理
|
||
ShopGoodsManageViewController *shopGoodsVC=[[ShopGoodsManageViewController alloc] init];
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
shopGoodsVC.shopID = self.ShopsInfo.shopsId;
|
||
[self.navigationController pushViewController:shopGoodsVC animated:YES];
|
||
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}else{
|
||
if (indexPath.section ==0) {
|
||
//认证
|
||
|
||
//商户验证
|
||
UserModel *user = [dataContorl getUserInfo];
|
||
if ([user.userType isEqualToString:@"0"]) {
|
||
//普通用户 普通用户展示认证入口
|
||
CertificationShopModel *CSModel= [[DataCenter defaultDtacenter] valueForKey:@"ShopsInfo"];
|
||
|
||
if (CSModel.shopsId) {
|
||
|
||
[self testShopStatusWith:CSModel];
|
||
|
||
}else{
|
||
|
||
ShopCertificationIntroduceController *introduce=[[ShopCertificationIntroduceController alloc] init];
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:introduce animated:YES];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}else{
|
||
[self.view makeToast:@"请先完成商家认证"];
|
||
}
|
||
}
|
||
}
|
||
- (void)didReceiveMemoryWarning {
|
||
[super didReceiveMemoryWarning];
|
||
// Dispose of any resources that can be recreated.
|
||
}
|
||
|
||
#pragma mark - 审核状态查询
|
||
-(void)testShopStatusWith:(CertificationShopModel *)CSModel{
|
||
|
||
[IFISHHTTPTOOL shopCertifyStausWith:CSModel.shopsId huishuiShiJian:^(ShopCertifyStausModel *shopCertifyd) {
|
||
|
||
ShopCertifyStausModel *statusmodel = [[ShopCertifyStausModel alloc] init];
|
||
statusmodel=shopCertifyd;
|
||
[self pushStatusViewWith:statusmodel];
|
||
|
||
|
||
}];
|
||
|
||
}
|
||
|
||
-(void)pushStatusViewWith:(ShopCertifyStausModel*)model{
|
||
|
||
UIViewController *puVC;
|
||
Class cls= nil;
|
||
//model.status = nil;
|
||
if (model.status) {
|
||
|
||
//model.status =@"0";
|
||
|
||
if ([model.status isEqualToString:@"0"]){
|
||
//审核不通过
|
||
// cls=NSClassFromString(@"ShopCertifyFailViewController");
|
||
|
||
ShopCertifyFailViewController *puVC=[[ShopCertifyFailViewController alloc] init];
|
||
puVC.statusModel = model;
|
||
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:puVC animated:YES];
|
||
|
||
|
||
}else if ([model.status isEqualToString:@"1"]){
|
||
|
||
cls=NSClassFromString(@"ShopCertifySucssesViewController");
|
||
puVC=[[cls alloc] initWithNibName:@"ShopCertifyFailViewController" bundle:nil];
|
||
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:puVC animated:YES];
|
||
|
||
}else if ([model.status isEqualToString:@"2"]){
|
||
|
||
|
||
cls=NSClassFromString(@"ShopCertifyCheckViewController");
|
||
puVC=[[cls alloc] initWithNibName:@"ShopCertifyFailViewController" bundle:nil];
|
||
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:puVC animated:YES];
|
||
|
||
|
||
}else if ([model.status isEqualToString:@"3"]){
|
||
//禁用
|
||
[self.view makeToast:@"已禁用"];
|
||
return;
|
||
}
|
||
|
||
}else{
|
||
|
||
[self.view makeToast:@"请求错误"];
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark - 店铺详情
|
||
-(void)shopDetailBtnAction{
|
||
|
||
IfishShopDetailViewController *shopDetailVC=[[IfishShopDetailViewController alloc] init];
|
||
CertificationShopModel *ShopsInfo= [[DataCenter defaultDtacenter] valueForKey:@"ShopsInfo"];
|
||
IfishShopInfo *shopinfo = [[IfishShopInfo alloc] init];
|
||
shopinfo.shopsId = ShopsInfo.shopsId;
|
||
shopinfo.userId = ShopsInfo.userId;
|
||
shopinfo.userImg = ShopsInfo.userImg;
|
||
shopinfo.userName = ShopsInfo.userName;
|
||
shopinfo.shopsName = ShopsInfo.shopsName;
|
||
shopinfo.shopsPhone = ShopsInfo.shopsPhone;
|
||
shopinfo.shopsProvince = ShopsInfo.shopsProvince;
|
||
shopinfo.shopsArea = ShopsInfo.shopsArea;
|
||
shopinfo.shopsCity = ShopsInfo.shopsCity;
|
||
shopinfo.shopsAddress = ShopsInfo.shopsAddress;
|
||
shopinfo.picture4 = ShopsInfo.picture4;
|
||
shopinfo.remark = ShopsInfo.remark;
|
||
//shopinfo.distance = ShopsInfo.
|
||
shopinfo.weixinCode = ShopsInfo.wechat;
|
||
shopinfo.shopLink = ShopsInfo.shoplink;
|
||
|
||
shopDetailVC.shopInfo = shopinfo;
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
[self.navigationController pushViewController:shopDetailVC animated:YES];
|
||
}
|
||
|
||
#pragma mark - 店铺二维码
|
||
-(void)saomaBtnClick
|
||
{
|
||
ShopErWeiMaViewController *erweimaVC = [[ShopErWeiMaViewController alloc] init];
|
||
self.hidesBottomBarWhenPushed = YES;
|
||
erweimaVC.shopId =self.ShopsInfo.shopsId;
|
||
erweimaVC.shopName = self.ShopsInfo.shopsName;
|
||
[self.navigationController pushViewController:erweimaVC animated:YES];
|
||
|
||
}
|
||
|
||
@end
|