美文网首页
iOS预订座位Demo

iOS预订座位Demo

作者: 碧海云天V | 来源:发表于2018-11-08 15:20 被阅读26次

自己在工作当中有一个预订座位的需求,于是自己就捣鼓了一下。这个需求是根据日期、人数、时间去预订座位,并且会消耗相应的积分,以下是效果图。

IMG_1600.PNG

1、模块分解

这里可以分为5个模块:
1、日期模块 -> 是一个单选框RadioBox
2、人数模块 -> 也是一个单选框RadioBox
3、时间模块 -> 是一个多选框CheckBox
4、享座专属 -> 普通的label展示
5、底部积分确认按钮 -> 普通的button按钮(需根据选择情况改变文字)

2、界面搭建

我是放在tableview里面的,具体的看我代码。Demo

3、逻辑处理

刚进入该界面时,如果今天的座位被预订完了,默认变为明天,依次类推;人数默认固定位1人不变;日期也是默认第一个时间段,当第一个时间段被预订了就自动变灰,默认时间段也依次往后类推选择一个。

日期、人数、时间的改变会影响底部按钮积分的变化,此时就需要这四个地方相互关联

关键代码:

#pragma mark---按钮点击的代理方法
//选择日期的代理方法
-(void)selectDateWidthValue:(NSString *)value index:(NSInteger)index{
    //更新时间按钮的状态
    [_timeCell updateButtonStstusWidthIsDefaultSelect:NO unSelectIndexArr:@[@(index)]];
    //积分按钮的状态
    self.dateSelectIndex = index;
    [_confirmView calculatePointsWithUserPoints:self.userPoints freezePoints:self.freezePoints numberIndex:self.numberSelectIndex timeSelectArr:self.timeCell.selectMuArr];
}
//选择人数的代理方法
-(void)selectNumberWidthValue:(NSString *)value index:(NSInteger)index{
    //更新时间按钮的状态
    [_timeCell updateButtonStstusWidthIsDefaultSelect:NO unSelectIndexArr:@[@(index)]];
    //积分按钮的状态
    self.numberSelectIndex = index;
    [_confirmView calculatePointsWithUserPoints:self.userPoints freezePoints:self.freezePoints numberIndex:self.numberSelectIndex timeSelectArr:self.timeCell.selectMuArr];
}
//选择时间的代理方法
-(void)selectIndexArr:(NSArray *)indexArr{
    //积分按钮的状态
    [_confirmView calculatePointsWithUserPoints:self.userPoints freezePoints:self.freezePoints numberIndex:self.numberSelectIndex timeSelectArr:self.timeCell.selectMuArr];
}
//底部按钮的点击事件代理
-(void)bottomButtonSelectTypt:(BottomButtonType)type callbackStr:(NSString *)str{
    if (type == BottomTipButton) {//提示按钮
        NSLog(@"-----%@",@"跳转积分说明");
    }else if (type == BottomConfirmButton){//确认按钮
        NSLog(@"-----%@",str);
    }
}

以上代码不能有效理出逻辑,如果想要理顺逻辑,请看我的代码Demo

相关文章

网友评论

      本文标题:iOS预订座位Demo

      本文链接:https://www.haomeiwen.com/subject/ocjwxqtx.html