first
This commit is contained in:
222
pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue
Normal file
222
pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue
Normal file
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-p-30">
|
||||
<view class="u-font-24">
|
||||
<text class="color-red">*</text>
|
||||
<text class="color-999">将临时菜添加至购物车,不会影响总商品库</text>
|
||||
</view>
|
||||
<view class="form">
|
||||
<uni-forms ref="refform" label-position="top" :model="form" label-align="left" label-width="300"
|
||||
:rules="rules">
|
||||
<uni-forms-item required label="" name="name">
|
||||
<template #label>
|
||||
<view class="u-text-left">
|
||||
<text class="color-333">菜品名称</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border-bottom u-p-t-10 u-p-b-10">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.name"
|
||||
placeholder="填写菜品名称"></uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item required label="" name="category">
|
||||
<template #label>
|
||||
<view class="u-text-left u-m-t-24">
|
||||
<text class="color-333">菜品分类</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<picker @change="categoryChange" :value="categoryCurrent" range-key="name" :range="category">
|
||||
<view class="u-m-t-14 u-p-t-10 u-flex u-row-between border-bottom u-p-b-10 u-relative ">
|
||||
<view class="zhezhao u-absolute position-all" style="z-index: 1;"></view>
|
||||
<!-- <view>
|
||||
<text class="" v-if="form.category!==''">{{category[form.category].name}}</text>
|
||||
<text class="color-999 " v-else>选择分类</text>
|
||||
</view> -->
|
||||
<view class="u-flex-1">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.category"
|
||||
placeholder="选择分类"></uni-easyinput>
|
||||
</view>
|
||||
<uni-icons type="right" size="18" color="#999"></uni-icons>
|
||||
</view>
|
||||
|
||||
</picker>
|
||||
|
||||
</uni-forms-item>
|
||||
|
||||
<uni-forms-item required label="" name="price">
|
||||
<template #label>
|
||||
<view class="u-m-t-24 u-text-left">
|
||||
<text class="color-333">价格(元)</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border-bottom u-p-t-10 u-p-b-10">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.price" placeholder="输入价格"
|
||||
type="digit"></uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item required label="" name="unit">
|
||||
<template #label>
|
||||
<view class="u-text-left u-m-t-24">
|
||||
<text class="color-333">单位</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<picker @change="unitChange" :value="units.current" range-key="name" :range="units.list">
|
||||
<view class="u-m-t-14 u-p-t-10 u-flex u-row-between border-bottom u-p-b-10 u-relative ">
|
||||
<view class="zhezhao u-absolute position-all" style="z-index: 1;"></view>
|
||||
<view class="u-flex-1">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.unit"
|
||||
placeholder="选择单位"></uni-easyinput>
|
||||
</view>
|
||||
<uni-icons type="right" size="18" color="#999"></uni-icons>
|
||||
</view>
|
||||
|
||||
</picker>
|
||||
|
||||
</uni-forms-item>
|
||||
<uni-forms-item required label="" name="price">
|
||||
<template #label>
|
||||
<view class="u-m-t-24 u-text-left">
|
||||
<text class="color-333">下单数量</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border-bottom u-p-t-10 u-p-b-10">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.number" placeholder="填写数量"
|
||||
type="digit"></uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="fixed-b">
|
||||
<my-button shape="circle" @tap="submit">加入购物车</my-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import myButton from '../../components/my-components/my-button';
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
const units = reactive({
|
||||
list: [{
|
||||
name: '件',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: '杯',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '个',
|
||||
value: 3
|
||||
}
|
||||
],
|
||||
current:''
|
||||
})
|
||||
const category = reactive([{
|
||||
name: '分类1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: '分类2',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '分类3',
|
||||
value: 3
|
||||
}
|
||||
])
|
||||
let categoryCurrent = ref('')
|
||||
|
||||
function categoryChange(e) {
|
||||
console.log(e);
|
||||
categoryCurrent.value = e.detail.value
|
||||
form.category = category[e.detail.value].name
|
||||
}
|
||||
function unitChange(e){
|
||||
units.current = e.detail.value
|
||||
form.unit = units.list[e.detail.value].name
|
||||
}
|
||||
|
||||
const refform = ref(null)
|
||||
const form = reactive({
|
||||
name: '',
|
||||
category: '',
|
||||
price: 0,
|
||||
unit:'',
|
||||
number:0
|
||||
})
|
||||
// 校验规则
|
||||
const rules = {
|
||||
name: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '菜品名称不能为空'
|
||||
}]
|
||||
},
|
||||
category: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请选择菜品分类'
|
||||
}]
|
||||
},
|
||||
price: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请输入价格'
|
||||
}]
|
||||
},
|
||||
unit: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请选择单位'
|
||||
}]
|
||||
},
|
||||
price: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请填写下单数量'
|
||||
}]
|
||||
},
|
||||
}
|
||||
|
||||
function submit() {
|
||||
refform.value.validate(res => {
|
||||
console.log(res)
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.form {
|
||||
margin-top: 32rpx;
|
||||
background-color: #fff;
|
||||
padding: 32rpx 24rpx 32rpx 24rpx;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
// background-color: transparent;
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item {
|
||||
align-items: inherit;
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item__error {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fixed-b {
|
||||
position: fixed;
|
||||
left: 100rpx;
|
||||
right: 100rpx;
|
||||
bottom: 100rpx;
|
||||
}
|
||||
</style>
|
||||
259
pagesCreateOrder/choose-table/choose-table.vue
Normal file
259
pagesCreateOrder/choose-table/choose-table.vue
Normal file
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<view class="page-gray">
|
||||
<view class="bg-fff">
|
||||
<view class="search bg-fff 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>
|
||||
<picker @change="areaChange" range-key="name" :value="area.defaultCateIndex" :range="area.list">
|
||||
<view class="u-flex u-row-between area">
|
||||
<view class="color-333">桌台类型:<text v-if="area.sel">{{area.sel.name}}</text> <text
|
||||
v-else>全部</text> </view>
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list ">
|
||||
<view class="u-m-t-32 bg-fff box bg-fff">
|
||||
<view class="u-flex item u-row-between" v-for="(item,index) in tables.list" :key="index"
|
||||
@tap="chooseTable(index,item)">
|
||||
<view class="u-flex">
|
||||
<view class="">
|
||||
<view class="u-flex">
|
||||
<view>{{item.name}}</view>
|
||||
<view class="line"></view>
|
||||
<view>{{''}}</view>
|
||||
</view>
|
||||
<view class="color-999 u-font-24 u-m-t-12">
|
||||
<text
|
||||
:style="{color:returnStutasColor(item.status)}">{{returnStutasText(item.status)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="my-radio u-font-28 u-flex color-333">
|
||||
<view class="circle u-flex u-row-center" :class="{active:index==tables.selIndex}">
|
||||
<uni-icons type="checkmarkempty" :size="16" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
$table,
|
||||
$tableArea
|
||||
} from '@/http/yskApi/table.js'
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import {
|
||||
$status
|
||||
} from '@/commons/table-status.js'
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
let nouser = ref(false)
|
||||
|
||||
function returnStutasText(key) {
|
||||
const item = $status[key]
|
||||
return item ? item.label : ''
|
||||
}
|
||||
|
||||
function returnStutasColor(key) {
|
||||
// if(key=='using'){
|
||||
// return 'rgb(250,85,85)'
|
||||
// }else{
|
||||
// return ''
|
||||
// }
|
||||
const item = $status[key]
|
||||
return item ? item.type : ''
|
||||
}
|
||||
|
||||
function emitChooeTable(data) {
|
||||
uni.$emit('choose-table', data)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function chooseTable(index, item) {
|
||||
if (item.status == 'closed') {
|
||||
return uni.showToast({
|
||||
title: '该桌台已关闭!',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (index === undefined || item === undefined) {
|
||||
nouser.value = true
|
||||
return emitChooeTable()
|
||||
} else {
|
||||
tables.selIndex=index
|
||||
emitChooeTable(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分类
|
||||
const area = reactive({
|
||||
list: [{
|
||||
name: '全部'
|
||||
}],
|
||||
defaultCateIndex: 0,
|
||||
sel: ''
|
||||
})
|
||||
|
||||
function areaChange(e) {
|
||||
area.defaultCateIndex = e.detail.value
|
||||
area.sel = area.list[e.detail.value]
|
||||
}
|
||||
const query = {
|
||||
page: 0,
|
||||
size: 100,
|
||||
areaId: 0
|
||||
}
|
||||
const tables = reactive({
|
||||
hasAjax: false,
|
||||
selIndex: -1,
|
||||
originList: [],
|
||||
list: []
|
||||
})
|
||||
async function getTable() {
|
||||
let {
|
||||
content
|
||||
} = await $table.get(query)
|
||||
tables.hasAjax = true
|
||||
content = content.filter(v => v.status != 'closed')
|
||||
tables.list = content
|
||||
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
|
||||
console.log(tables.selIndex );
|
||||
tables.originList = content
|
||||
}
|
||||
async function getArea() {
|
||||
const {
|
||||
content
|
||||
} = await $tableArea.get({
|
||||
page: 0,
|
||||
size: 300
|
||||
})
|
||||
content.unshift({
|
||||
name: '全部'
|
||||
})
|
||||
area.list = content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => area.sel, (newval) => {
|
||||
tables.list = tables.originList.filter(v => v.areaId == newval.id)
|
||||
})
|
||||
let option = {}
|
||||
onLoad(opt => {
|
||||
Object.assign(option, opt)
|
||||
console.log(option);
|
||||
getTable()
|
||||
getArea()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.line {
|
||||
width: 1px;
|
||||
height: 20rpx;
|
||||
background-color: #E5E5E5;
|
||||
margin-left: 8rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.my-radio {
|
||||
|
||||
.circle {
|
||||
background: #FFFFFF;
|
||||
|
||||
&.active {
|
||||
background-color: $my-main-color;
|
||||
border-color: $my-main-color;
|
||||
}
|
||||
|
||||
border: 1px solid #707070;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
|
||||
&.square {
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.area {
|
||||
padding: 2px 28rpx 24rpx 10px;
|
||||
}
|
||||
|
||||
.scale7 {
|
||||
transform: scale(0.7);
|
||||
}
|
||||
|
||||
.search {
|
||||
padding-right: 28rpx;
|
||||
|
||||
.icon-saoma {
|
||||
margin-left: 20rpx;
|
||||
width: 34rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
padding: 32rpx 24rpx;
|
||||
|
||||
.no-choose {
|
||||
padding: 36rpx 30rpx 36rpx 24rpx;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 32rpx 30rpx 32rpx 24rpx;
|
||||
|
||||
.item {
|
||||
padding: 24rpx 0;
|
||||
|
||||
.headimg {
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
overflow: hidden;
|
||||
font-size: 0;
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
|
||||
.img {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item:not(:first-child) {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
144
pagesCreateOrder/choose-user/choose-user.vue
Normal file
144
pagesCreateOrder/choose-user/choose-user.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<view class="page-gray u-font-28">
|
||||
<view class="search bg-fff u-flex u-col-center ">
|
||||
<view class="u-flex-1">
|
||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索" @confirm="search" :focus="true"
|
||||
v-model="query.name">
|
||||
</uni-search-bar>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<image src="/pagesCreateOrder/static/images/icon-saoma.svg" class="icon-saoma" mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list ">
|
||||
<view class="bg-fff u-row-between u-flex no-choose border-r-12" @tap="chooseUser">
|
||||
<view>不选择用户</view>
|
||||
<my-radio v-model="nouser" :size="18" border-color="#d1d1d1" @change="chooseUser"></my-radio>
|
||||
</view>
|
||||
<view class="u-m-t-32 bg-fff box bg-fff">
|
||||
<view class="u-flex item u-row-between" v-for="(item,index) in list" :key="index" @tap="chooseUser(index,item)">
|
||||
<view class="u-flex">
|
||||
<view class="headimg u-flex u-row-center u-col-center">
|
||||
<image v-if="item.headImg" :src="item.headImg" class="img" mode=""></image>
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view>{{item.nickName}}</view>
|
||||
<view class=" u-font-24 u-m-t-12 u-flex">
|
||||
<text class="color-999" v-if="!item.isVip">非会员</text>
|
||||
<text class="color-main" v-else>会员</text>
|
||||
<view class="u-m-l-30 u-flex">
|
||||
<text class="">余额:</text>
|
||||
<text class="color-main">{{item.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-flex">
|
||||
<text class="">积分:</text>
|
||||
<text class="color-main">{{item.totalScore}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<my-radio @change="chooseUser(index,item)" v-model="item.checked" :size="18" border-color="#d1d1d1"></my-radio>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as Api from '@/http/yskApi/shop-user.js'
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
let nouser = ref(false)
|
||||
|
||||
function emitChooser(data){
|
||||
uni.$emit('choose-user',data)
|
||||
setTimeout(()=>{
|
||||
uni.navigateBack()
|
||||
},100)
|
||||
}
|
||||
|
||||
function chooseUser(index,item){
|
||||
if(index===undefined||item===undefined){
|
||||
nouser.value=true
|
||||
return emitChooser()
|
||||
}
|
||||
else{
|
||||
list[index].checked=true
|
||||
emitChooser(item)
|
||||
}
|
||||
}
|
||||
|
||||
const query=reactive({
|
||||
page:0,
|
||||
name:'',
|
||||
size:10
|
||||
})
|
||||
const list=reactive([])
|
||||
async function getUser(){
|
||||
const {content}=await Api.queryAllShopUser(query)
|
||||
for(let i in content){
|
||||
list.push({...content[i],checked:false})
|
||||
}
|
||||
console.log(list);
|
||||
}
|
||||
function search(){
|
||||
query.page=0
|
||||
list.length=0
|
||||
getUser()
|
||||
}
|
||||
onLoad(()=>{
|
||||
getUser()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.scale7{
|
||||
transform: scale(0.7);
|
||||
}
|
||||
.search {
|
||||
padding-right: 28rpx;
|
||||
|
||||
.icon-saoma {
|
||||
margin-left: 20rpx;
|
||||
width: 34rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
padding: 32rpx 24rpx;
|
||||
|
||||
.no-choose {
|
||||
padding: 36rpx 30rpx 36rpx 24rpx;
|
||||
}
|
||||
.box{
|
||||
padding: 32rpx 30rpx 78rpx 24rpx;
|
||||
.item{
|
||||
padding: 24rpx 0;
|
||||
.headimg{
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
font-size: 0;
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
.img{
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item:not(:first-child){
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
196
pagesCreateOrder/components/edit-discount.vue
Normal file
196
pagesCreateOrder/components/edit-discount.vue
Normal file
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-30 color-666">
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<view>应付金额</view>
|
||||
<view class="u-m-l-32">
|
||||
{{form.price}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-40 u-flex ">
|
||||
<view>实收金额</view>
|
||||
<view class="u-m-l-32 border-bottom u-flex-1">
|
||||
<uni-easyinput style="digit" @input="currentPriceInput" @change="currentPriceChange" paddingNone :inputBorder="false"
|
||||
v-model="form.currentPrice"
|
||||
placeholder="输入实际金额"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-54 u-flex ">
|
||||
<view>优惠折扣</view>
|
||||
<view class="u-m-l-32 u-flex-1 u-flex border-bottom">
|
||||
<view class="u-flex-1">
|
||||
<uni-easyinput @input="discountInput" @change="discountChange" style="digit" paddingNone :inputBorder="false"
|
||||
v-model="form.discount"
|
||||
placeholder="输入折扣"></uni-easyinput>
|
||||
</view>
|
||||
<view class="u-font-32 color-333">%</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>修改</my-button>
|
||||
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref,watch
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
price: {
|
||||
type: [Number,String],
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
function currentPriceInput(newval){
|
||||
form.discount=(newval*100/form.price).toFixed()
|
||||
}
|
||||
function discountInput(newval){
|
||||
form.currentPrice=(form.price*newval/100).toFixed(2)
|
||||
}
|
||||
function currentPriceChange(newval){
|
||||
if(newval<0){
|
||||
form.currentPrice=0
|
||||
form.discount=100
|
||||
return infoBox.showToast('实收金额不能小于0')
|
||||
}
|
||||
if(newval>props.price){
|
||||
form.currentPrice=props.price
|
||||
form.discount=0
|
||||
return infoBox.showToast('实收金额不能大于应付金额')
|
||||
}
|
||||
}
|
||||
function discountChange(newval){
|
||||
if(newval<0){
|
||||
form.currentPrice=props.price
|
||||
form.discount=0
|
||||
return infoBox.showToast('优惠折扣不能小于0')
|
||||
}
|
||||
if(newval>100){
|
||||
form.discount=100
|
||||
form.currentPrice=0
|
||||
return infoBox.showToast('优惠折扣不能大于100')
|
||||
}
|
||||
}
|
||||
|
||||
const $form = {
|
||||
price:props.price,
|
||||
currentPrice: props.price,
|
||||
discount: 100
|
||||
}
|
||||
const form = reactive({
|
||||
...$form
|
||||
})
|
||||
watch(()=>props.price,(newval)=>{
|
||||
console.log(newval);
|
||||
form.price=newval
|
||||
form.currentPrice=newval
|
||||
})
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {
|
||||
price,
|
||||
} = form
|
||||
close()
|
||||
emits('confirm',form)
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.lh34 {
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
258
pagesCreateOrder/confirm-order/components/discount.vue
Normal file
258
pagesCreateOrder/confirm-order/components/discount.vue
Normal file
@@ -0,0 +1,258 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-m-t-48 tab">
|
||||
<my-tabs :list="tabs" @change="tabsChange"></my-tabs>
|
||||
</view>
|
||||
<view class="u-text-left u-p-30 ">
|
||||
<template v-if="!current">
|
||||
<view>
|
||||
<view class="u-m-t-24 border discount u-relative u-flex input-box">
|
||||
<view class="u-flex-1">
|
||||
<input @input="discountInput" v-model="form.discount" type="digit"
|
||||
placeholder-class="placeholder-class" placeholder="打八折请输入80" />
|
||||
|
||||
</view>
|
||||
<view class="color-999 u-p-l-48 u-p-r-48 u-flex u-row-center u-col-center">
|
||||
<view>%</view>
|
||||
</view>
|
||||
<view class="color-999 u-p-l-48 u-p-r-48 bg1 u-absolute u-flex u-row-center u-col-center">
|
||||
<view>%</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24">
|
||||
<view class="u-flex" v-for="(item,index) in discounts" :key="index">
|
||||
<button @tap="setForm('discount',item)" class="tag u-m-r-20"
|
||||
hover-class="hover-class">{{item}}%</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>
|
||||
<view class="u-m-t-24 border discount u-relative u-flex input-box">
|
||||
<view class="u-flex-1">
|
||||
<input @input="discountMoneyInput" v-model="form.discountMoney" type="digit"
|
||||
placeholder-class="placeholder-class" placeholder="减8.55元请输入8.55" />
|
||||
|
||||
</view>
|
||||
<view class="color-999 u-p-l-48 u-p-r-48 u-flex u-row-center u-col-center">
|
||||
<view>元</view>
|
||||
</view>
|
||||
<view class="color-999 u-p-l-48 u-p-r-48 bg1 u-absolute u-flex u-row-center u-col-center">
|
||||
<view>元</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<view class="u-m-t-48">
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">打折原因</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24">
|
||||
<view class="u-flex" v-for="(item,index) in causes" :key="index">
|
||||
<button @tap="changeCauses(item)" class="tag u-m-r-20"
|
||||
:class="{active:item.checked}">{{item.name}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="textarea" v-model="value" placeholder="自定义内容"></uni-easyinput>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>确认</my-button>
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
const props = defineProps({
|
||||
price: {
|
||||
type: [Number,String],
|
||||
default: 0
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
function changeCauses(item) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
|
||||
const discounts = [95, 90, 85, 80]
|
||||
const causes = reactive([{
|
||||
name: '顾客投诉质量问题',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '友情打折',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '临时活动',
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
function discountInput(e) {
|
||||
if (e.detail.value >= 100) {
|
||||
nextTick(() => {
|
||||
form.discount = 100
|
||||
})
|
||||
}
|
||||
}
|
||||
function discountMoneyInput(e) {
|
||||
const max=100
|
||||
if (e.detail.value >= max) {
|
||||
nextTick(() => {
|
||||
form.discountMoney = 100
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function setForm(key, val) {
|
||||
form[key] = val
|
||||
}
|
||||
|
||||
|
||||
const tabs = ['打折', '减免']
|
||||
let current = ref(0)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
current.value = i
|
||||
}
|
||||
|
||||
const $form = {
|
||||
discountMoney: '',
|
||||
discount: '',
|
||||
name: '',
|
||||
price: ''
|
||||
}
|
||||
const form = reactive({
|
||||
...$form
|
||||
})
|
||||
watch(()=>props.price,(newval)=>{
|
||||
console.log(newval);
|
||||
form.price=newval
|
||||
form.currentPrice=newval
|
||||
})
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {
|
||||
discount,discountMoney
|
||||
} = form
|
||||
if (current.value===0&& discount==='') {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入有效折扣!'
|
||||
})
|
||||
}
|
||||
if (current.value===1&& discountMoney==='') {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入有效减免价格!'
|
||||
})
|
||||
}
|
||||
close()
|
||||
emits('confirm', form)
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
197
pagesCreateOrder/confirm-order/components/give-food.vue
Normal file
197
pagesCreateOrder/confirm-order/components/give-food.vue
Normal file
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-30 ">
|
||||
<view style="transform: scale(1.5);transform-origin:left;">
|
||||
<uni-number-box :min="1" :max="1" :value="form.number" @change="changeValue" :width="300" />
|
||||
</view>
|
||||
<view class="u-m-t-48">
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">赠菜原因</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24">
|
||||
<view class="u-flex" v-for="(item,index) in causes" :key="index">
|
||||
<button @tap="changeCauses(item)" class="tag u-m-r-20"
|
||||
:class="{active:item.checked}">{{item.name}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="textarea" v-model="value" placeholder="自定义内容"></uni-easyinput>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>确认</my-button>
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
function changeCauses(item) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
|
||||
const discounts = [95, 90, 85, 80]
|
||||
const causes = reactive([{
|
||||
name: '顾客投诉质量问题',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '友情打折',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '临时活动',
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
function discountInput(e) {
|
||||
if (e.detail.value >= 100) {
|
||||
nextTick(() => {
|
||||
form.discount = 100
|
||||
})
|
||||
}
|
||||
}
|
||||
function discountMoneyInput(e) {
|
||||
const max=100
|
||||
if (e.detail.value >= max) {
|
||||
nextTick(() => {
|
||||
form.discountMoney = 100
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function setForm(key, val) {
|
||||
form[key] = val
|
||||
}
|
||||
|
||||
|
||||
const tabs = ['打折', '减免']
|
||||
let current = ref(0)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
current.value = i
|
||||
}
|
||||
|
||||
const $form = {
|
||||
number:1
|
||||
}
|
||||
function changeValue(e){
|
||||
form.number=e
|
||||
}
|
||||
const form = reactive({
|
||||
...$form
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {number
|
||||
} = form
|
||||
close()
|
||||
emits('confirm', {
|
||||
name,
|
||||
price
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
168
pagesCreateOrder/confirm-order/components/remark.vue
Normal file
168
pagesCreateOrder/confirm-order/components/remark.vue
Normal file
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-30 ">
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="textarea" v-model="form.remark" placeholder="自定义内容"></uni-easyinput>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24">
|
||||
<view class="u-flex u-flex-wrap u-m-r-20 u-m-b-20 lh34" v-for="(item,index) in causes" :key="index">
|
||||
<button @tap="changeCauses(item)" class="tag ">{{item.name}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>确认</my-button>
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function changeCauses(item) {
|
||||
let prve=form.remark.length?',':''
|
||||
form.remark +=prve+item.name
|
||||
}
|
||||
|
||||
const causes = reactive([{
|
||||
name: '免葱',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '免香菜',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '不要辣',
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
function setForm(key, val) {
|
||||
form[key] = val
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const $form = {
|
||||
remark:''
|
||||
}
|
||||
const form = reactive({
|
||||
...$form
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {remark
|
||||
} = form
|
||||
close()
|
||||
emits('confirm', {
|
||||
name,
|
||||
price
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.lh34{
|
||||
line-height: 34rpx;
|
||||
}
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
528
pagesCreateOrder/confirm-order/confirm-order.vue
Normal file
528
pagesCreateOrder/confirm-order/confirm-order.vue
Normal file
@@ -0,0 +1,528 @@
|
||||
<template>
|
||||
<view class="page-gray color-333 u-font-28">
|
||||
<view class="block">
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view>选择用户</view>
|
||||
<view class="u-m-t-24 u-flex u-row-between " @tap="chooseUser">
|
||||
<view v-if="!user">选择用户</view>
|
||||
<view class="u-flex" v-else>
|
||||
<view class="headeimg">
|
||||
<image class="img" :src="user.headImg" mode=""></image>
|
||||
</view>
|
||||
<view class="u-m-l-20">{{user.nickName}}</view>
|
||||
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view>
|
||||
<view class="u-font-24 u-m-l-30"><text>余额:</text><text class="color-main">{{user.amount}}</text>
|
||||
</view>
|
||||
<view class="u-font-24 u-m-l-30"><text>积分:</text><text
|
||||
class="color-main">{{user.totalScore}}</text></view>
|
||||
</view>
|
||||
<uni-icons type="right" color="#999" size="22"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view>就餐类型</view>
|
||||
<view class="u-m-t-24 u-flex ">
|
||||
<view class="u-flex color-666">
|
||||
<radio-group @change="radioGroupChange">
|
||||
<label class="radio u-m-r-60" v-for="(item,index) in eatTypes.list" :key="index">
|
||||
<radio :value="''+index" :checked="index === eatTypes.active" class="scale7 " />
|
||||
<text>{{item.label}}</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom" @tap="chooseTable">
|
||||
<view>选择桌码</view>
|
||||
<view class="u-m-t-24 u-flex u-row-between ">
|
||||
<view>
|
||||
<text v-if="table">{{table.name}}</text>
|
||||
<text v-else>不选择桌台</text>
|
||||
</view>
|
||||
<uni-icons type="right" color="#999" size="22"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="block">
|
||||
<template v-if="!user">
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view>用餐人数(人)</view>
|
||||
<picker @change="userNumberChange" :value="userNumbers.defaultCateIndex" :range="userNumbers.list">
|
||||
<view class="u-m-t-24 u-flex u-row-between ">
|
||||
<view class="color-333">{{userNumbers.defaultCateIndex||''}}</view>
|
||||
<uni-icons type="right" color="#999" size="22"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>
|
||||
<view class="u-flex border-bottom u-p-b-24">
|
||||
<image class="headeimg" src="@/static/uni.png" mode=""></image>
|
||||
<view class="u-m-l-32">
|
||||
<view class="">{{user.name}}</view>
|
||||
<view class="color-main u-font-24">{{user.isVip?'永久会员':'' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24 u-row-between u-font-24 color-999">
|
||||
<view class="u-flex">
|
||||
<view>余额</view>
|
||||
<view class="color-333 u-m-l-10"> 0.00</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view>积分</view>
|
||||
<view class="color-333 u-m-l-10"> 0</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view>已消费</view>
|
||||
<view class="color-333 u-m-l-10"> 0.00</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
<view class="block">
|
||||
<view class="u-p-b-24 ">
|
||||
<view class="font-bold">订单备注</view>
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="textarea" v-model="note" placeholder="请输入备注"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="block">
|
||||
<view class="u-flex">
|
||||
<view>共</view>
|
||||
<view class="fen font-bold">{{goodsNumber}}</view>
|
||||
<view>份菜品</view>
|
||||
</view>
|
||||
|
||||
<view class="goods u-m-t-32">
|
||||
<view class="item u-m-b-40" @click="changeGoodsSel(index)" v-for="(item,index) in goods.list"
|
||||
:key="index">
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="u-flex">
|
||||
<image class="img" :src="item.coverImg" mode=""></image>
|
||||
<view class="u-m-l-32">
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-20" v-if="item.isWait">
|
||||
<uni-tag text="等叫"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.isGift">
|
||||
<uni-tag text="赠送"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.isPack">
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
</view>
|
||||
<view>
|
||||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{item.specSnap||' '}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">
|
||||
<text>¥</text>
|
||||
<text v-if="item.isGift">0</text>
|
||||
<text v-else>{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
</view>
|
||||
<view class="color-999 u-text-right u-font-24 u-m-t-12">×{{item.number}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-x="true" v-if="index==goods.sel">
|
||||
<view class="u-m-t-32 u-flex no-wrap">
|
||||
<view class="u-flex u-m-r-20 u-m-b-20">
|
||||
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 u-m-b-20">
|
||||
<!-- <button class="tag" hover-class="hover-class" @tap="showModel('giveFood')">赠菜</button> -->
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'isGift')">{{item.isGift?'取消赠送':'赠送'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 u-m-b-20">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-m-r-20 u-m-b-20">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button>
|
||||
</view> -->
|
||||
<view class="u-flex u-m-r-20 u-m-b-20">
|
||||
<button class="tag" hover-class="hover-class" @tap="showModel('remark')">单品备注</button>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-between u-m-t-30 u-p-b-34 border-bottom">
|
||||
<view>
|
||||
<text v-if="eatTypes.active==1">包装费</text>
|
||||
<text v-else>桌位费</text>
|
||||
</view>
|
||||
<view>¥0.00</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-right u-m-t-38">
|
||||
<view class="color-main" @tap="showModel('editMoney')">修改</view>
|
||||
<view class="u-flex price u-m-l-32">
|
||||
<view class="">实收金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(allPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
<view style="height: 300rpx;"></view>
|
||||
<view class="safe-bottom fixed">
|
||||
<view>
|
||||
<label class="radio">
|
||||
<radio value="" class="scale7" /><text>打印预结算</text>
|
||||
</label>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-48 btn">
|
||||
<my-button shape="circle" @click="createOrder">提交</my-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<model-discount title="菜品打折/减免" :ref="setModel" name="discount" :price="allPrice"></model-discount>
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<my-remark title="单品备注" :ref="setModel" name="remark"></my-remark>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
</view>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
ref,
|
||||
onBeforeUnmount,
|
||||
reactive,
|
||||
computed
|
||||
} from 'vue';
|
||||
import myButton from '@/components/my-components/my-button'
|
||||
import modelDiscount from './components/discount'
|
||||
import giveFood from './components/give-food'
|
||||
import myRemark from './components/remark'
|
||||
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
returnBoolean
|
||||
} from '@/commons/utils/format.js';
|
||||
import color from '@/commons/color.js';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
const models = new Map();
|
||||
//备注
|
||||
let note=ref('')
|
||||
function setModel(el) {
|
||||
if (el && el.$attrs['name']) {
|
||||
models.set(el.$attrs['name'], el);
|
||||
}
|
||||
}
|
||||
|
||||
function showModel(key) {
|
||||
const model = models.get(key)
|
||||
model && model.open()
|
||||
}
|
||||
|
||||
function formatPrice(n) {
|
||||
return Number(n).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//用餐人数
|
||||
const userNumbers = reactive({
|
||||
list: new Array(100).fill(1).map((v, index) => {
|
||||
return index === 0 ? '无' : index + '人'
|
||||
}),
|
||||
defaultCateIndex: 1,
|
||||
})
|
||||
|
||||
function userNumberChange(e) {
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
}
|
||||
|
||||
const form = reactive({})
|
||||
//切换商品状态
|
||||
async function toggleGoodsItemKey(item, index, key) {
|
||||
const {
|
||||
productId,
|
||||
skuId,
|
||||
id,
|
||||
number
|
||||
} = item
|
||||
const par = {
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId,
|
||||
productId,
|
||||
num: number,
|
||||
skuId
|
||||
}
|
||||
par[key] = !item[key]
|
||||
const res = await Api.addCart(par)
|
||||
goods.list[index][key] = returnBoolean(res[key])
|
||||
}
|
||||
//等叫
|
||||
function toggleWait(item) {
|
||||
item.isWait = !item.isWait
|
||||
}
|
||||
|
||||
|
||||
|
||||
const eatTypes = reactive({
|
||||
list: [{
|
||||
label: '堂食',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '自取',
|
||||
value: '2'
|
||||
},
|
||||
],
|
||||
active: 1
|
||||
})
|
||||
|
||||
function radioGroupChange(e) {
|
||||
eatTypes.active = e.detail.value
|
||||
console.log(eatTypes.active);
|
||||
}
|
||||
|
||||
|
||||
function chooseUser() {
|
||||
go.to('PAGES_CHOOSE_USER')
|
||||
}
|
||||
|
||||
function chooseTable() {
|
||||
go.to('PAGES_CHOOSE_TABLE',{
|
||||
...table.value
|
||||
})
|
||||
}
|
||||
|
||||
// 监听选择用户事件
|
||||
let user = ref(null)
|
||||
|
||||
function watchChooseuser() {
|
||||
uni.$off('choose-user')
|
||||
uni.$on('choose-user', (data) => {
|
||||
console.log(data);
|
||||
user.value = data
|
||||
})
|
||||
}
|
||||
let table = ref(null)
|
||||
|
||||
function watchChooseTable() {
|
||||
uni.$off('choose-table')
|
||||
uni.$on('choose-table', (data) => {
|
||||
table.value = data
|
||||
console.log(table.value);
|
||||
})
|
||||
}
|
||||
|
||||
const option = reactive({
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
const goods = reactive({
|
||||
list: [],
|
||||
sel: 0
|
||||
})
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
function setGoodsItem(key, val) {
|
||||
item[key] = val
|
||||
}
|
||||
|
||||
function changeGoodsSel(index) {
|
||||
goods.sel = index
|
||||
}
|
||||
//获取购物车数据
|
||||
async function getCart(par = {
|
||||
page: 0,
|
||||
size: 300,
|
||||
masterId: option.masterId,
|
||||
tableId: option.tableId
|
||||
}) {
|
||||
const res = await Api.getCart(par)
|
||||
goods.list = res.records.map(item => {
|
||||
return {
|
||||
...item,
|
||||
isPack: returnBoolean(item.isPack),
|
||||
isGift: returnBoolean(item.isGift)
|
||||
}
|
||||
})
|
||||
console.log(goods.list);
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
async function createOrder(par = {
|
||||
masterId: option.masterId,
|
||||
vipUserId:user.value?user.value.id:'',
|
||||
note:note.value,
|
||||
postPay:true,
|
||||
orderId:'',
|
||||
tableId: option.tableId
|
||||
}) {
|
||||
const res = await Api.$createOrder(par)
|
||||
uni.showToast({
|
||||
title:'提交成功',
|
||||
icon:'none'
|
||||
})
|
||||
setTimeout(()=>{
|
||||
uni.navigateBack({delta:2})
|
||||
},500)
|
||||
}
|
||||
|
||||
onLoad((opt) => {
|
||||
console.log(opt);
|
||||
Object.assign(option, opt)
|
||||
if(opt){
|
||||
table.value={
|
||||
tableId:opt.tableId,
|
||||
name:opt.tableName
|
||||
}
|
||||
}
|
||||
getCart()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
})
|
||||
onShow(()=>{
|
||||
watchChooseuser()
|
||||
watchChooseTable()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fen {
|
||||
color: #FF9F2E;
|
||||
}
|
||||
|
||||
.page-gray {
|
||||
padding: 32rpx 28rpx;
|
||||
}
|
||||
|
||||
.headeimg {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
}
|
||||
|
||||
.block {
|
||||
background-color: #fff;
|
||||
padding: 32rpx 24rpx;
|
||||
border-radius: 18rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
padding: 32rpx 0 32rpx 24rpx;
|
||||
border: 1px solid #999999;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.goods {
|
||||
padding-bottom: 30rpx;
|
||||
border-bottom: 1px dashed #E5E5E5;
|
||||
|
||||
.item {
|
||||
.img {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.headeimg {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
background-color: #eee;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.img {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #EB4F4F;
|
||||
}
|
||||
|
||||
.opacity0 {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.fixed {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.safe-bottom {
|
||||
padding: 34rpx 28rpx;
|
||||
background-color: #fff;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 10;
|
||||
|
||||
.btn {
|
||||
padding: 0 88rpx 56rpx 88rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 100rpx;
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
</style>
|
||||
1087
pagesCreateOrder/index/classify.data.js
Normal file
1087
pagesCreateOrder/index/classify.data.js
Normal file
File diff suppressed because it is too large
Load Diff
278
pagesCreateOrder/index/components/car.vue
Normal file
278
pagesCreateOrder/index/components/car.vue
Normal file
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<view class="mask" @tap="hideGoods" v-if="switchGoods"></view>
|
||||
<view class="car border-top u-flex u-row-between u-col-bottom u-relative">
|
||||
<view class="u-absolute goods bg-fff">
|
||||
<view
|
||||
class="u-p-t-32 color-666 border-bottom bg-fff u-absolute total u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between">
|
||||
<view>已添加{{goodsNumber}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="clear">清空</text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" class="tranistion" :style="{height:switchGoods?'50vh':0 }">
|
||||
<!-- 占位 -->
|
||||
<view class="u-p-t-32 color-666 border-bottom u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"
|
||||
style="opacity: 0;">
|
||||
<view>已添加{{goodsNumber}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10">清空</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 占位 -->
|
||||
<view class="color-333 item border-top u-flex u-row-center u-row-between" v-for="(item,index) in data"
|
||||
:key="index">
|
||||
<view class="">
|
||||
<view>{{item.name}}</view>
|
||||
<view class="u-m-t-10 u-font-24 color-666">{{item.specSnap||''}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.salePrice*item.number) }}</view>
|
||||
<view class="u-flex" @tap="updateNumber(false,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-m-r-30 color-333">
|
||||
{{item.number}}
|
||||
</view>
|
||||
<view class="u-flex" @tap="updateNumber(true,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<my-empty v-if="!data.length" text="暂未有添加商品"></my-empty>
|
||||
</scroll-view>
|
||||
|
||||
</view>
|
||||
<view class="icon-car-box" @tap="toggleGoods">
|
||||
<image src="/pagesCreateOrder/static/images/icon-car.svg" class="icon-car" />
|
||||
<view class="dot">{{goodsNumber}}</view>
|
||||
</view>
|
||||
<view class="price font-bold u-flex">
|
||||
<view>¥</view>
|
||||
<view>{{allPrice}}</view>
|
||||
</view>
|
||||
<my-button shape="circle" height="80" width="220" @tap="toConfimOrder">去下单</my-button>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import {formatPrice} from '@/commons/utils/format.js';
|
||||
|
||||
import {
|
||||
computed,
|
||||
ref
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
user:{
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: ""
|
||||
}
|
||||
}
|
||||
},
|
||||
table:{
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
tableId:''
|
||||
}
|
||||
}
|
||||
},
|
||||
masterId:{
|
||||
type: [String,Number],
|
||||
default:''
|
||||
}
|
||||
})
|
||||
|
||||
const edmits = defineEmits(['clear', 'updateNumber'])
|
||||
|
||||
// mask
|
||||
let switchGoods = ref(false)
|
||||
|
||||
function hideGoods() {
|
||||
switchGoods.value = false
|
||||
}
|
||||
|
||||
function showGoods() {
|
||||
switchGoods.value = true
|
||||
}
|
||||
|
||||
function toggleGoods() {
|
||||
switchGoods.value = !switchGoods.value
|
||||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
console.log(props.user);
|
||||
if(props.data.length<=0){
|
||||
return infoBox.showToast('还没有选择商品')
|
||||
}
|
||||
go.to('PAGES_CONFIRM_ORDER',{
|
||||
...props.user,
|
||||
masterId:props.masterId,
|
||||
...props.table,
|
||||
})
|
||||
}
|
||||
|
||||
const allPrice = computed(() => {
|
||||
return props.data.reduce((prve,cur)=>{
|
||||
return prve+cur.salePrice*cur.number
|
||||
},0).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result >= 99 ? 99 : result
|
||||
})
|
||||
|
||||
function updateNumber(isAdd, index, goods) {
|
||||
const step = isAdd ? 1 : -1
|
||||
const newval = goods.number + step
|
||||
const par = {
|
||||
num: newval,
|
||||
index: index,
|
||||
goods: goods
|
||||
}
|
||||
edmits('updateNumber', par)
|
||||
}
|
||||
|
||||
function clear() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否清空全部已添加的商品?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
edmits('clear')
|
||||
hideGoods()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$car-size: 96rpx;
|
||||
$car-top: -16rpx;
|
||||
|
||||
@mixin fixedAll {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.total {
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx
|
||||
}
|
||||
|
||||
.mask {
|
||||
@include fixedAll;
|
||||
background: rgba(51, 51, 51, 0.5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.goods {
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transition: all .2s ease-in-out;
|
||||
overflow: hidden;
|
||||
|
||||
.item {
|
||||
padding: 32rpx 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #EB4F4F;
|
||||
}
|
||||
|
||||
.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));
|
||||
/* #ifdef H5 */
|
||||
padding-bottom: 68rpx;
|
||||
|
||||
/* #endif */
|
||||
.icon-car-box {
|
||||
position: absolute;
|
||||
left: 28rpx;
|
||||
top: $car-top;
|
||||
display: flex;
|
||||
width: $car-size;
|
||||
height: $car-size;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 2;
|
||||
.dot {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
background: #EB4F4F;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 20rpx;
|
||||
font-weight: bold;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #EB4F4F;
|
||||
margin-left: calc(38rpx + $car-size);
|
||||
transform: translateY(calc($car-top / 2));
|
||||
}
|
||||
|
||||
.icon-car {
|
||||
width: $car-size;
|
||||
height: $car-size;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
140
pagesCreateOrder/index/components/goods-item.vue
Normal file
140
pagesCreateOrder/index/components/goods-item.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<view class="u-relative u-flex item">
|
||||
<image lazy-load class="img" :src="data.coverImg" mode=""></image>
|
||||
<view class="info u-flex u-row-between u-col-top u-flex-col" @tap="emitEvent('add')">
|
||||
<view>
|
||||
<view>{{data.name}}</view>
|
||||
<view class="u-font-32 font-bold u-m-t-16">
|
||||
¥{{data.price}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<template v-if="!isSellout">
|
||||
<template v-if="!data.isDan">
|
||||
<button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">选规格</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="u-flex icon-btn">
|
||||
<view class="u-flex" @tap.stop="emitEvent('add')">
|
||||
<image src="/pagesCreateOrder/static/images/icon-add.svg" class="icon" mode=""></image>
|
||||
</view>
|
||||
<template v-if="data.chooseNumber">
|
||||
<view class="u-font-32">
|
||||
{{data.chooseNumber}}
|
||||
</view>
|
||||
<view class="u-flex" @tap.stop="emitEvent('reduce')">
|
||||
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class=" u-m-t-16">
|
||||
已售罄
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
toRef,
|
||||
toRefs,
|
||||
watch
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
chooseNumber: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
//判断是否是菜品
|
||||
function isGoods(){
|
||||
return props.data.hasOwnProperty('id')
|
||||
}
|
||||
|
||||
//判断商品是否售尽
|
||||
const isSellout = computed(() => {
|
||||
const item = props.data
|
||||
if(!isGoods()){
|
||||
return false
|
||||
}
|
||||
return (
|
||||
item.isPauseSale ||
|
||||
(item.typeEnum !== "sku" && item.specList[0].stockNumber <= 0)
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
const emits = defineEmits(['add', 'reduce', 'chooseGuige'])
|
||||
|
||||
function emitEvent(emitName){
|
||||
if(isGoods()){
|
||||
emits(emitName, props.index)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #EB4F4F;
|
||||
border-radius: 100rpx;
|
||||
font-size: 28rpx;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-hover-class {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 250rpx;
|
||||
height: 272rpx;
|
||||
background: #F9B798;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.img {
|
||||
width: 250rpx;
|
||||
height: 272rpx;
|
||||
}
|
||||
|
||||
.info {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
color: #fff;
|
||||
padding: 32rpx 24rpx 24rpx 24rpx;
|
||||
top: 0;
|
||||
background: rgba(37, 22, 15, 0.5);
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
211
pagesCreateOrder/index/components/guige.vue
Normal file
211
pagesCreateOrder/index/components/guige.vue
Normal file
@@ -0,0 +1,211 @@
|
||||
<template>
|
||||
<my-model ref="model" borderRadius="12" :title="title">
|
||||
<template #desc>
|
||||
<scroll-view scroll-y="true" style="height: 50vh;" class="u-p-30 guigeModel">
|
||||
<view class="u-m-b-40" v-for="(item,index) in skus" :key="index">
|
||||
<view class="u-text-left">
|
||||
<view class="color-333">{{item.name}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap">
|
||||
<view class="item" @tap="chooseSkd(index,skd)"
|
||||
:class="{active:item.sel===skd.name,disabled:skd.disabled}" v-for="(skd,skdIndex) in item.values"
|
||||
:key="skdIndex">
|
||||
{{skd.name}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30 border-top ">
|
||||
<view class="u-flex u-p-b-30 u-row-between">
|
||||
<view class="price" >
|
||||
<template v-if="goods&&goods.isGrounding">
|
||||
<text>¥</text>
|
||||
<text>{{to2(goods.salePrice*number) }}</text>
|
||||
</template>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="u-flex" @tap="reduce">
|
||||
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-m-r-30 color-333">
|
||||
{{number}}
|
||||
</view>
|
||||
<view class="u-flex" @tap="add">
|
||||
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
</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="confirm" v-else>添加</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
skuMap: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
skus: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
defaultIndex: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function to2(number){
|
||||
return Number(number).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
const selSku=computed(()=>{
|
||||
return props.skus.reduce((prve,cur)=>{
|
||||
prve.push(cur.sel)
|
||||
return prve
|
||||
},[]).join()
|
||||
})
|
||||
|
||||
|
||||
const goods=computed(()=>{
|
||||
return props.skuMap[selSku.value]
|
||||
})
|
||||
|
||||
//全部规格是否都无法使用
|
||||
const isAllDisabled=computed(()=>{
|
||||
console.log(props.skus);
|
||||
return props.skus.reduce((prve,cur)=>{
|
||||
return prve&&cur.values.filter(v=>v.disabled).length===cur.values.length
|
||||
},true)
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm','updateSku'])
|
||||
let number = ref(1)
|
||||
|
||||
|
||||
function chooseSkd(skusIndex, skd) {
|
||||
const {name,disabled}=skd
|
||||
if(disabled){
|
||||
return
|
||||
}
|
||||
if(props.skus[skusIndex].sel!=name){
|
||||
emits('updateSku',skusIndex,name)
|
||||
}
|
||||
}
|
||||
const defaultIndex=reactive(new Array(props.skus.length).fill(''))
|
||||
for(let i in props.defaultIndex){
|
||||
defaultIndex[i]=props.defaultIndex[i]
|
||||
}
|
||||
const activeArr = defaultIndex
|
||||
|
||||
console.log(activeArr);
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
function reduce() {
|
||||
if(isDisabled()){
|
||||
return
|
||||
}
|
||||
const newval = number.value - 1
|
||||
number.value = newval <= 1 ? 1 : newval
|
||||
}
|
||||
|
||||
function add() {
|
||||
if(isDisabled()){
|
||||
return
|
||||
}
|
||||
const newval = number.value + 1
|
||||
number.value = newval
|
||||
}
|
||||
|
||||
function isDisabled(){
|
||||
return isAllDisabled.value
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
close()
|
||||
if(isDisabled()){
|
||||
return
|
||||
}
|
||||
emits('confirm',goods.value,number.value)
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.border-top {}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.guigeModel {
|
||||
.item {
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
padding: 4rpx 28rpx;
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
transition: all .2s ease-in-out;
|
||||
|
||||
&.active {
|
||||
border-color: $my-main-color;
|
||||
color: $my-main-color;
|
||||
}
|
||||
&.disabled{
|
||||
color: #ccc;
|
||||
border-color: #eee;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #EB4F4F;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
</style>
|
||||
109
pagesCreateOrder/index/components/surcharge.vue
Normal file
109
pagesCreateOrder/index/components/surcharge.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-30 ">
|
||||
<view>
|
||||
<view>名称</view>
|
||||
<view class="u-m-t-24 border u-flex input-box">
|
||||
<input v-model="form.name" type="text" placeholder-class="placeholder-class"
|
||||
placeholder="请输入名称" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32">
|
||||
<view>价格</view>
|
||||
<view class="u-m-t-24 border u-flex input-box">
|
||||
<input v-model="form.price" type="digit" placeholder-class="placeholder-class"
|
||||
placeholder="请输入价格" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>添加</my-button>
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
const $form = {
|
||||
name: '',
|
||||
price: ''
|
||||
}
|
||||
const form = reactive({...$form})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form,{...$form})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {
|
||||
name,
|
||||
price
|
||||
} = form
|
||||
if (!name) {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入附加费名称'
|
||||
})
|
||||
}
|
||||
close()
|
||||
emits('confirm',{
|
||||
name,
|
||||
price
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
618
pagesCreateOrder/index/index - 副本 (2).vue
Normal file
618
pagesCreateOrder/index/index - 副本 (2).vue
Normal file
@@ -0,0 +1,618 @@
|
||||
<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>
|
||||
407
pagesCreateOrder/index/index - 副本.vue
Normal file
407
pagesCreateOrder/index/index - 副本.vue
Normal file
@@ -0,0 +1,407 @@
|
||||
<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>
|
||||
996
pagesCreateOrder/index/index.vue
Normal file
996
pagesCreateOrder/index/index.vue
Normal file
@@ -0,0 +1,996 @@
|
||||
<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="!data.vipUser.id">选择用户</view>
|
||||
<view class="u-flex" v-else>
|
||||
<view class="headeimg">
|
||||
<image class="img" :src="data.vipUser.headImg" mode=""></image>
|
||||
</view>
|
||||
<view class="u-m-l-20">{{data.vipUser.nickName}}</view>
|
||||
<view class="color-main u-m-l-10 u-font-24">{{data.vipUser.isVip?'会员':'' }}</view>
|
||||
<view class="u-font-24 u-m-l-30"><text>余额:</text><text
|
||||
class="color-main">{{data.vipUser.amount}}</text></view>
|
||||
<view class="u-font-24 u-m-l-30"><text>积分:</text><text
|
||||
class="color-main">{{data.vipUser.totalScore}}</text></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">
|
||||
<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>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="bottom w-full">
|
||||
<my-car @updateNumber="carsNumberChange" :user="data.vipUser" :masterId="data.masterId"
|
||||
:table="data.table"
|
||||
:data="cars" @clear="onClearCart"></my-car>
|
||||
</view>
|
||||
|
||||
<!-- 选择规格 -->
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :title="guigeModelData.title"
|
||||
:sku-map="guigeModelData.chooseGoods.skuMap" :skus="guigeModelData.chooseGoods.skus"></guige-model>
|
||||
<!-- 添加附加费 -->
|
||||
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import _ from 'lodash';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
$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'
|
||||
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';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
const cars = reactive([])
|
||||
const data = reactive({
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
oldScrollTop: 0,
|
||||
current: 0, // 预设当前项的值
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
itemId: '', // 栏目右边scroll-view用于滚动的id
|
||||
tabbar: [],
|
||||
menuItemPos: [],
|
||||
arr: [],
|
||||
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
|
||||
timer: null, // 定时器
|
||||
topZhanwei: 136 + 24,
|
||||
// 选择用户
|
||||
vipUser: {
|
||||
id: "",
|
||||
},
|
||||
//餐桌号
|
||||
masterId: "",
|
||||
table: {
|
||||
tableId: ""
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
function setTabBar(category, goods, cars) {
|
||||
const goodsCategoryMap = goods.reduce((prve, cur) => {
|
||||
if (!prve.hasOwnProperty(cur.categoryId)) {
|
||||
prve[cur.categoryId] = []
|
||||
}
|
||||
prve[cur.categoryId].push(cur)
|
||||
return prve
|
||||
}, {})
|
||||
const chooseGoodsNumberMap = cars.reduce((prve, cur) => {
|
||||
if (!prve.hasOwnProperty(cur.productId)) {
|
||||
prve[cur.productId] = 0
|
||||
}
|
||||
prve[cur.productId] += cur.number
|
||||
return prve
|
||||
}, {})
|
||||
let tabbar = category.map(v => {
|
||||
const foods = goodsCategoryMap[v.id] || []
|
||||
return {
|
||||
...v,
|
||||
foods: foods.map((fgoods, index) => {
|
||||
return {
|
||||
...fgoods,
|
||||
chooseNumber: chooseGoodsNumberMap[fgoods.id],
|
||||
price: fgoods.lowPrice,
|
||||
isDan: fgoods.typeEnum !== 'sku'
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
tabbar.push({
|
||||
name: '附加费',
|
||||
foods: [{
|
||||
name: "小费",
|
||||
price: Math.ceil(Math.random() * 10),
|
||||
chooseNumber: 0,
|
||||
isDan: true
|
||||
},
|
||||
{
|
||||
name: "打包费",
|
||||
price: 1,
|
||||
chooseNumber: 0,
|
||||
isDan: true
|
||||
}
|
||||
]
|
||||
})
|
||||
tabbar = tabbar.filter(v => {
|
||||
return v.foods.length
|
||||
})
|
||||
data.tabbar = tabbar
|
||||
}
|
||||
|
||||
|
||||
//request类
|
||||
//获取分类
|
||||
function getCategory(par = {
|
||||
page: 0,
|
||||
size: 300
|
||||
}) {
|
||||
return $tbShopCategory(par)
|
||||
}
|
||||
//获取商品列表
|
||||
function getGoods(par = {
|
||||
page: 0,
|
||||
size: 300
|
||||
}) {
|
||||
return Api.getGoodsLists(par)
|
||||
}
|
||||
//获取购物车数据
|
||||
function getCart(par = {
|
||||
page: 0,
|
||||
size: 300,
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId
|
||||
}) {
|
||||
return Api.getCart(par)
|
||||
}
|
||||
//获取取餐码
|
||||
function getMasterId() {
|
||||
return Api.$getMasterId({
|
||||
tableId: data.table.tableId
|
||||
})
|
||||
}
|
||||
//清空购物车
|
||||
function clearCart() {
|
||||
return Api.$clearCart({
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId
|
||||
})
|
||||
}
|
||||
//加入购物车
|
||||
function addCart(par) {
|
||||
const submitPar = {
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
isPack: false,
|
||||
num: 1,
|
||||
productId: '',
|
||||
skuId: '',
|
||||
vipUserId: data.vipUser.id
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.addCart(submitPar)
|
||||
}
|
||||
//更新购物车
|
||||
function updateCartGoods(par) {
|
||||
const submitPar = {
|
||||
cartId: '',
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
isPack: false,
|
||||
num: 1,
|
||||
productId: '',
|
||||
skuId: '',
|
||||
vipUserId: data.vipUser.id
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.$updateCart(submitPar)
|
||||
}
|
||||
//删除购物车某商品
|
||||
function removeCartGoods(par) {
|
||||
const submitPar = {
|
||||
cartId: '',
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.$removeCart(submitPar)
|
||||
}
|
||||
//更新选择用户
|
||||
function setUser(par) {
|
||||
const submitPar = {
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
vipUserId: data.vipUser.id ? data.vipUser.id : '',
|
||||
type: data.vipUser.id ? 0 : 1 //0 设置 1 取消
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.$setUser(submitPar)
|
||||
}
|
||||
|
||||
|
||||
//点击清空购物车
|
||||
async function onClearCart() {
|
||||
await clearCart()
|
||||
cars.length = 0
|
||||
for (let i in data.tabbar) {
|
||||
for (let k in data.tabbar[i].fgoods) {
|
||||
data.tabbar[i].fgoods[k].chooseNumber = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
async function init() {
|
||||
const {
|
||||
masterId
|
||||
} = await getMasterId()
|
||||
data.masterId = masterId
|
||||
const cartRes = await getCart()
|
||||
cars.length = 0
|
||||
for (let i in cartRes.records) {
|
||||
cars.push(cartRes.records[i])
|
||||
}
|
||||
const categoryRes = await getCategory()
|
||||
const category = categoryRes.content.reduce((prve, cur) => {
|
||||
prve.push({
|
||||
...cur,
|
||||
childrenList: null
|
||||
});
|
||||
return [...prve, ...cur.childrenList];
|
||||
}, []);
|
||||
console.log(category);
|
||||
const goodsRes = await getGoods()
|
||||
const goods = goodsRes.records.filter((v) => {
|
||||
let isShow = true;
|
||||
if (v.typeEnum !== "sku") {
|
||||
isShow = v.specList.length >= 1;
|
||||
}
|
||||
return isShow;
|
||||
});
|
||||
|
||||
setTabBar(category, goods, cars)
|
||||
|
||||
}
|
||||
|
||||
// 监听选择用户事件
|
||||
|
||||
|
||||
|
||||
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: {
|
||||
skuMap: {},
|
||||
item: '',
|
||||
skus: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 返回当前选中商品skuList
|
||||
function returnSelGoodsSkuList(skuList, specSnap) {
|
||||
const specSnapArr = specSnap ? specSnap.split(",") : [];
|
||||
const result = skuList.map((v, index) => {
|
||||
const values = v.value.split(",");
|
||||
return {
|
||||
...v,
|
||||
valueArr: values,
|
||||
sel: specSnap ? specSnapArr[index] : "",
|
||||
values: values.map((name) => {
|
||||
return {
|
||||
name,
|
||||
disabled: false
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
return result
|
||||
}
|
||||
//返回当前选中商品skuMap
|
||||
function returnSelGoodsSkuMap(specList) {
|
||||
const skuMap = {}
|
||||
for (let i in specList) {
|
||||
skuMap[specList[i].specSnap] = specList[i];
|
||||
}
|
||||
return skuMap
|
||||
}
|
||||
|
||||
//多规格商品弹窗时,找到默认可以下单的规格商品
|
||||
function findGoods(skuList = [], goodsListMap = {}, specList) {
|
||||
const skuMapNumber = skuList.reduce((prve, cur) => {
|
||||
for (let i in cur.valueArr) {
|
||||
prve[cur.valueArr[i]] = i;
|
||||
}
|
||||
return prve;
|
||||
}, {});
|
||||
const canBudyGoods = specList
|
||||
.filter((v) => util.isCanBuy(v))
|
||||
.sort((a, b) => {
|
||||
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
|
||||
return prve + skuMapNumber[cur];
|
||||
}, 0);
|
||||
const bNumber = b.specSnap.split(",").reduce((prve, cur) => {
|
||||
return prve + skuMapNumber[cur];
|
||||
}, 0);
|
||||
return aNumber - bNumber;
|
||||
});
|
||||
return canBudyGoods[0];
|
||||
}
|
||||
|
||||
//设置商品默认选中,规格禁止以及选中
|
||||
function setSkugoodsDefaultInit(goods, skuList, skuMap, specList) {
|
||||
guigeModelData.chooseGoods.item = goods
|
||||
guigeModelData.chooseGoods.skus = skuList
|
||||
guigeModelData.chooseGoods.skuMap = skuMap
|
||||
const skuGoods = findGoods(skuList, skuMap, specList);
|
||||
console.log(skuList, skuMap);
|
||||
console.log(skuGoods);
|
||||
if (skuGoods) {
|
||||
// this.skuGoods.data = skuGoods;
|
||||
// this.skuGoods.number = skuGoods.suit || 1;
|
||||
skuGoods.specSnap.split(",").map((v, index) => {
|
||||
guigeModelData.chooseGoods.skus[index].sel = v;
|
||||
});
|
||||
}
|
||||
console.log(guigeModelData.chooseGoods.skus);
|
||||
setTagDisabled();
|
||||
}
|
||||
|
||||
//更新选中规格
|
||||
function updateSkuSel(skusIndex, skdName) {
|
||||
const skuList = guigeModelData.chooseGoods.skus
|
||||
const skuMap = guigeModelData.chooseGoods.skuMap
|
||||
guigeModelData.chooseGoods.skus[skusIndex].sel = skdName
|
||||
const specSnap = guigeModelData.chooseGoods.skus.reduce((prve, cur) => {
|
||||
prve.push(cur.sel)
|
||||
return prve
|
||||
}, []).join()
|
||||
setTagDisabled();
|
||||
// const canChooseGoods = skuList.every((v) => v.sel);
|
||||
// if (canChooseGoods) {
|
||||
// const skuGoods =skuMap[specSnap];
|
||||
// guigeModelData.chooseGoods.item = skuGoods
|
||||
// }
|
||||
}
|
||||
//设置规格按钮的禁止状态
|
||||
function setTagDisabled() {
|
||||
const skuList = guigeModelData.chooseGoods.skus
|
||||
const skuMap = guigeModelData.chooseGoods.skuMap
|
||||
const selArr = skuList.reduce((prve, cur) => {
|
||||
if (cur.sel) {
|
||||
prve.push(cur.sel);
|
||||
} else {}
|
||||
return prve;
|
||||
}, []);
|
||||
|
||||
console.log(selArr);
|
||||
let selArrAllGroup = util.generateCombinations(selArr, selArr.length - 1);
|
||||
console.log(selArrAllGroup);
|
||||
const matchArr = [];
|
||||
for (let key in skuMap) {
|
||||
const goods = skuMap[key];
|
||||
const keyArr = key.split(",");
|
||||
for (let spe of selArrAllGroup) {
|
||||
if (util.arrayContainsAll(keyArr, spe)) {
|
||||
matchArr.push(goods);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//全部规格都已下架
|
||||
if (!matchArr.length) {
|
||||
for (let k in skuList) {
|
||||
for (let i in skuList[k].values) {
|
||||
skuList[k].values[i].disabled = true
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
const includeSkuMap = matchArr.reduce((prve, cur) => {
|
||||
const speArr = cur.specSnap.split(",");
|
||||
for (let i of speArr) {
|
||||
if (!prve.hasOwnProperty("i")) {
|
||||
prve[i] = matchArr
|
||||
.filter((v) => v.specSnap.match(i))
|
||||
.every((v) => {
|
||||
return util.isCanBuy(v)
|
||||
});
|
||||
}
|
||||
}
|
||||
return prve;
|
||||
}, {});
|
||||
for (let i in includeSkuMap) {
|
||||
for (let k in skuList) {
|
||||
const index = skuList[k].valueArr.findIndex((val) => val === i);
|
||||
if (index !== -1) {
|
||||
skuList[k].values[index].disabled = includeSkuMap[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
const skuMap = returnSelGoodsSkuMap(specList)
|
||||
const skuList = returnSelGoodsSkuList(tagSnap)
|
||||
setSkugoodsDefaultInit($goods, skuList, skuMap, specList)
|
||||
chooseGuigeModel.value.open()
|
||||
}
|
||||
|
||||
async function guigeConfirm(sku, num) {
|
||||
const goods = guigeModelData.chooseGoods.item
|
||||
const skuId = sku.id
|
||||
const productId = goods.id
|
||||
const res = findGoodsInCar(goods, skuId)
|
||||
if (res) {
|
||||
//更新
|
||||
const {
|
||||
index
|
||||
} = res
|
||||
const carGoods = cars[index]
|
||||
const cartId = carGoods.id
|
||||
const newNumber = carGoods.number * 1 + num
|
||||
const {
|
||||
number
|
||||
} = await updateCartGoods({
|
||||
num: newNumber,
|
||||
cartId,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
carGoods.number = number
|
||||
} else {
|
||||
//添加
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
cars.push({
|
||||
...cartGoods,
|
||||
specSnap: sku.specSnap
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//购物车商品数量改变
|
||||
async function carsNumberChange(e) {
|
||||
const {
|
||||
num,
|
||||
index,
|
||||
goods
|
||||
} = e
|
||||
const {
|
||||
productId,
|
||||
categoryId,
|
||||
skuId
|
||||
} = goods
|
||||
const cartId = goods.id
|
||||
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
||||
const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||
if (num === 0) {
|
||||
//移除
|
||||
await removeCartGoods({
|
||||
cartId
|
||||
})
|
||||
cars.splice(index, 1)
|
||||
$goods.chooseNumber = 0
|
||||
return
|
||||
}
|
||||
await updateCartGoods({
|
||||
num,
|
||||
cartId,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
cars[index].number = num
|
||||
if ($goods) {
|
||||
$goods.chooseNumber = num
|
||||
}
|
||||
}
|
||||
|
||||
// 找到该规格商品在购物车中是否存在并返回index值以及对应的数据
|
||||
function findGoodsInCar($goods, skuId) {
|
||||
const productId = $goods.id
|
||||
const goodsInCarIndex = cars.findIndex((carsGoods) => {
|
||||
return carsGoods.skuId == skuId && carsGoods.productId == productId;
|
||||
});
|
||||
const carGoods = cars[goodsInCarIndex]
|
||||
return carGoods ? {
|
||||
index: goodsInCarIndex,
|
||||
carGoods
|
||||
} : false
|
||||
}
|
||||
|
||||
async function goodsUpdate(foodsindex, index, isAdd) {
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
if ($goods.isDan) {
|
||||
//单规格
|
||||
const goodsInCarIndex = cars.findIndex((carsGoods) => {
|
||||
return carsGoods.skuId == $goods.specList[0].id && carsGoods.productId == $goods.id;
|
||||
});
|
||||
const productId = $goods.id
|
||||
const skuId = $goods.specList[0].id
|
||||
if (goodsInCarIndex !== -1) {
|
||||
//更新
|
||||
const carGoods = cars[goodsInCarIndex]
|
||||
const cartId = carGoods.id
|
||||
const step = isAdd ? 1 : -1
|
||||
const num = carGoods.number * 1 + step
|
||||
if (num === 0) {
|
||||
//移除
|
||||
cars.splice(goodsInCarIndex, 1)
|
||||
$goods.chooseNumber = 0
|
||||
return await removeCartGoods({
|
||||
cartId
|
||||
})
|
||||
}
|
||||
const {
|
||||
number
|
||||
} = await updateCartGoods({
|
||||
num,
|
||||
cartId,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
carGoods.number = number
|
||||
$goods.chooseNumber = number
|
||||
} else {
|
||||
//增加
|
||||
const num = 1
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
$goods.chooseNumber = num
|
||||
cars.push(cartGoods)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
onReady(() => {
|
||||
getMenuItemTop()
|
||||
})
|
||||
|
||||
let isTabClickOver=true
|
||||
// 点击左边的栏目切换
|
||||
async function swichMenu(index) {
|
||||
if (data.arr.length == 0) {
|
||||
await getMenuItemTop();
|
||||
}
|
||||
if (index == data.current) return;
|
||||
isTabClickOver=false;
|
||||
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) {
|
||||
if(!isTabClickOver){
|
||||
return
|
||||
}
|
||||
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) {
|
||||
if(isTabClickOver){
|
||||
leftMenuStatus(i);
|
||||
}else{
|
||||
isTabClickOver=true
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
function watchChooseuser() {
|
||||
uni.$off('choose-user')
|
||||
uni.$on('choose-user', (user) => {
|
||||
console.log(user);
|
||||
data.vipUser = user ? user : {
|
||||
id: ''
|
||||
}
|
||||
setUser()
|
||||
})
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
})
|
||||
onShow(()=>{
|
||||
watchChooseuser()
|
||||
})
|
||||
onLoad((opt) => {
|
||||
console.log(opt)
|
||||
Object.assign(data.table,opt)
|
||||
if (!opt.tableId) {
|
||||
infoBox.showErrorToast('暂不支持不选择台桌下载,请从桌台点餐')
|
||||
return setTimeout(() => {
|
||||
go.back()
|
||||
}, 1500)
|
||||
}
|
||||
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;
|
||||
display: flex;
|
||||
background-color: #eee;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.img {
|
||||
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%;
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.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>
|
||||
52
pagesCreateOrder/index/util.js
Normal file
52
pagesCreateOrder/index/util.js
Normal file
@@ -0,0 +1,52 @@
|
||||
//判断商品是否可以下单
|
||||
export function isCanBuy(goods,isStock) {
|
||||
return goods.isGrounding && goods.isPauseSale == 0 && (isStock?goods.stockNumber > 0:true) ;
|
||||
}
|
||||
|
||||
|
||||
// 一个数组是否包含另外一个数组全部元素
|
||||
function arrayContainsAll(arr1, arr2) {
|
||||
for (let i = 0; i < arr2.length; i++) {
|
||||
if (!arr1.includes(arr2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//n项 n-1项组合,生成全部结果
|
||||
function generateCombinations(arr, k) {
|
||||
let result = [];
|
||||
|
||||
function helper(index, current) {
|
||||
if (current.length === k) {
|
||||
result.push(current.slice()); // 使用slice()来避免直接修改原始数组
|
||||
} else {
|
||||
for (let i = index; i < arr.length; i++) {
|
||||
current.push(arr[i]); // 将当前元素添加到组合中
|
||||
helper(i + 1, current); // 递归调用,索引增加以避免重复选择相同的元素
|
||||
current.pop(); // 回溯,移除当前元素以便尝试其他组合
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
helper(0, []); // 从索引0开始,初始空数组作为起点
|
||||
return result;
|
||||
}
|
||||
|
||||
function returnReverseVal(val, isReturnString = true) {
|
||||
const isBol = typeof val === "boolean";
|
||||
const isString = typeof val === "string";
|
||||
let reverseNewval = "";
|
||||
if (isBol) {
|
||||
reverseNewval = !val;
|
||||
}
|
||||
if (isString) {
|
||||
reverseNewval = val === "true" ? "false" : "true";
|
||||
}
|
||||
return reverseNewval;
|
||||
}
|
||||
|
||||
export default{
|
||||
isCanBuy,arrayContainsAll,generateCombinations,returnReverseVal
|
||||
}
|
||||
103
pagesCreateOrder/order-detail/components/list.vue
Normal file
103
pagesCreateOrder/order-detail/components/list.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<view class="default-box-padding bg-fff border-r-12 u-m-t-20" v-if="data.length">
|
||||
<view class="u-font-32">
|
||||
<text>共</text>
|
||||
<text class="color-main font-bold"> {{goodsNumber}}</text>
|
||||
<text>份菜品</text>
|
||||
</view>
|
||||
<view class="u-m-t-20 list">
|
||||
<view class="item u-m-b-20" v-for="(item,index) in data" :key="index">
|
||||
<view class="u-flex u-col-top">
|
||||
<view>
|
||||
<image class="img" :src="item.coverImg" mode=""></image>
|
||||
</view>
|
||||
<view class="u-p-l-30 u-flex-1">
|
||||
<view class="u-flex u-row-between u-col-top">
|
||||
<view>{{item.name}}</view>
|
||||
<view class="u-text-right">
|
||||
<view>¥{{item.salePrice}}</view>
|
||||
<view class="u-m-t-10 u-font-24">X{{item.number}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-20">
|
||||
<my-button :height="60" color="#333" plain type="cancel" shape="circle">更多操作</my-button>
|
||||
<my-button :width="168" :height="60" plain shape="circle">退菜</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bg-gray u-p-20 u-m-t-20 ">
|
||||
<view>备注</view>
|
||||
<view class="u-m-t-10">无</view>
|
||||
</view>
|
||||
<view class="u-m-t-40">
|
||||
<view class="u-flex u-row-between border-bottom u-p-b-20">
|
||||
<view class="tag no-pay">
|
||||
未支付
|
||||
</view>
|
||||
<view>
|
||||
<text>小计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view></view>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-30">
|
||||
<my-button type="cancel" :color="color.ColorMain">重新打印</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed
|
||||
} from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
return props.data.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.img {
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
}
|
||||
.border-bottom{
|
||||
border-color: rgb(240, 240, 240);
|
||||
}
|
||||
.tag {
|
||||
padding: 2rpx 8rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.no-pay {
|
||||
background-color: rgb(170, 170, 170);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
63
pagesCreateOrder/order-detail/components/order.vue
Normal file
63
pagesCreateOrder/order-detail/components/order.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<view class="default-box-padding bg-fff border-r-12 u-m-t-20">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>订单状态</view>
|
||||
<view>{{returnStatus(data.status)}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>订单类型</view>
|
||||
<view>堂食</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>桌位号</view>
|
||||
<view>{{table.name}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>就餐人数</view>
|
||||
<view>1</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>支付方式</view>
|
||||
<view></view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>预约时间</view>
|
||||
<view></view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>下单时间</view>
|
||||
<view>2024-08-31 15:54:40</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>订单编号</view>
|
||||
<view>2024083115544056362</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view>商家备注</view>
|
||||
<my-button plain shape="circle" :width="160" :height="60">编辑</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
table:{
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
|
||||
const statusMap={
|
||||
unpaid:'未支付'
|
||||
}
|
||||
function returnStatus(status){
|
||||
return statusMap[status]||''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
26
pagesCreateOrder/order-detail/components/step.vue
Normal file
26
pagesCreateOrder/order-detail/components/step.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<view class="default-box-padding bg-fff border-r-12 u-m-t-20">
|
||||
<my-steps :dot="true" current="0" direction="column">
|
||||
<my-steps-item title="2024-09-02 09:19" :itemStyle="itemStyle" desc="[东风(id:124413)]使用代客下单提交。(未打印预结单)">
|
||||
</my-steps-item>
|
||||
<my-steps-item title="2024-09-02 09:19" desc="[东风(id:124413)]使用代客下单提交。(未打印预结单)">
|
||||
</my-steps-item>
|
||||
</my-steps>
|
||||
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive
|
||||
} from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
const itemStyle = reactive({
|
||||
color: 'rgb(255,0,0)'
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
40
pagesCreateOrder/order-detail/components/user.vue
Normal file
40
pagesCreateOrder/order-detail/components/user.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<view class="u-font-28 default-box-padding u-relative bg-fff border-r-12 u-overflow-hide">
|
||||
<view class="change u-absolute my-bg-main color-fff left-top" >切换</view>
|
||||
<view class="u-flex u-row-between u-m-t-20 border-bottom u-p-b-20">
|
||||
<view class="u-flex">
|
||||
<my-avatar :size="30"></my-avatar>
|
||||
<view class="color-666 u-m-l-30">未绑定手机号</view>
|
||||
</view>
|
||||
<view>
|
||||
<my-button :height="60" plain shape="circle">他的订单</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-20 u-row-between">
|
||||
<view class="">
|
||||
<view class="font-bold">0.00</view>
|
||||
<view class="color-666 u-m-t-10">余额</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">0.00</view>
|
||||
<view class="color-666 u-m-t-10">积分</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="font-bold">0.00</view>
|
||||
<view class="color-666 u-m-t-10">已消费</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.change{
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 0 0 16rpx 0;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
</style>
|
||||
125
pagesCreateOrder/order-detail/order-detail.vue
Normal file
125
pagesCreateOrder/order-detail/order-detail.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-font-28 u-p-30">
|
||||
<user-vue></user-vue>
|
||||
<view class="default-box-padding bg-fff border-r-12 u-m-t-20">
|
||||
<text class="color-666">桌位号:</text>
|
||||
<text class="font-bold">{{options.name}}</text>
|
||||
</view>
|
||||
<goods-list :data="orderDetail.goodsList"></goods-list>
|
||||
<order-vue :data="orderDetail.info" :table="options"></order-vue>
|
||||
<step-vue></step-vue>
|
||||
<view style="height: 200rpx;"></view>
|
||||
<view class="u-fixed bottom bg-fff ">
|
||||
<view class="u-flex u-abso">
|
||||
<view class="u-flex-1">
|
||||
<my-button @tap="diancan" color="#fff" bgColor="rgb(57,53,52)" borderRadius="100rpx 0 0 100rpx"
|
||||
shape="circle" plain type="primary">加菜</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button @tap="toPay" borderRadius="0 100rpx 100rpx 0" shape="circle"
|
||||
type="primary">结账</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import userVue from './components/user.vue';
|
||||
import orderVue from './components/order.vue';
|
||||
import goodsList from './components/list.vue';
|
||||
import stepVue from './components/step.vue';
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onHide
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive
|
||||
} from 'vue';
|
||||
import OrderDetail from './page.js'
|
||||
const uiPage = new OrderDetail()
|
||||
setTimeout(() => {
|
||||
uiPage.setVal('user', {
|
||||
name: 1
|
||||
})
|
||||
}, 1500)
|
||||
|
||||
function diancan() {
|
||||
go.to('PAGES_CREATE_ORDER', {
|
||||
tableId: options.tableId,
|
||||
tableName: options.name
|
||||
})
|
||||
}
|
||||
|
||||
function toPay() {
|
||||
go.to('PAGES_CRESATE_ORDER_PAY', {
|
||||
...orderDetail.info,
|
||||
tableId: options.tableId,
|
||||
tableName: options.name,
|
||||
masterId: options.masterId,
|
||||
})
|
||||
}
|
||||
|
||||
const orderDetail = reactive({
|
||||
goodsList: [],
|
||||
info: {}
|
||||
})
|
||||
const options = reactive({})
|
||||
async function init() {
|
||||
const {
|
||||
masterId
|
||||
} = await Api.$getMasterId(options)
|
||||
console.log(masterId);
|
||||
options.masterId=masterId
|
||||
const {
|
||||
records
|
||||
} = await Api.getCart({
|
||||
...options,
|
||||
masterId
|
||||
})
|
||||
orderDetail.goodsList = records
|
||||
const info = await Api.$createOrder({
|
||||
masterId,
|
||||
vipUserId: '',
|
||||
tableId: options.tableId,
|
||||
note: '',
|
||||
postPay: true,
|
||||
orderld: ''
|
||||
})
|
||||
orderDetail.info = info
|
||||
}
|
||||
function watchEmit(){
|
||||
uni.$off('orderDetail:update')
|
||||
uni.$once('orderDetail:update',(newval)=>{
|
||||
console.log(newval);
|
||||
init()
|
||||
})
|
||||
}
|
||||
onShow(()=>{
|
||||
watchEmit()
|
||||
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt)
|
||||
console.log(options);
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bottom {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 68rpx;
|
||||
|
||||
.u-abso {
|
||||
bottom: 84rpx;
|
||||
left: 28rpx;
|
||||
right: 28rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
23
pagesCreateOrder/order-detail/page.js
Normal file
23
pagesCreateOrder/order-detail/page.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
reactive, ref
|
||||
} from 'vue';
|
||||
function isSameType(a, b) {
|
||||
return a instanceof b === true || b instanceof a === true;
|
||||
}
|
||||
class OrderDetail {
|
||||
constructor(data) {
|
||||
const user ={}
|
||||
const table = {}
|
||||
const goodsList =[]
|
||||
const orderInfo = {}
|
||||
this.data=reactive({
|
||||
user,table,goodsList,orderInfo
|
||||
})
|
||||
Object.assign(this, data)
|
||||
}
|
||||
setVal(key,val){
|
||||
this.data[key]=val
|
||||
}
|
||||
}
|
||||
|
||||
export default OrderDetail
|
||||
209
pagesCreateOrder/pay-order/pay-order.vue
Normal file
209
pagesCreateOrder/pay-order/pay-order.vue
Normal file
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<view class="bg-gray min-page u-p-30 u-font-28">
|
||||
<view class="u-p-t-60 u-p-b-60 u-text-center">
|
||||
<view class="u-font-32 ">
|
||||
<text class="price-fuhao">¥</text>
|
||||
<text class="font-bold price">{{order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 old-price">
|
||||
<text class="">¥</text>
|
||||
<text class=" ">{{order.amount}}</text>
|
||||
</view>
|
||||
<view class="u-m-t-10 u-flex u-row-center color-main">
|
||||
<view @click="showModel('editMoney',true)">修改</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bg-fff box-shadow u-p-t-30 u-p-l-50 u-p-r-50 card top border-r-12 u-m-t-30">
|
||||
<view class="u-flex border-bottom-dashed u-row-between u-p-b-30">
|
||||
<view>优惠券</view>
|
||||
<view class="color-999 u-flex u-col-center">
|
||||
<text>选择优惠券</text>
|
||||
<view class="u-flex u-col-center">
|
||||
<uni-icons type="right"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bg-fff box-shadow u-p-t-30 u-p-l-50 u-p-r-50 card bottom border-r-12 ">
|
||||
<my-tabs :list="pays.list"></my-tabs>
|
||||
<view class="list">
|
||||
<view class="item" @click="changePayType(index)" v-for="(item,index) in pays.payTypes.list"
|
||||
:key="index">
|
||||
<view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom">
|
||||
<view class="u-flex">
|
||||
<image class="icon" :src="item.icon" mode=""></image>
|
||||
<text class="u-m-l-10">{{item.payName}}</text>
|
||||
</view>
|
||||
<view class="u-flex color-999 u-font-24">
|
||||
<!-- <view class="u-m-r-20">
|
||||
<text>余额:</text>
|
||||
<text>¥0.00</text>
|
||||
</view> -->
|
||||
<my-radio @click="changePayType(index)" :modelValue="index==pays.payTypes.selIndex">
|
||||
</my-radio>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-m-t-60 u-p-b-30">
|
||||
<my-button @click="payOrder">确认付款</my-button>
|
||||
</view>
|
||||
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="order.amount"></edit-discount>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
const pays = reactive({
|
||||
list: ['普通支付', '混合支付'],
|
||||
payTypes: {
|
||||
list: [],
|
||||
selIndex: 0
|
||||
}
|
||||
})
|
||||
|
||||
const models = new Map();
|
||||
|
||||
function setModel(el) {
|
||||
if (el && el.$attrs['name']) {
|
||||
models.set(el.$attrs['name'], el);
|
||||
}
|
||||
}
|
||||
|
||||
function showModel(key) {
|
||||
const model = models.get(key)
|
||||
model && model.open()
|
||||
}
|
||||
|
||||
async function getPayType() {
|
||||
const payTypeList = await Api.$getPayType()
|
||||
pays.payTypes.list = payTypeList.filter(v=>v.payType!='scanCode')
|
||||
}
|
||||
|
||||
function changePayType(i) {
|
||||
pays.payTypes.selIndex = i
|
||||
}
|
||||
|
||||
async function payOrder() {
|
||||
const payType=pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
await Api.$payOrder({
|
||||
tableId: order.tableId,
|
||||
masterId: order.masterId,
|
||||
orderId: order.id,
|
||||
payType,
|
||||
vipUserId: order.userId,
|
||||
discount: 1,
|
||||
code: ''
|
||||
})
|
||||
infoBox.showToast('支付成功')
|
||||
setTimeout(()=>{
|
||||
uni.$emit('orderDetail:update')
|
||||
uni.navigateBack()
|
||||
},500)
|
||||
}
|
||||
onMounted(() => {
|
||||
getPayType()
|
||||
})
|
||||
const order = reactive({
|
||||
amount: 0
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(order, opt)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.box-shadow {
|
||||
box-shadow: 0 0 5px #eee;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.border-bottom-dashed {
|
||||
border-bottom: 1px dashed #bbb;
|
||||
}
|
||||
|
||||
.border-bottom {
|
||||
border-color: rgb(240, 240, 240);
|
||||
}
|
||||
|
||||
.list {
|
||||
.item:last-child {
|
||||
.border-bottom {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.old-price {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.price-fuhao {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
$dotSize: 20rpx;
|
||||
$position: calc($dotSize / (-2));
|
||||
|
||||
.card {
|
||||
position: relative;
|
||||
|
||||
&::after,
|
||||
&:before {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
background-color: #F9F9F9;
|
||||
width: $dotSize;
|
||||
height: $dotSize;
|
||||
box-shadow: 0 0 5px #eee;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
&.top {
|
||||
&::after {
|
||||
right: $position;
|
||||
bottom: $position;
|
||||
}
|
||||
|
||||
&:before {
|
||||
left: $position;
|
||||
bottom: $position;
|
||||
}
|
||||
}
|
||||
|
||||
&.bottom {
|
||||
&::after {
|
||||
right: $position;
|
||||
top: $position;
|
||||
}
|
||||
|
||||
&:before {
|
||||
left: $position;
|
||||
top: $position;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
1
pagesCreateOrder/static/images/icon-add-black.svg
Normal file
1
pagesCreateOrder/static/images/icon-add-black.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#333;}.b{fill:#fff;}</style></defs><circle class="a" cx="10" cy="10" r="10"/><rect class="b" width="12" height="2" rx="1" transform="translate(4 10)"/><rect class="b" width="12" height="2" rx="1" transform="translate(11 5) rotate(90)"/></svg>
|
||||
|
After Width: | Height: | Size: 346 B |
1
pagesCreateOrder/static/images/icon-add.svg
Normal file
1
pagesCreateOrder/static/images/icon-add.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:#eb4f4f;}.b{fill:#fff;}</style></defs><circle class="a" cx="12" cy="12" r="12"/><rect class="b" width="12" height="2" rx="1" transform="translate(6 11)"/><rect class="b" width="12" height="2" rx="1" transform="translate(13 6) rotate(90)"/></svg>
|
||||
|
After Width: | Height: | Size: 349 B |
1
pagesCreateOrder/static/images/icon-car.svg
Normal file
1
pagesCreateOrder/static/images/icon-car.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><defs><style>.a{fill:#333;}.b{fill:#fff;}</style></defs><g transform="translate(-20 -720)"><circle class="a" cx="24" cy="24" r="24" transform="translate(20 720)"/><g transform="translate(-90.089 607.626)"><path class="b" d="M147.12,144.087H126.754a1.818,1.818,0,0,1-1.846-1.6l-1.169-18.028a2.611,2.611,0,0,0-1.477-2.215l-1.846-.8a.948.948,0,0,0-1.231.492.9.9,0,0,0,.492,1.231l1.784.8a.757.757,0,0,1,.431.677L123,142.672a3.686,3.686,0,0,0,3.692,3.323H147.12a.946.946,0,0,0,.923-.923A1,1,0,0,0,147.12,144.087Z" transform="translate(0 0)"/><path class="b" d="M335.566,240.984a2.979,2.979,0,0,0-2.215-.984H314.523a.923.923,0,1,0,0,1.846h18.828a.992.992,0,0,1,.8.369,1.47,1.47,0,0,1,.308.861l-1.477,8.122v.062a1.119,1.119,0,0,1-1.046.984l-16.182,1.231a1,1,0,0,0-.861.984.935.935,0,0,0,.923.861h.062L332,254.09a2.9,2.9,0,0,0,2.707-2.584l1.477-8.183v-.062A2.579,2.579,0,0,0,335.566,240.984Z" transform="translate(-187.031 -114.064)"/><path class="b" d="M251.754,802.154m-2.154,0A2.154,2.154,0,1,0,251.754,800,2.153,2.153,0,0,0,249.6,802.154Z" transform="translate(-125.492 -652.529)"/><path class="b" d="M699.753,802.154m-2.154,0A2.154,2.154,0,1,0,699.753,800,2.153,2.153,0,0,0,697.6,802.154Z" transform="translate(-556.264 -652.529)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
pagesCreateOrder/static/images/icon-reduce-black.svg
Normal file
1
pagesCreateOrder/static/images/icon-reduce-black.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#fff;stroke:#333;}.b{fill:#333;}.c{stroke:none;}.d{fill:none;}</style></defs><g class="a"><circle class="c" cx="10" cy="10" r="10"/><circle class="d" cx="10" cy="10" r="9.5"/></g><rect class="b" width="12" height="2" rx="1" transform="translate(4 10)"/></svg>
|
||||
|
After Width: | Height: | Size: 363 B |
1
pagesCreateOrder/static/images/icon-reduce.svg
Normal file
1
pagesCreateOrder/static/images/icon-reduce.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:#fff;stroke:#eb4f4f;}.b{fill:#eb4f4f;}.c{stroke:none;}.d{fill:none;}</style></defs><g class="a"><circle class="c" cx="12" cy="12" r="12"/><circle class="d" cx="12" cy="12" r="11.5"/></g><rect class="b" width="12" height="2" rx="1" transform="translate(6 11)"/></svg>
|
||||
|
After Width: | Height: | Size: 370 B |
1
pagesCreateOrder/static/images/icon-saoma.svg
Normal file
1
pagesCreateOrder/static/images/icon-saoma.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="17.196" height="15.968" viewBox="0 0 17.196 15.968"><defs><style>.a{fill:#318afe;}</style></defs><g transform="translate(0 0)"><path class="a" d="M80.571,481.147H64.6a.614.614,0,0,1,0-1.228H80.571a.614.614,0,0,1,0,1.228Z" transform="translate(-63.989 -472.551)"/><path class="a" d="M612.2,645.591h-3.687a.614.614,0,0,1,0-1.228H612.2a.613.613,0,0,0,.614-.614v-3.07a.614.614,0,0,1,1.228,0v3.07A1.842,1.842,0,0,1,612.2,645.591Z" transform="translate(-597.46 -629.623)"/><path class="a" d="M100.9,645.591h-3.07a1.843,1.843,0,0,1-1.842-1.842v-3.07a.614.614,0,1,1,1.228,0v3.07a.615.615,0,0,0,.614.614h3.07a.614.614,0,1,1,0,1.228Z" transform="translate(-95.37 -629.623)"/><path class="a" d="M96.6,101.51a.613.613,0,0,1-.614-.614v-3.07a1.843,1.843,0,0,1,1.842-1.842h3.07a.614.614,0,1,1,0,1.228h-3.07a.617.617,0,0,0-.614.614v3.07A.613.613,0,0,1,96.6,101.51Z" transform="translate(-95.37 -95.983)"/><path class="a" d="M613.428,101.51a.613.613,0,0,1-.614-.614v-3.07a.615.615,0,0,0-.614-.614h-3.687a.614.614,0,0,1,0-1.228H612.2a1.843,1.843,0,0,1,1.842,1.842v3.07A.608.608,0,0,1,613.428,101.51Z" transform="translate(-597.46 -95.984)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user