490 lines
18 KiB
Objective-C
490 lines
18 KiB
Objective-C
//
|
|
// IfishShopDetailViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/1/13.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "IfishShopDetailViewController.h"
|
|
#import "ShopDetailViewfirstCell.h"
|
|
#import "ShopDetailThredViewCell.h"
|
|
#import "ShopDetailCodeFirstCell.h"
|
|
#import "IfishSessionViewController.h"
|
|
#import "MineKanHuViewController.h"
|
|
#import "GoNetShopViewCell.h"
|
|
#import "ShopInfosViewCell.h"
|
|
#import "PushMasssageWebViewController.h"
|
|
#import "ShopDetailViewGoodsViewCell.h"
|
|
#import "ShopGoodsListData.h"
|
|
#import "IFishVideoPalyViewController.h"
|
|
@interface IfishShopDetailViewController ()<UITableViewDelegate,UITableViewDataSource,IfishShopGoodsListDelegate>
|
|
@property(nonatomic,strong)UITableView *tableView;
|
|
@property (nonatomic,strong) NSMutableArray *goodsArr;
|
|
@end
|
|
|
|
@implementation IfishShopDetailViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
[self addTitleViewWithTitle:@"店铺详情"];
|
|
_goodsArr= [[NSMutableArray alloc] init];
|
|
self.view.backgroundColor =[UIColor redColor];
|
|
[self creatTab];
|
|
[self loadDatas];
|
|
}
|
|
-(void)creatTab{
|
|
CGFloat BtnH = self.view.frame.size.width * 0.12;
|
|
|
|
[self.tableView registerNib:[UINib nibWithNibName:@"ShopDetailCodeFirstCell" bundle:nil] forCellReuseIdentifier:@"ShopDetailCodeFirstCell"];
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height - BtnH) style:UITableViewStyleGrouped];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.scrollEnabled = YES;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tableView.showsVerticalScrollIndicator = NO;
|
|
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
|
|
|
|
[self.view addSubview:self.tableView];
|
|
|
|
|
|
NSString *str= @" 咨询TA";
|
|
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:str];
|
|
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
|
|
attch.image = [UIImage imageNamed:@"businesslistings_comments"];
|
|
attch.bounds = CGRectMake(0,-4,17,16);//35*33
|
|
NSAttributedString *attristr=[NSAttributedString attributedStringWithAttachment:attch];
|
|
[attri insertAttributedString:attristr atIndex:0];
|
|
UIButton *zixunbtn =[UIButton buttonWithType:UIButtonTypeCustom];
|
|
[zixunbtn setAttributedTitle:attri forState:UIControlStateNormal];
|
|
zixunbtn.frame = CGRectMake(0,CGRectGetMaxY(self.tableView.frame),self.view.frame.size.width/2, BtnH);
|
|
zixunbtn.backgroundColor = RGB(255, 115, 92);
|
|
[attri addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,str.length+1)];
|
|
[attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0,str.length+1)];
|
|
[zixunbtn addTarget:self action:@selector(ziXunBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self.view addSubview:zixunbtn];
|
|
|
|
NSString *str2= @" 让TA帮我看护";
|
|
NSMutableAttributedString *attri2 = [[NSMutableAttributedString alloc] initWithString:str2];
|
|
NSTextAttachment *attch2 = [[NSTextAttachment alloc] init];
|
|
attch2.image = [UIImage imageNamed:@"businesslistings_nurse"];
|
|
attch2.bounds = CGRectMake(0,-3,14,16);//33*39
|
|
NSAttributedString *attristr2=[NSAttributedString attributedStringWithAttachment:attch2];
|
|
[attri2 insertAttributedString:attristr2 atIndex:0];
|
|
UIButton *kanhubtn =[UIButton buttonWithType:UIButtonTypeCustom];
|
|
[kanhubtn setAttributedTitle:attri2 forState:UIControlStateNormal];
|
|
kanhubtn.frame = CGRectMake(CGRectGetMaxX(zixunbtn.frame),CGRectGetMinY(zixunbtn.frame), self.view.frame.size.width/2, BtnH);
|
|
kanhubtn.backgroundColor = RGB(0, 180,239);
|
|
[attri2 addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,str2.length+1)];
|
|
[attri2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0,str2.length+1)];
|
|
[kanhubtn addTarget:self action:@selector(kanHuAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[self.view addSubview:kanhubtn];
|
|
|
|
|
|
}
|
|
|
|
#pragma mark - Table view data source
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
|
|
return 5;
|
|
}
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
if (section ==1) {
|
|
return 3;
|
|
}
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
if (indexPath.section ==0) {
|
|
|
|
ShopDetailCodeFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopDetailCodeFirstCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[ShopDetailCodeFirstCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ShopDetailCodeFirstCell"];
|
|
cell.backgroundColor = [UIColor whiteColor];
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
}
|
|
[cell loadDataWith:self.shopInfo];
|
|
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==1){
|
|
|
|
ShopInfosViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopInfosViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopInfosViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[cell loadDataWith:self.shopInfo atIndex:indexPath];
|
|
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==2){
|
|
|
|
GoNetShopViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GoNetShopViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"GoNetShopViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==4){
|
|
|
|
static NSString *identfire=@"ShopDetailViewGoodsViewCell";
|
|
ShopDetailViewGoodsViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identfire];
|
|
|
|
if (!cell) {
|
|
|
|
cell=[[ShopDetailViewGoodsViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identfire];
|
|
cell.backgroundColor = [UIColor whiteColor];
|
|
}
|
|
|
|
cell.delegate = self;
|
|
[cell setGoodsdataArr:_goodsArr];
|
|
[cell refreshCollellction];
|
|
return cell;
|
|
|
|
|
|
}else{
|
|
|
|
ShopDetailThredViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShopDetailThredViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"ShopDetailThredViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[cell loadDataWith:self.shopInfo];
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
//750 * 1080
|
|
|
|
if (indexPath.section ==0 ){
|
|
|
|
return self.view.frame.size.width*0.39;
|
|
|
|
}else if (indexPath.section ==1){
|
|
|
|
return 40;
|
|
|
|
}else if (indexPath.section ==2){
|
|
|
|
return self.view.frame.size.width*0.12;
|
|
|
|
}else if (indexPath.section==4)
|
|
{
|
|
CGFloat Itemwidth = (kScreenSize.width-1)/2;
|
|
CGFloat ItemH = Itemwidth*1.03 +1;
|
|
if (_goodsArr.count!=0) {
|
|
|
|
int total = (int)[_goodsArr count];
|
|
int rowCount =total%2==0?total/2:total/2+1;
|
|
return ItemH*rowCount;
|
|
}
|
|
return ItemH*2;
|
|
|
|
}else{
|
|
|
|
return self.view.frame.size.width*0.60;
|
|
}
|
|
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
if (section ==3||section==4) {
|
|
return self.view.frame.size.width*0.12 + 1;
|
|
|
|
}else if (section ==0){
|
|
return 1;
|
|
}
|
|
else{
|
|
return 0.000001;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
|
if (section ==2||section==3) {
|
|
return 10;
|
|
}else if (section ==0||section ==1){
|
|
return 1;
|
|
}
|
|
return 0.000001;
|
|
}
|
|
|
|
|
|
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
|
|
if (section ==3||section==4) {
|
|
|
|
UIView *backvew =[[UIView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.width*0.12)];
|
|
backvew.backgroundColor = [UIColor whiteColor];
|
|
//backvew.backgroundColor = [UIColor blueColor];
|
|
UILabel *zhanshiLabel = [[UILabel alloc] init];
|
|
zhanshiLabel.frame = CGRectMake(16,CGRectGetHeight(backvew.frame)/2 - 5,self.view.frame.size.width, CGRectGetHeight(backvew.frame)/2);
|
|
if (section==3) {
|
|
zhanshiLabel.text = @"店铺门面展示";
|
|
}else{
|
|
zhanshiLabel.text = @"商品列表";
|
|
}
|
|
//zhanshiLabel.text = @"店铺门面展示";
|
|
zhanshiLabel.textColor = RGB(0, 0, 0);
|
|
zhanshiLabel.font = [UIFont systemFontOfSize:15];
|
|
//zhanshiLabel.backgroundColor = [UIColor redColor];
|
|
[zhanshiLabel sizeToFit];
|
|
[backvew addSubview:zhanshiLabel];
|
|
UIView *backlinevew =[[UIView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(backvew.frame) , self.view.frame.size.width,1)];
|
|
backlinevew.backgroundColor = TABLE_BACKGROUD_COLOR;
|
|
[backvew addSubview:backlinevew];
|
|
return backvew;
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
if (indexPath.section==2) {
|
|
//进入网店
|
|
if ([self.shopInfo.shopLink isKindOfClass:[NSNull class]]||!self.shopInfo.shopLink||[self.shopInfo.shopLink isEqualToString:@""]) {
|
|
[self.view makeToast:@"商家暂未开通网店"];
|
|
return;
|
|
}
|
|
|
|
PushMasssageWebViewController *web=[[PushMasssageWebViewController alloc] init];
|
|
web.pushlink = self.shopInfo.shopLink;
|
|
web.pushtitle = @"网店";
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:web animated:YES];
|
|
}else if (indexPath.section==1&&indexPath.row ==0){
|
|
|
|
//拨打电话
|
|
if ([UIApplication instancesRespondToSelector:@selector(canOpenURL:)]) {
|
|
|
|
NSString *telNumber = [NSString stringWithFormat:@"telprompt://%@",self.shopInfo.shopsPhone];
|
|
|
|
NSURL *aURL = [NSURL URLWithString: telNumber];
|
|
|
|
if ([[UIApplication sharedApplication] canOpenURL:aURL])
|
|
|
|
{
|
|
[[UIApplication sharedApplication] openURL:aURL];
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
#pragma mark - vziXunBtnAction
|
|
|
|
-(void)ziXunBtnAction
|
|
{
|
|
|
|
UserModel*model=[dataContorl getUserInfo];
|
|
|
|
NSString *myAcount = [NSString stringWithFormat:@"%@",model.userId];
|
|
|
|
NSString *tarGetAcount = [NSString stringWithFormat:@"%@",self.shopInfo.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
|
|
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}else{
|
|
NSLog(@"登录失败");
|
|
}
|
|
}];
|
|
}
|
|
|
|
#pragma mark - 看护action
|
|
-(void)kanHuAction{
|
|
//判断是否已有看护商家
|
|
UserModel *model = [dataContorl getUserInfo];
|
|
if ([model.userType isEqualToString:@"1"]) {
|
|
[self.view makeToast:@"您是商家,不能让别人进行看护。"];
|
|
return;
|
|
}
|
|
|
|
|
|
//判断是否是自己的店铺
|
|
NSString *userId = [dataContorl dataControlGetUserIdInfo];
|
|
NSString *shopUserId =[NSString stringWithFormat:@"%@", self.shopInfo.userId];
|
|
if ([shopUserId isEqualToString:userId]) {
|
|
[self.view makeToast:@"您是商家,不能让别人进行看护。"];
|
|
return;
|
|
}
|
|
|
|
__weak typeof (self)weskSelf=self;
|
|
UIAlertController*ac=[UIAlertController alertControllerWithTitle:@"" message:@"确认看护后,该商家对您的爱鱼进行实时的看护,确认让这位商家对您的爱鱼看护吗?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[self presentViewController:ac animated:YES completion:nil];
|
|
[ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction*action){
|
|
|
|
|
|
}]];
|
|
[ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction*action){
|
|
|
|
[weskSelf kanhuWith:userId];
|
|
|
|
}]];
|
|
|
|
|
|
}
|
|
|
|
-(void)kanhuWith:(NSString *)userId
|
|
{
|
|
[AFHttpTool newChoiceShops:self.shopInfo.userId userId:userId success:^(id response) {
|
|
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
|
//选择看护商家成功加金币
|
|
[[IfishUserObsever sharedInstance] addGoldWith:CHIOCELOOKSHOPS addType:IFISHADDGOLDTYPE1];
|
|
|
|
CertificationShopModel*kanHuShangJiaXinXi=[[CertificationShopModel alloc] init];
|
|
|
|
kanHuShangJiaXinXi.userId= self.shopInfo.userId;
|
|
kanHuShangJiaXinXi.userName= self.shopInfo.userName;
|
|
kanHuShangJiaXinXi.userImg = self.shopInfo.userImg;
|
|
kanHuShangJiaXinXi.shopsPhone= self.shopInfo.shopsPhone;
|
|
kanHuShangJiaXinXi.shopsName= self.shopInfo.shopsName;
|
|
kanHuShangJiaXinXi.shopsProvince= self.shopInfo.shopsProvince;
|
|
kanHuShangJiaXinXi.shopsCity= self.shopInfo.shopsCity;
|
|
kanHuShangJiaXinXi.shopsArea= self.shopInfo.shopsArea;
|
|
kanHuShangJiaXinXi.shopsAddress= self.shopInfo.shopsAddress;
|
|
kanHuShangJiaXinXi.shopsId = self.shopInfo.shopsId;
|
|
kanHuShangJiaXinXi.picture4 = self.shopInfo.picture4;
|
|
|
|
//存储
|
|
[[DataCenter defaultDtacenter]setValue:kanHuShangJiaXinXi forKey:@"ShopsInfo2"];
|
|
|
|
MineKanHuViewController *wodeKanHu=[[MineKanHuViewController alloc] init];
|
|
|
|
wodeKanHu.xinXiModel = kanHuShangJiaXinXi;
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:wodeKanHu animated:YES];
|
|
|
|
}else{
|
|
|
|
[self.view makeToast:@"请求失败"];
|
|
}
|
|
|
|
} failure:^(NSError *err) {
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark - 商品列表
|
|
|
|
-(void)loadDatas
|
|
{
|
|
__weak typeof (self)weskSelf=self;
|
|
NSString *shopId = weskSelf.shopInfo.shopsId;
|
|
[AFHttpTool getCommodityInfoByPage:shopId pageSize:20 firstResult:0 commodityState:@"0" success:^(id response) {
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
if ([reDic[@"result"] isEqualToString:@"100"]){
|
|
|
|
NSArray*goodsArr=reDic[@"data"];
|
|
for (NSDictionary *goodsDic in goodsArr) {
|
|
ShopGoodsListData *goodsData=[[ShopGoodsListData alloc] initWithDict:goodsDic];
|
|
|
|
[weskSelf.goodsArr addObject:goodsData];
|
|
}
|
|
|
|
NSIndexSet *asset = [NSIndexSet indexSetWithIndex:4];
|
|
[weskSelf.tableView reloadSections:asset withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
|
|
} failure:^(NSError *err) {
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
#pragma mark -商品详情视频
|
|
|
|
-(void)tapTtemListAt:(NSString *)goodslink commdyId:(NSString *)commdyId
|
|
{
|
|
|
|
if ([goodslink isKindOfClass:[NSNull class]]||!goodslink) {
|
|
[self.view makeToast:@"空链接"];
|
|
return;
|
|
}
|
|
|
|
IFishVideoPalyViewController *palyvc= [[IFishVideoPalyViewController alloc] init];
|
|
|
|
palyvc.videoPath = goodslink;
|
|
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:palyvc];
|
|
|
|
[self presentViewController:nav animated:YES completion:nil];
|
|
[self addClickNumber:commdyId];
|
|
}
|
|
|
|
#pragma mark -商品点击数加1
|
|
|
|
-(void)addClickNumber:(NSString *)commdyId{
|
|
|
|
[AFHttpTool updateCommodityClickCount:commdyId success:^(id response) {
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
if ([reDic[@"result"] isEqualToString:@"100"]){
|
|
|
|
}
|
|
|
|
} failure:^(NSError *err) {
|
|
|
|
}];
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|