现在点餐小程序成为餐饮店的标配,顾客只要扫码,即可进入小程序点餐。顾客付款后,后厨自动打印出订单并开始制作。整个过程非常方便流畅,甚至还可以免去收银(或服务)人员。那么,这种餐饮小程序要如何搭建呢?找小程序开发商还是商家自己搭建呢?
外卖行业近几年发展迅猛,微信平台也成为其中的一个主力军,小程序的横空出世,让不少微信外卖平台加入其中,纷纷开发了自己的餐厅点餐小程序
餐厅点餐小程序功能非常方便,对于用户来讲,操作如下:
1.打开自己的微信账号,选择【小程序】
2.点击【小程序】进入,进入餐厅点餐小程序系统
3.选择这家餐厅之后,进入微信授权界面,选择允许
4.进入店内之后,选择外卖字样,可以看到这家店的详细地址和详细联系电话以及营业时间,还有商家的环境
5.选择外卖的界面之后,在左边有一个列表是大分类:如热销、优惠、套餐、主食、配菜、饮料等等
6.点击选择规格之后进入选项中口味的选择:选择好之后【加入购物车】
7.选择【加入购物车】,如何没有其他需要点餐的就可以直接点击【选好了】,还需要选择其他外卖的话都一致加入购物车
8.最后在想【选好了】点击进入【订单提交】,添加好收货地址之后、收货人、联系电话进去付款即可。可选择填写备注,比如口味、偏好等
微信小程序餐厅点餐界面截图,所有数据都是通过后台设置上传。
菜单界面代码逻辑
<view class="section">
<!-- 左侧类型 -->
<scroll-view scroll-y="true" class="left">
<view wx:for="{{types}}" wx:key="typeId" data-type-id="{{item.typeId}}" bindtap="tapType" class="{{item.typeId == currType ? 'active' : ''}}" style="font-size:33rpx">
{{item.name}}
</view>
</scroll-view>
<!-- 右侧数据 -->
<scroll-view scroll-y="true" class="right">
<view class="typeTree">
<view class="brand" wx:for="{{typeTree}}" wx:for-item="data">
<navigator url="{{data.pic}}" wx:key="typeId" class="item">
<image src="{{data.pic}}"></image>
<text>{{data.name}}</text>
</navigator>
</view>
</view>
</scroll-view>
</view>
// import ApiList from '../../config/api';
// import request from '../../utils/request.js';
Page({
data: {
// types: null,
typeTree: {}, // 数据缓存
currType: 0 ,
// 当前类型
"types": [
{
"name":"热销产品",
"typeId":"0",
},
{
"name":"人气产品",
"typeId":"1",
},
{
"name":"店家推荐",
"typeId":"2",
},
],
"typeTree": [
],
},
onLoad (){
var me = this;
request({
url: ApiList.goodsType,
success: function (res) {
me.setData({
types: res.data.data
});
}
});
this.getTypeTree(this.data.currType);
},
tapType(e){
const currType = e.currentTarget.dataset.typeId;
this.setData({
currType: currType
});
this.getTypeTree(currType);
},
// 加载二级类目数据
getTypeTree (currType) {
const me = this, _data = me.data;
if(!_data.typeTree[currType]){
request({
url: ApiList.goodsTypeTree,
data: {typeId: +currType},
success: function (res) {
_data.typeTree[currType] = res.data.data;
me.setData({
typeTree: _data.typeTree
});
}
});
}
}
})
管理后台逻辑代码
//***************************
// 产品分类
//***************************
public function index(){
$flavor = M('user')->where('id='.intval($_REQUEST['uid']))->field('flavor')->find();
$list = M('pro_cat')->where('del=0')->field('id,name')->select();
$type = $_REQUEST['type'];
if($type == 'tuijian' && ($flavor['flavor'] == '' || !isset($flavor['flavor']))){
echo json_encode(array('status'=>0,'err'=>'请先去选择自己喜欢的口味吧'));
exit();
}
$plist = array();
foreach ($list as $k => $val) {
$pro = M('product')->where('del=0 AND cid='.intval($val['id']))->field('id,name,price_yh,photo_x,salenum,renqi,flavor')->select();
foreach ($pro as $key => $v) {
if($type != 'tuijian' || $this->is_same_flavor($flavor['flavor'],$v)) {
$pro[$key]['photo_x'] = __DATAURL__ . $v['photo_x'];
$pro[$key]['cartnum'] = 0;
$pro[$key]['cartid'] = 0;
$pro[$key]['flavor'] = $this->get_flavor($v['flavor']);
if (intval($_REQUEST['uid'])) {
$cartinfo = M('shopping_char')->where('uid=' . intval($_REQUEST['uid']) . ' AND pid=' . intval($v['id']))->find();
$pro[$key]['cartnum'] = intval($cartinfo['num']);
$pro[$key]['cartid'] = intval($cartinfo['id']);
}
}else{
unset($pro[$key]);
}
}
if(sizeof($pro) > 0){
$list[$k]['list'] = $pro;
array_push($plist,$list[$k]);
}
}
if(sizeof($plist) <= 0 ){
echo json_encode(array('status'=>0,'err'=>'没有适合您口味的菜可推荐!'));
exit();
}
$cartnum = 0;
$cartmoney = 0;
$cartlist = array();
if (intval($_REQUEST['uid'])) {
$cartlist = M('shopping_char')->where('uid='.intval($_REQUEST['uid']))->select();
if ($cartlist) {
foreach ($cartlist as $k => $v) {
$cartlist[$k]['name'] = M('product')->where('id='.intval($v['pid']))->getField('name');
$cartlist[$k]['photo'] = __DATAURL__.M('product')->where('id='.intval($v['pid']))->getField('photo_x');
$cartmoney += floatval($v['price']*$v['num']);
$cartnum += intval($v['num']);
}
}
}
$fee = M('program')->where('1=1')->getField('yunfei');
//json加密输出
echo json_encode(array('status'=>1,'list'=>$plist,'cartlist'=>$cartlist,'cartnum'=>$cartnum,'cartmoney'=>sprintf("%.2f",$cartmoney),'fee'=>floatval($fee)));
exit();
}
作者:云诺说
来源:简书