This commit is contained in:
duan
2025-09-29 10:42:48 +08:00
parent 89db955ec1
commit 096f591123
80 changed files with 8735 additions and 3286 deletions

View File

@@ -26,33 +26,37 @@
<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="" v-for="(item,index) in tables.list" :key="index" @tap="chooseTable(index,item)">
<template v-if="item.status=='idle'">
<view class="u-flex item u-row-between" style="border-bottom: 1px solid #E5E5E5;">
<view class="u-flex">
<view>{{item.name}}</view>
<view class="line"></view>
<view>{{''}}</view>
<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="color-999 u-font-24 u-m-t-12">
<text
:style="{color:returnStutasColor(item.status)}">{{returnStutasText(item.status)}}</text>
<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="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>
</template>
</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>
@@ -108,7 +112,7 @@
let searchValue = ref('')
function search() {
query.page=1
query.page = 1
getTable()
}
@@ -142,14 +146,14 @@
function areaChange(e) {
area.defaultCateIndex = e.detail.value
area.sel = area.list[e.detail.value]
query.page=1
query.page = 1
getTable()
}
const query = {
page: 1,
size: 10,
areaId: 0,
totalElements:0
totalElements: 0
}
// 页数改变事件
function pageChange(page) {
@@ -166,28 +170,32 @@
async function getTable() {
// let state=status.list[status.active].key
// state=state?(state=='all'?'':state):''
const areaId=area.list[area.defaultCateIndex].id||''
const areaId = area.list[area.defaultCateIndex].id || ''
let {
content,total
} = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
query.totalElements=total||0;
data
} = await $table.get({
...query,
areaId,
name: searchValue.value,
state: 'idle'
})
query.totalElements = data.totalRow || 0;
tables.hasAjax = true;
console.log(content);
tables.list = content
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
tables.originList = content
tables.list = data.records
tables.selIndex = data.records.findIndex(v => v.tableCode == option.tableCode)
tables.originList = data.records
}
async function getArea() {
const {
content
data
} = await $tableArea.get({
page: 0,
size: 300
})
content.unshift({
data.records.unshift({
name: '全部'
})
area.list = content.map(v => {
area.list = data.records.map(v => {
return {
...v,
}

View File

@@ -1,9 +1,6 @@
<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>
@@ -33,8 +30,7 @@
<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" />
placeholder-class="placeholder-class" placeholder="请输入最终优惠金额" />
</view>
<view class="color-999 u-p-l-48 u-p-r-48 u-flex u-row-center u-col-center">
<view></view>
@@ -46,19 +42,22 @@
</view>
</template>
<view class="u-m-t-48">
<view class="u-font-24">
<text class="color-999">打折原因</text>
<text class="color-red">*</text>
</view>
<view class="u-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)" class="tag u-m-r-20"
<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="value" placeholder="自定义内容"></uni-easyinput>
<uni-easyinput type="textarea" v-model="form.note" placeholder="自定义内容"></uni-easyinput>
</view>
</view>
@@ -67,7 +66,10 @@
<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 style="height: 20rpx;">
</view>
<!-- <my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button> -->
</view>
</view>
</template>
@@ -75,18 +77,13 @@
</template>
<script setup>
import {
reactive,
nextTick,
ref,
watch
} from 'vue';
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],
type: [Number, String],
default: 0
},
title: {
@@ -99,12 +96,6 @@
}
})
function changeCauses(item) {
item.checked = !item.checked
}
const discounts = [95, 90, 85, 80]
const causes = reactive([{
name: '顾客投诉质量问题',
@@ -120,6 +111,11 @@
}
])
function changeCauses(item, index) {
item.checked = !item.checked
form.notes = causes
}
function discountInput(e) {
if (e.detail.value >= 100) {
nextTick(() => {
@@ -127,8 +123,9 @@
})
}
}
function discountMoneyInput(e) {
const max=100
const max = 100
if (e.detail.value >= max) {
nextTick(() => {
form.discountMoney = 100
@@ -142,7 +139,7 @@
const tabs = ['打折', '减免']
let current = ref(0)
let current = ref(1)
function tabsChange(i) {
console.log(i);
@@ -158,11 +155,11 @@
const form = reactive({
...$form
})
watch(()=>props.price,(newval)=>{
console.log(newval);
form.price=newval
form.currentPrice=newval
watch(() => props.price, (newval) => {
form.price = newval
form.currentPrice = newval
})
function resetForm() {
Object.assign(form, {
...$form
@@ -182,22 +179,23 @@
function confirm() {
const {
discount,discountMoney
discount,
discountMoney
} = form
if (current.value===0&& discount==='') {
if (current.value === 0 && discount === '') {
return uni.showToast({
icon: 'none',
title: '请输入有效折扣!'
})
}
if (current.value===1&& discountMoney==='') {
if (current.value === 1 && discountMoney === '') {
return uni.showToast({
icon: 'none',
title: '请输入有效减免价格!'
})
}
close()
emits('confirm', form)
close()
}
defineExpose({
open,

View File

@@ -0,0 +1,131 @@
<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="number" v-model="form.pack_number" placeholder="打包数量"></uni-easyinput>
</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: ''
}
})
const $form = {
pack_number: 1
}
const form = reactive({
number: null,
...$form
})
function resetForm() {
Object.assign(form, {
...$form
})
}
const model = ref(null)
function open(data) {
console.log(data)
form.number = data.number
model.value.open()
}
function close() {
model.value.close()
}
const emits = defineEmits(['confirm'])
function confirm() {
const { pack_number } = form
if( pack_number > form.number){
uni.showToast({
title: '打包数量不能大于菜品数量',
icon: 'none'
})
return false;
}
emits('confirm', pack_number)
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>

View File

@@ -99,8 +99,7 @@
const emits = defineEmits(['confirm'])
function confirm() {
const {remark
} = form
const { remark } = form
emits('confirm', {
remark
})

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
<template>
<view class="mask" @tap="hideGoods" v-if="switchGoods">
</view>
<view class="fixed goods-box u-flex u-flex-col" :class="{active:switchGoods}" @tap.stop="nullFun">
<view class="u-row-between top u-flex">
@@ -12,7 +12,7 @@
已选菜品({{goodsNumber}})
</view>
</view>
<view class="u-flex" @click="setModalShow('clear',true)">
<view class="u-flex" @click="setModalShow('clear',true,'','是否清空点餐?')">
<view>
<up-icon name="trash-fill" size="20" color="rgb(102,102,102)"></up-icon>
</view>
@@ -26,28 +26,32 @@
<view class=""></view>
</view>
</view>
<scroll-view scroll-y="true" class=" u-flex-1 ">
<scroll-view scroll-y="true" style="height: 300px;background-color: #fff;">
<!-- <scroll-view scroll-y="true" class=" u-flex-1 " > -->
<view class=" ">
<view class="color-333item border-bottom u-p-l-20 u-p-r-20 u-p-b-10 u-p-t-20 u-flex u-row-center u-row-between"
v-for="(item,index) in data" :key="index">
<view
class="color-333 item border-bottom u-p-l-20 u-p-r-20 u-p-b-10 u-p-t-20 u-flex u-row-center u-row-between"
v-for="(item,index) in data" :key="item.id">
<view class="u-flex u-col-top">
<view class="u-p-r-20">
{{index+1}}
</view>
<view class="">
<view>{{item.name}}</view>
<view class="u-m-t-10 u-font-24 color-666">{{item.specSnap||''}}</view>
<view class="u-m-t-10 u-font-24 color-666">{{item.specInfo||''}}</view>
<view class="u-flex u-m-t-14">
<up-icon name="edit-pen" @click="showModel('remark',index)" color="#333" size="16"></up-icon>
<up-icon name="edit-pen" @click="showModel('remark',index)" color="#333"
size="16"></up-icon>
<view class="color-666 u-font-24">
{{item.note}}
</view>
</view>
</view>
</view>
<view class="u-flex">
<view class="font-bold red u-m-r-32">{{formatPrice(item.salePrice*item.number) }}</view>
<view class="font-bold red u-m-r-32">{{formatPrice(item.lowPrice*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>
@@ -55,17 +59,57 @@
<view class="u-p-l-30 u-p-r-30 color-333" style="">
{{item.number}}
</view>
<view class="u-flex" @tap="updateNumber(true,index,item)">
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
</image>
</view>
<template v-if="item.type!='package'">
<view class="u-flex" @tap="updateNumber(true,index,item)">
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
</image>
</view>
</template>
<template v-else>
<view class="u-flex" >
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" style=" filter: opacity(30%);" class="icon" mode="">
</image>
</view>
</template>
</view>
</view>
<my-empty v-if="!data.length" text="暂未有添加商品"></my-empty>
</view>
<!-- 历史订单 -->
<view v-if="historyOrder.length > 0"
class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between">
<view class="color-333" style="font-weight: bold;">历史订单</view>
<view class="color-666">
<uni-icons color="#666" type="trash"></uni-icons>
<text class="u-m-l-10" @tap="setModalShow('clear',true,'allHistoryOrder','清空历史订单')">清空历史订单</text>
</view>
</view>
<view v-for="(item,index) in historyOrder" :key="index" style="margin-top: 20rpx;">
<view v-if="historyOrder.length > 0"
class="u-p-t-32 border-top bg-fff u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between">
<view class="color-333" style="font-size: 30rpx;">{{item.placeNum}}次下单</view>
<view class="color-666">
<!-- <uni-icons color="#666" type="trash"></uni-icons>
<text class="u-m-l-10"
@tap="setModalShow('clear',true,item.placeNum,'清空第'+item.placeNum+'次下单历史订单')">清空</text> -->
</view>
</view>
<view class="color-333 item border-top u-flex u-row-center u-row-between" style="margin-left: 60rpx;"
v-for="(v,i) in item.info" :key="i">
<view style="display: flex;align-items: center;">
<view class="up-line-1" style="margin-right: 10rpx;">{{v.productName}}</view>
<uni-tag v-if="v.returnNum>0" :text="'退菜X'+v.returnNum"
custom-style="background-color: #EB4F4F; border-color: #EB4F4F; color: #fff;">
</uni-tag>
</view>
<view class="u-flex" style="flex-shrink: 0;margin-top: 20rpx;">
<view class="font-bold red u-m-r-32">{{formatPrice(v.price*(v.num - v.returnNum)) }}</view>
<view class="u-m-l-30 u-m-r-30 color-333"> X{{v.num.toFixed(2)}} </view>
</view>
</view>
</view>
</scroll-view>
<view class="u-row-between bottom u-flex">
<view class="u-row-between bottom u-flex" style="position: absolute;left: 0;bottom: 0;background-color: #fff;">
<view class="u-flex" @click="hideGoods">
<view>
<up-icon name="arrow-left" size="14" color="#333"></up-icon>
@@ -80,8 +124,8 @@
</view>
</view>
<view class="car u-flex u-row-between u-col-bottom u-relative" @touchmove.stop.prevent="moveHandle"
:style="{transform: 'translateY(' + offset.y + 'px)'}" @touchstart="touchstart"
@touchmove="touchmove" @touchend="touchend">
:style="{transform: 'translateY(' + offset.y + 'px)'}" @touchstart="touchstart" @touchmove="touchmove"
@touchend="touchend">
<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">
@@ -98,17 +142,10 @@
<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
<up-modal title="提示" :content="modal.title" :show="modal.clear" showCancelButton closeOnClickOverlay
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
width="300px"></up-modal>
<one-remark width="400px" @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
@@ -121,6 +158,13 @@
import {
formatPrice
} from '@/commons/utils/format.js';
import {
$tbProduct,
adminProduct
} from '@/http/yskApi/goods.js'
// import {
// addWXCart
// } from "@/http/yskApi/Instead.js"
import {
getElRect
} from '@/commons/utils/safe-bottom.js'
@@ -132,21 +176,28 @@
reactive,
watch
} from 'vue';
let shopList = ref()
const props = defineProps({
sysInfo:{
sysInfo: {
type: Object,
default:()=>{
default: () => {
return {
windowWidth: 0,
windowHeight: 0,
statusBarHeight:0
statusBarHeight: 0
}
}
},
historyOrder: {
type: Array,
default: () => {
return []
}
},
instance: {
type: Object,
default: {
}
},
data: {
@@ -171,7 +222,7 @@
type: Object,
default: () => {
return {
tableId: ''
}
}
},
@@ -180,12 +231,26 @@
default: ''
}
})
const edmits = defineEmits(['clear', 'updateNumber', 'updateSafeBottom','updateCart'])
const edmits = defineEmits(['clear', 'updateNumber', 'updateSafeBottom', 'updateCart'])
const modal = reactive({
key: '',
title: '',
type: '',
clear: false
})
let allHistoryOrder = ref([]);
const allPrice = computed(() => {
let cartPrice = props.data.reduce((prve, cur) => {
let price = Math.floor((cur.lowPrice * cur.number) * 100) / 100
return prve + price
}, 0)
let historyOrderPrice = allHistoryOrder.value.reduce((prve, cur) => {
let price = Math.floor((cur.price * (cur.num - cur.returnNum)) * 100) / 100
return prve + price
}, 0)
return (cartPrice + historyOrderPrice).toFixed(2)
})
const models = new Map();
const modelData = reactive({
data: {},
@@ -193,29 +258,35 @@
})
//备注
let note = ref('')
watch(() => props.historyOrder, (newval) => {
allHistoryOrder.value = [];
newval.forEach(item => {
allHistoryOrder.value = [...allHistoryOrder.value, ...item.info]
})
})
function setModel(el) {
if (el && el.$attrs['name']) {
models.set(el.$attrs['name'], el);
}
}
function showModel(key, index) {
modelData.data = props.data[index]
modelData.selIndex = index
const model = models.get(key)
model && model.open({
remark: modelData.data.note||''
remark: modelData.data.note || ''
})
}
function confirmModelConfirm() {
if (modal.key == 'clear') {
clear()
}
}
//单品备注确认
async function goodsOneRemarkConfirm(e) {
const cart = props.data[modelData.selIndex]
@@ -229,18 +300,21 @@
})
edmits('updateCart')
}
function setModalShow(key = 'show', show = true) {
if (key == 'clear' && show && props.data.length <= 0) {
return infoBox.showToast('购物车是空的!')
// 清空购物车
function setModalShow(key = 'show', show = true, type = '', title = '') {
if (title) {
modal.title = title
}
if (type) {
modal.type = type
}
modal.key = key
modal[key] = show
console.log(modal);
console.log(modal, 123);
}
function nullFun() {
@@ -260,56 +334,86 @@
function toggleGoods() {
switchGoods.value = !switchGoods.value
// 获取商品详情
// getshopsInfo()
}
function getshopsInfo() {
let arr = uni.getStorageSync('wxList')
let att = []
arr.forEach(async ele => {
let res = await adminProduct(ele.product_id)
console.log(res);
att.push({
...res.data,
...ele,
ele
})
})
setTimeout(() => {
// uni.setStorageSync('shopsList', att)
shopList.value = att
console.log(att, '初始化')
}, 200)
// product_id()
// const findCategory = layoutData.category.list.find(v => v.shopId == goods.shop_id)
}
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
})
}else{
go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId,
type,
tableId,
if (props.table.id) {
const {
id,
name,
maxCapacity,
status,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
type
} = props.table
go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId,
type,
tableId: id,
name,
maxCapacity,
status,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0,
tableCode: props.table.tableCode,
})
} else {
go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0,
tableCode: props.table.tableCode,
})
}
hideGoods()
}
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) => {
let cart = props.data.reduce((prve, cur) => {
return prve + cur.number
}, 0)
return result >= 99 ? 99 : result
let historyOrderNum = allHistoryOrder.value.reduce((prve, cur) => {
return prve + cur.num
}, 0)
result = cart + historyOrderNum
result = result > 0 ? result.toFixed(2) : 0
return result >= 99 ? 99 : parseFloat(result)
})
function updateNumber(isAdd, index, goods) {
const step = isAdd ? 1 : -1
const newval = goods.number + step
const newval = (goods.number) + step
const par = {
num: newval,
index: index,
@@ -321,17 +425,22 @@
const offset = ref({
x: 0,
y: (props.sysInfo.windowHeight-70-40)/2
y: (props.sysInfo.windowHeight - 70 - 40) / 2
})
const startPoint = ref({
x: 0,
y: 0
})
watch(()=>props.sysInfo.windowHeight,(newval)=>{
watch(() => props.sysInfo.windowHeight, (newval) => {
console.log('---------');
console.log(newval);
offset.value.y=(newval-70-40)/2
offset.value.y = (newval - 70 - 40) / 2
})
// watch(() => props.data, (n) => {
// shopList.value = uni.getStorageSync('wxList')
// getshopsInfo()
// })
// function
function touchstart(event) {
startPoint.value = {
x: event.touches[0].clientX,
@@ -348,13 +457,14 @@
x: currentPoint.x - startPoint.value.x,
y: currentPoint.y - startPoint.value.y
};
const minY=props.sysInfo.statusBarHeight||0 ,maxY=props.sysInfo.windowHeight-70-40;
let newY=offset.value.y + delta.y
if(newY>maxY){
newY=maxY
const minY = props.sysInfo.statusBarHeight || 0,
maxY = props.sysInfo.windowHeight - 70 - 40;
let newY = offset.value.y + delta.y
if (newY > maxY) {
newY = maxY
}
if(newY<minY){
newY=minY
if (newY < minY) {
newY = minY
}
offset.value = {
// x: offset.value.x + delta.x,
@@ -372,15 +482,22 @@
}
function clear() {
if (modal.type == 'cart') {
hideGoods()
}
setModalShow('clear', false)
edmits('clear')
hideGoods()
edmits('clear', modal.type)
// setModalShow('clear', false)
// edmits('clear')
// hideGoods()
}
onMounted(() => {
onMounted(async () => {
getElRect('car', props.instance).then(res => {
console.log(res);
edmits('updateSafeBottom', res)
}).catch(err=>{
}).catch(err => {
console.log(err);
})
})
@@ -416,6 +533,7 @@
transition: all .2s ease-in-out;
transform: translateX(100%);
z-index: 10;
&.active {
transform: translateX(0);
}

View File

@@ -1,39 +1,72 @@
<template>
<view class="u-relative u-flex item box-shadow " @tap="emitEvent('showDetail')">
<!-- 已下架 -->
<view v-if="!data.isSale"
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);">
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_yxj.svg" />
</view>
<!-- 未开售 -->
<view v-else-if="!isProductAvailable(data.days,data.startTime.substring(11),data.endTime.substring(11))"
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);">
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_wks.svg" />
</view>
<!-- 已售罄 -->
<view v-else-if="(data.isStock && data.stockNumber<=0) "
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);">
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_sq.svg" />
</view>
<!-- 库存不足 -->
<view v-else-if="data.isSoldStock"
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);">
<image style="width: 220px;height: 220px;" src="@/static/iconImg/Insufficient_inventory.svg" />
</view>
<view class="img">
<image lazy-load :src="data.coverImg" mode="aspectFill"></image>
</view>
<!-- <image lazy-load class="img" :src="data.coverImg" mode="" ></image> -->
<view class="info u-flex u-flex-col u-row-right " >
<view class="info u-flex u-flex-col u-row-right ">
<view class="u-flex w-full u-row-right u-p-r-20 u-p-b-16 u-flex-1 u-flex-col">
<template v-if="!isSellout">
<template v-if="data.typeEnum=='sku'">
<template v-if="data.type=='sku'||data.groupType==1">
<view class="u-flex u-row-right w-full">
<view class="u-flex">
<button class="btn" hover-class="btn-hover-class" @tap.stop="emitEvent('chooseGuige')">选规格</button>
<button class="btn" hover-class="btn-hover-class"
@tap.stop="emitEvent('chooseGuige')">选规格</button>
</view>
</view>
</template>
<template v-else-if="data.type=='weight'">
<view class="u-flex u-row-right w-full">
<view class="u-flex">
<button class="btn" hover-class="btn-hover-class"
@tap.stop="emitEvent('tapweigh')">称重</button>
</view>
</view>
</template>
<template v-else>
<view class="u-flex w-full u-row-right ">
<view class="u-flex icon-btn">
<template v-if="data.chooseNumber">
<view class="u-flex" @tap.stop="emitEvent('reduce')">
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" mode="">
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon"
mode="">
</image>
</view>
<view class="u-font-32 ">
{{data.chooseNumber}}
</view>
</template>
<view class="u-flex" @tap.stop="emitEvent('add')">
<view class="u-flex" @tap.stop="emitEvent(data.type=='weight'?'tapweigh':'add')">
<image src="/pagesCreateOrder/static/images/icon-add.svg" class="icon" mode="">
</image>
</view>
</view>
</view>
</template>
</template>
@@ -64,6 +97,12 @@
toRefs,
watch
} from 'vue';
import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
dayjs.extend(isBetween)
import {
onLoad
} from '@dcloudio/uni-app'
const props = defineProps({
img: {
type: Object,
@@ -113,6 +152,7 @@
console.log(newval);
})
const computedImgStyle = computed(() => {
const stylobj = {
width: props.img.width,
@@ -126,6 +166,10 @@
}
return stylobj
})
// const asd = computed(()=>{
// })
// function computedImgStyle() {
// return {
// width: props.img.width,
@@ -141,17 +185,53 @@
//判断商品是否售尽
const isSellout = computed(() => {
const item = props.data
if(!isGoods()){
if (!isGoods()) {
return false
}
return (
item.isPauseSale ||
(item.typeEnum !== "sku" && item.isStock==1&& item.stockNumber <= 0)
(item.typeEnum !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
);
})
const emits = defineEmits(['add', 'reduce', 'chooseGuige','showDetail'])
const emits = defineEmits(['add', 'reduce', 'chooseGuige', 'showDetail', 'tapweigh'])
// 判断商品是否在可售时间内
// 判断商品是否在可售时间内
function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
    // 将后端返回的字符串转换为数组
    const sellDays = sellDaysStr.split(',');
    const now = dayjs();
    const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
    const currentDay = days[now.day()];
    // console.log('当前日期:', currentDay);
    // console.log('可售日期列表:', sellDays);
    // 检查当前周几是否在可售周几列表中
    if (!sellDays.includes(currentDay)) {
        // console.log('当前日期不在可售日期列表中');
        return false;
    }
    const startTime = dayjs(`${now.format('YYYY-MM-DD')} ${startTimeStr}`);
    let endTime = dayjs(`${now.format('YYYY-MM-DD')} ${endTimeStr}`);
    // 处理跨天情况
    if (endTime.isBefore(startTime)) {
        endTime = endTime.add(1, 'day');
    }
    // console.log('当前时间:', now.format('YYYY-MM-DD HH:mm:ss'));
    // console.log('开始时间:', startTime.format('YYYY-MM-DD HH:mm:ss'));
    // console.log('结束时间:', endTime.format('YYYY-MM-DD HH:mm:ss'));
    const isInRange = now.isBetween(startTime, endTime, null, '[)');
    // console.log('当前时间是否在可售时间范围内:', isInRange);
    return isInRange;
}
// 新增兼容了隔天时间区域兼容需引入isBetween插件
function emitEvent(emitName) {
if (isGoods()) {

View File

@@ -1,7 +1,10 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="top" :round="0">
<view class="u-p-32 box u-font-28">
<up-search v-model="searchVal" @search="search" @clear="search" @click="search"></up-search>
<view style="display: flex;align-items: center;">
<up-search v-model="searchVal" actionText="" @search="search" @clear="search"></up-search>
<text @tap="search">搜索</text>
</view>
</view>
</up-popup>
</template>
@@ -16,7 +19,7 @@
} from 'vue';
const refForm = ref(null)
let searchVal=ref('')
let searchVal = ref('')
const props = defineProps({
show: {
@@ -49,11 +52,12 @@
function open() {
}
function search(){
emits('search',searchVal.value)
function search() {
console.log(searchVal.value, '值啊啊啊啊 ')
emits('search', searchVal.value)
close()
}
</script>
<style lang="scss" scoped>

View File

@@ -0,0 +1,185 @@
<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, reactive, ref, watch } from 'vue';
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: () => {}
},
})
const model = ref(null)
const popup = ref()
let datas = reactive({
item: "",
title: "",
price: "",
skus: [],
// 几选几,的和
selectNumber: 0,
})
watch(() => props.goodsData, (newval) => {
let gArr = JSON.parse(newval.groupSnap)
gArr.forEach(ele => {
ele.selectData = []
})
console.log(newval,11);
datas.item = newval
datas.title = newval.name
datas.price = newval.lowPrice
datas.skus = gArr
})
const selectNumber = computed(() => {
return datas.skus.reduce((prve, cur) => {
console.log(prve)
return 0 + cur.number
}, 0)
})
const emits = defineEmits(['confirm', 'updateSku'])
function confirm() {
// 将数据保存进对应的值
let arr = []
let arrlength = 0
datas.selectNumber = 0
datas.skus.map(ele => {
let group = {
...ele,
goods: [],
}
if(ele.goods&&ele.goods.length>0){
ele.goods.map(item=>{
if(item.select){
group.goods.push(item)
arrlength++
}
})
}
arr.push(group)
datas.selectNumber += ele.number
})
console.log(arrlength)
console.log(datas.selectNumber)
if (arrlength == datas.selectNumber) {
emits('confirm', arr, datas.item)
close()
} else {
popup.value.open()
}
}
/**
* 套餐选择处理
* @param {Object} skd
* @param {Object} item
*/
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)
}
}
}
function open() {
model.value.open()
}
function close() {
datas.selectNumber = 0
model.value.close()
}
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>

View File

@@ -0,0 +1,279 @@
<template>
<view class="">
<up-overlay :show="overlayshow" @click="overlayshow = false">
<view class="boxoverlay" v-if="form&&form.goods">
<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">
{{ (Math.floor((form.goods.lowPrice * currentInput)*100)/100).toFixed(2) }}
</view>
<view class="classconfirm" @click="clickconfirm"> 确认 </view>
</view>
</view>
</up-overlay>
</view>
</template>
<script setup>
import { onLoad, onShow } from '@dcloudio/uni-app';
import { 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;
}
console.log(currentInput.value,'称重数量')
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) => {
console.log("222",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: 30%;
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>

File diff suppressed because it is too large Load Diff

View File

@@ -2,35 +2,77 @@ 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 = {}
export function getNowCart(carItem,goodsList,user) {
// console.log("carItem===",carItem)
// console.log("goodsList===",goodsList)
// const nowCart = records.find(v => v.placeNum == 0)
const arr = []
for (let i in Cart) {
const item=Cart[i]
const key = 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;
}
if( carItem.is_temporary != 1 ){
carItem.isGrounding = false;
goodsList.map(goodsItem => {
if(carItem.product_id == goodsItem.id){
goodsItem.skuList.map(item=>{
if(carItem.product_id == item.productId){
carItem.lowPrice = item.salePrice
carItem.lowMemberPrice = item.memberPrice
carItem.specInfo = item.specInfo
if( uni.getStorageSync('shopInfo').isMemberPrice && user && user.id && user.isVip ){
carItem.salePrice = item.memberPrice
} else {
carItem.salePrice = item.salePrice
}
}
})
carItem.name = goodsItem.name
carItem.coverImg = goodsItem.coverImg
carItem.packFee = goodsItem.packFee
carItem.type = goodsItem.type
carItem.isGrounding = true;
}
carItem.number = parseFloat(carItem.number)
})
} else {
// 临时菜
console.log(carItem,'salePrice1111111111')
carItem.number = parseFloat(carItem.number)
carItem.name = carItem.product_name
carItem.lowPrice = carItem.discount_sale_amount
carItem.discount_sale_amount = 0
}
// const result = Cart.map(item => {
// return {
// ...item,
// isPack: returnBoolean(item.isPack),
// isGift: returnBoolean(item.isGift)
// }
// })
return arr
}
return carItem
}
// 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 key = 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
// }