宴席2.0

This commit is contained in:
sjeam 2025-08-15 14:16:03 +08:00
parent 5ba9a3eb76
commit dfc54ea015
2 changed files with 237 additions and 190 deletions

View File

@ -1,29 +1,29 @@
<style lang='scss'>
.custom-count-down {
display: inline-block;
width: 22px;
color: #ff3232;
font-size: 12px;
text-align: center;
background-color: #ff404021;
border-radius: 2px;
}
.custom-count-down {
display: inline-block;
width: 22px;
color: #ff3232;
font-size: 12px;
text-align: center;
background-color: #ff404021;
border-radius: 2px;
}
.custom-count-down-colon {
display: inline-block;
margin: 0 4px;
color: #ff4040;
}
.custom-count-down-colon {
display: inline-block;
margin: 0 4px;
color: #ff4040;
}
.cell-icon {
display: block;
box-sizing: border-box;
width: 16px;
height: 16px;
margin-right: 4px;
background: url('https://img10.360buyimg.com/jmadvertisement/jfs/t1/71075/7/3762/1820/5d1f26d1E0d600b9e/a264c901943080ac.png') no-repeat;
background-size: cover;
}
.cell-icon {
display: block;
box-sizing: border-box;
width: 16px;
height: 16px;
margin-right: 4px;
background: url('https://img10.360buyimg.com/jmadvertisement/jfs/t1/71075/7/3762/1820/5d1f26d1E0d600b9e/a264c901943080ac.png') no-repeat;
background-size: cover;
}
</style>
<template>
<view>
@ -39,7 +39,7 @@
<u-cell class="" style="line-height: 60rpx;" :border="true">
<template #title>
<view class="h-50 p-2 align-center font-blod" @click="close">
支付金额 <wd-text size="36rpx" bold text="16354.156" mode="price" type="error" prefix="¥" suffix="元" />
支付金额 <wd-text size="36rpx" bold :text="`${pre_price}`" mode="price" type="error" prefix="¥" suffix="元" />
</view>
<view class="h-50 p-2 align-center">
剩余时间
@ -68,7 +68,7 @@
</up-text>
<!-- <u-icon size="48rpx" slot="right" label-color="red" :label="`¥2000.00元`"></u-icon> -->
<view style="display: inline-block; float:right">
<u-radio iconSize="36rpx" size="36rpx" activeColor="#59CB56" label=""></u-radio>
<u-radio checked iconSize="36rpx" size="36rpx" activeColor="#59CB56" label=""></u-radio>
</view>
</view>
@ -93,7 +93,7 @@
<!-- <text class="font-size-32 color-red font-bold ">213213.00</text> -->
</view>
</view>
<view class="title font-size-28 pt-4">
<view class="title font-size-28 pt-4" v-if="order_type===1">
<view>做宴时段{{ matchedItems[0].banquet_date }}</view>
<view class="title-tip font-size-28">
做宴时段{{ matchedItems[0].banquet_time }}
@ -147,7 +147,7 @@
<view class="title font-size-32">
<view>费用合计</view>
<view class="title-tip ">
<text class="font-size-32 font-bold color-red" >{{ totalPrice }}</text>
<text class="font-size-32 font-bold color-red">{{ totalPrice }}</text>
</view>
</view>
</template>
@ -186,10 +186,10 @@
]" />
<wd-input label="联系电话" prop="phone" clearable v-model="orderInfo.phone" placeholder="请填写联系电话"
:rules="[{ required: false, pattern: /^1[3-9]\d{9}$/, message: '请输入有效手机号码' }]" />
<wd-select-picker label="宴席类型" prop="banquet_type" v-model="orderInfo.banquet_type" :columns="banquetType"
<wd-select-picker label="宴席类型" prop="banquet_type" v-model="orderInfo.banquet_type" :columns="banquetType"
type="radio"
:rules="[
:rules="[
{
required: false,
validator: (value: string) => {
@ -197,10 +197,19 @@
},
message: '请选择宴席类型'
}
]"
></wd-select-picker>
]"></wd-select-picker>
<wd-col-picker label="做宴地址" v-model="orderInfo.district_name" prop="district_name" :columns="area"
<wd-calendar v-if="order_type===2" label="做宴日期" placeholder="请选择日期" prop="banquet_date" :formatter="formatter" :min-date="min_data"
v-model="orderInfo.banquet_date" :rules="[{ required: false, pattern: /^\d{13}$/, message: '请选择日期' }]"
@confirm="handleTimeConfirm" />
<wd-input v-if="order_type===2" label="做宴桌数" placeholder="请输做宴桌数" prop="table_number" type="number" clearable
v-model="orderInfo.table_number" :rules="[{ required: false, pattern: /^[1-9]\d*$/, message: '请输入有效的桌数' }]"
placeholder-style="color: #999999; font-size: 14px;" />
<wd-col-picker label="做宴地址" v-model="orderInfo.district_name" prop="district_name" :columns="area"
:column-change="columnChange" placeholder="请填写做宴地址" @confirm="handleConfirm" :rules="[
{
required: false,
@ -215,6 +224,9 @@
}
]"></wd-col-picker>
<wd-input label="详细地址" prop="street_name" clearable v-model="orderInfo.street_name" placeholder="请填写详细地址"
:rules="[
{
@ -226,7 +238,7 @@
}
]" />
<wd-textarea label="备注" auto-height v-model="orderInfo.remark" placeholder="请填写备注" />
<view class="pb-4" />
<view class="pb-4" />
<wd-button plain hairline custom-style="width: calc(100vw - 100rpx);"
@click="handleSubmit(1)">确定预定做席后再支付</wd-button>
<wd-button hairline custom-style="width: calc(100vw - 100rpx);" @click="handleSubmit(1)">付定金锁定订单</wd-button>
@ -243,167 +255,196 @@
</template>
<script lang="ts">
import { useColPickerData, useModal } from '@/hooks'
import { defineComponent } from "vue";
import { CommonApi, UserApi } from "@/api";
// import { setToken, getToken, isLogin } from '@/utils/auth';
const { colPickerData, findChildrenByCode } = useColPickerData()
export default defineComponent({
data () {
return {
totalPrice: 0,
server_user: {
phone: '',
public_name: '',
},
server_user_id: 0,
address_string: '',
banquetType: this.getBanquetType(),
propShowOrder: false,
area: [],
value: [],
orderInfo: {
district_name: [],
street_name: '',
// cart_ids: [],
customer_name: '',
phone: '',
address: '',
remark: '',
banquet_type: '1',
reservation_type: 1,
import {
useColPickerData,
useModal
} from '@/hooks'
import {
defineComponent
} from "vue";
import {
CommonApi,
UserApi
} from "@/api";
// import { setToken, getToken, isLogin } from '@/utils/auth';
const {
colPickerData,
findChildrenByCode
} = useColPickerData()
export default defineComponent({
data() {
return {
totalPrice: 0,
pre_price: 0,
server_user: {
phone: '',
public_name: '',
},
server_user_id: 0,
// table_number: 0,
// banquet_date: '',
address_string: '',
banquetType: this.getBanquetType(),
propShowOrder: false,
area: [],
value: [],
order_type: 1, // 2
orderInfo: {
district_name: [],
street_name: '',
cart_ids: 0, //
customer_name: '',
phone: '',
address: '',
remark: '',
banquet_type: '1',
reservation_type: 1,
server_user_id: 0,
table_number: 1, //
banquet_date: [], //
},
matchedItems_sp: [],
};
},
onLoad(option) {
this.server_user_id = option.id;;
this.orderInfo.cart_ids = option.cart_ids || 0;
if (this.orderInfo.cart_ids) {
this.order_type = 2; //
}
this.orderInfo.server_user_id = option.id;
this.getCartCheck()
this.getArea()
},
created() {
},
methods: {
close() {
this.propShowOrder = false;
},
matchedItems_sp: [],
};
},
onLoad (option) {
this.server_user_id = option.id;;
this.orderInfo.server_user_id = option.id;
this.getCartCheck()
this.getArea()
},
created () {
},
methods: {
close () {
this.propShowOrder = false;
},
//
handleSubmit (reservation_type) {
// console.log(this.orderInfo);
this.orderInfo.reservation_type = reservation_type; //
this.$refs.form.validate()
.then(({ valid, errors }) => {
if (valid) {
this.orderInfo.address = this.address_string+this.orderInfo.street_name;
console.log(this.orderInfo);
this.addOrder();
}
})
.catch((error) => {
console.log(error, 'error')
})
},
//
addOrder () {
CommonApi.commonPost('/api/banquet/order/createOrder', this.orderInfo).catch((res) => {
if (res.code === 1) {
this.propShowOrder = true;
} else {
uni.$u.toast(res.msg);
}
});
},
//
payOrder (order_id) {
CommonApi.commonPost('/api/banquet/order/pay', {order_id:order_id}).catch((res) => {
if (res.code === 1) {
// this.payOrder(res.data.order_id);
//
handleSubmit(reservation_type) {
// this.propShowOrder = true;
// console.log(this.orderInfo);
this.orderInfo.reservation_type = reservation_type; //
this.$refs.form.validate()
.then(({
valid,
errors
}) => {
if (valid) {
this.orderInfo.address = this.address_string + this.orderInfo.street_name;
// console.log(this.orderInfo);
this.addOrder();
}
})
.catch((error) => {
console.log(error, 'error')
})
},
//
addOrder() {
CommonApi.commonPost('/api/banquet/order/createOrder', this.orderInfo).catch((res) => {
if (res.code === 1) {
this.propShowOrder = true;
} else {
uni.$u.toast(res.msg);
}
});
},
//
payOrder(order_id) {
CommonApi.commonPost('/api/banquet/order/pay', {
order_id: order_id
}).catch((res) => {
if (res.code === 1) {
// this.payOrder(res.data.order_id);
// this.propShowOrder = true;
console.log(res.data);
// this.close();
} else {
uni.$u.toast(res.msg);
// this.close();
} else {
uni.$u.toast(res.msg);
}
});
},
//
getArea() {
this.area = [colPickerData.map(item => ({
value: item.value,
label: item.text
}))];
},
//--
handleConfirm(value) {
this.address_string = value.selectedItems.map(item => item.label).join('')
},
//
columnChange({
selectedItem,
resolve,
finish
}) {
try {
const areaData = findChildrenByCode(colPickerData, selectedItem.value);
if (areaData && areaData.length) {
resolve(areaData.map(item => ({
value: item.value,
label: item.text
})));
} else {
finish();
}
} catch (error) {
console.error('处理列变更时出错:', error);
finish(); //
}
});
},
//
getBanquetType() {
CommonApi.commonGet('/api/banquet/dishes/banquetType').catch((res) => {
if (res.code === 1) {
res.data.forEach(item => {
item.label = item.name;
});
this.banquetType = res.data;
} else {
uni.$u.toast(res.msg);
}
});
},
// //
getCartCheck() {
CommonApi.commonPost('/api/banquet/order/check', {
server_user_id: this.server_user_id
}).catch((res) => {
if (res.code === 1) {
this.matchedItems_sp = res.data.cart_list;
this.totalPrice = res.data.total_price;
this.pre_price = this.totalPrice>=1000?1000:this.totalPrice;
this.server_user.phone = res.data.server_user.certification.phone;
this.server_user.public_name = res.data.server_user.certification.public_name;
this.$refs.pagingRefSP?.complete(res.data);
// console.log(res);
} else {
uni.$u.toast(res.msg);
}
});
},
},
//
getArea () {
this.area = [colPickerData.map(item => ({
value: item.value,
label: item.text
}))];
},
//--
handleConfirm (value) {
this.address_string = value.selectedItems.map(item => item.label).join('')
},
//
columnChange ({ selectedItem, resolve, finish }) {
try {
const areaData = findChildrenByCode(colPickerData, selectedItem.value);
if (areaData && areaData.length) {
resolve(areaData.map(item => ({
value: item.value,
label: item.text
})));
} else {
finish();
}
} catch (error) {
console.error('处理列变更时出错:', error);
finish(); //
}
},
//
getBanquetType () {
CommonApi.commonGet('/api/banquet/dishes/banquetType').catch((res) => {
if (res.code === 1) {
res.data.forEach(item => {
item.label = item.name;
});
this.banquetType = res.data;
} else {
uni.$u.toast(res.msg);
}
});
},
// //
getCartCheck () {
CommonApi.commonPost('/api/banquet/order/check', { server_user_id: this.server_user_id }).catch((res) => {
if (res.code === 1) {
this.matchedItems_sp = res.data.cart_list;
this.totalPrice = res.data.total_price;
this.server_user.phone = res.data.server_user.certification.phone;
this.server_user.public_name = res.data.server_user.certification.public_name;
this.$refs.pagingRefSP?.complete(res.data);
// console.log(res);
} else {
uni.$u.toast(res.msg);
}
});
},
},
});
</script>
});
</script>

View File

@ -400,9 +400,15 @@ export default defineComponent({
//
handleConfirm () {
uni.navigateTo({
url: `/pages/banquet/combo/detail?id=${this.search.server_user_id}`
});
if(this.set_num===0){
this.$u.toast('未添加购物车');
}else{
uni.navigateTo({
url: `/pages/banquet/combo/detail?id=${this.search.server_user_id}`
});
}
},
formatter (day) {