代客下单更新

This commit is contained in:
YeMingfei666 2024-09-29 16:13:10 +08:00
parent eea3e1e010
commit 74c6237037
11 changed files with 130 additions and 2186 deletions

View File

@ -91,7 +91,10 @@
uni.navigateBack()
}, 100)
}
let searchValue=ref('')
function search(){
}
function chooseTable(index, item) {
if (item.status == 'closed') {
return uni.showToast({
@ -187,7 +190,8 @@
.circle {
background: #FFFFFF;
width: 18px;
height: 18px;
&.active {
background-color: $my-main-color;
border-color: $my-main-color;

View File

@ -65,7 +65,7 @@
function chooseUser(index,item){
if(index===undefined||item===undefined){
nouser.value=true
return emitChooser()
return emitChooser({id:''})
}
else{
list[index].checked=true
@ -76,7 +76,7 @@
const query=reactive({
page:0,
name:'',
size:10
size:300
})
const list=reactive([])
async function getUser(){

View File

@ -149,7 +149,7 @@
</view>
<scroll-view scroll-x="true" v-if="index==goods.sel">
<view class="u-m-t-32 u-flex no-wrap">
<view class="u-m-t-32 u-flex no-wrap u-p-b-12">
<!-- <view class="u-flex u-m-r-20 u-m-b-20">
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
</view> -->
@ -175,7 +175,7 @@
</view>
</view>
<view class="u-flex u-row-between u-m-t-30 u-p-b-34 border-bottom">
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 border-bottom">
<view>
<text v-if="eatTypes.active=='takeout'">包装费</text>
<text v-else>桌位费</text>
@ -492,7 +492,7 @@
console.log(res);
if ($shop.value.registerType == 'munchies') {
//
return go.to('PAGES_CRESATE_ORDER_PAY', {
return go.to('PAGES_ORDER_PAY', {
orderId: res.id
})
} else {
@ -519,6 +519,7 @@
}
onLoad((opt) => {
console.log('opt');
console.log(opt);
Object.assign(option, opt)
if (opt) {

File diff suppressed because it is too large Load Diff

View File

@ -120,10 +120,10 @@
if(props.data.length<=0){
return infoBox.showToast('还没有选择商品')
}
const {tableId,name,maxCapacity,status}=props.table
go.to('PAGES_CONFIRM_ORDER',{
...props.user,
masterId:props.masterId,
...props.table,
tableId,name,maxCapacity,status
})
}
@ -227,12 +227,9 @@
.car {
padding: 0 28rpx;
position: relative;
left: 0;
right: 0;
background-color: #fff;
padding-top: 10rpx;
bottom: 0;
padding-bottom: calc(1px + env(safe-area-inset-bottom));
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
/* #ifdef H5 */
padding-bottom: 68rpx;

View File

@ -53,6 +53,11 @@
index: {
type: Number,
},
isSeatFee:{
//
type:Boolean,
default:false
},
data: {
type: Object,
default: () => {

View File

@ -40,7 +40,7 @@
</view>
</view>
<view class="u-m-t-10">
<my-button @tap="close" type="cancel" v-if="isAllDisabled||!goods.isGrounding"><view class="color-999">已下架</view></my-button>
<my-button @tap="close" type="cancel" v-if="isAllDisabled||!goods.isGrounding"><view class="color-999">已下架/售罄</view></my-button>
<my-button @tap="confirm" v-else>添加</my-button>
</view>
</view>

View File

@ -1,618 +0,0 @@
<template>
<view class="u-wrap">
<view class="top bg-fff w-full">
<view class="u-flex u-row-between choose-user" @tap="chooseUser">
<view>
<view v-if="!user">选择用户</view>
<view class="u-flex" v-else>
<image class="headeimg" src="@/static/uni.png" mode=""></image>
<view class="u-m-l-20">{{user.name}}</view>
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'永久会员':'' }}</view>
</view>
</view>
<view class="u-flex">
<uni-icons type="right" size="20" color="#999"></uni-icons>
</view>
</view>
<view class="search u-flex u-col-center ">
<view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
:focus="true" v-model="searchValue">
</uni-search-bar>
</view>
<view class="u-flex">
<image src="/pagesCreateOrder/static/images/icon-saoma.svg" class="icon-saoma" mode=""></image>
</view>
</view>
</view>
<view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop"
:scroll-into-view="data.itemId">
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
</view>
</scroll-view>
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll">
<view class="page-view u-p-l-24">
<view class="lingshi" @tap="toLinshi">
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">临时菜</view>
</view>
<view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar" :key="index">
<view class="item-title">
<text>{{item.name}}</text>
</view>
<view class="item-container">
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
<!-- <image class="item-menu-image" :src="item1.icon" mode=""></image>
<view class="item-menu-name">{{item1.name}}</view> -->
<goods-item @chooseGuige="chooseGuige($event,index)" @add="goodsAdd($event,index)"
@reduce="goodsReduce($event,index)" :index="goodsIndex"
:data="goodsItem"></goods-item>
</view>
<template v-if="item.name==='附加费'">
<view class="addCai" @tap="surchargeShow">
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">自定义添加</view>
</view>
</template>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="bottom w-full">
<my-car :data="cars"></my-car>
</view>
</view>
<!-- 选择规格 -->
<guige-model @confirm="guigeConfirm" ref="chooseGuigeModel" :title="guigeModelData.title"
:data="guigeModelData.chooseGoods.skus"></guige-model>
<!-- 添加附加费 -->
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
</template>
<script setup>
import * as Api from '@/http/yskApi/Instead.js'
import {
$tbShopCategory
} from '@/http/yskApi/goods.js'
import classifyData from './classify.data.js';
import color from '@/commons/color.js';
import guigeModel from './components/guige'
import goodsItem from './components/goods-item'
import mySurcharge from './components/surcharge'
import {
onLoad,
onReady,
onShow,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
onBeforeUnmount,
computed,
reactive,
ref,
nextTick
} from 'vue';
import myCar from './components/car'
import go from '@/commons/utils/go.js';
async function init() {
const {
content
} = await $tbShopCategory({
page: 0,
size: 300
})
const category = content.reduce((prve, cur) => {
prve.push({
...cur,
childrenList: null
});
return [...prve, ...cur.childrenList];
}, []);
console.log(category);
const {records}= await Api.getGoodsLists({
page: 0,
size: 300
})
const goods=records
console.log(goods);
}
//
let user = ref(null)
function watchChooseuser() {
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
user.value = data
console.log(user.value);
})
}
watchChooseuser()
onBeforeUnmount(() => {
})
const surcharge = ref(null)
function surchargeConfirm(e) {
data.tabbar[data.tabbar.length - 1].foods.unshift({
...e,
chooseNumber: 0
})
}
function surchargeShow() {
surcharge.value.open()
}
let searchValue = ref('')
function search() {
}
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
function toLinshi() {
go.to('PAGES_ADD_TEMP_CUISINE')
}
const chooseGuigeModel = ref(null)
const guigeModelData = reactive({
title: '',
chooseGoods: {
item: '',
skus: [{
title: '口味',
skds: [{
title: '麻辣',
id: 1
},
{
title: '中辣',
id: 2
},
{
title: '微辣',
id: 3
},
{
title: '不辣',
id: 4
},
{
title: '三鲜',
id: 5
}
]
},
{
title: '辣度',
skds: [{
title: '麻辣',
id: 1
},
{
title: '中辣',
id: 2
},
{
title: '微辣',
id: 3
},
{
title: '不辣',
id: 4
},
{
title: '三鲜',
id: 5
}
]
},
{
title: '配料',
skds: [{
title: '丸子',
id: 1
},
{
title: '五花肉',
id: 2
},
{
title: '鸡块',
id: 3
},
{
title: '排骨',
id: 4
},
{
title: '火腿',
id: 5
}
]
}
]
}
})
function chooseGuige(foodsindex, index) {
const $goods = data.tabbar[index].foods[foodsindex]
guigeModelData.title = $goods.name
chooseGuigeModel.value.open()
}
function guigeConfirm(e) {
console.log(e);
}
function goodsAdd(foodsindex, index) {
const $goods = data.tabbar[index].foods[foodsindex]
const newval = $goods.chooseNumber + 1
$goods.chooseNumber = newval
let item = cars.find(v => v.id == $goods.id)
if (item) {
item.number += 1
} else {
cars.push({
...$goods,
number: 1
})
}
}
function goodsReduce(foodsindex, index) {
const $goods = data.tabbar[index].foods[foodsindex]
const newval = $goods.chooseNumber - 1
$goods.chooseNumber = newval <= 0 ? 0 : newval
}
const cars = reactive([])
const tabbar = classifyData.map(v => {
return {
...v,
foods: v.foods.map((goods, index) => {
return {
...goods,
chooseNumber: 0,
price: Math.ceil(Math.random() * 100),
isDan: index % 2 === 0
}
})
}
})
tabbar.push({
name: '附加费',
foods: [{
name: "小费",
price: Math.ceil(Math.random() * 10),
chooseNumber: 0,
isDan: true
},
{
name: "打包费",
price: 1,
chooseNumber: 0,
isDan: true
}
]
})
const data = reactive({
scrollTop: 0, //tab
oldScrollTop: 0,
current: 0, //
menuHeight: 0, //
menuItemHeight: 0, // item
itemId: '', // scroll-viewid
tabbar: tabbar,
menuItemPos: [],
arr: [],
scrollRightTop: 0, // scroll-view
timer: null, //
topZhanwei: 136 + 24
})
onReady(() => {
getMenuItemTop()
})
//
async function swichMenu(index) {
if (data.arr.length == 0) {
await getMenuItemTop();
}
if (index == data.current) return;
data.scrollRightTop = data.oldScrollTop;
nextTick(function() {
data.scrollRightTop = data.arr[index] + data.topZhanwei;
data.current = index;
leftMenuStatus(index);
})
}
//
function getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
getElRect(elClass);
}, 10);
return;
}
data[dataVal] = res.height;
resolve();
}).exec();
})
}
//
async function observer() {
tabbar.map((val, index) => {
let observer = uni.createIntersectionObserver(this);
// scroll-viewiditemxxright-box
// .right-box
observer.relativeTo('.right-box', {
top: 0
}).observe('#item' + index, res => {
if (res.intersectionRatio > 0) {
let id = res.id.substring(4);
leftMenuStatus(id);
}
})
})
}
//
async function leftMenuStatus(index) {
data.current = index;
// 0
if (data.menuHeight == 0 || data.menuItemHeight == 0) {
await getElRect('menu-scroll-view', 'menuHeight');
await getElRect('u-tab-item', 'menuItemHeight');
}
// item
data.scrollTop = index * data.menuItemHeight + data.menuItemHeight / 2 - data.menuHeight / 2;
}
// item
function getMenuItemTop() {
new Promise(resolve => {
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// rects[](selectAll)
if (!rects.length) {
setTimeout(() => {
getMenuItemTop();
}, 10);
return;
}
rects.forEach((rect) => {
// rects[0].top()
data.arr.push(rect.top - rects[0].top);
resolve();
})
}).exec()
})
}
//
async function rightScroll(e) {
data.oldScrollTop = e.detail.scrollTop;
if (data.arr.length == 0) {
await getMenuItemTop();
}
if (data.timer) return;
if (!data.menuHeight) {
await getElRect('menu-scroll-view', 'menuHeight');
}
setTimeout(() => { //
data.timer = null;
// scrollHeight
let scrollHeight = e.detail.scrollTop + data.menuHeight / 2 + data.topZhanwei / 2;
for (let i = 0; i < data.arr.length; i++) {
let height1 = data.arr[i];
let height2 = data.arr[i + 1];
// height2
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
leftMenuStatus(i);
return;
}
}
}, 10)
}
onLoad(() => {
init()
})
</script>
<style lang="scss" scoped>
.choose-user {
background: #F9F9F9;
padding: 22rpx 28rpx;
}
.search {
padding-right: 28rpx;
}
.icon-saoma {
margin-left: 20rpx;
width: 34rpx;
height: 32rpx;
}
$u-tips-color: $my-main-color;
$u-primary: $my-main-color;
$u-main-color: $my-main-color;
.u-wrap {
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
display: flex;
flex-direction: column;
}
.headeimg {
width: 60rpx;
height: 60rpx;
}
.u-menu-wrap {
flex: 1;
display: flex;
overflow: hidden;
}
.u-search-inner {
// background-color: rgb(234, 234, 234);
background-color: #fff;
border-radius: 100rpx;
display: flex;
align-items: center;
padding: 10rpx 16rpx;
}
.u-search-text {
font-size: 26rpx;
color: $u-tips-color;
margin-left: 10rpx;
}
.u-tab-view {
width: 178rpx;
height: 100%;
}
.u-tab-item {
height: 110rpx;
background: #f6f6f6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #444;
font-weight: 400;
line-height: 1;
}
.u-tab-item-active {
position: relative;
color: #000;
font-size: 30rpx;
font-weight: 600;
background: #fff;
}
.u-tab-item-active::before {
content: "";
position: absolute;
border-left: 4px solid $u-primary;
left: 0;
top: 0;
bottom: 0;
}
.u-tab-view {
height: 100%;
}
.addCai {
width: 250rpx;
height: 272rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
box-sizing: border-box;
border: 4rpx solid #90BDF6;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.lingshi {
width: 250rpx;
height: 136px;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 4rpx solid #90BDF6;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 24px;
}
.right-box {
width: 572rpx;
// background-color: rgb(250, 250, 250);
background-color: rgb(255, 255, 255);
}
.page-view {
// padding: 24rpx 28rpx 24rpx 24rpx;
}
.class-item {
margin-bottom: 30rpx;
background-color: #fff;
border-radius: 8rpx;
}
.class-item:last-child {
min-height: 100vh;
}
.item-title {
font-size: 26rpx;
color: $u-main-color;
font-weight: bold;
}
.item-menu-name {
font-weight: normal;
font-size: 24rpx;
color: $u-main-color;
}
.item-container {
display: flex;
flex-wrap: wrap;
margin-top: 24rpx;
}
.thumb-box {
margin-right: 24rpx;
margin-bottom: 24rpx;
}
.item-menu-image {
width: 120rpx;
height: 120rpx;
}
</style>

View File

@ -1,407 +0,0 @@
<template>
<view class="u-flex u-flex-col u-row-between page">
<view class="top bg-fff w-full">
<view class="u-flex u-row-between choose-user" @tap="chooseUser">
<view>选择用户</view>
<view class="u-flex">
<uni-icons type="right" size="20" color="#999"></uni-icons>
</view>
</view>
<view class="search u-flex u-col-center ">
<view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
:focus="true" v-model="searchValue">
</uni-search-bar>
</view>
<view class="u-flex">
<image src="/pagesCreateOrder/static/images/icon-saoma.svg" class="icon-saoma" mode=""></image>
</view>
</view>
</view>
<view class="list u-flex w-full u-flex-1">
<view class="category u-flex" :style="computedCatrgoryStyle">
<scroll-view scroll-with-animation class="scroll-view_style menu-scroll-view" :scroll-into-view="category.intoviewId"
scroll-y="true" :scroll-top="category.scrollTop" :style="{height:listHeight+'px'}">
<view>
<view :id="'category'+index" class="item u-tab-item" @tap="changeCategoryActive(index)"
:class="{active:index==category.active}" v-for="(item,index) in category.list" :key="index">
{{item.title}}
</view>
</view>
</scroll-view>
</view>
<view class="goods-list u-flex-1 u-p-l-24">
<scroll-view @scroll="goodsScroll" scroll-with-animation class="scroll-view_style"
:scroll-top="goods.scrollTop" :scroll-into-view="goods.intoviewId" scroll-y="true"
:style="{height:listHeight+'px'}">
<view class="">
<view class="item" :class="{active:index==category.active}" v-for="(item,index) in goods.list"
:key="index">
<view class="color-main">{{item.title}}</view>
<view class="u-m-t-24 u-m-b-24 u-flex u-flex-wrap">
<view :id="'goods'+index" class="u-m-r-24 u-m-b-24 class-item"
v-for="(goodsItem,goodsIndex) in item.list" :key="goodsIndex">
<goods-item @chooseGuige="chooseGuige($event,index)" @add="goodsAdd($event,index)" @reduce="goodsReduce($event,index)"
:index="goodsIndex" :data="goodsItem"></goods-item>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view class="bottom w-full">
<my-car :data="cars"></my-car>
</view>
<!-- 选择规格 -->
<my-model ref="guigeModel" :title="guigeModelData.title">
<template #desc>
<view v-for="(item,index) in guigeModelData.chooseGoods.skus" :key="index">
</view>
</template>
</my-model>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import myModel from '@/components/my-components/my-model.vue'
import {
computed,
reactive,
ref,nextTick
} from 'vue';
import myCar from './components/car'
import goodsItem from './components/goods-item'
const guigeModel=ref(null)
const guigeModelData=reactive({
title:'',
chooseGoods:{
skus:[{
title:'',
skds:[]
}]
}
})
function chooseGuige(listindex, index){
const $goods=goods.list[index].list[listindex]
guigeModelData.title=$goods.title
guigeModel.value.open()
}
let searchValue = ref('')
const categoryArr = new Array(20).fill(1).map((v, index) => {
if (index % 2 === 0) {
return {
title: '围炉茶煮'
}
} else {
return {
title: '主食'
}
}
})
let pageHeight = ref(0)
const category = reactive({
list: categoryArr,
active: 0,
height: 0,
top: 0,
bottom: 0,
statusbarHeight: 0,
intoviewId: '',
scrollTop: 0
})
const goodslist = new Array(20).fill(1).map((v, index) => {
if (index % 2 === 0) {
return {
title: '围炉茶煮' + index,
list: new Array(10).fill(1).map((g, gIndex) => {
return {
id:gIndex,
title: '拿铁咖啡' + gIndex,
price: 28,
isDan: gIndex % 2 == 0,
chooseNumber: 0
}
})
}
} else {
return {
title: '主食' + index,
list: new Array(10).fill(1).map((g, gIndex) => {
return {
id:10000+gIndex,
title: '意大利面' + gIndex,
price: 28,
isDan: gIndex % 2 == 0,
chooseNumber: 0
}
})
}
}
})
let goods = reactive({
intoviewId: '',
scrollTop: 0,
list: goodslist
})
const cars=reactive([])
function chooseUser() {
goods.intoviewId = 'goods' + 5
}
function goodsAdd(listindex, index) {
const $goods=goods.list[index].list[listindex]
const newval =$goods.chooseNumber + 1
$goods.chooseNumber = newval
let item=cars.find(v=>v.id==$goods.id)
if(item){
item.number+=1
}else{
cars.push({...$goods,number:1})
}
}
function goodsReduce(listindex, index) {
const $goods = goods.list[index].list[listindex]
const newval = $goods.chooseNumber - 1
$goods.chooseNumber = newval <= 0 ? 0 : newval
}
async function changeCategoryActive(index) {
if(rightArr.length == 0) {
await getMenuItemTop();
}
if (index == category.active) return;
goods.scrollTop =oldScrollTop;
nextTick (function(){
goods.scrollTop = rightArr[index];
category.active = index;
leftMenuStatus(index);
})
}
let oldScrollTop=0;
let rightArr=[]
// item
function getMenuItemTop() {
new Promise(resolve => {
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// rects[](selectAll)
if(!rects.length) {
setTimeout(() => {
getMenuItemTop();
}, 10);
return ;
}
rects.forEach((rect) => {
// rects[0].top()
rightArr.push(rect.top - rects[0].top);
resolve();
})
}).exec()
})
}
let timer=null
let menuHeight=0 //
//
function getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
getElRect(elClass);
}, 10);
return;
}
if(dataVal==='menuHeight'){
menuHeight=res.height
}
if(dataVal==='menuItemHeight'){
menuItemHeight=res.height
}
resolve();
}).exec();
})
}
let menuItemHeight=0
//
async function leftMenuStatus(index) {
category.active = index;
// 0
if (menuHeight == 0 || menuItemHeight == 0) {
await getElRect('menu-scroll-view', 'menuHeight');
await getElRect('u-tab-item', 'menuItemHeight');
}
// item
category.scrollTop = index * menuItemHeight + menuItemHeight / 2 - menuHeight / 2;
}
async function goodsScroll(e) {
oldScrollTop = e.detail.scrollTop;
if (rightArr.length == 0) {
await getMenuItemTop();
}
if (timer) return;
if (!menuHeight) {
await getElRect('menu-scroll-view', 'menuHeight');
}
setTimeout(() => { //
timer = null;
// scrollHeight
let scrollHeight = e.detail.scrollTop + menuHeight / 2;
for (let i = 0; i < rightArr.length; i++) {
let height1 = rightArr[i];
let height2 = rightArr[i + 1];
// height2
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
leftMenuStatus(i);
return;
}
}
}, 10)
}
onReady(() => {
initCategory()
getMenuItemTop()
})
function initCategory() {
uni.getSystemInfo({
success: (res) => {
pageHeight.value = res.windowHeight
const screenHeight = res.windowHeight; //
const topinfo = uni.createSelectorQuery().select(".top");
const bottominfo = uni.createSelectorQuery().select(".bottom");
topinfo.boundingClientRect(function(data) { //data -
category.top = data.height + category.statusbarHeight
}).exec()
bottominfo.boundingClientRect(function(data) { //data -
category.bottom = data.height
}).exec()
}
});
}
const listHeight = computed(() => {
return pageHeight.value - category.bottom - category.top
})
const computedCatrgoryStyle = computed(() => {
return `
top:${category.top}px;
bottom:${category.bottom}px;
`
})
function search() {
}
</script>
<style lang="scss" scoped>
/* 针对微信小程序的滚动条样式 */
::v-deep.scroll-view_style::-webkit-scrollbar {
width: 8rpx;
}
::v-deep.scroll-view_style::-webkit-scrollbar-thumb {
background: #90BDF6;
border-radius: 5px;
/* 设置滚动条圆角 */
}
::v-deep.scroll-view_style::-webkit-scrollbar-track {
background-color: #f1f1f1;
/* 设置滚动条轨道颜色 */
}
.page {
height: calc(100vh - 44px);
}
.goods-list {
box-sizing: border-box;
width: 572rpx;
}
.category {
box-sizing: border-box;
// position: fixed;
width: 178rpx;
// left: 0;
.item {
padding: 36rpx 32rpx;
position: relative;
background: #F9F9F9;
transition: all .2s ease-in-out;
&.active {
background: #fff;
}
&.active::after {
background-color: $my-main-color;
}
&::after {
content: '';
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 8rpx;
}
}
}
.choose-user {
background: #F9F9F9;
padding: 22rpx 28rpx;
}
.search {
padding-right: 28rpx;
}
.icon-saoma {
margin-left: 20rpx;
width: 34rpx;
height: 32rpx;
}
</style>

View File

@ -35,6 +35,7 @@
<view class="search u-flex u-col-center ">
<view class="u-flex-1">
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
@clear="clearSearch"
v-model="searchValue">
</uni-search-bar>
</view>
@ -43,43 +44,58 @@
</view>
</view>
</view>
<view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop"
:scroll-into-view="data.itemId">
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
</view>
</scroll-view>
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll">
<view class="page-view u-p-l-24">
<view class="lingshi" @tap="toLinshi">
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">临时菜</view>
<template v-if="!isSearch">
<view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop"
:scroll-into-view="data.itemId">
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
</view>
<view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar" :key="index">
<view class="item-title">
<text>{{item.name}}</text>
</view>
<view class="item-container">
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
<goods-item @chooseGuige="chooseGuige($event,index)"
@add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)"
:index="goodsIndex" :data="goodsItem"></goods-item>
</view>
<template v-if="item.name==='附加费'">
<view class="addCai" @tap="surchargeShow">
</scroll-view>
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll">
<view class="page-view u-p-l-24">
<view class="list-tight-top">
<template v-if="lingshi.show">
<view id="lingshi" class="lingshi" @tap="toLinshi" >
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">自定义添加</view>
<view class="u-m-t-24 color-main">临时菜</view>
</view>
</template>
<template v-else>
<view style="height: 24px;"></view>
</template>
</view>
<view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar" :key="index">
<view class="item-title">
<text>{{item.name}}</text>
</view>
<view class="item-container">
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
<goods-item @chooseGuige="chooseGuige($event,index)"
@add="goodsUpdate($event,index,true)" @reduce="goodsUpdate($event,index,false)"
:index="goodsIndex" :data="goodsItem"></goods-item>
</view>
<!-- <template v-if="item.name==='附加费'">
<view class="addCai" @tap="surchargeShow">
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
<view class="u-m-t-24 color-main">自定义添加</view>
</view>
</template> -->
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</scroll-view>
</view>
</template>
<template v-else>
<view class="u-menu-wrap">
11
</view>
</template>
<view class="bottom w-full">
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table"
:data="cars" @clear="onClearCart"></my-car>
@ -102,7 +118,6 @@
$tbShopCategory
} from '@/http/yskApi/goods.js'
import util from './util.js';
import classifyData from './classify.data.js';
import color from '@/commons/color.js';
import guigeModel from './components/guige'
import goodsItem from './components/goods-item'
@ -134,6 +149,17 @@
import {
tbShopInfo
} from '@/http/yskApi/user.js'
//
const lingshi=reactive({
show:false
})
//
const extraFee=reactive({
show:false
})
const cars = reactive([])
const data = reactive({
scrollTop: 0, //tab
@ -172,7 +198,8 @@
}
function setTabBar(category, goods, cars) {
const goodsCategoryMap = goods.reduce((prve, cur) => {
@ -203,22 +230,17 @@
})
}
})
tabbar.push({
name: '附加费',
foods: [{
name: "小费",
price: Math.ceil(Math.random() * 10),
chooseNumber: 0,
isDan: true
},
{
name: "打包费",
price: 1,
chooseNumber: 0,
isDan: true
}
]
})
// tabbar.push({
// name: '',
// foods: [{
// name: "",
// price:$shop.value.tableFee,
// chooseNumber: 0,
// isSeatFee:true,
// isDan: true
// }
// ]
// })
tabbar = tabbar.filter(v => {
return v.foods.length
})
@ -339,7 +361,11 @@
}
}
async function init() {
getTbShopInfo()
const shopInfo = await tbShopInfo()
$shop.value = shopInfo
const useType=data.table.status=='using'?data.table.useType:$returnUseType(shopInfo)
uni.setStorageSync('useType',useType)
console.log(shopInfo);
getTableInfo()
const categoryRes = await getCategory()
const category = categoryRes.content.reduce((prve, cur) => {
@ -397,12 +423,16 @@
let searchValue = ref('')
let isSearch=ref(false)
function search() {
// isSearch.value=true
console.log(searchValue.value);
console.log(data.tabbar );
}
function clearSearch(){
// isSearch.value=false
}
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
@ -673,8 +703,14 @@
carGoods
} : false
}
function canAddGoods(){
return data.table.tableId
}
async function goodsUpdate(foodsindex, index, isAdd) {
if(!canAddGoods()){
return infoBox.showToast('清先选择台桌')
}
const $goods = data.tabbar[index].foods[foodsindex]
if ($goods.isDan) {
//
@ -724,8 +760,11 @@
}
onReady(() => {
getElRect('list-tight-top').then(res=>{
data.topZhanwei=res.height
})
getMenuItemTop()
})
@ -746,7 +785,7 @@
}
//
function getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({
size: true
@ -758,8 +797,11 @@
}, 10);
return;
}
data[dataVal] = res.height;
resolve();
console.log(res);
if(dataVal){
data[dataVal] = res.height;
}
resolve(res);
}).exec();
})
}
@ -1014,7 +1056,6 @@
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 24px;
}
.right-box {

View File

@ -76,7 +76,8 @@
import {
reactive,
onMounted,
watch
watch,
ref
} from 'vue';
import {
onLoad
@ -84,6 +85,7 @@
import * as Api from '@/http/yskApi/Instead.js'
import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '/pagesCreateOrder/components/edit-discount.vue'
import {queryAllShopUser} from '@/http/yskApi/shop-user.js'
const pays = reactive({
list: ['扫码收款', '二维码收款'],
selIndex: 0,
@ -105,7 +107,8 @@
const model = models.get(key)
model && model.open()
}
let user=ref({})
async function getPayType() {
const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList
@ -181,6 +184,11 @@
onLoad((opt) => {
console.log(opt);
Object.assign(order, opt)
if(order.userId){
queryAllShopUser({id:opt.userId}).then(res=>{
user.value=res.content[0]||opt
})
}
})
</script>