代客下单更新
This commit is contained in:
@@ -91,7 +91,10 @@
|
|||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
let searchValue=ref('')
|
||||||
|
function search(){
|
||||||
|
|
||||||
|
}
|
||||||
function chooseTable(index, item) {
|
function chooseTable(index, item) {
|
||||||
if (item.status == 'closed') {
|
if (item.status == 'closed') {
|
||||||
return uni.showToast({
|
return uni.showToast({
|
||||||
@@ -187,7 +190,8 @@
|
|||||||
|
|
||||||
.circle {
|
.circle {
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
&.active {
|
&.active {
|
||||||
background-color: $my-main-color;
|
background-color: $my-main-color;
|
||||||
border-color: $my-main-color;
|
border-color: $my-main-color;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
function chooseUser(index,item){
|
function chooseUser(index,item){
|
||||||
if(index===undefined||item===undefined){
|
if(index===undefined||item===undefined){
|
||||||
nouser.value=true
|
nouser.value=true
|
||||||
return emitChooser()
|
return emitChooser({id:''})
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
list[index].checked=true
|
list[index].checked=true
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
const query=reactive({
|
const query=reactive({
|
||||||
page:0,
|
page:0,
|
||||||
name:'',
|
name:'',
|
||||||
size:10
|
size:300
|
||||||
})
|
})
|
||||||
const list=reactive([])
|
const list=reactive([])
|
||||||
async function getUser(){
|
async function getUser(){
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view scroll-x="true" v-if="index==goods.sel">
|
<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">
|
<!-- <view class="u-flex u-m-r-20 u-m-b-20">
|
||||||
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
|
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
|
||||||
</view> -->
|
</view> -->
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</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>
|
<view>
|
||||||
<text v-if="eatTypes.active=='takeout'">包装费</text>
|
<text v-if="eatTypes.active=='takeout'">包装费</text>
|
||||||
<text v-else>桌位费</text>
|
<text v-else>桌位费</text>
|
||||||
@@ -492,7 +492,7 @@
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
if ($shop.value.registerType == 'munchies') {
|
if ($shop.value.registerType == 'munchies') {
|
||||||
//先付
|
//先付
|
||||||
return go.to('PAGES_CRESATE_ORDER_PAY', {
|
return go.to('PAGES_ORDER_PAY', {
|
||||||
orderId: res.id
|
orderId: res.id
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -519,6 +519,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad((opt) => {
|
onLoad((opt) => {
|
||||||
|
console.log('opt');
|
||||||
console.log(opt);
|
console.log(opt);
|
||||||
Object.assign(option, opt)
|
Object.assign(option, opt)
|
||||||
if (opt) {
|
if (opt) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -120,10 +120,10 @@
|
|||||||
if(props.data.length<=0){
|
if(props.data.length<=0){
|
||||||
return infoBox.showToast('还没有选择商品')
|
return infoBox.showToast('还没有选择商品')
|
||||||
}
|
}
|
||||||
|
const {tableId,name,maxCapacity,status}=props.table
|
||||||
go.to('PAGES_CONFIRM_ORDER',{
|
go.to('PAGES_CONFIRM_ORDER',{
|
||||||
...props.user,
|
|
||||||
masterId:props.masterId,
|
masterId:props.masterId,
|
||||||
...props.table,
|
tableId,name,maxCapacity,status
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,12 +227,9 @@
|
|||||||
.car {
|
.car {
|
||||||
padding: 0 28rpx;
|
padding: 0 28rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding-top: 10rpx;
|
padding-top: 10rpx;
|
||||||
bottom: 0;
|
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
|
||||||
padding-bottom: calc(1px + env(safe-area-inset-bottom));
|
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
padding-bottom: 68rpx;
|
padding-bottom: 68rpx;
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,11 @@
|
|||||||
index: {
|
index: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
isSeatFee:{
|
||||||
|
//是否为餐位费
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-10">
|
<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>
|
<my-button @tap="confirm" v-else>添加</my-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -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-view用于滚动的id
|
|
||||||
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 => {
|
|
||||||
// 如果节点尚未生成,res值为null,循环调用执行
|
|
||||||
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-view的id为itemxx的元素与right-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>
|
|
||||||
@@ -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 => {
|
|
||||||
// 如果节点尚未生成,res值为null,循环调用执行
|
|
||||||
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>
|
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
<view class="search u-flex u-col-center ">
|
<view class="search u-flex u-col-center ">
|
||||||
<view class="u-flex-1">
|
<view class="u-flex-1">
|
||||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
|
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
|
||||||
|
@clear="clearSearch"
|
||||||
v-model="searchValue">
|
v-model="searchValue">
|
||||||
</uni-search-bar>
|
</uni-search-bar>
|
||||||
</view>
|
</view>
|
||||||
@@ -43,43 +44,58 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-menu-wrap">
|
<template v-if="!isSearch">
|
||||||
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop"
|
<view class="u-menu-wrap">
|
||||||
:scroll-into-view="data.itemId">
|
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="data.scrollTop"
|
||||||
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
|
:scroll-into-view="data.itemId">
|
||||||
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
|
<view v-for="(item,index) in data.tabbar" :key="index" class="u-tab-item"
|
||||||
<text class="u-line-1">{{item.name}}</text>
|
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
|
||||||
</view>
|
<text class="u-line-1">{{item.name}}</text>
|
||||||
</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>
|
||||||
<view class="class-item" :id="'item' + index" v-for="(item , index) in data.tabbar" :key="index">
|
</scroll-view>
|
||||||
<view class="item-title">
|
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
|
||||||
<text>{{item.name}}</text>
|
@scroll="rightScroll">
|
||||||
</view>
|
<view class="page-view u-p-l-24">
|
||||||
<view class="item-container">
|
<view class="list-tight-top">
|
||||||
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
|
<template v-if="lingshi.show">
|
||||||
<goods-item @chooseGuige="chooseGuige($event,index)"
|
<view id="lingshi" class="lingshi" @tap="toLinshi" >
|
||||||
@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>
|
<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>
|
</view>
|
||||||
</template>
|
</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>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</scroll-view>
|
</view>
|
||||||
</view>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="u-menu-wrap">
|
||||||
|
11
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<view class="bottom w-full">
|
<view class="bottom w-full">
|
||||||
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table"
|
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId" :table="data.table"
|
||||||
:data="cars" @clear="onClearCart"></my-car>
|
:data="cars" @clear="onClearCart"></my-car>
|
||||||
@@ -102,7 +118,6 @@
|
|||||||
$tbShopCategory
|
$tbShopCategory
|
||||||
} from '@/http/yskApi/goods.js'
|
} from '@/http/yskApi/goods.js'
|
||||||
import util from './util.js';
|
import util from './util.js';
|
||||||
import classifyData from './classify.data.js';
|
|
||||||
import color from '@/commons/color.js';
|
import color from '@/commons/color.js';
|
||||||
import guigeModel from './components/guige'
|
import guigeModel from './components/guige'
|
||||||
import goodsItem from './components/goods-item'
|
import goodsItem from './components/goods-item'
|
||||||
@@ -134,6 +149,17 @@
|
|||||||
import {
|
import {
|
||||||
tbShopInfo
|
tbShopInfo
|
||||||
} from '@/http/yskApi/user.js'
|
} from '@/http/yskApi/user.js'
|
||||||
|
|
||||||
|
//临时菜
|
||||||
|
const lingshi=reactive({
|
||||||
|
show:false
|
||||||
|
})
|
||||||
|
//附加费
|
||||||
|
const extraFee=reactive({
|
||||||
|
show:false
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const cars = reactive([])
|
const cars = reactive([])
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
scrollTop: 0, //tab标题的滚动条位置
|
scrollTop: 0, //tab标题的滚动条位置
|
||||||
@@ -172,7 +198,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setTabBar(category, goods, cars) {
|
function setTabBar(category, goods, cars) {
|
||||||
const goodsCategoryMap = goods.reduce((prve, cur) => {
|
const goodsCategoryMap = goods.reduce((prve, cur) => {
|
||||||
@@ -203,22 +230,17 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
tabbar.push({
|
// tabbar.push({
|
||||||
name: '附加费',
|
// name: '附加费',
|
||||||
foods: [{
|
// foods: [{
|
||||||
name: "小费",
|
// name: "餐位费",
|
||||||
price: Math.ceil(Math.random() * 10),
|
// price:$shop.value.tableFee,
|
||||||
chooseNumber: 0,
|
// chooseNumber: 0,
|
||||||
isDan: true
|
// isSeatFee:true,
|
||||||
},
|
// isDan: true
|
||||||
{
|
// }
|
||||||
name: "打包费",
|
// ]
|
||||||
price: 1,
|
// })
|
||||||
chooseNumber: 0,
|
|
||||||
isDan: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
tabbar = tabbar.filter(v => {
|
tabbar = tabbar.filter(v => {
|
||||||
return v.foods.length
|
return v.foods.length
|
||||||
})
|
})
|
||||||
@@ -339,7 +361,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function init() {
|
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()
|
getTableInfo()
|
||||||
const categoryRes = await getCategory()
|
const categoryRes = await getCategory()
|
||||||
const category = categoryRes.content.reduce((prve, cur) => {
|
const category = categoryRes.content.reduce((prve, cur) => {
|
||||||
@@ -397,12 +423,16 @@
|
|||||||
|
|
||||||
|
|
||||||
let searchValue = ref('')
|
let searchValue = ref('')
|
||||||
|
let isSearch=ref(false)
|
||||||
function search() {
|
function search() {
|
||||||
|
// isSearch.value=true
|
||||||
console.log(searchValue.value);
|
console.log(searchValue.value);
|
||||||
console.log(data.tabbar );
|
console.log(data.tabbar );
|
||||||
}
|
}
|
||||||
|
function clearSearch(){
|
||||||
|
// isSearch.value=false
|
||||||
|
}
|
||||||
|
|
||||||
function chooseUser() {
|
function chooseUser() {
|
||||||
go.to('PAGES_CHOOSE_USER')
|
go.to('PAGES_CHOOSE_USER')
|
||||||
}
|
}
|
||||||
@@ -673,8 +703,14 @@
|
|||||||
carGoods
|
carGoods
|
||||||
} : false
|
} : false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canAddGoods(){
|
||||||
|
return data.table.tableId
|
||||||
|
}
|
||||||
async function goodsUpdate(foodsindex, index, isAdd) {
|
async function goodsUpdate(foodsindex, index, isAdd) {
|
||||||
|
if(!canAddGoods()){
|
||||||
|
return infoBox.showToast('清先选择台桌')
|
||||||
|
}
|
||||||
const $goods = data.tabbar[index].foods[foodsindex]
|
const $goods = data.tabbar[index].foods[foodsindex]
|
||||||
if ($goods.isDan) {
|
if ($goods.isDan) {
|
||||||
//单规格
|
//单规格
|
||||||
@@ -724,8 +760,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onReady(() => {
|
onReady(() => {
|
||||||
|
getElRect('list-tight-top').then(res=>{
|
||||||
|
data.topZhanwei=res.height
|
||||||
|
})
|
||||||
getMenuItemTop()
|
getMenuItemTop()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -746,7 +785,7 @@
|
|||||||
}
|
}
|
||||||
// 获取一个目标元素的高度
|
// 获取一个目标元素的高度
|
||||||
function getElRect(elClass, dataVal) {
|
function getElRect(elClass, dataVal) {
|
||||||
new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const query = uni.createSelectorQuery().in(this);
|
const query = uni.createSelectorQuery().in(this);
|
||||||
query.select('.' + elClass).fields({
|
query.select('.' + elClass).fields({
|
||||||
size: true
|
size: true
|
||||||
@@ -758,8 +797,11 @@
|
|||||||
}, 10);
|
}, 10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data[dataVal] = res.height;
|
console.log(res);
|
||||||
resolve();
|
if(dataVal){
|
||||||
|
data[dataVal] = res.height;
|
||||||
|
}
|
||||||
|
resolve(res);
|
||||||
}).exec();
|
}).exec();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1014,7 +1056,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-box {
|
.right-box {
|
||||||
|
|||||||
@@ -76,7 +76,8 @@
|
|||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
onMounted,
|
onMounted,
|
||||||
watch
|
watch,
|
||||||
|
ref
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import {
|
import {
|
||||||
onLoad
|
onLoad
|
||||||
@@ -84,6 +85,7 @@
|
|||||||
import * as Api from '@/http/yskApi/Instead.js'
|
import * as Api from '@/http/yskApi/Instead.js'
|
||||||
import infoBox from '@/commons/utils/infoBox.js'
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
import editDiscount from '/pagesCreateOrder/components/edit-discount.vue'
|
import editDiscount from '/pagesCreateOrder/components/edit-discount.vue'
|
||||||
|
import {queryAllShopUser} from '@/http/yskApi/shop-user.js'
|
||||||
const pays = reactive({
|
const pays = reactive({
|
||||||
list: ['扫码收款', '二维码收款'],
|
list: ['扫码收款', '二维码收款'],
|
||||||
selIndex: 0,
|
selIndex: 0,
|
||||||
@@ -105,7 +107,8 @@
|
|||||||
const model = models.get(key)
|
const model = models.get(key)
|
||||||
model && model.open()
|
model && model.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let user=ref({})
|
||||||
async function getPayType() {
|
async function getPayType() {
|
||||||
const payTypeList = await Api.$getPayType()
|
const payTypeList = await Api.$getPayType()
|
||||||
pays.payTypes.list = payTypeList
|
pays.payTypes.list = payTypeList
|
||||||
@@ -181,6 +184,11 @@
|
|||||||
onLoad((opt) => {
|
onLoad((opt) => {
|
||||||
console.log(opt);
|
console.log(opt);
|
||||||
Object.assign(order, opt)
|
Object.assign(order, opt)
|
||||||
|
if(order.userId){
|
||||||
|
queryAllShopUser({id:opt.userId}).then(res=>{
|
||||||
|
user.value=res.content[0]||opt
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user