『壹』 JAVA语言编写的网上订餐系统购物车功能如何实现
用Vector 或者是HashMap去装
<下面有部分代码你去看吧>
packagecom.aptech.restrant.DAO;
importjava.util.ArrayList;
importjava.util.HashMap;
importjava.util.List;
importjava.util.Map;
importjava.util.Set;
importjava.sql.Connection;
importcom.aptech.restrant.bean.CartItemBean;
importcom.aptech.restrant.bean.FoodBean;
publicclassCartModel{
privateConnectionconn;
publicCartModel(Connectionconn){
this.conn=conn;
}
/**
*得到订餐列表
*
*@return
*/
publicListchangeToList(Mapcarts){
//将Set中元素转换成数组,以便使用循环进行遍历
Object[]foodItems=carts.keySet().toArray();
//定义double变量total,用于存放购物车内餐品总价格
doubletotal=0;
Listlist=newArrayList();
//循环遍历购物车内餐品,并显示各个餐品的餐品名称,价格,数量
for(inti=0;i<foodItems.length;i++){
//从Map对象cart中取出第i个餐品,放入cartItem中
CartItemBeancartItem=(CartItemBean)carts
.get((String)foodItems[i]);
//从cartItem中取出FoodBean对象
FoodBeanfood1=cartItem.getFoodBean();
//定义int类型变量quantity,用于表示购物车中单个餐品的数量
intquantity=cartItem.getQuantity();
//定义double变量price,表示餐品单价
doubleprice=food1.getFoodPrice();
//定义double变量,subtotal表示单个餐品总价
doublesubtotal=quantity*price;
////计算购物车内餐品总价格
total+=subtotal;
cartItem.setSubtotal(subtotal);
cartItem.setTotal(total);
list.add(cartItem);
}
returnlist;
}
/**
*增加订餐
*/
publicMapadd(Mapcart,StringfoodID){
//购物车为空
if(cart==null){
cart=newHashMap();
}
FoodModelfd=newFoodModel(conn);
FoodBeanfood=fd.findFoodById(foodID);
//判断购物车是否放东西(第一次点餐)
if(cart.isEmpty()){
CartItemBeancartBean=newCartItemBean(food,1);
cart.put(foodID,cartBean);
}else{
//判断当前菜是否在购物车中,false表示当前菜没有被点过。。
booleanflag=false;
//得到键的集合
Setset=cart.keySet();
//遍历集合
Object[]obj=set.toArray();
for(inti=0;i<obj.length;i++){
Objectobject=obj[i];
//如果购物车已经存在当前菜,数量+1
if(object.equals(foodID)){
intquantity=((CartItemBean)cart.get(object))
.getQuantity();
quantity+=1;
System.out.println(quantity);
((CartItemBean)cart.get(object)).setQuantity(quantity);
flag=true;
break;
}
}
if(flag==false){
//把当前菜放到购物车里面
CartItemBeancartBean=newCartItemBean(food,1);
cart.put(foodID,cartBean);
}
}
returncart;
}
/**
*取消订餐
*/
publicMapremove(Mapcart,StringfoodID){
cart.remove(foodID);
returncart;
}
/**
*更新购物车信息
*
*@paramcart
*@paramfoodID
*@return
*/
publicMap<String,CartItemBean>update(Mapcart,StringfoodID,
booleanisAddorRemove){
Mapmap;
if(isAddorRemove){
map=add(cart,foodID);
}else{
map=remove(cart,foodID);
}
returnmap;
}
}
『贰』 Android 实现美团,饿了么购物车效果
对两个按钮的背复景进行改变button、button2的选中制和为选择状态.beijing1).drawable.setBackgroundResource(R,让后再button1和button2的点击事件中,分别为button1的选中和为选择状态;上面是改变按钮背景的代码可以做两组图片
『叁』 仿饿了么,百度,美团外卖,订餐网站外卖系统源码
现在都用微信啦,看看云快卖订餐系统
『肆』 iOS仿美团外卖饿了吗App点餐动画
tableViewCell布局篇–为方便大家查看, 我会尽量贴出全部代码
/***/
typedef void(^)(NSInteger count, BOOL animated);
@interface XTFoodCell : UITableViewCell
@property (nonatomic, strong) UIImageView *foodImage; // cyan
@property (nonatomic, strong) UILabel *nameLabel; // orange
@property (nonatomic, strong) UILabel *priceLabel; // gray
@property (nonatomic, strong) UIButton *btnMinus; // black
@property (nonatomic, strong) UIButton *btnPlus; // black
@property (nonatomic, strong) UILabel *orderCount; // red
@property (nonatomic, ) btnPulsBlock block; // block
@property (nonatomic, strong) UIImageView *animateView; // 购物车图标
@property (nonatomic, assign) NSInteger numCount; // 计数器
@end
.m 实现篇
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
[self.contentView addSubview:self.foodImage];
[self.contentView addSubview:self.nameLabel];
[self.contentView addSubview:self.priceLabel];
[self.contentView addSubview:self.btnMinus];
[self.contentView addSubview:self.btnPlus];
[self.contentView addSubview:self.orderCount];
}
- (UIImageView *)foodImage
{
if (!_foodImage) {
_foodImage = [[UIImageView alloc] init];
}
return _foodImage;
}
- (UILabel *)nameLabel
{
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
}
return _nameLabel;
}
- (UILabel *)priceLabel
{
if (!_priceLabel) {
_priceLabel = [[UILabel alloc] init];
}
return _priceLabel;
}
- (UIButton *)btnMinus
{
if (!_btnMinus) {
_btnMinus = [UIButton buttonWithType:UIButtonTypeCustom];
}
return _btnMinus;
}
- (UIButton *)btnPlus
{
if (!_btnPlus) {
_btnPlus = [UIButton buttonWithType:UIButtonTypeCustom];
}
return _btnPlus;
}
- (UILabel *)orderCount
{
if (!_orderCount) {
_orderCount = [[UILabel alloc] init];
}
return _orderCount;
}
UI布局篇–Masonry
- (void)layoutSubviews
{
[super layoutSubviews];
[_foodImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.mas_top).with.offset(5.0);
make.left.equalTo(self.contentView.mas_left).with.offset(5.0);
make.width.equalTo(@88.0);
make.height.equalTo(@88.0);
}];
self.foodImage.backgroundColor = [UIColor cyanColor];
[_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.foodImage.mas_right).with.offset(5.0);
make.top.equalTo(self.contentView.mas_top).with.offset(5.0);
make.right.equalTo(self.contentView.mas_right).with.offset(-5.0);
make.height.equalTo(@30);
}];
self.nameLabel.backgroundColor = [UIColor orangeColor];
[_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_nameLabel);
make.width.equalTo(@50.0);
make.height.equalTo(@30);
make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-5.0);
}];
self.priceLabel.backgroundColor = [UIColor lightGrayColor];
[_btnMinus mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_nameLabel);
make.centerY.equalTo(self.contentView);
make.width.height.mas_equalTo(CGSizeMake(25, 25));
}];
self.btnMinus.backgroundColor = [UIColor blackColor];
[_orderCount mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_btnMinus.mas_right).with.offset(10);
make.centerY.equalTo(self.contentView);
make.width.height.mas_equalTo(CGSizeMake(35, 25));
}];
self.orderCount.backgroundColor = [UIColor redColor];
[self.btnPlus mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_orderCount.mas_right).with.offset(10);
make.centerY.equalTo(self.contentView);
make.width.height.mas_equalTo(CGSizeMake(25, 25));
}];
self.btnPlus.backgroundColor = [UIColor blackColor];
[_btnMinus setTitle:@"减" forState:UIControlStateNormal];
[_btnMinus addTarget:self action:@selector(clickMin:) forControlEvents:UIControlEventTouchUpInside];
_btnMinus.hidden = YES;
[_btnPlus setTitle:@"加" forState:UIControlStateNormal];
[_btnPlus addTarget:self action:@selector(clickPuls:) forControlEvents:UIControlEventTouchUpInside];
}
btn点击方法–
- (void)clickPuls:(UIButton *)btn
{
self.numCount += 1;
self.block(self.numCount, YES);
[self showOrderNums:self.numCount];
}
- (void)clickMin:(UIButton *)btn
{
self.numCount -= 1;
self.block(self.numCount, NO);
[self showOrderNums:self.numCount];
}
VC篇– 这里给出cellForRowAtIndexPath中代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
XTFoodCell *cell = [tableView :cellIdentifier forIndexPath:indexPath];
// Block 回调
__weak __typeof(&*cell) weakCell = cell;
cell.block = ^(NSInteger nCount, BOOL boo){
CGRect parentRect = [weakCell convertRect:weakCell.btnPlus.frame toView:self.view];
if (boo) {
// 这里是动画开始的方法
[self JoinCartAnimationWithRect:parentRect];
}
else
{
}
};
return cell;
}
#pragma mark -加入购物车动画
-(void) JoinCartAnimationWithRect:(CGRect)rect
{
_endPoint_x = 35;
_endPoint_y = Screen_height - 35;
CGFloat startX = rect.origin.x;
CGFloat startY = rect.origin.y;
_path= [UIBezierPath bezierPath];
[_path moveToPoint:CGPointMake(startX, startY)];
//三点曲线
[_path addCurveToPoint:CGPointMake(_endPoint_x, _endPoint_y)
controlPoint1:CGPointMake(startX, startY)
controlPoint2:CGPointMake(startX - 180, startY - 200)];
_dotLayer = [CALayer layer];
_dotLayer.backgroundColor = [UIColor purpleColor].CGColor;
_dotLayer.frame = CGRectMake(0, 0, 20, 20);
_dotLayer.cornerRadius = 5;
[self.view.layer addSublayer:_dotLayer];
[self groupAnimation];
}
#pragma mark - 组合动画
-(void)groupAnimation
{
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path = _path.CGPath;
animation.rotationMode = kCAAnimationRotateAuto;
CABasicAnimation *alphaAnimation = [CABasicAnimation animationWithKeyPath:@"alpha"];
alphaAnimation.ration = 0.5f;
alphaAnimation.fromValue = [NSNumber numberWithFloat:1.0];
alphaAnimation.toValue = [NSNumber numberWithFloat:0.1];
alphaAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
CAAnimationGroup *groups = [CAAnimationGroup animation];
groups.animations = @[animation,alphaAnimation];
groups.ration = 0.8f;
groups.removedOnCompletion = NO;
groups.fillMode = kCAFillModeForwards;
groups.delegate = self;
[groups setValue:@"groupsAnimation" forKey:@"animationName"];
[_dotLayer addAnimation:groups forKey:nil];
[self performSelector:@selector(removeFromLayer:) withObject:_dotLayer afterDelay:0.8f];
}
- (void)removeFromLayer:(CALayer *)layerAnimation{
[layerAnimation removeFromSuperlayer];
}
#pragma mark - CAAnimationDelegate
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if ([[anim valueForKey:@"animationName"]isEqualToString:@"groupsAnimation"]) {
CABasicAnimation *shakeAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shakeAnimation.ration = 0.25f;
shakeAnimation.fromValue = [NSNumber numberWithFloat:0.9];
shakeAnimation.toValue = [NSNumber numberWithFloat:1];
shakeAnimation.autoreverses = YES;
// 这里是下方的自定义View上面 放的btn. 自己随便定义一个 0.-
[_shopCartView.btnBackImg.layer addAnimation:shakeAnimation forKey:nil];
}
『伍』 开发,仿美团,饿了么外卖订餐系统
一句话总结:羊毛出在羊身上!餐饮老板们迟早会很痛苦的,只有做自己的点餐渠道才是出路!
『陆』 实现美团,饿了么购物车效果
网络啥时候在外卖方面赶上饿了么和美团了?这三大是你并列的么?
『柒』 仿美团类的外卖订餐软件有哪些
这个不叫仿,商业模式是这样子
『捌』 外卖人8.4源码 订餐系统 微信订餐源码 仿美团饿了么 外卖安卓APP
半小时微信自助服务系统让消费者感觉速度更快、更简单,订单更多、商回家经营更答省钱、营销效率高等优点,已被各种类型商户(如:西餐厅、火锅店、外卖盒饭、便利店,水果店,面包店、甜点店等等)使用。近日,半小时微信餐厅订餐服务系统发布3.0最新版本,对此之前2.0版本中的功能进行整合, 3.0版本主要更新两大功能,1:新增会员卡功能,为商家发放会员卡,同时消费者可通过消费进行积分,享受不同的活动内容,商家还可以发优惠券,让消费者享受更多优惠。 2:改版系统前台操作界面,新版界面更注重消费者视觉,以及操作习惯体验,下单模式多层次,多模块,更好的服务消费者。