下单退款相关更新
This commit is contained in:
@@ -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>
|
||||
@@ -80,12 +77,7 @@
|
||||
</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'
|
||||
@@ -164,7 +156,6 @@
|
||||
...$form
|
||||
})
|
||||
watch(() => props.price, (newval) => {
|
||||
console.log(newval);
|
||||
form.price = newval
|
||||
form.currentPrice = newval
|
||||
})
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<view class="block u-m-b-0">
|
||||
<view class="u-flex">
|
||||
<view>共</view>
|
||||
<view class="fen font-bold">{{goodsNumber}}</view>
|
||||
<view class="fen font-bold">{{goods.list.length}}</view>
|
||||
<view>份菜品</view>
|
||||
</view>
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
<view>
|
||||
<text>桌位费</text>
|
||||
</view>
|
||||
<view>¥{{$seatFee.totalAmount||'0.00'}}</view>
|
||||
<view>¥{{$seatFee.totalAmount.toFixed(2)||'0.00'}}</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="$packFee>0">
|
||||
@@ -256,7 +256,7 @@
|
||||
|
||||
<view class="u-flex price u-m-l-32">
|
||||
<view class="">实收金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(allPrice) }}</view>
|
||||
<view class="font-bold u-font-32">¥{{allPrice }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||
<pack-number @confirm="goodsOnePackNumberConfirm" title="打包" :ref="setModel" name="packNumber"></pack-number>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
<!-- <edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount> -->
|
||||
</view>
|
||||
|
||||
|
||||
@@ -290,21 +290,23 @@
|
||||
<script setup>
|
||||
import { onLoad, onReady, onShow } from '@dcloudio/uni-app'
|
||||
import { ref, inject, 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 packNumber from './components/pack-number'
|
||||
import oneRemark from './components/remark'
|
||||
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
// import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
|
||||
import { getSafeBottomHeight } from '@/commons/utils/safe-bottom.js'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import $storageManage from '@/commons/utils/storageManage.js'
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import { getNowCart } from '@/pagesCreateOrder/util.js'
|
||||
import { number } from 'uview-plus/libs/function/test';
|
||||
|
||||
import { getShopInfo } from '@/http/api/shop.js'
|
||||
import { getShopTableDetail } from '@/http/api/table.js'
|
||||
import { getProductPage } from '@/http/api/product.js'
|
||||
import { getProductList } from '@/http/api/product.js'
|
||||
import { createOrder,getHistoryOrder } from '@/http/api/order.js'
|
||||
import { number } from 'uview-plus/libs/function/test';
|
||||
|
||||
const models = new Map();
|
||||
const modelData = reactive({
|
||||
@@ -351,14 +353,15 @@
|
||||
// value: "take-away",
|
||||
// }
|
||||
],
|
||||
active: 'dine-in'
|
||||
active: 'dine-in',
|
||||
isShow: false,
|
||||
},
|
||||
form: {
|
||||
note: ""
|
||||
},
|
||||
orderInfo: {}
|
||||
})
|
||||
|
||||
const websocketUtil = inject('websocketUtil'); // 注入 WebSocket 工具类实例
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
console.log("opt====",opt);
|
||||
@@ -368,13 +371,11 @@
|
||||
getTableInfo(opt)
|
||||
}
|
||||
getTbShopInfo()
|
||||
init()
|
||||
|
||||
})
|
||||
let bottomHeight = ref(100)
|
||||
onReady(() => {
|
||||
getSafeBottomHeight('safe-bottom').then(res => {
|
||||
console.log(res);
|
||||
bottomHeight.value = res
|
||||
})
|
||||
})
|
||||
@@ -383,12 +384,14 @@
|
||||
})
|
||||
|
||||
watch(() => pageData.eatTypes.active, (newval) => {
|
||||
pageData.eatTypes.isShow = true
|
||||
changeUseType()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
})
|
||||
onShow(() => {
|
||||
init()
|
||||
watchChooseuser()
|
||||
watchChooseTable()
|
||||
})
|
||||
@@ -412,9 +415,9 @@
|
||||
* 打包费
|
||||
*/
|
||||
const $packFee = computed(() => {
|
||||
console.log("打包费===",goods.list)
|
||||
let packAmount = 0;
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + ((cur.packFee||0)*parseFloat(cur.pack_number).toFixed(0))
|
||||
return prve + (cur.packFee||0)*parseFloat(cur.pack_number).toFixed(2)
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -447,11 +450,11 @@
|
||||
const goodsPrice = computed(() => {
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const lowMemberPrice = cur.lowMemberPrice ? cur.lowMemberPrice : cur.lowPrice
|
||||
const tPrice = (isVip.value ? lowMemberPrice : cur.lowPrice) * cur.number
|
||||
const tpackFee = cur.is_temporary !=1&&parseFloat(cur.pack_number).toFixed(0) > 0 ? cur.packFee*parseFloat(cur.pack_number).toFixed(0) : 0
|
||||
return prve + (cur.is_gift ? 0 : tPrice) + tpackFee
|
||||
const tPrice = Math.floor(((isVip.value ? lowMemberPrice : cur.lowPrice) * cur.number)*100)/100
|
||||
return prve + (cur.is_gift ? 0 : tPrice)
|
||||
}, 0)
|
||||
return ((goodsTotalPrice - discount_sale_amount.value) || 0).toFixed(2)
|
||||
const tpackFee = $packFee.value > 0 ? $packFee.value*1 : 0
|
||||
return ((goodsTotalPrice - discount_sale_amount.value + tpackFee) || 0).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -471,10 +474,8 @@
|
||||
goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const tPrice = cur.lowPrice * cur.number
|
||||
const tpackFee = (cur.pack_number*1) > 0 ? cur.packFee * (cur.pack_number*1) : 0
|
||||
console.log(cur)
|
||||
return prve + tPrice + tpackFee
|
||||
}, 0)
|
||||
console.log(goodsTotalPrice)
|
||||
return (goodsTotalPrice + $seatFee.totalAmount) - allPrice.value
|
||||
} else {
|
||||
return (discount_sale_amount.value)
|
||||
@@ -482,7 +483,19 @@
|
||||
return (goodsTotalPrice + discount_sale_amount.value * 1).toFixed(2)
|
||||
})
|
||||
|
||||
const websocketUtil = inject('websocketUtil'); // 注入 WebSocket 工具类实例
|
||||
/**
|
||||
* init
|
||||
*/
|
||||
async function init() {
|
||||
// 获取商品列表
|
||||
$goods = await getProductList({},'product', false)
|
||||
console.log("商品列表===",$goods)
|
||||
|
||||
|
||||
// 获取购物车数据
|
||||
getCart()
|
||||
}
|
||||
|
||||
/**
|
||||
* socket消息监听
|
||||
*/
|
||||
@@ -511,7 +524,30 @@
|
||||
} else {
|
||||
delCart(cartItem.id)
|
||||
}
|
||||
|
||||
})
|
||||
if( pageData.eatTypes.isShow ){
|
||||
if( pageData.eatTypes.active == 'take-out') {
|
||||
cartItem.pack_number = cartItem.number
|
||||
} else {
|
||||
cartItem.pack_number = 0
|
||||
}
|
||||
let par = {
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type:'batch',
|
||||
table_code: pageData.table.tableCode,
|
||||
is_pack: pageData.eatTypes.active == 'take-out' ? 1 : 0,
|
||||
}
|
||||
updateCart(par)
|
||||
}
|
||||
// 是否更新就餐人数
|
||||
if (!$seatFee.totalNumber) {
|
||||
updateChoseCount()
|
||||
}
|
||||
|
||||
pageData.eatTypes.isShow = false
|
||||
break;
|
||||
case 'onboc_add':
|
||||
case 'add':
|
||||
@@ -529,7 +565,10 @@
|
||||
break;
|
||||
case 'onboc_cleanup':
|
||||
case 'cleanup':
|
||||
goods.lis = []
|
||||
goods.list = []
|
||||
$seatFee.totalNumber = 0
|
||||
$seatFee.totalAmount = 0
|
||||
userNumbers.defaultCateIndex = 0
|
||||
break;
|
||||
case 'product_update':
|
||||
init()
|
||||
@@ -562,6 +601,11 @@
|
||||
pageData.table.tableCode = cartItem.table_code
|
||||
}
|
||||
let cartIndex = 0;
|
||||
goods.list.map((item,index)=>{
|
||||
if(item.id == cartItem.id) {
|
||||
cartIndex = index;
|
||||
}
|
||||
})
|
||||
|
||||
if( type == 'del' ) {
|
||||
goods.list.splice(cartIndex, 1)
|
||||
@@ -575,27 +619,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function init() {
|
||||
let goodsRes = await getGoods()
|
||||
// await getCart()
|
||||
$goods = goodsRes.records
|
||||
if (!$seatFee.totalNumber) {
|
||||
updateChoseCount()
|
||||
}
|
||||
getCart()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
*/
|
||||
function getGoods() {
|
||||
return getProductPage({
|
||||
page: 1,
|
||||
size: 300
|
||||
},'product', false)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取购物车数据
|
||||
@@ -609,8 +632,6 @@
|
||||
operate_type:'init',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
// pageData.eatTypes.active = useType == 'take-out' ? useType : useType.replace(
|
||||
// /-after|-before/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,7 +654,6 @@
|
||||
return (index + 1) + '人'
|
||||
})
|
||||
}
|
||||
|
||||
getHistoryOrderDetail(opt.tableCode)
|
||||
}
|
||||
|
||||
@@ -651,18 +671,6 @@
|
||||
* 就餐类型切换监听
|
||||
*/
|
||||
async function changeUseType() {
|
||||
const { registerType } = pageData.shopInfo
|
||||
//before 先付 after 后付
|
||||
const isPayAfter = registerType == "before" ? false : true;
|
||||
let useType = "take-out";
|
||||
if (pageData.eatTypes.active == "take-out") {
|
||||
uni.setStorageSync("useType", "take-out");
|
||||
} else {
|
||||
//堂食
|
||||
useType = `dine-in-${isPayAfter? "after" : "before"}`;
|
||||
uni.setStorageSync("useType", useType);
|
||||
}
|
||||
const tableId = useType == 'take-out' ? undefined : pageData.table.id;
|
||||
if (!goods.list.length) {
|
||||
return
|
||||
}
|
||||
@@ -674,7 +682,6 @@
|
||||
* @param {Object} par
|
||||
*/
|
||||
function updateCart (par) {
|
||||
// 初始化购物车
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
@@ -699,20 +706,7 @@
|
||||
par[key] = item[key] == 0 ? 1 : 0
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包
|
||||
*/
|
||||
function toggleIsPack (item,key) {
|
||||
let par = {
|
||||
id: item.id,
|
||||
product_id: item.product_id ,
|
||||
sku_id: item.sku_id,
|
||||
pack_num: 0
|
||||
}
|
||||
par['pack_number'] = item['pack_number'] == 0 ? 1 : 0
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单品打折
|
||||
@@ -790,10 +784,20 @@
|
||||
const model = models.get(key)
|
||||
console.log("弹窗数据===",modelData.data)
|
||||
if( key == 'packNumber'){
|
||||
if( modelData.data.type == 'weight' && item.pack_number <= 0){
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: 1
|
||||
}
|
||||
updateCart(par)
|
||||
return false;
|
||||
}
|
||||
if( item.pack_number > 0 ){
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id ,
|
||||
product_id: modelData.data.product_id,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: 0
|
||||
}
|
||||
@@ -812,7 +816,7 @@
|
||||
}
|
||||
|
||||
function formatPrice(n) {
|
||||
return Number(n).toFixed(2)
|
||||
return (Math.floor(n*100)/100).toFixed(2)
|
||||
}
|
||||
|
||||
function rotatingTables() {
|
||||
@@ -833,10 +837,9 @@
|
||||
userNumbers.defaultCateIndex = maxCapacity - 1
|
||||
return
|
||||
}
|
||||
console.log(pageData.table)
|
||||
if (!pageData.shopInfo.isTableFee && pageData.table && pageData.table.id) {
|
||||
|
||||
if (!pageData.shopInfo.isTableFee && pageData.table && pageData.table.id && goods.list.length > 0) {
|
||||
//不免餐位费
|
||||
|
||||
let seatFee = {
|
||||
totalNumber: userNumbers.defaultCateIndex * 1 + 1,
|
||||
totalAmount: (userNumbers.defaultCateIndex * 1 + 1) * pageData.shopInfo.tableFee,
|
||||
@@ -852,7 +855,6 @@
|
||||
* @param {Object} e
|
||||
*/
|
||||
function userNumberChange(e) {
|
||||
console.log(e);
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
}
|
||||
|
||||
@@ -870,7 +872,7 @@
|
||||
uni.$off('choose-table')
|
||||
uni.$on('choose-table', (data) => {
|
||||
pageData.table = data
|
||||
console.log(pageData.table);
|
||||
console.log("台桌信息",pageData.table);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -931,14 +933,11 @@
|
||||
}, '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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user