添加绑定码牌

This commit is contained in:
GaoHao 2024-10-24 17:36:28 +08:00
parent 44fc24c52f
commit c232d9ce76
4 changed files with 70 additions and 7 deletions

View File

@ -1,5 +1,6 @@
// 桌台管理
import http from './http.js'
const request=http.request
import $API from '@/http/classApi.js'
import appConfig from '@/config/appConfig.js'
import {
@ -11,4 +12,15 @@ import infoBox from '@/commons/utils/infoBox.js'
export const $tableArea=new $API('/api/tbShopArea',http.req)
/* 台桌 */
export const $table=new $API('/api/tbShopTable',http.req)
/* 绑定 */
// export const $bind=new $API('/api/tbShopTable/bind',http.req)
export function $bind(data) {
return request({
url: "/api/tbShopTable/bind",
method: "post",
data: {
shopId: uni.getStorageSync('shopId'),
...data
}
});
}

View File

@ -39,6 +39,11 @@
<template v-else>
<view class="u-flex u-row-center u-m-t-16">
<template v-if="data.tableId">
<template v-if="data.status =='unbind' ">
<my-button color="#333" :width="200" :height="56" type="default" @click="bind">
绑定码牌
</my-button>
</template>
<template v-if="data.status=='idle'||(data.status=='using'&&!data.orderId) ">
<my-button color="#333" :width="150" :height="56" type="default" @click="diancan">
选择
@ -80,7 +85,7 @@
} from '@/http/yskApi/table.js'
import infoBox from '@/commons/utils/infoBox.js'
const status = $status
const emits = defineEmits(['more', 'update'])
const emits = defineEmits(['more', 'update', 'bind'])
function returnStutasText(key) {
key = returnIsUseing(key)
@ -147,6 +152,10 @@
emits('more')
}
function bind() {
emits('bind',props.data)
}
async function diancan() {
hasPermission('允许下单').then(res=>{

View File

@ -57,7 +57,7 @@
<view class="u-m-t-30 u-flex u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(item,index) in tables.list" :key="index">
<table-item @update="getTable" :areaMap="areaMap" @more="moreShow(item)" :data="item"></table-item>
<table-item @bind="unBind" @update="getTable" :areaMap="areaMap" @more="moreShow(item)" :data="item"></table-item>
</view>
<my-img-empty v-if="tables.hasAjax&&!tables.list.length" tips="未找到相关桌台"></my-img-empty>
</view>
@ -80,7 +80,8 @@
} from '@/commons/table-status.js'
import {
$table,
$tableArea
$tableArea,
$bind
} from '@/http/yskApi/table.js'
import {
objToArrary
@ -111,7 +112,7 @@
import {hasPermission} from '@/commons/utils/hasPermission.js'
const refMoreSheet = ref(null)
const actionSheet = reactive({
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单'],
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单','绑定码牌'],
title: '',
selTable: ''
})
@ -175,10 +176,51 @@
//
const res = await $fun.printOrder(actionSheet.selTable.tableId)
return
}
if (index == 6) {
//
scanCode(item)
// const res = await $fun.printOrder(actionSheet.selTable.tableId)
return
}
infoBox.showToast('待开放,请敬请期待!')
}
function unBind (item) {
scanCode(item)
}
function scanCode(item) {
if ( item.status != 'unbind') {
infoBox.showToast('当前桌台已绑定')
return;
}
uni.scanCode({
onlyFromCamera: true,
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
let params = getQueryString(res.result);
$bind({
"code": params.code,
"id": item.id,
}).then(res => {
getTable()
})
}
});
}
function getQueryString(url) { //
let params = {};
// URL
let reg = /(?:\?|#|&){1}([^=]*)=([^&]*)/g;
url.replace(reg, (match, key, value) => {
params[key] = value;
});
return params;
}
const refTable = ref(null)

View File

@ -1120,7 +1120,7 @@
"iconPath": "static/tabImg/index.png",
"selectedIconPath": "static/tabImg/index-select.png",
"text": "首页"
}
},
{
"pagePath": "pages/user/user",
"iconPath": "static/tabImg/user.png",