『壹』 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:改版系統前台操作界面,新版界面更注重消費者視覺,以及操作習慣體驗,下單模式多層次,多模塊,更好的服務消費者。