下单详情
This commit is contained in:
@@ -79,12 +79,9 @@
|
||||
});
|
||||
return false;
|
||||
}
|
||||
uni.pro.redirectTo('product/index', dinersNum.value)
|
||||
|
||||
uni.cache.set('dinersNum', dinersNum.value)
|
||||
uni.pro.redirectTo('product/index')
|
||||
}
|
||||
|
||||
uni.cache.get('tableCode')
|
||||
uni.cache.get('shopId')
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
1162
pages/product/components/confirmorder.vue
Normal file
1162
pages/product/components/confirmorder.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,232 +0,0 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<image class="top_bg" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/order/orderAMeal.png" mode="aspectFill"></image>
|
||||
<view class="content_box">
|
||||
<view class="content">
|
||||
<view class="title">
|
||||
<view class="title_text">请选择就餐人数</view>
|
||||
<view class="title_tabNum">桌号A2</view>
|
||||
</view>
|
||||
<view class="num" :class="{'active':numIndex==-1}">
|
||||
<view class="item" @click="tabCut(index)" v-for="(item,index) in 9" :key="index">
|
||||
<view class="num_item" :class="{'active':numIndex==index }">{{index+1}}</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<u--input class="num_item" v-model="otherNum" :class="{'active':numIndex==-1 }" @input="isOtherNum" @focus="tabCut(-1)" @blur="blur()" border="none" type="nubmer" maxlength="3"></u--input>
|
||||
</view>
|
||||
<!-- <view class="num_item" v-else :class="{'active':numIndex==-1 }">其</view> -->
|
||||
</view>
|
||||
<view class="startBtn" @click="start">
|
||||
开始点餐
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tableCode: null,
|
||||
shopId: null,
|
||||
numIndex: 0,
|
||||
otherNum: '其他',
|
||||
dinersNum: 1,
|
||||
type: ""
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.tableCode = options.tableCode;
|
||||
this.shopId = options.shopId;
|
||||
if ( options.type ) { this.type = options.type}
|
||||
},
|
||||
onShow() {
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
|
||||
isOtherNum (e) {
|
||||
this.$nextTick(() => {
|
||||
this.otherNum = this.otherNum.replace(/\D/g, '')
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 切换桌型
|
||||
*/
|
||||
tabCut(index) {
|
||||
this.numIndex = index;
|
||||
if ( index != -1) {
|
||||
this.dinersNum = index+1;
|
||||
} else {
|
||||
this.otherNum = this.otherNum == "其他" ? "" : this.otherNum;
|
||||
}
|
||||
},
|
||||
|
||||
blur ( index ) {
|
||||
this.otherNum = this.otherNum == "" ? "其他" : this.otherNum;
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始点餐
|
||||
*/
|
||||
async start () {
|
||||
if ( this.numIndex == -1 && (this.otherNum == "其他"||this.otherNum <= 0)) {
|
||||
uni.showToast({
|
||||
title: '请选择就餐人数',
|
||||
icon: 'none',
|
||||
})
|
||||
return;
|
||||
}
|
||||
if ( this.numIndex == -1 && this.otherNum != "其他") {
|
||||
this.dinersNum = this.otherNum
|
||||
}
|
||||
|
||||
let res = await this.api.productChoseCount({
|
||||
tableId: this.tableCode,
|
||||
num: this.dinersNum,
|
||||
shopId: this.shopId,
|
||||
}) //判断是否支付成功
|
||||
if ( res.code == 0) {
|
||||
if( this.type == 'confirm') {
|
||||
uni.pro,navigateBack()
|
||||
} else {
|
||||
uni.pro.redirectTo('order_food/order_food', {
|
||||
// uni.pro.navigateTo('order_food/order_food', {
|
||||
tableCode: this.tableCode,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
page {
|
||||
// background: #f6f6f6;
|
||||
}
|
||||
.top_bg{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
}
|
||||
.content_box{
|
||||
width: 100%;
|
||||
padding: 0 28rpx;
|
||||
position: absolute;
|
||||
bottom: 148rpx;
|
||||
}
|
||||
.content{
|
||||
width: 100%;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 48rpx 0 32rpx 32rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 44rpx 44rpx 44rpx 44rpx;
|
||||
.title{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 48rpx;
|
||||
padding-right: 32rpx;
|
||||
.title_text{
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
.title_tabNum{
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
.num{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
.item{
|
||||
width: 20%;
|
||||
padding-right: 32rpx;
|
||||
}
|
||||
.num_item{
|
||||
width: 100%;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
margin-right: 28rpx;
|
||||
margin-bottom: 32rpx;
|
||||
background-color: #FEF4EB;
|
||||
border-radius: 12rpx;
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
.num_item:nth-child(5n){
|
||||
margin-right: 0;
|
||||
}
|
||||
::v-deep .u-input{
|
||||
width: 100%;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 32rpx;
|
||||
background-color: #FEF4EB;
|
||||
border-radius: 12rpx;
|
||||
|
||||
}
|
||||
::v-deep input{
|
||||
font-weight: 400;
|
||||
border-radius: 12rpx;
|
||||
font-size: 28rpx!important;
|
||||
color: #333333!important;
|
||||
text-align: center!important;
|
||||
background-color: #FEF4EB!important;
|
||||
}
|
||||
.active{
|
||||
color: #fff;
|
||||
background-color: #E8AD7B;
|
||||
}
|
||||
|
||||
}
|
||||
::v-deep .num.active .u-input{
|
||||
width: 100%;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 32rpx;
|
||||
background-color: #E8AD7B!important;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
::v-deep .num.active input{
|
||||
color: #fff!important;
|
||||
border-radius: 12rpx;
|
||||
background-color: #E8AD7B!important;
|
||||
}
|
||||
|
||||
}
|
||||
.startBtn{
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
text-align: center;
|
||||
background-color: #E8AD7B;
|
||||
border-radius: 48rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
@@ -32,7 +32,6 @@
|
||||
const cartListsdatashow = ref(false)
|
||||
const showCart = ref(false)
|
||||
const orderdetail = () => {
|
||||
|
||||
if (this.cartLists.data.length == 0) {
|
||||
uni.showToast({
|
||||
title: '请先添加商品',
|
||||
|
||||
@@ -232,7 +232,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<confirmorder :cartLists_count="cartLists_count" :cartList="matchedProducts" :totalPrices='totalPrices'
|
||||
:confirmordershow="confirmordershow" @close="confirmordershow = !confirmordershow"></confirmorder>
|
||||
<!-- 店铺详情 -->
|
||||
<shopindex ref="showShopInfoRef"></shopindex>
|
||||
<!-- 购物车 -->
|
||||
@@ -241,7 +242,7 @@
|
||||
</shoppingCartes>
|
||||
|
||||
<!-- 显示购物车栏 -->
|
||||
<view class="cart-wrap" v-if="cartLists_count>0">
|
||||
<view class="cart-wrap" v-if="cartLists_count>0 && !confirmordershow">
|
||||
<view class="cart-content">
|
||||
<view class="left">
|
||||
<view class="iconBox">
|
||||
@@ -253,7 +254,7 @@
|
||||
</view>
|
||||
|
||||
<text class="i">¥</text>
|
||||
<text class="num">{{TotalPrices}}</text>
|
||||
<text class="num">{{totalPrices}}</text>
|
||||
</view>
|
||||
<view class="btn" @tap="$u.debounce(orderdetail, 500)">
|
||||
<text class="t">去结算</text>
|
||||
@@ -341,15 +342,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
|
||||
<!-- <view>
|
||||
<button @click="manualClose">手动关闭连接</button>
|
||||
<p>连接状态: {{ isConnected ? '已连接' : '未连接' }}</p>
|
||||
<view>收到的消息:</view>
|
||||
<view>
|
||||
<view v-for="(message, index) in receivedMessages" :key="index">{{ message }}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -360,7 +352,8 @@
|
||||
onMounted,
|
||||
watchEffect,
|
||||
getCurrentInstance,
|
||||
computed
|
||||
computed,
|
||||
watch
|
||||
} from "vue";
|
||||
|
||||
import {
|
||||
@@ -374,6 +367,7 @@
|
||||
import Nav from '@/components/CustomNavbar.vue';
|
||||
import shopindex from './components/shopindex.vue'
|
||||
import shoppingCartes from './components/shoppingCartes.vue'
|
||||
import confirmorder from './components/confirmorder.vue'
|
||||
// 获取全局属性
|
||||
const {
|
||||
proxy
|
||||
@@ -394,8 +388,14 @@
|
||||
import {
|
||||
useNavbarStore
|
||||
} from '@/stores/navbarStore';
|
||||
const store = useNavbarStore();
|
||||
|
||||
// 结账管理
|
||||
import {
|
||||
Memberpay
|
||||
} from '@/stores/pay.js';
|
||||
|
||||
const storeMemberpay = Memberpay();
|
||||
const store = useNavbarStore();
|
||||
|
||||
import {
|
||||
productStore
|
||||
@@ -403,6 +403,12 @@
|
||||
|
||||
const userStore = productStore();
|
||||
|
||||
// 金额管理
|
||||
import {
|
||||
useCartStore
|
||||
} from '@/stores/order.js';
|
||||
const cartStore = useCartStore()
|
||||
|
||||
// 动态更新导航栏配置
|
||||
store.updateNavbarConfig({
|
||||
showBack: true, //左边返回键
|
||||
@@ -413,7 +419,6 @@
|
||||
hasPlaceholder: false //是否要占位符
|
||||
});
|
||||
|
||||
const userInfo = uni.cache.get('userInfo')
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
const shopTable = uni.cache.get('shopTable')
|
||||
const distance = uni.cache.get('distance') //距离
|
||||
@@ -434,9 +439,6 @@
|
||||
// 计算高度
|
||||
const navScroll = ref(null)
|
||||
|
||||
// 用餐人数
|
||||
const dinersNum = ref(0)
|
||||
|
||||
// 获取商品数据
|
||||
const shopProductList = reactive({
|
||||
hots: [],
|
||||
@@ -809,6 +811,9 @@
|
||||
//购物车显示
|
||||
const showCart = ref(false)
|
||||
|
||||
// 提交订单显示
|
||||
const confirmordershow = ref(false)
|
||||
|
||||
// 购物车数组
|
||||
const cartList = ref([])
|
||||
|
||||
@@ -863,14 +868,21 @@
|
||||
const Message = receivedMessages.value[receivedMessages.value.length - 1];
|
||||
if (Message) {
|
||||
// 心跳返回 过滤
|
||||
if (Message.type == "p") {
|
||||
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
|
||||
return false
|
||||
}
|
||||
|
||||
// 清空购物车
|
||||
if (Message.operate_type == 'shopping_cleanup') {
|
||||
cartList.value = []
|
||||
showCart.value = false
|
||||
// 初始化
|
||||
if (Message.operate_type == "shopping_init") {
|
||||
cartList.value = Message.data
|
||||
}
|
||||
|
||||
|
||||
// 购物车数据更新从新请求
|
||||
if (Message.type == 'product') {
|
||||
isDataLoaded.value = false;
|
||||
await productqueryProduct()
|
||||
// 数据可以更新
|
||||
}
|
||||
|
||||
// 初始化购物车数据
|
||||
@@ -959,29 +971,27 @@
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 计算购物车商品费用
|
||||
const totalPrices = ref(0);
|
||||
|
||||
// 使用 computed 计算购物车总价格
|
||||
const TotalPrices = computed(() => {
|
||||
// 购物车总数价格
|
||||
let cart = matchedProducts.value.reduce((total, item) => {
|
||||
// 是否启用会员价 0否1是
|
||||
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
|
||||
// memberPrice会员价
|
||||
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
|
||||
} else {
|
||||
// salePrice销售价
|
||||
return total + parseFloat(item.salePrice) * parseFloat(item.salePrice);
|
||||
}
|
||||
}, 0);
|
||||
// 是否免除桌位费 0否1是
|
||||
if (uni.cache.get('shopInfo').isTableFee == 0) {
|
||||
console.log( cart + dinersNum.value * parseFloat(uni.cache.get('shopInfo').tableFee))
|
||||
return cart + parseFloat(dinersNum.value) * parseFloat(uni.cache.get('shopInfo').tableFee)
|
||||
} else {
|
||||
return cart;
|
||||
watchEffect(() => {
|
||||
if (matchedProducts.value.length > 0) {
|
||||
totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
}
|
||||
});
|
||||
|
||||
// matchedProducts 变化时,更新总打包费用
|
||||
watch(() => matchedProducts.value, () => {
|
||||
if (matchedProducts.value.length > 0) {
|
||||
totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
}
|
||||
});
|
||||
|
||||
// 结账
|
||||
const orderdetail = async () => {
|
||||
confirmordershow.value = true
|
||||
}
|
||||
|
||||
// 定义 ifcartNumber 计算属性方法 展示数量
|
||||
const ifcartNumber = computed(() => {
|
||||
return (item) => {
|
||||
@@ -1007,7 +1017,6 @@
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
// 计算处理后的购物车列表 // 用于筛选后的购物车数组
|
||||
const cartListFilter = computed(() => {
|
||||
// 使用 reduce 方法对 cartList 进行处理
|
||||
@@ -1034,20 +1043,6 @@
|
||||
}));
|
||||
})
|
||||
|
||||
// 结账
|
||||
|
||||
const orderdetail = () => {
|
||||
|
||||
if (this.cartLists.data.length == 0) {
|
||||
uni.showToast({
|
||||
title: '请先添加商品',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 列表请求
|
||||
const productqueryProduct = async () => {
|
||||
shopProductList.hots = await productminiApphotsquery()
|
||||
@@ -1079,8 +1074,13 @@
|
||||
const currentPage = pages[pages.length - 1];
|
||||
// 获取页面参数
|
||||
const options = currentPage.options;
|
||||
dinersNum.value = options.dinersNum
|
||||
await productqueryProduct()
|
||||
|
||||
orderId.value = options.orderId
|
||||
let res = await APIshopUserInfo({
|
||||
shopId: uni.cache.get('shopId')
|
||||
})
|
||||
cartStore.shopInfo = uni.cache.get('shopInfo')
|
||||
setTimeout(() => {
|
||||
getElementTop()
|
||||
}, 500)
|
||||
|
||||
Reference in New Issue
Block a user