下单退款相关更新
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user