外賣(mài)行業(yè)近幾年發(fā)展迅猛婉徘,微信平臺(tái)也成為其中的一個(gè)主力軍捌议,小程序的橫空出世,讓不少微信外賣(mài)平臺(tái)加入其中嚼黔,紛紛開(kāi)發(fā)了自己的餐廳點(diǎn)餐小程序
餐廳點(diǎn)餐小程序功能非常方便细层,對(duì)于用戶(hù)來(lái)講,操作如下:
1.打開(kāi)自己的微信賬號(hào)唬涧,選擇【小程序】
2.點(diǎn)擊【小程序】進(jìn)入疫赎,進(jìn)入餐廳點(diǎn)餐小程序系統(tǒng)
3.選擇這家餐廳之后,進(jìn)入微信授權(quán)界面碎节,選擇允許
4.進(jìn)入店內(nèi)之后捧搞,選擇外賣(mài)字樣,可以看到這家店的詳細(xì)地址和詳細(xì)聯(lián)系電話以及營(yíng)業(yè)時(shí)間,還有商家的環(huán)境
5.選擇外賣(mài)的界面之后胎撇,在左邊有一個(gè)列表是大分類(lèi):如熱銷(xiāo)介粘、優(yōu)惠、套餐晚树、主食姻采、配菜、飲料等等
6.點(diǎn)擊選擇規(guī)格之后進(jìn)入選項(xiàng)中口味的選擇:選擇好之后【加入購(gòu)物車(chē)】
7.選擇【加入購(gòu)物車(chē)】爵憎,如何沒(méi)有其他需要點(diǎn)餐的就可以直接點(diǎn)擊【選好了】慨亲,還需要選擇其他外賣(mài)的話都一致加入購(gòu)物車(chē)
8.最后在想【選好了】點(diǎn)擊進(jìn)入【訂單提交】,添加好收貨地址之后宝鼓、收貨人刑棵、聯(lián)系電話進(jìn)去付款即可∮拚。可選擇填寫(xiě)備注蛉签,比如口味、偏好等
微信小程序餐廳點(diǎn)餐界面截圖茂附,所有數(shù)據(jù)都是通過(guò)后臺(tái)設(shè)置上傳正蛙。
菜單界面代碼邏輯
<view class="section">
<!-- 左側(cè)類(lèi)型 -->
<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>
<!-- 右側(cè)數(shù)據(jù) -->
<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: {}, // 數(shù)據(jù)緩存
currType: 0 ,
// 當(dāng)前類(lèi)型
"types": [
{
"name":"熱銷(xiāo)產(chǎn)品",
"typeId":"0",
},
{
"name":"人氣產(chǎn)品",
"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);
},
// 加載二級(jí)類(lèi)目數(shù)據(jù)
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
});
}
});
}
}
})
管理后臺(tái)邏輯代碼
//***************************
// 產(chǎn)品分類(lèi)
//***************************
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'=>'請(qǐng)先去選擇自己喜歡的口味吧'));
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'=>'沒(méi)有適合您口味的菜可推薦!'));
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();
}
需要可以加微信(LGY178888)了解下营曼!