124 lines
5.2 KiB
Objective-C
124 lines
5.2 KiB
Objective-C
//
|
|
// DetailViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 15/10/27.
|
|
// Copyright © 2015年 imac. All rights reserved.
|
|
//
|
|
//店铺详情
|
|
#import "DetailViewController.h"
|
|
#import "AFNetworking.h"
|
|
#import "UserModel.h"
|
|
#import "merchantModel.h"
|
|
#import "LeftViewController.h"
|
|
#import "CenterViewController.h"
|
|
#import "ICSDrawerController.h"
|
|
#import "AppDelegate.h"
|
|
@interface DetailViewController ()
|
|
@property (weak, nonatomic) IBOutlet UIButton *morenBtn;
|
|
@property(nonatomic)BOOL isDefault;
|
|
|
|
@end
|
|
|
|
@implementation DetailViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.view.backgroundColor= [UIColor colorWithRed:239.0/256.0 green:239.0/256.0 blue:244.0/256.0 alpha:1];
|
|
[self addTitleViewWithTitle:@"店铺"];
|
|
|
|
[self initData];
|
|
|
|
merchantModel*model=[[DataCenter defaultDtacenter]valueForKey:@"merchantInfo"];
|
|
if (model) {
|
|
if (model.merchantId==_shopModel.merchantId) {
|
|
self.morenBtn.backgroundColor=[UIColor lightGrayColor];
|
|
self.morenBtn.userInteractionEnabled=NO;
|
|
}else{
|
|
self.morenBtn.backgroundColor=COLOR_LABEL_TITLE;
|
|
self.morenBtn.userInteractionEnabled=YES;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
[self.morenBtn addTarget:self action:@selector(morenButnClick)forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
}
|
|
-(void)morenButnClick{
|
|
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
|
|
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
|
UserModel*usermodel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
|
NSMutableDictionary * para = [NSMutableDictionary dictionary];
|
|
[para setValue:usermodel.userId forKey:@"userId"];
|
|
[para setValue:_shopModel.merchantId forKey:@"merchantId"];
|
|
[mannager POST:kSetMoRenShop parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
if (responseObject) {
|
|
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
if ([dict[@"result" ] isEqualToString:@"100"]) {
|
|
[self showTitle:@"" messsage:@"设置成功"];
|
|
// _isDefault=YES;
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.morenBtn.backgroundColor=[UIColor lightGrayColor];
|
|
self.morenBtn.userInteractionEnabled=NO;
|
|
|
|
});
|
|
|
|
|
|
// 更新默认数据
|
|
|
|
merchantModel*model=[[merchantModel alloc]init];
|
|
model.merchantId=_shopModel.merchantId;
|
|
model.shopName=_shopModel.shopName;
|
|
model.areaName=_shopModel.areaName;
|
|
model.appShow=_shopModel.appShow;
|
|
model.cityName=_shopModel.cityName;
|
|
model.contactPhone=_shopModel.contactPhone;
|
|
model.endTime=_shopModel.endTime;
|
|
model.isPass=_shopModel.isPass;
|
|
model.mainBusiness=_shopModel.mainBusiness;
|
|
model.provinceName=_shopModel.provinceName;
|
|
model.road=_shopModel.road;
|
|
model.salutation=_shopModel.salutation;
|
|
model.startTime=_shopModel.startTime;
|
|
[[DataCenter defaultDtacenter]setValue:model forKey:@"merchantInfo"];
|
|
|
|
LeftViewController*left=[[LeftViewController alloc]init];
|
|
CenterViewController*center=[[CenterViewController alloc]init];
|
|
ICSDrawerController*ics=[[ICSDrawerController alloc]initWithLeftViewController:left centerViewController:center];
|
|
UIApplication*app=[UIApplication sharedApplication];
|
|
AppDelegate*app1=(AppDelegate*)app.delegate;
|
|
UINavigationController*nav=[[UINavigationController alloc]initWithRootViewController:ics];
|
|
[nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"bar.png"] forBarMetrics:UIBarMetricsDefault];
|
|
app1.window.rootViewController=nav;
|
|
|
|
|
|
}else if ([dict[@"result" ] isEqualToString:@"101"]){
|
|
[self showTitle:@"" messsage:@"设置失败"];
|
|
}else if ([dict[@"result" ] isEqualToString:@"301"]){
|
|
[self showTitle:@"" messsage:@"请求验证失败,请重新登陆"];
|
|
}else if ([dict[@"result" ] isEqualToString:@"301"]){
|
|
[self showTitle:@"" messsage:@"请求被舍弃,未执行"];
|
|
}
|
|
|
|
}
|
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
|
[self showTitle:@"" messsage:@"error"];
|
|
}];
|
|
|
|
|
|
}
|
|
-(void)initData{
|
|
//
|
|
self.detailView.text=[NSString stringWithFormat:@"地址:%@%@%@\n营业时间:%@\n主营:%@\n联系电话:%@\n店长:%@\n", _shopModel.cityName, _shopModel.areaName, _shopModel.road, _shopModel.startTime, _shopModel.mainBusiness, _shopModel.contactPhone, _shopModel.salutation];
|
|
self.detailView.textColor=[UIColor grayColor];
|
|
self.nameLabel.text= _shopModel.shopName;
|
|
self.nameLabel.textColor=COLOR_LABEL_TITLE;
|
|
}
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
}
|
|
@end
|