下单退款相关更新
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
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">
|
||||
@@ -103,7 +100,6 @@
|
||||
})
|
||||
onLoad(opt => {
|
||||
Object.assign(option, opt)
|
||||
console.log(option);
|
||||
getTable()
|
||||
getArea()
|
||||
})
|
||||
|
||||
@@ -44,11 +44,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'
|
||||
@@ -111,7 +107,6 @@
|
||||
...$form
|
||||
})
|
||||
watch(()=>props.price,(newval)=>{
|
||||
console.log(newval);
|
||||
form.price=newval
|
||||
form.currentPrice=newval
|
||||
})
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -70,17 +70,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import go from '@/commons/utils/go.js';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import {
|
||||
formatPrice
|
||||
} from '@/commons/utils/format.js';
|
||||
import { formatPrice } from '@/commons/utils/format.js';
|
||||
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
@@ -92,14 +87,6 @@
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: ""
|
||||
}
|
||||
}
|
||||
},
|
||||
table: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
@@ -173,7 +160,8 @@
|
||||
const allPrice = computed(() => {
|
||||
console.log("购物车数据==",props.data)
|
||||
return props.data.reduce((prve, cur) => {
|
||||
return prve + cur.lowPrice * cur.number
|
||||
let price = Math.floor((cur.lowPrice * cur.number)*100)/100
|
||||
return prve + price
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -182,8 +170,9 @@
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
// console.log(result)
|
||||
return result >= 99 ? 99 : result
|
||||
console.log(result)
|
||||
result = result > 0 ? result.toFixed(2) : 0
|
||||
return result >= 99 ? 99 : parseFloat(result)
|
||||
})
|
||||
|
||||
function updateNumber(isAdd, index, goods) {
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
let arrlength = 0
|
||||
datas.selectNumber = 0
|
||||
datas.skus.map(ele => {
|
||||
let group = {
|
||||
...ele,
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
<view class="boxoverlay" v-if="form&&form.goods">
|
||||
<view class="rect" @tap.stop>
|
||||
<view class="title">
|
||||
<view>
|
||||
标题
|
||||
</view>
|
||||
<view> 标题 </view>
|
||||
<view class="" @click="overlayshow = false">
|
||||
<up-icon name="close" color="#93969b" size="20"></up-icon>
|
||||
</view>
|
||||
@@ -31,11 +29,9 @@
|
||||
<button @click="deleteLast">←</button>
|
||||
</view>
|
||||
<view class="classmoney">
|
||||
¥ {{ (form.goods.lowPrice * currentInput).toFixed(2) }}
|
||||
</view>
|
||||
<view class="classconfirm" @click="clickconfirm">
|
||||
确认
|
||||
¥ {{ (Math.floor((form.goods.lowPrice * currentInput)*100)/100).toFixed(2) }}
|
||||
</view>
|
||||
<view class="classconfirm" @click="clickconfirm"> 确认 </view>
|
||||
</view>
|
||||
</view>
|
||||
</up-overlay>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</template>
|
||||
|
||||
<view class="bottom w-full">
|
||||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :user="data.vipUser"
|
||||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange"
|
||||
:table="data.table" :data="cars" @clear="cleaCart"></my-car>
|
||||
</view>
|
||||
<!-- 套餐选择规格 -->
|
||||
@@ -105,8 +105,7 @@
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :goodsData="selGoods"
|
||||
:title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap"
|
||||
:skus="guigeModelData.chooseGoods.skus"></guige-model>
|
||||
<!-- 添加附加费 -->
|
||||
<my-surcharge @confirm="surchargeConfirm" ref="surcharge" title="添加附加费"></my-surcharge>
|
||||
|
||||
<!-- 称重 -->
|
||||
<weigh-item ref="refweighitem" @weighgoodsUpdate='goodsUpdate'></weigh-item>
|
||||
</view>
|
||||
@@ -116,28 +115,21 @@
|
||||
import { onLoad, onReady, onShow } from '@dcloudio/uni-app';
|
||||
import { computed, reactive, ref, nextTick, watch, getCurrentInstance, onUnmounted, onBeforeUnmount } from 'vue';
|
||||
|
||||
import util from './util.js';
|
||||
import color from '@/commons/color.js';
|
||||
import guigeModel from './components/guige'
|
||||
import taocanModel from './components/taocanModel.vue'
|
||||
import weighItem from './components/weigh.vue'
|
||||
import listGoodsItem from './components/list-goods-item.vue'
|
||||
import mySurcharge from './components/surcharge'
|
||||
import myCar from './components/car'
|
||||
|
||||
import util from './util.js';
|
||||
import color from '@/commons/color.js';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import { getNowCart } from '@/pagesCreateOrder/util.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
$returnUseType
|
||||
} from './util.js'
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
|
||||
import appConfig from '@/config/appConfig.js';
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import WebsocketUtil from '@/commons/utils/websocket.js'
|
||||
|
||||
import { getShopTable,getShopTableDetail } from '@/http/api/table.js'
|
||||
import { getProductList } from '@/http/api/product.js'
|
||||
import { categoryPage } from '@/http/api/cateGory.js'
|
||||
@@ -209,9 +201,7 @@
|
||||
option = opt
|
||||
console.log("opt===",opt)
|
||||
Object.assign(data.table, opt)
|
||||
if (opt.useType) {
|
||||
uni.setStorageSync('useType', opt.useType)
|
||||
}
|
||||
|
||||
uni.setNavigationBarTitle({
|
||||
title: (opt && opt.type == 'add') ? '顾客加菜' : '代客下单'
|
||||
})
|
||||
@@ -221,7 +211,7 @@
|
||||
if(uni.getStorageSync("table_code")){
|
||||
data.table.tableCode = uni.getStorageSync("table_code")
|
||||
}
|
||||
init()
|
||||
// init()
|
||||
xiadanClick()
|
||||
})
|
||||
watch(() => data.table.id, (newval, oldval) => {
|
||||
@@ -230,13 +220,13 @@
|
||||
}
|
||||
})
|
||||
onShow(() => {
|
||||
// watchChooseuser()
|
||||
watchChooseTable()
|
||||
watchUpdate()
|
||||
data.isGoodsAdd = true;
|
||||
nextTick(()=>{
|
||||
onMessage()
|
||||
})
|
||||
init()
|
||||
})
|
||||
onReady(() => {
|
||||
getElRect('list-tight-top').then(res => {
|
||||
@@ -264,16 +254,12 @@
|
||||
let $category = []
|
||||
|
||||
async function init() {
|
||||
// console.log(option.type)
|
||||
if (option.type == 'add') {
|
||||
setTabBar($category, $originGoods, [])
|
||||
}
|
||||
let shopInfo = await getShopInfo({id:uni.getStorageSync('shopInfo').id})
|
||||
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo)
|
||||
uni.setStorageSync('useType', useType)
|
||||
|
||||
// await getTableInfo()
|
||||
|
||||
console.log(shopInfo)
|
||||
uni.setStorageSync("shopInfo",shopInfo)
|
||||
// 获取分类数据
|
||||
let categoryRes = await categoryPage({ page: 1, size: 300 })
|
||||
$category = categoryRes.records
|
||||
@@ -312,7 +298,8 @@
|
||||
console.log("onMessage===",msg)
|
||||
if( msg.msg == "收到了"){
|
||||
data.isCars = true;
|
||||
// initCart()
|
||||
data.isGoodsAdd = true;
|
||||
initCart()
|
||||
}
|
||||
if( msg.msg_id ){
|
||||
websocketUtil.send(JSON.stringify({
|
||||
@@ -341,7 +328,7 @@
|
||||
data.table.tableCode = msg.table_code
|
||||
uni.setStorageSync("table_code",msg.table_code)
|
||||
}
|
||||
console.log("cartArr===",cartArr)
|
||||
console.log("商品信息===",cartArr)
|
||||
msg.data.map(item=>{
|
||||
cartItem = getNowCart(item,cartArr)
|
||||
console.log("cartItem===",cartItem)
|
||||
@@ -398,8 +385,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 初始化购物车
|
||||
*/
|
||||
@@ -411,9 +396,6 @@
|
||||
}
|
||||
console.log("购物车初始化参数===",params)
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,9 +408,9 @@
|
||||
operate_type: operate_type,
|
||||
table_code: data.table.tableCode,
|
||||
product_id: '',
|
||||
is_print: 1,
|
||||
sku_id: '', //
|
||||
number: 1, //数量
|
||||
is_temporary: 0, //是否是临时菜
|
||||
}
|
||||
Object.assign(params, par)
|
||||
console.log('购物车添加菜品参数===',params)
|
||||
@@ -511,7 +493,6 @@
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function onChooseTable(item) {
|
||||
console.log('onChooseTable');
|
||||
if (!item) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.showModal({
|
||||
@@ -533,8 +514,6 @@
|
||||
table_code: data.table.tableCode,
|
||||
new_table_code: item.tableCode,
|
||||
}
|
||||
console.log(cars)
|
||||
|
||||
if (data.table.id || cars.length <= 0) {
|
||||
data.table = {
|
||||
...item
|
||||
@@ -576,11 +555,10 @@
|
||||
if( !data.isCars ){
|
||||
return infoBox.showToast('购物车加载失败请刷新重试...')
|
||||
}
|
||||
if( !data.isGoodsAdd ){ return; }
|
||||
if( !data.isGoodsAdd ){ return;infoBox.showToast('isGoodsAdd...') }
|
||||
let $goods = data.tabbar[index].foods[foodsindex]
|
||||
if ($goods.type !== 'sku') {
|
||||
//单规格
|
||||
console.log($goods)
|
||||
let goodsInCarIndex = cars.findIndex((carsGoods) => {
|
||||
return carsGoods.sku_id == $goods.skuList[0].id && carsGoods.product_id == $goods.id;
|
||||
});
|
||||
@@ -609,6 +587,7 @@
|
||||
number: number,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
is_temporary: cartItem.is_temporary
|
||||
},'edit')
|
||||
data.isGoodsAdd = false;
|
||||
setSearchGoods(searchGoodsIndex, number)
|
||||
@@ -624,6 +603,7 @@
|
||||
number: suitNum,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
is_temporary: 0, //是否是临时菜
|
||||
},'add')
|
||||
data.isGoodsAdd = false;
|
||||
}
|
||||
@@ -680,7 +660,6 @@
|
||||
* @param {Object} e
|
||||
*/
|
||||
async function carsNumberChange(e) {
|
||||
console.log("carsNumberChange===",e)
|
||||
if( !data.isGoodsAdd ){ return; }
|
||||
let $sku;
|
||||
let $goods;
|
||||
@@ -714,7 +693,8 @@
|
||||
number: e.num,
|
||||
id: e.goods.id,
|
||||
product_id: e.goods.product_id,
|
||||
sku_id: e.goods.sku_id
|
||||
sku_id: e.goods.sku_id,
|
||||
is_temporary: e.goods.is_temporary
|
||||
},'edit')
|
||||
data.isGoodsAdd = false;
|
||||
}
|
||||
@@ -725,51 +705,44 @@
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function taocanConfirm(d, item) {
|
||||
console.log(d)
|
||||
//添加
|
||||
editCart({
|
||||
number: item.skuList[0].suitNum,
|
||||
product_id: item.id,
|
||||
sku_id: item.skuList[0].id,
|
||||
pro_group_info: JSON.stringify(d),
|
||||
is_temporary: 0, //是否是临时菜
|
||||
},'add')
|
||||
data.isGoodsAdd = false;
|
||||
}
|
||||
|
||||
const instance = getCurrentInstance();
|
||||
let selGoods = ref({});
|
||||
|
||||
/**
|
||||
* 打开规格弹窗
|
||||
* @param {Object} foodsindex
|
||||
* @param {Object} index
|
||||
*/
|
||||
function chooseGuige(foodsindex, index) {
|
||||
// if (!data.table.id) {
|
||||
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
|
||||
// chooseTable()
|
||||
// })
|
||||
// }
|
||||
|
||||
if( !data.isCars ){
|
||||
return infoBox.showToast('购物车加载失败请刷新重试...')
|
||||
}
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
console.log($goods)
|
||||
selGoods.value = $goods
|
||||
if ($goods.groupType == 1) {
|
||||
data.goodsData = $goods
|
||||
instance.ctx.$refs.taocanModelRef.open()
|
||||
} else {
|
||||
console.log($goods)
|
||||
guigeModelData.title = $goods.name
|
||||
const skuMap = returnSelGoodsSkuMap($goods.skuList)
|
||||
console.log(skuMap)
|
||||
// 多规格,和套餐规格区分.groupType=1 套餐多规格
|
||||
const selectSpecInfo = returnSelGoodsSkuList($goods.selectSpecInfo)
|
||||
setSkugoodsDefaultInit($goods, selectSpecInfo, skuMap, $goods.skuList)
|
||||
chooseGuigeModel.value.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//返回当前选中商品skuMap
|
||||
function returnSelGoodsSkuMap(specList) {
|
||||
const skuMap = {}
|
||||
@@ -812,7 +785,6 @@
|
||||
* @param {Object} num
|
||||
*/
|
||||
async function guigeConfirm(sku, suitNum) {
|
||||
console.log(sku)
|
||||
if( !data.isGoodsAdd ){ return; }
|
||||
let goods = guigeModelData.chooseGoods.item
|
||||
let sku_id = sku.id
|
||||
@@ -830,6 +802,7 @@
|
||||
number: newNumber,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
is_temporary: carGoods.is_temporary, //是否是临时菜
|
||||
},'edit')
|
||||
data.isGoodsAdd = false;
|
||||
} else {
|
||||
@@ -838,6 +811,7 @@
|
||||
number: suitNum,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
is_temporary: 0, //是否是临时菜
|
||||
},'add')
|
||||
data.isGoodsAdd = false;
|
||||
}
|
||||
@@ -860,8 +834,9 @@
|
||||
} : false
|
||||
}
|
||||
|
||||
|
||||
//多规格商品弹窗时,找到默认可以下单的规格商品
|
||||
/**
|
||||
* 多规格商品弹窗时,找到默认可以下单的规格商品
|
||||
*/
|
||||
function findGoods(selectSpecInfo = [], goodsListMap = {}, skuList) {
|
||||
let skuMapNumber = selectSpecInfo.reduce((prve, cur) => {
|
||||
for (let i in cur.valueArr) {
|
||||
@@ -869,10 +844,7 @@
|
||||
}
|
||||
return prve;
|
||||
}, {});
|
||||
console.log("selectSpecInfo",selectSpecInfo)
|
||||
console.log("skuMapNumber",guigeModelData.chooseGoods.item)
|
||||
let canBudyGoods = skuList.filter((v) => util.isCanBuy(v, guigeModelData.chooseGoods.item))
|
||||
console.log("canBudyGoods",canBudyGoods)
|
||||
return canBudyGoods[0];
|
||||
}
|
||||
|
||||
@@ -894,7 +866,6 @@
|
||||
guigeModelData.chooseGoods.skus[index].sel = v;
|
||||
});
|
||||
}
|
||||
console.log("guigeModelData.chooseGoods.skus===",guigeModelData.chooseGoods.skus);
|
||||
setTagDisabled();
|
||||
}
|
||||
|
||||
@@ -910,7 +881,10 @@
|
||||
setTagDisabled();
|
||||
|
||||
}
|
||||
//设置规格按钮的禁止状态
|
||||
|
||||
/**
|
||||
* 设置规格按钮的禁止状态
|
||||
*/
|
||||
function setTagDisabled() {
|
||||
const skuList = guigeModelData.chooseGoods.skus
|
||||
const skuMap = guigeModelData.chooseGoods.skuMap
|
||||
@@ -925,7 +899,6 @@
|
||||
const matchArr = [];
|
||||
for (let key in skuMap) {
|
||||
let goods = skuMap[key];
|
||||
console.log(key)
|
||||
let keyArr = key.split(",");
|
||||
for (let spe of selArrAllGroup) {
|
||||
if (util.arrayContainsAll(keyArr, spe)) {
|
||||
@@ -934,7 +907,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(matchArr);
|
||||
//全部规格都已下架
|
||||
if (!matchArr.length) {
|
||||
for (let k in skuList) {
|
||||
@@ -975,8 +947,6 @@
|
||||
* 扫桌台码
|
||||
*/
|
||||
function scanCode() {
|
||||
// 只允许通过相机扫码
|
||||
console.log('scanCode');
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
success: async function(res) {
|
||||
@@ -993,13 +963,10 @@
|
||||
title: '请扫描正确的桌台码'
|
||||
})
|
||||
}
|
||||
// uni.showModal({
|
||||
// title:'',
|
||||
// content:res.result
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function returnUrlPar(str) {
|
||||
let arr = str.split("?")[1].split("&"); //先通过?分解得到?后面的所需字符串,再将其通过&分解开存放在数组里
|
||||
let obj = {};
|
||||
@@ -1009,8 +976,12 @@
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品数据处理
|
||||
* @param {Object} category
|
||||
* @param {Object} goods
|
||||
* @param {Object} cars
|
||||
*/
|
||||
function setTabBar(category, goods, cars) {
|
||||
const goodsCategoryMap = goods.reduce((prve, cur) => {
|
||||
if (!prve.hasOwnProperty(cur.categoryId)) {
|
||||
@@ -1049,27 +1020,22 @@
|
||||
storageManage.cacheGoods(data.tabbar)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const surcharge = ref(null)
|
||||
|
||||
function surchargeConfirm(e) {
|
||||
data.tabbar[data.tabbar.length - 1].foods.unshift({
|
||||
...e,
|
||||
chooseNumber: 0
|
||||
})
|
||||
}
|
||||
|
||||
function surchargeShow() {
|
||||
surcharge.value.open()
|
||||
}
|
||||
|
||||
|
||||
let searchValue = ref('')
|
||||
let isSearch = ref(false)
|
||||
let searchResult = ref([])
|
||||
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function search() {
|
||||
if (searchValue.value === '') {
|
||||
isSearch.value = false
|
||||
return
|
||||
}
|
||||
isSearch.value = true
|
||||
searchResult.value = returnSearchGoods()
|
||||
}
|
||||
|
||||
function returnSearchGoods() {
|
||||
const newval = searchValue.value
|
||||
let arr = []
|
||||
@@ -1094,16 +1060,6 @@
|
||||
return arr
|
||||
}
|
||||
|
||||
function search() {
|
||||
if (searchValue.value === '') {
|
||||
isSearch.value = false
|
||||
return
|
||||
}
|
||||
isSearch.value = true
|
||||
searchResult.value = returnSearchGoods()
|
||||
console.log(searchResult.value);
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
isSearch.value = false
|
||||
}
|
||||
@@ -1121,13 +1077,7 @@
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 称重
|
||||
*/
|
||||
@@ -1157,10 +1107,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let isTabClickOver = true
|
||||
/**
|
||||
* 点击左边的栏目切换
|
||||
@@ -1285,25 +1231,11 @@
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function watchChooseuser() {
|
||||
uni.$off('choose-user')
|
||||
uni.$on('choose-user', (user) => {
|
||||
console.log(user);
|
||||
data.vipUser = user ? user : {
|
||||
id: ''
|
||||
}
|
||||
setUser()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌切换
|
||||
*/
|
||||
async function onSelTable() {
|
||||
// const cartRes = await getCart()
|
||||
// cars.length = 0
|
||||
// const cartArr = getNowCart(cartRes.records)
|
||||
// for (let i in cartArr) {
|
||||
// cars.push(cartArr[i])
|
||||
// }
|
||||
setTabBar($category, $originGoods, cars)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export function getNowCart(carItem,goodsList,user) {
|
||||
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 {
|
||||
@@ -25,6 +26,7 @@ export function getNowCart(carItem,goodsList,user) {
|
||||
carItem.name = goodsItem.name
|
||||
carItem.coverImg = goodsItem.coverImg
|
||||
carItem.packFee = goodsItem.packFee
|
||||
carItem.type = goodsItem.type
|
||||
carItem.isGrounding = true;
|
||||
}
|
||||
carItem.number = parseFloat(carItem.number)
|
||||
|
||||
Reference in New Issue
Block a user