同步代码
This commit is contained in:
329
pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue
Normal file
329
pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue
Normal file
@@ -0,0 +1,329 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-p-30 u-font-28">
|
||||
<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 ">
|
||||
<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 ">
|
||||
<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-flex u-row-between border-bottom 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-text-left">
|
||||
<text class="color-333">价格(元)</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border-bottom ">
|
||||
<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 ">
|
||||
<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-flex u-row-between border-bottom 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="num">
|
||||
<template #label>
|
||||
<view class=" u-text-left">
|
||||
<text class="color-333">下单数量</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border-bottom ">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.num" placeholder="填写数量"
|
||||
type="digit"></uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item required label="" name="note">
|
||||
<template #label>
|
||||
<view class=" u-text-left">
|
||||
<text class="color-333">备注</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="border u-m-t-16">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.note" placeholder="请输入自定义备注"
|
||||
type="textarea"></uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
</view>
|
||||
|
||||
<view style="height: 200rpx;"></view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-b">
|
||||
<my-button shape="circle" @tap="submit">加入购物车</my-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
returnAllCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import {
|
||||
$tbShopCategory,
|
||||
$tbShopUnit
|
||||
} from '@/http/yskApi/goods.js'
|
||||
import {
|
||||
$temporaryDishes
|
||||
} from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
reactive,
|
||||
onMounted,
|
||||
ref,
|
||||
onBeforeMount,
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
const units = reactive({
|
||||
list: [],
|
||||
current: ''
|
||||
})
|
||||
let category = reactive([])
|
||||
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: '',
|
||||
unit: '',
|
||||
num: ''
|
||||
})
|
||||
// 校验规则
|
||||
const rules = {
|
||||
name: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '菜品名称不能为空'
|
||||
}]
|
||||
},
|
||||
category: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请选择菜品分类'
|
||||
}]
|
||||
},
|
||||
num: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请输入价格'
|
||||
}]
|
||||
},
|
||||
unit: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请选择单位'
|
||||
}]
|
||||
},
|
||||
price: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '请填写下单数量'
|
||||
}]
|
||||
},
|
||||
}
|
||||
let timer = null
|
||||
|
||||
function submit() {
|
||||
refform.value.validate(res => {
|
||||
console.log(res)
|
||||
if (!res) {
|
||||
$temporaryDishes({
|
||||
"useType": option.useType,
|
||||
"masterId": option.masterId,
|
||||
"tableId": option.tableId,
|
||||
"name": form.name,
|
||||
"categoryId": category[categoryCurrent.value].id,
|
||||
"price": form.price,
|
||||
"num": form.num,
|
||||
unit: units.list[units.current].id,
|
||||
"note": form.note,
|
||||
"vipUserId": option.vipUserId
|
||||
}).then(r => {
|
||||
uni.$emit('add:cashCai')
|
||||
clearInterval(timer)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
//获取单位数据
|
||||
async function getTbShopUnit() {
|
||||
const res = await $tbShopUnit({
|
||||
page: 0,
|
||||
size: 200,
|
||||
sort: "id"
|
||||
})
|
||||
units.list = res.content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
}
|
||||
async function getCategory() {
|
||||
const res = await $tbShopCategory({
|
||||
page: 0,
|
||||
size: 600
|
||||
})
|
||||
const arr = forList(res.content).map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
category.length = arr.length
|
||||
for (let i in arr) {
|
||||
category[i] = arr[i]
|
||||
}
|
||||
}
|
||||
|
||||
function forList(arr) {
|
||||
let arrs = []
|
||||
arr.forEach(ele => {
|
||||
arrs.push(ele)
|
||||
if (ele.childrenList.length) {
|
||||
ele.childrenList.forEach(res => {
|
||||
arrs.push(res)
|
||||
})
|
||||
}
|
||||
})
|
||||
return arrs
|
||||
}
|
||||
async function init() {
|
||||
getTbShopUnit()
|
||||
getCategory()
|
||||
}
|
||||
// onMounted(() => {
|
||||
// init()
|
||||
// })
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
setTimeout(() => {
|
||||
init()
|
||||
}, 600)
|
||||
})
|
||||
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
const option = reactive({
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.u-text-left {}
|
||||
|
||||
.form {
|
||||
margin-top: 32rpx;
|
||||
background-color: #fff;
|
||||
padding: 32rpx 24rpx 32rpx 24rpx;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
// background-color: transparent;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #F4F4F4;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item {
|
||||
align-items: inherit;
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item__error {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::v-deep .uni-easyinput__content-input {
|
||||
height: inherit;
|
||||
padding-top: 16rpx;
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
|
||||
::v-deep .uni-forms-item:not(:first-child) {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.fixed-b {
|
||||
position: fixed;
|
||||
left: 100rpx;
|
||||
right: 100rpx;
|
||||
bottom: 100rpx;
|
||||
}
|
||||
</style>
|
||||
297
pagesCreateOrder/choose-table/choose-table.vue
Normal file
297
pagesCreateOrder/choose-table/choose-table.vue
Normal file
@@ -0,0 +1,297 @@
|
||||
<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"
|
||||
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="">
|
||||
<template v-if="tables.list.length">
|
||||
<view class=" 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 class="u-m-t-32">
|
||||
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
|
||||
@change="pageChange"></my-pagination>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
<template v-if="tables.list.length<=0">
|
||||
<my-img-empty tips="未找到相关的桌台"></my-img-empty>
|
||||
</template>
|
||||
</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)
|
||||
}
|
||||
let searchValue = ref('')
|
||||
|
||||
function search() {
|
||||
query.page=1
|
||||
getTable()
|
||||
}
|
||||
|
||||
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]
|
||||
query.page=1
|
||||
getTable()
|
||||
}
|
||||
const query = {
|
||||
page: 1,
|
||||
size: 10,
|
||||
areaId: 0,
|
||||
totalElements:0
|
||||
}
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
console.log(page);
|
||||
query.page = page
|
||||
getTable()
|
||||
}
|
||||
const tables = reactive({
|
||||
hasAjax: false,
|
||||
selIndex: -1,
|
||||
originList: [],
|
||||
list: []
|
||||
})
|
||||
async function getTable() {
|
||||
// let state=status.list[status.active].key
|
||||
// state=state?(state=='all'?'':state):''
|
||||
const areaId=area.list[area.defaultCateIndex].id||''
|
||||
let {
|
||||
content,total
|
||||
} = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
|
||||
query.totalElements=total||0;
|
||||
tables.hasAjax = true;
|
||||
console.log(content);
|
||||
tables.list = content
|
||||
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
|
||||
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) => {
|
||||
getTable()
|
||||
})
|
||||
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;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
|
||||
&.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 28rpx;
|
||||
}
|
||||
|
||||
.scale7 {
|
||||
transform: scale(0.7);
|
||||
}
|
||||
|
||||
::v-deep .uni-searchbar {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.search {
|
||||
padding: 20rpx 28rpx 20rpx 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>
|
||||
194
pagesCreateOrder/choose-user/choose-user.vue
Normal file
194
pagesCreateOrder/choose-user/choose-user.vue
Normal file
@@ -0,0 +1,194 @@
|
||||
<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" @clear="search"
|
||||
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>
|
||||
<template v-if="list.length>0">
|
||||
<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 class="u-flex">
|
||||
<view>{{item.nickName}}</view>
|
||||
</view>
|
||||
<view class="u-m-t-12 ">手机号:{{item.telephone}}</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.accountPoints}}</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 class="u-m-t-32">
|
||||
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
|
||||
@change="pageChange"></my-pagination>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template v-if="hasAjax&&list.length<=0">
|
||||
<my-img-empty tips="未找到相关用户"></my-img-empty>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as Api from '@/http/yskApi/shop-user.js'
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
reactive,
|
||||
onBeforeMount,
|
||||
ref
|
||||
} from 'vue';
|
||||
let nouser = ref(false)
|
||||
let timer = null
|
||||
|
||||
function emitChooser(data) {
|
||||
uni.$emit('choose-user', data)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
||||
function chooseUser(index, item) {
|
||||
if (index === undefined || item === undefined) {
|
||||
nouser.value = true
|
||||
return emitChooser({
|
||||
id: '',
|
||||
headImg: '',
|
||||
telephone: '',
|
||||
amount: '0.00',
|
||||
accountPoints: '0.00'
|
||||
})
|
||||
} else {
|
||||
list[index].checked = true
|
||||
emitChooser(item)
|
||||
}
|
||||
}
|
||||
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
name: '',
|
||||
totalElements: 0,
|
||||
size: 10,
|
||||
isVip: 1
|
||||
})
|
||||
const list = reactive([])
|
||||
let hasAjax = ref(false)
|
||||
async function getUser() {
|
||||
const {
|
||||
content,
|
||||
totalElements
|
||||
} = await Api.queryAllShopUser(query)
|
||||
hasAjax.value = true
|
||||
list.length = content.length
|
||||
for (let i in content) {
|
||||
list[i] = {
|
||||
...content[i],
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
query.totalElements = totalElements
|
||||
console.log(list);
|
||||
}
|
||||
|
||||
function pageChange(e) {
|
||||
query.page = e
|
||||
getUser()
|
||||
}
|
||||
|
||||
function search() {
|
||||
query.page = 1
|
||||
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>
|
||||
203
pagesCreateOrder/components/edit-discount.vue
Normal file
203
pagesCreateOrder/components/edit-discount.vue
Normal file
@@ -0,0 +1,203 @@
|
||||
<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" >修改</my-button>
|
||||
<view class="">
|
||||
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button>
|
||||
</view>
|
||||
</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: []
|
||||
},
|
||||
discount:{
|
||||
type: [Number,String],
|
||||
default:100
|
||||
},
|
||||
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()
|
||||
form.price=props.price
|
||||
form.currentPrice=props.price
|
||||
form.discount=props.discount
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
console.log(form);
|
||||
emits('confirm',{...form,currentPrice:Number(form.currentPrice).toFixed(2)})
|
||||
close()
|
||||
}
|
||||
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>
|
||||
269
pagesCreateOrder/confirm-order/components/discount.vue
Normal file
269
pagesCreateOrder/confirm-order/components/discount.vue
Normal file
@@ -0,0 +1,269 @@
|
||||
<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">当前单品价格:{{price}}</text>
|
||||
</view>
|
||||
<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,index)" 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="form.note" 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>
|
||||
<view style="height: 20rpx;">
|
||||
|
||||
</view>
|
||||
<!-- <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: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const discounts = [95, 90, 85, 80]
|
||||
const causes = reactive([{
|
||||
name: '顾客投诉质量问题',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '友情打折',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '临时活动',
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
function changeCauses(item, index) {
|
||||
item.checked = !item.checked
|
||||
form.notes = causes
|
||||
}
|
||||
|
||||
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(1)
|
||||
|
||||
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: '请输入有效减免价格!'
|
||||
})
|
||||
}
|
||||
emits('confirm', form)
|
||||
close()
|
||||
}
|
||||
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>
|
||||
170
pagesCreateOrder/confirm-order/components/remark.vue
Normal file
170
pagesCreateOrder/confirm-order/components/remark.vue
Normal file
@@ -0,0 +1,170 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-l-30 u-p-r-30 u-p-t-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-l-30 u-p-r-30 u-m-t-28 u-p-b-30">
|
||||
<view class="">
|
||||
<my-button @tap="confirm" shape="circle" fontWeight="700">确认</my-button>
|
||||
<view class="u-m-t-10">
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function changeCauses(item) {
|
||||
let prve=form.remark?',':''
|
||||
form.remark +=prve+item.name
|
||||
console.log(form.remark);
|
||||
}
|
||||
|
||||
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(data) {
|
||||
Object.assign(form,data)
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {remark
|
||||
} = form
|
||||
emits('confirm', {
|
||||
remark
|
||||
})
|
||||
console.log(remark);
|
||||
close()
|
||||
|
||||
}
|
||||
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>
|
||||
924
pagesCreateOrder/confirm-order/confirm-order.vue
Normal file
924
pagesCreateOrder/confirm-order/confirm-order.vue
Normal file
@@ -0,0 +1,924 @@
|
||||
<template>
|
||||
<view class="page-gray color-333 u-font-28">
|
||||
<template v-if="true">
|
||||
<view class="block u-p-t-32 u-p-b-32" v-if="table&&table.tableId">
|
||||
<view>桌位号</view>
|
||||
<view class="font-bold u-font-32 u-m-t-16">
|
||||
{{table.name||''}}
|
||||
</view>
|
||||
</view>
|
||||
<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||!user.id">选择用户</view>
|
||||
<view class="u-flex" v-if="user&&user.id">
|
||||
<up-avatar :src="user.headImg" shape="square" :size="30"></up-avatar>
|
||||
<!-- <view class="headeimg">
|
||||
<image class="img" :src="user.headImg" mode=""></image>
|
||||
</view> -->
|
||||
<view class="u-m-l-20">
|
||||
<!-- <view class="color-main u-font-24 no-wrap">{{user.isVip?'会员':'' }}</view> -->
|
||||
<view class="">{{user.nickName}}</view>
|
||||
</view>
|
||||
<view class="u-font-24 u-m-l-30 u-text-center"><text>余额:</text><text
|
||||
class="color-main">{{user.amount}}</text>
|
||||
</view>
|
||||
<view class="u-font-24 u-m-l-30 u-text-center"><text>积分:</text><text
|
||||
class="color-main">{{user.accountPoints}}</text></view>
|
||||
</view>
|
||||
<uni-icons type="right" color="#999" size="20" bold></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class=" ">
|
||||
<view>就餐类型</view>
|
||||
<view class="u-m-t-24 u-flex ">
|
||||
<view class="u-flex color-666">
|
||||
<up-radio-group :disabled="option.type=='add'" v-model="eatTypes.active" placement="row">
|
||||
<up-radio :customStyle="{marginRight: '30px'}" v-for="(item, index) in eatTypes.list"
|
||||
:key="index" :label="item.name" :name="item.value">
|
||||
</up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
</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">
|
||||
<up-radio-group :disabled="option.type=='add'" v-model="eatTypes.active" placement="row">
|
||||
<up-radio :customStyle="{marginRight: '30px'}" v-for="(item, index) in eatTypes.list"
|
||||
:key="index" :label="item.name" :name="item.value">
|
||||
</up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class=" " @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="16"></uni-icons>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
|
||||
<template v-if="user&&user.id">
|
||||
<view class="block">
|
||||
<view class="">
|
||||
<view class="u-flex border-bottom u-p-b-24 ">
|
||||
<up-avatar :src="user.headImg" shape="square" :size="60"></up-avatar>
|
||||
<!-- <image class="headeimg" src="@/static/uni.png" mode=""></image> -->
|
||||
<view class="u-m-l-32">
|
||||
<view class="">{{user.nickName}}</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"> {{user.amount}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view>积分</view>
|
||||
<view class="color-333 u-m-l-10"> {{user.accountPoints}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="u-text-center">订单数量</view>
|
||||
<view class="color-333 u-m-l-10">{{user.orderNumber||0}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="!$shop.isTableFee">
|
||||
<!-- 不免餐位费 -->
|
||||
<view class="block">
|
||||
<view class=" ">
|
||||
<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*1+1+'人'}}</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<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 u-m-b-0">
|
||||
<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-48" @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" v-if="item.coverImg" :src="item.coverImg" mode=""></image>
|
||||
<view
|
||||
style="background-color: #3f9eff; width: 84rpx;height: 84rpx;line-height: 84rpx;text-align: center;color: #fff;"
|
||||
v-else>
|
||||
临时菜
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-20" v-if="item.isWaitCall">
|
||||
<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 class="u-m-r-20 u-flex" v-if="item.isPrint">
|
||||
<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=" u-relative">
|
||||
<template v-if="item.isGift">
|
||||
<text class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
||||
<text class="font-bold">¥0</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="isVip&&item.memberPrice&&item.memberPrice*1!=item.salePrice*1">
|
||||
<text
|
||||
class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
||||
<text
|
||||
class="font-bold">¥{{formatPrice(item.memberPrice*item.number) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="font-bold">
|
||||
<text>¥</text>
|
||||
<text class="">{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
</view>
|
||||
<view class="color-999 u-text-right u-font-24 u-m-t-12">×{{item.number}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="item.note">
|
||||
<view class="u-p-20 bg-gray u-m-t-16">
|
||||
{{item.note}}
|
||||
</view>
|
||||
</template>
|
||||
<scroll-view class="u-m-t-32" scroll-x="true" v-if="index==goods.sel">
|
||||
<view class=" u-flex no-wrap ">
|
||||
<view class="u-flex u-m-r-20 " v-if="!item.isGift">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="showModel('discount',index)">单品打折</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-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 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleWait(item)">{{item.isWaitCall?'取消等叫':'等叫'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggisPrint(item)">{{item.isPrint?'免厨打':'打印'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="showModel('remark',index)">单品备注</button>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-bottom">
|
||||
<template v-if="$seatFee&&$seatFee.totalAmount">
|
||||
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
|
||||
<view>
|
||||
<text>桌位费</text>
|
||||
</view>
|
||||
<view>¥{{$seatFee.totalAmount||'0.00'}}</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="$packFee>0">
|
||||
<view class="u-flex u-row-between u-m-t-18 u-p-b-34 ">
|
||||
<view>
|
||||
<text>打包费</text>
|
||||
</view>
|
||||
<view>¥{{$packFee||'0.00'}}</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="u-flex u-row-between u-m-t-38">
|
||||
<!-- <template v-if="$shop.registerType=='munchies'">
|
||||
<view class="color-main" @tap="showModel('editMoney')">修改</view>
|
||||
</template> -->
|
||||
<view class="u-flex">
|
||||
<view class="u-flex price" v-if="youhui*1>0">
|
||||
<view class="">优惠金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(youhui) }}</view>
|
||||
</view>
|
||||
</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:bottomHeight+'px'}"></view>
|
||||
<view class="safe-bottom fixed">
|
||||
<!-- <view class="u-m-b-48">
|
||||
<label class="radio">
|
||||
<radio value="" class="scale7" /><text>打印预结算</text>
|
||||
</label>
|
||||
</view> -->
|
||||
|
||||
<view class="btn ">
|
||||
<my-button shape="circle" @click="createOrder">
|
||||
<view class="font-bold u-font-32">
|
||||
{{($shop.registerType=='munchies'||eatTypes.active=='takeout')?'结算': '下单'}}
|
||||
</view>
|
||||
</my-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<model-discount title="菜品减免" :ref="setModel" name="discount" :price="modelData.data.salePrice"
|
||||
@confirm="discountconfirm"></model-discount>
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
</view>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
ref,
|
||||
onBeforeUnmount,
|
||||
reactive,
|
||||
computed,
|
||||
watch
|
||||
} from 'vue';
|
||||
import {
|
||||
getSafeBottomHeight
|
||||
} from '@/commons/utils/safe-bottom.js'
|
||||
import modelDiscount from './components/discount'
|
||||
import giveFood from './components/give-food'
|
||||
import oneRemark 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'
|
||||
import $storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
tbShopInfo
|
||||
} from '@/http/yskApi/user.js'
|
||||
import {
|
||||
getNowCart
|
||||
} from '@/pagesCreateOrder/util.js'
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
const models = new Map();
|
||||
const modelData = reactive({
|
||||
data: {},
|
||||
selIndex: -1
|
||||
})
|
||||
//备注
|
||||
let note = ref('')
|
||||
|
||||
function setModel(el) {
|
||||
if (el && el.$attrs['name']) {
|
||||
models.set(el.$attrs['name'], el);
|
||||
}
|
||||
}
|
||||
|
||||
function showModel(key, index) {
|
||||
modelData.data = goods.list[index]
|
||||
modelData.selIndex = index
|
||||
const model = models.get(key)
|
||||
model && model.open({
|
||||
remark: modelData.data.note || ''
|
||||
})
|
||||
}
|
||||
|
||||
function formatPrice(n) {
|
||||
return Number(n).toFixed(2)
|
||||
}
|
||||
|
||||
// 单品打折
|
||||
async function discountconfirm(form) {
|
||||
if (form.discountMoney != '.') {
|
||||
let str = ''
|
||||
if (form.notes) {
|
||||
form.notes.forEach(ele => {
|
||||
if (ele.checked) {
|
||||
str = str + ele.name + ','
|
||||
}
|
||||
})
|
||||
}
|
||||
let obj = {
|
||||
saleAmount: form.discountMoney,
|
||||
note: str + form.note,
|
||||
cartId: modelData.data.id
|
||||
}
|
||||
const res = await Api.$updatePrice(obj)
|
||||
getCart()
|
||||
}
|
||||
}
|
||||
|
||||
//用餐人数
|
||||
const userNumbers = reactive({
|
||||
list: new Array(100).fill(1).map((v, index) => {
|
||||
// return index === 0 ? '无' : index + '人'
|
||||
return (index + 1) + '人'
|
||||
}),
|
||||
defaultCateIndex: 0,
|
||||
})
|
||||
watch(() => userNumbers.defaultCateIndex, (newval) => {
|
||||
updateChoseCount()
|
||||
})
|
||||
|
||||
//更新就餐人数
|
||||
async function updateChoseCount() {
|
||||
console.log($shop.value);
|
||||
const maxCapacity = table.value.tableId ? (table.value.maxCapacity || 0) : 100
|
||||
if (table.value.tableId && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
|
||||
uni.showToast({
|
||||
title: '当前台桌最大人数为: ' + maxCapacity
|
||||
})
|
||||
userNumbers.defaultCateIndex = maxCapacity - 1
|
||||
return
|
||||
}
|
||||
if (!$shop.value.isTableFee && table.value.tableId) {
|
||||
//不免餐位费
|
||||
const res = await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: table.value.tableId || '',
|
||||
num: userNumbers.defaultCateIndex * 1 + 1,
|
||||
})
|
||||
Object.assign($seatFee, res)
|
||||
userNumbers.defaultCateIndex = res.totalNumber - 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function userNumberChange(e) {
|
||||
console.log(e);
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
}
|
||||
|
||||
const form = reactive({})
|
||||
//切换商品状态
|
||||
async function toggleGoodsItemKey(item, index, key) {
|
||||
const {
|
||||
productId,
|
||||
skuId,
|
||||
id,
|
||||
number,
|
||||
isPack,
|
||||
isGift
|
||||
} = item
|
||||
const par = {
|
||||
cartId: id,
|
||||
isPack,
|
||||
isGift,
|
||||
masterId: option.masterId,
|
||||
tableId: table.value.tableId || '',
|
||||
productId,
|
||||
num: number,
|
||||
skuId
|
||||
}
|
||||
par[key] = !item[key]
|
||||
|
||||
|
||||
const res = await Api.$updateCart(par)
|
||||
goods.list[index][key] = returnBoolean(res[key])
|
||||
getCart()
|
||||
}
|
||||
//等叫
|
||||
async function toggleWait(item) {
|
||||
item.isWaitCall = !item.isWaitCall
|
||||
let obj = {
|
||||
cartId: item.id,
|
||||
isGift: item.isGift,
|
||||
isPack: item.isPack,
|
||||
isPrint: item.isPrint,
|
||||
isWaitCall: item.isWaitCall,
|
||||
masterId: option.masterId,
|
||||
num: item.number, // 0会删除此商品
|
||||
productId: item.productId,
|
||||
skuId: item.skuId,
|
||||
vipUserId: '',
|
||||
}
|
||||
let res = await Api.$updateCart(obj)
|
||||
}
|
||||
// 打印
|
||||
async function toggisPrint(item) {
|
||||
item.isPrint = !item.isPrint
|
||||
let obj = {
|
||||
cartId: item.id,
|
||||
isGift: item.isGift,
|
||||
isPack: item.isPack,
|
||||
isPrint: item.isPrint,
|
||||
isWaitCall: item.isWaitCall,
|
||||
masterId: option.masterId,
|
||||
num: item.number, // 0会删除此商品
|
||||
productId: item.productId,
|
||||
skuId: item.skuId,
|
||||
vipUserId: '',
|
||||
}
|
||||
let res = await Api.$updateCart(obj)
|
||||
}
|
||||
|
||||
const eatTypes = reactive({
|
||||
list: [{
|
||||
name: "堂食",
|
||||
value: "dine-in",
|
||||
},
|
||||
{
|
||||
name: "自取",
|
||||
value: "takeout",
|
||||
}
|
||||
],
|
||||
active: 'dine-in'
|
||||
})
|
||||
|
||||
const $packFee = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.packFee
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
function chooseUser() {
|
||||
go.to('PAGES_CHOOSE_USER')
|
||||
}
|
||||
|
||||
function chooseTable() {
|
||||
go.to('PAGES_CHOOSE_TABLE', {
|
||||
...table.value
|
||||
})
|
||||
}
|
||||
const option = reactive({
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
// 监听选择用户事件
|
||||
let user = ref(null)
|
||||
//更新选择用户
|
||||
function setUser(par) {
|
||||
console.log(option);
|
||||
const submitPar = {
|
||||
masterId: option.masterId,
|
||||
tableId: table.value.tableId || "",
|
||||
vipUserId: user.value.id ? user.value.id : '',
|
||||
type: user.value.id ? 0 : 1 //0 设置 1 取消
|
||||
}
|
||||
Object.assign(submitPar, par)
|
||||
return Api.$setUser(submitPar)
|
||||
}
|
||||
|
||||
function watchChooseuser() {
|
||||
uni.$off('choose-user')
|
||||
uni.$on('choose-user', (data) => {
|
||||
user.value = data
|
||||
setUser()
|
||||
})
|
||||
}
|
||||
let table = ref(null)
|
||||
//监听桌台改变
|
||||
watch(() => table.value, (newval, oldval) => {
|
||||
if (newval && oldval) {
|
||||
// Api.$choseTable({
|
||||
// orderId: 4462,
|
||||
// oldTableId: oldval.tableId,
|
||||
// newTableId: newval.tableId,
|
||||
// })
|
||||
}
|
||||
})
|
||||
|
||||
function watchChooseTable() {
|
||||
uni.$off('choose-table')
|
||||
uni.$on('choose-table', (data) => {
|
||||
table.value = data
|
||||
console.log(table.value);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const goods = reactive({
|
||||
list: [],
|
||||
sel: 0
|
||||
})
|
||||
const goodsNumber = computed(() => {
|
||||
const result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
//餐位费
|
||||
const $seatFee = reactive({
|
||||
totalNumber: 0,
|
||||
totalAmount: 0,
|
||||
})
|
||||
const isVip = computed(() => {
|
||||
return $shop.value.isMemberPrice && user.value && user.value.id && user.value.isVip
|
||||
})
|
||||
const discountSaleAmount = computed(() => {
|
||||
return goods.list.filter((v) => v.discountSaleAmount && v.discountSaleAmount > 0)
|
||||
.reduce((a, b) => {
|
||||
return a + b.number * b.discountSaleAmount;
|
||||
}, 0);
|
||||
})
|
||||
const goodsPrice = computed(() => {
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.salePrice
|
||||
const tPrice = (isVip.value ? memberPrice : cur.salePrice) * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
|
||||
}, 0)
|
||||
return ((goodsTotalPrice - discountSaleAmount.value) || 0).toFixed(2)
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
const n = goodsPrice.value * 1 + $seatFee.totalAmount
|
||||
return n.toFixed(2)
|
||||
// const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
// return prve + cur.salePrice * cur.number * (cur.isGift ? 0 : 1)
|
||||
// }, 0)
|
||||
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
|
||||
})
|
||||
const youhui = computed(() => {
|
||||
let goodsTotalPrice = 0
|
||||
if (user.value && user.value.id && user.value.isVip) {
|
||||
goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const tPrice = cur.salePrice * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + tPrice + tpackFee
|
||||
}, 0)
|
||||
return goodsTotalPrice - allPrice.value
|
||||
} else {
|
||||
console.log(discountSaleAmount.value,'优惠金额')
|
||||
return (discountSaleAmount.value)
|
||||
}
|
||||
console.log(discountSaleAmount.value,'优惠金额1')
|
||||
return (goodsTotalPrice + discountSaleAmount.value * 1).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: table.value.tableId || ''
|
||||
}) {
|
||||
const {
|
||||
records,
|
||||
seatFee
|
||||
} = await Api.getCart(par)
|
||||
let useType = ''
|
||||
if (seatFee && seatFee.useType) {
|
||||
useType = seatFee.useType
|
||||
$storageManage.useType(useType)
|
||||
} else {
|
||||
useType = records[0].info[0].useType
|
||||
$storageManage.useType(useType)
|
||||
}
|
||||
console.log(useType);
|
||||
eatTypes.active = useType == 'takeout' ? useType : useType.replace(
|
||||
/-after|-before/g, '');
|
||||
goods.list = getNowCart(records)
|
||||
if (seatFee && seatFee.totalNumber) {
|
||||
userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0
|
||||
Object.assign($seatFee, seatFee)
|
||||
} else {
|
||||
$seatFee.totalAmount = 0
|
||||
}
|
||||
console.log(userNumbers.defaultCateIndex);
|
||||
}
|
||||
|
||||
let $shop = ref({
|
||||
registerType: ''
|
||||
})
|
||||
// 获取账号信息
|
||||
async function getTbShopInfo() {
|
||||
const res = await tbShopInfo()
|
||||
$shop.value = res
|
||||
console.log(res);
|
||||
return res
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
async function createOrder(par = {
|
||||
masterId: option.masterId,
|
||||
vipUserId: user.value ? user.value.id : '',
|
||||
note: note.value,
|
||||
postPay: true,
|
||||
orderId: '',
|
||||
tableId: table.value.tableId || ''
|
||||
}) {
|
||||
if (!$shop.value.isTableFee) {
|
||||
//不免餐位费
|
||||
await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: table.value.tableId || "",
|
||||
num: userNumbers.defaultCateIndex + 1,
|
||||
})
|
||||
}
|
||||
if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
|
||||
const canJiesuan = await hasPermission('允许收款')
|
||||
if (!canJiesuan) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// updateChoseCount()
|
||||
const res = await Api.$createOrder(par)
|
||||
uni.$emit('update:createOrderIndex')
|
||||
console.log($shop.value);
|
||||
console.log(res);
|
||||
if ($shop.value.registerType == 'munchies' || eatTypes.active == 'takeout') {
|
||||
//先付
|
||||
return go.to('PAGES_ORDER_PAY', {
|
||||
orderId: res.id,
|
||||
isNowPay: true
|
||||
}, 'redirect')
|
||||
} else {
|
||||
//后付
|
||||
console.log(option.isCreateOrderToDetail);
|
||||
if (option.isCreateOrderToDetail != '0') {
|
||||
console.log('PAGES_ORDER_DETAIL');
|
||||
go.to('PAGES_ORDER_DETAIL', {
|
||||
id: res.id
|
||||
}, 'redirect')
|
||||
} else {
|
||||
console.log('back');
|
||||
uni.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}
|
||||
|
||||
// return go.to('PAGES_ORDER_DETAIL', {
|
||||
// id: res.id
|
||||
// })
|
||||
}
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'none'
|
||||
})
|
||||
// setTimeout(() => {
|
||||
// uni.$emit('orderDetail:update')
|
||||
// uni.navigateBack({
|
||||
// delta: 2
|
||||
// })
|
||||
// }, 500)
|
||||
}
|
||||
|
||||
//单品备注确认
|
||||
async function goodsOneRemarkConfirm(e) {
|
||||
const cart = goods.list[modelData.selIndex]
|
||||
await Api.$updateCart({
|
||||
cartId: cart.id,
|
||||
productId: cart.productId,
|
||||
skuId: cart.skuId,
|
||||
tableId: option.tableId || "",
|
||||
note: e.remark,
|
||||
num: cart.number // 0会删除此商品
|
||||
})
|
||||
cart.note = e.remark
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await getTbShopInfo()
|
||||
await getCart()
|
||||
console.log($seatFee);
|
||||
if (!$seatFee.totalNumber) {
|
||||
updateChoseCount()
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
console.log(opt);
|
||||
if (opt) {
|
||||
table.value = {
|
||||
...option,
|
||||
tableId: opt.tableId || '',
|
||||
name: opt.name
|
||||
}
|
||||
userNumbers.list = new Array(opt.maxCapacity ? opt.maxCapacity * 1 : 100).fill(1).map((v, index) => {
|
||||
return (index + 1) + '人'
|
||||
})
|
||||
// console.log(userNumbers.list);
|
||||
}
|
||||
init()
|
||||
|
||||
// updateChoseCount()
|
||||
})
|
||||
let bottomHeight = ref(100)
|
||||
onReady(() => {
|
||||
getSafeBottomHeight('safe-bottom').then(res => {
|
||||
console.log(res);
|
||||
bottomHeight.value = res
|
||||
})
|
||||
})
|
||||
|
||||
async function changeUseType() {
|
||||
const {
|
||||
registerType
|
||||
} = $shop.value
|
||||
//munchies 先付 restaurant 后付
|
||||
const isPayAfter = registerType == "munchies" ? false : true;
|
||||
let useType = "takeout";
|
||||
if (eatTypes.active == "takeout") {
|
||||
uni.setStorageSync("useType", "takeout");
|
||||
} else {
|
||||
//堂食
|
||||
useType = `dine-in-${isPayAfter? "after" : "before"}`;
|
||||
uni.setStorageSync("useType", useType);
|
||||
}
|
||||
const tableId = useType == 'takeout' ? undefined : table.value.tableId;
|
||||
if (!goods.list.length) {
|
||||
return
|
||||
}
|
||||
const res = await Api.$changeUseType({
|
||||
useType,
|
||||
tableId: tableId || '',
|
||||
cartIds: goods.list.map((v) => v.id),
|
||||
})
|
||||
getCart()
|
||||
return res
|
||||
}
|
||||
watch(() => eatTypes.active, (newval) => {
|
||||
changeUseType()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
})
|
||||
onShow(() => {
|
||||
watchChooseuser()
|
||||
watchChooseTable()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fen {
|
||||
color: #FF9F2E;
|
||||
}
|
||||
|
||||
.page-gray {
|
||||
padding: 32rpx 28rpx 0 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>
|
||||
324
pagesCreateOrder/index/components/car.vue
Normal file
324
pagesCreateOrder/index/components/car.vue
Normal file
@@ -0,0 +1,324 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
<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.toFixed(0)}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true)">清空</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 class="u-line-1">{{item.name}}</view>
|
||||
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{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).toFixed(2)}}
|
||||
</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">
|
||||
<text class="u-font-32 font-bold">{{table.type=='add'?'确认加菜':'去下单'}} </text>
|
||||
</my-button>
|
||||
|
||||
|
||||
</view>
|
||||
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
|
||||
width="300px"></up-modal>
|
||||
</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,
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
isCreateOrderToDetail: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: ""
|
||||
}
|
||||
}
|
||||
},
|
||||
table: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
tableId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
masterId: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
const modal = reactive({
|
||||
key: '',
|
||||
clear: false
|
||||
})
|
||||
|
||||
function confirmModelConfirm() {
|
||||
if (modal.key == 'clear') {
|
||||
clear()
|
||||
}
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true) {
|
||||
if (key == 'clear' && show && props.data.length <= 0) {
|
||||
return infoBox.showToast('购物车是空的!')
|
||||
}
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
console.log(modal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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('还没有选择商品')
|
||||
}
|
||||
const {
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
type
|
||||
} = props.table
|
||||
if (props.table.tableId == '') {
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
return
|
||||
}
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
type,
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
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() {
|
||||
setModalShow('clear', false)
|
||||
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;
|
||||
background-color: #fff;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(40rpx + 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>
|
||||
246
pagesCreateOrder/index/components/guige.vue
Normal file
246
pagesCreateOrder/index/components/guige.vue
Normal file
@@ -0,0 +1,246 @@
|
||||
<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="isDisabled">
|
||||
<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,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
import infobox from '@/commons/utils/infoBox.js'
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
const props = defineProps({
|
||||
goodsData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
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]
|
||||
})
|
||||
watch(() => goods.value, (newval) => {
|
||||
console.log(props.goodsData.isStock);
|
||||
number.value = newval.suit || 1
|
||||
})
|
||||
|
||||
|
||||
const isCanBuy = computed(() => {
|
||||
if (!goods.value) {
|
||||
return false
|
||||
}
|
||||
return util.isCanBuy(
|
||||
goods.value,
|
||||
props.goodsData
|
||||
)
|
||||
|
||||
})
|
||||
|
||||
//全部规格是否都无法使用
|
||||
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()
|
||||
}
|
||||
|
||||
const isDisabled = computed(() => {
|
||||
return isAllDisabled.value || !isCanBuy.value
|
||||
})
|
||||
|
||||
function reduce() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const suit = goods.value.suit || 1
|
||||
const newval = number.value - 1
|
||||
if (newval < suit) {
|
||||
return infobox.showToast(suit + '个起售')
|
||||
}
|
||||
number.value = newval <= 1 ? 1 : newval
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const newval = number.value + 1
|
||||
number.value = newval
|
||||
}
|
||||
|
||||
|
||||
|
||||
function confirm() {
|
||||
close()
|
||||
if (isDisabled.value) {
|
||||
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>
|
||||
183
pagesCreateOrder/index/components/list-goods-item.vue
Normal file
183
pagesCreateOrder/index/components/list-goods-item.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<view class="u-relative u-flex item">
|
||||
|
||||
<up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
|
||||
<!-- <image lazy-load class="img" :src="data.coverImg" mode="aspectFill" :style="computedImgStyle()"></image> -->
|
||||
<view class="info u-flex u-row-between u-col-top u-flex-col">
|
||||
<view>
|
||||
<view>
|
||||
<text class="u-line-2">{{data.name}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="u-font-32 font-bold u-m-t-16">
|
||||
¥{{data.price}}
|
||||
</view>
|
||||
<template v-if="data.type=='weigh'">
|
||||
<view class="btnweigh">称重</view>
|
||||
</template>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<template v-if="!isSellout">
|
||||
<template v-if="!data.isDan||data.groupType==1">
|
||||
<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(data.type=='weigh'?'tapweigh':'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).toFixed(2)}}
|
||||
</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';
|
||||
import util from '../util.js';
|
||||
const props = defineProps({
|
||||
img: {
|
||||
type: Object,
|
||||
default: {
|
||||
width: '250rpx',
|
||||
height: '272rpx'
|
||||
}
|
||||
},
|
||||
index: {
|
||||
type: [Number, String],
|
||||
},
|
||||
isSeatFee: {
|
||||
//是否为餐位费
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
chooseNumber: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function computedImgStyle() {
|
||||
return {
|
||||
width: props.img.width,
|
||||
height: props.img.height
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否是菜品
|
||||
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.isStock == 1 && item.stockNumber <= 0)
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
const emits = defineEmits(['add', 'reduce', 'chooseGuige','tapweigh'])
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.btnweigh {
|
||||
margin: 5rpx 0;
|
||||
width: 100rpx;
|
||||
background: linear-gradient(124deg, #73c969 6%, #27921b 93%);
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
padding: 6rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn-hover-class {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
image {
|
||||
will-change: transform
|
||||
}
|
||||
|
||||
.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>
|
||||
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>
|
||||
180
pagesCreateOrder/index/components/taocanModel.vue
Normal file
180
pagesCreateOrder/index/components/taocanModel.vue
Normal file
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<my-model ref="model" borderRadius="12" :title="datas.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 datas.skus" :key="index">
|
||||
<view class="u-text-left">
|
||||
<view class="color-333">{{item.title}} <text
|
||||
style="color:#999">({{item.count}}选{{item.number}})</text> </view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap">
|
||||
<view class="item" @tap="chooseSkd(skd,item)" :class="{active:skd.select==true}"
|
||||
v-for="(skd,skdIndex) in item.goods" :key="skdIndex">
|
||||
{{skd.proName}}
|
||||
</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">
|
||||
<text>¥</text>
|
||||
<text>{{datas.price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm">添加</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
<uni-popup ref="popup" type="message">
|
||||
<uni-popup-message type="info" message="请选择套餐" :duration="2000"></uni-popup-message>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
import infobox from '@/commons/utils/infoBox.js'
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
const props = defineProps({
|
||||
goodsData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
})
|
||||
|
||||
let datas = reactive({
|
||||
item: "",
|
||||
title: "",
|
||||
price: "",
|
||||
skus: [],
|
||||
// 几选几,的和
|
||||
selectNumber: 0,
|
||||
})
|
||||
|
||||
|
||||
// const selSku = computed(() => {
|
||||
// return props.skus.reduce((prve, cur) => {
|
||||
// prve.push(cur.sel)
|
||||
// return prve
|
||||
// }, []).join()
|
||||
// })
|
||||
|
||||
|
||||
// const goods = computed(() => {
|
||||
// return props.skuMap[selSku.value]
|
||||
// })
|
||||
watch(() => props.goodsData, (newval) => {
|
||||
newval.proGroupVo.forEach(ele => {
|
||||
ele.selectData = []
|
||||
})
|
||||
datas.item = newval
|
||||
datas.title = newval.name
|
||||
datas.price = newval.price
|
||||
datas.skus = newval.proGroupVo
|
||||
datas.skus.forEach(ele => {
|
||||
datas.selectNumber += ele.number
|
||||
})
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
|
||||
function chooseSkd(skd, item) {
|
||||
if (item.selectData.includes(skd.proId)) {
|
||||
skd.select = false
|
||||
let indexs = item.selectData.indexOf(skd.proId)
|
||||
item.selectData.splice(indexs, 1)
|
||||
} else {
|
||||
if (item.selectData.length < item.number) {
|
||||
skd.select = true
|
||||
item.selectData.push(skd.proId)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
datas.item.proGroupVo.forEach(ele => {
|
||||
arr.push(...ele.selectData)
|
||||
})
|
||||
if (arr.length == datas.selectNumber) {
|
||||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
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>
|
||||
290
pagesCreateOrder/index/components/weigh.vue
Normal file
290
pagesCreateOrder/index/components/weigh.vue
Normal file
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<up-overlay :show="overlayshow" @click="overlayshow = false">
|
||||
<view class="boxoverlay">
|
||||
<view class="rect" @tap.stop>
|
||||
<view class="title">
|
||||
<view>
|
||||
标题
|
||||
</view>
|
||||
<view class="" @click="overlayshow = false">
|
||||
<up-icon name="close" color="#93969b" size="20"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="inputtop">
|
||||
<view class="dj">
|
||||
<view class="text">单价</view>
|
||||
<view class="jg">¥{{form.goods.lowPrice}}/{{form.goods.unitName}}</view>
|
||||
</view>
|
||||
<view class="inputdj">
|
||||
<view>重量</view>
|
||||
<view class="inputdjbox">
|
||||
<view class="inputdisplay">{{ currentInput }}</view>
|
||||
<text>{{ form.goods.unitName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="keyboard">
|
||||
<button v-for="(num, index) in numberButtons" :key="index" @click="handleClick(num)">
|
||||
{{ num }}
|
||||
</button>
|
||||
<button @click="deleteLast">←</button>
|
||||
</view>
|
||||
<view class="classmoney">
|
||||
¥ {{ (form.goods.lowPrice * currentInput).toFixed(2) }}
|
||||
</view>
|
||||
<view class="classconfirm" @click="clickconfirm">
|
||||
确认
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-overlay>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
defineExpose,
|
||||
defineEmits
|
||||
} from 'vue';
|
||||
const emit = defineEmits(['refresh'])
|
||||
const currentInput = ref('');
|
||||
|
||||
const numberButtons = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.'];
|
||||
|
||||
const handleClick = (value) => {
|
||||
// 首位不能输入0
|
||||
if (currentInput.value === '') {
|
||||
if (value === '0') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (value === '.' && currentInput.value.indexOf('.') !== -1) {
|
||||
return; // 如果已经存在小数点,不再添加
|
||||
}
|
||||
if (value === '.' && currentInput.value === '') {
|
||||
currentInput.value = '0.';
|
||||
} else {
|
||||
currentInput.value += value;
|
||||
}
|
||||
// 限制小数点后两位
|
||||
const parts = currentInput.value.split('.');
|
||||
if (parts.length > 1 && parts[1].length > 2) {
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
}
|
||||
};
|
||||
const deleteLast = () => {
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
};
|
||||
|
||||
const clickconfirm = () => {
|
||||
// 首位不能输入0
|
||||
if (currentInput.value === '') {
|
||||
uni.showToast({
|
||||
title: '请输入',
|
||||
icon: 'none'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
emit('weighgoodsUpdate', form.foodsindex, form.index, true, undefined, currentInput.value)
|
||||
overlayshow.value = false
|
||||
}
|
||||
//显示
|
||||
const overlayshow = ref(false);
|
||||
const form = reactive({})
|
||||
const open = (foodsindex, index, goods) => {
|
||||
currentInput.value = ''
|
||||
Object.assign(form, {
|
||||
foodsindex,
|
||||
index,
|
||||
goods
|
||||
})
|
||||
overlayshow.value = true
|
||||
}
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
.boxoverlay {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
|
||||
.rect {
|
||||
padding: 32rpx 28rpx;
|
||||
width: 80%;
|
||||
background-color: #fff;
|
||||
border-radius: 18rpx;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 20rpx;
|
||||
font-size: 40rpx;
|
||||
border-bottom: 1rpx solid #ccc;
|
||||
}
|
||||
|
||||
.inputtop {
|
||||
margin-top: 20rpx;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.dj {
|
||||
width: 32%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
|
||||
.text {
|
||||
font-weight: 300;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.jg {
|
||||
margin-top: 16rpx;
|
||||
background-color: #e8f4ff;
|
||||
color: #1890ff;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #1890ff;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.inputdj {
|
||||
width: 66%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
font-weight: 300;
|
||||
font-size: 24rpx;
|
||||
|
||||
.inputdjbox {
|
||||
margin-top: 16rpx;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border: 1rpx solid #ccc;
|
||||
border-radius: 10rpx;
|
||||
padding-left: 20rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background: #fff;
|
||||
|
||||
.inputdisplay {
|
||||
width: auto;
|
||||
|
||||
}
|
||||
|
||||
text {
|
||||
border: 1rpx solid #ccc;
|
||||
border-radius: 10rpx;
|
||||
border-radius: 10rpx;
|
||||
padding: 0 20rpx;
|
||||
background: #f5f7fa;
|
||||
color: #a7aaaf;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.keyboard {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 28%;
|
||||
margin: 10rpx;
|
||||
}
|
||||
|
||||
.keyboard-button {
|
||||
width: 28%;
|
||||
margin: 10rpx;
|
||||
border: none;
|
||||
border-radius: 5rpx;
|
||||
box-shadow: 0 0 5rpx rgba(0, 0, 0, 0.3), 0 0 10rpx rgba(0, 0, 0, 0.2);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
// .keyboard-button:hover {
|
||||
// box-shadow: 0 0 10rpx rgba(255, 0, 0, 0.5), 0 0 20px rgba(255, 0, 0, 0.3);
|
||||
// transform: translateY(-2rpx);
|
||||
// }
|
||||
|
||||
.dot-button {
|
||||
// background-color: #FFC107;
|
||||
}
|
||||
|
||||
.clear-button {
|
||||
// background-color: #FF5733;
|
||||
}
|
||||
|
||||
.clear-button:hover {
|
||||
box-shadow: 0 0 10px rgba(255, 87, 51, 0.5), 0 0 20px rgba(255, 87, 51, 0.3);
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
// background-color: #33FF57;
|
||||
}
|
||||
|
||||
.delete-button:hover {
|
||||
// box-shadow: 0 0 10px rgba(51, 255, 87, 0.5), 0 0 20px rgba(51, 255, 87, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.classmoney {
|
||||
margin-top: 16rpx;
|
||||
width: 100%;
|
||||
font-size: 40rpx;
|
||||
text-align: left;
|
||||
color: #ff5152;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.classconfirm {
|
||||
width: 100%;
|
||||
margin: 30rpx auto 0 auto;
|
||||
border-radius: 16rpx;
|
||||
text-align: center;
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
1496
pagesCreateOrder/index/index.vue
Normal file
1496
pagesCreateOrder/index/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
81
pagesCreateOrder/index/util.js
Normal file
81
pagesCreateOrder/index/util.js
Normal file
@@ -0,0 +1,81 @@
|
||||
//根据店铺信息返回是否是后付款
|
||||
export function $trturnPayAfter(shop) {
|
||||
//munchies 先付 restaurant 后付
|
||||
const payAfter = shop.registerType == "munchies" ? false : true;
|
||||
return payAfter
|
||||
}
|
||||
//根据店铺信息返回就餐类型
|
||||
export function $returnUseType(shop, useType) {
|
||||
//是否是后付款
|
||||
const payAfter = $trturnPayAfter(shop)
|
||||
let result = "takeout";
|
||||
if (useType == "takeout") {
|
||||
result = 'takeout'
|
||||
} else {
|
||||
//堂食
|
||||
result = `dine-in-${payAfter ? "after" : "before"}`;
|
||||
}
|
||||
return result
|
||||
}
|
||||
//判断商品是否可以下单
|
||||
export function isCanBuy(skuGoods,goods) {
|
||||
if(goods.typeEnum=='normal'){
|
||||
//单规格
|
||||
return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||
}else{
|
||||
//多规格
|
||||
return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.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,$returnUseType
|
||||
}
|
||||
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 |
39
pagesCreateOrder/util.js
Normal file
39
pagesCreateOrder/util.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
returnBoolean
|
||||
} from '@/commons/utils/format.js';
|
||||
// 返回购物车未下单的数据
|
||||
export function getNowCart(records) {
|
||||
const nowCart = records.find(v => v.placeNum == 0)
|
||||
const Cart = nowCart ? nowCart.info : []
|
||||
const goodsMap = {}
|
||||
const arr = []
|
||||
for (let i in Cart) {
|
||||
const item=Cart[i]
|
||||
const productId=item.productId
|
||||
const skuId=item.skuId
|
||||
const isLinShiCai=!productId&&!skuId?true:false
|
||||
const key =isLinShiCai?item.name: (item.productId + '_' + item.skuId)
|
||||
if (goodsMap.hasOwnProperty(key)) {
|
||||
const index = goodsMap[key]
|
||||
arr[index].number = arr[index].number * 1 + item.number
|
||||
arr[index].totalNumber = arr[index].totalNumber * 1 + item.totalNumber
|
||||
arr[index].totalAmount = arr[index].totalAmount * 1 + item.totalAmount
|
||||
arr[index].packFee = arr[index].packFee * 1 + item.packFee
|
||||
} else {
|
||||
arr.push({
|
||||
...item,
|
||||
isPack: returnBoolean(item.isPack),
|
||||
isGift: returnBoolean(item.isGift)
|
||||
})
|
||||
goodsMap[key] = arr.length - 1;
|
||||
}
|
||||
}
|
||||
// const result = Cart.map(item => {
|
||||
// return {
|
||||
// ...item,
|
||||
// isPack: returnBoolean(item.isPack),
|
||||
// isGift: returnBoolean(item.isGift)
|
||||
// }
|
||||
// })
|
||||
return arr
|
||||
}
|
||||
Reference in New Issue
Block a user