完成购物车所有功能
This commit is contained in:
parent
d2689b226c
commit
e925948dcd
|
|
@ -78,3 +78,56 @@ export function createCode(params) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部打包
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function packall(data) {
|
||||||
|
return request({
|
||||||
|
method: "post",
|
||||||
|
url: "/order/packall",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除购物车
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function delCart(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/order/delCart",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂单/j激活购物车
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function cartStatus(data) {
|
||||||
|
return request({
|
||||||
|
method: "post",
|
||||||
|
url: "/order/cartStatus",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取挂起购物车列表
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getCartList(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/order/getCartList",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import { queryProductSku } from '@/api/product'
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
|
const type = ref('shop')
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const goods = ref({})
|
const goods = ref({})
|
||||||
|
|
||||||
|
|
@ -54,7 +54,16 @@ const loading = ref(false)
|
||||||
// 确认选择规格
|
// 确认选择规格
|
||||||
function submitSku() {
|
function submitSku() {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
emit('success', goodsInfo.value)
|
switch (type.value) {
|
||||||
|
case 'shop':
|
||||||
|
emit('success', goodsInfo.value)
|
||||||
|
break;
|
||||||
|
case 'cart':
|
||||||
|
emit('success', goods.value)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择规格
|
// 选择规格
|
||||||
|
|
@ -99,10 +108,13 @@ async function queryProductSkuAjax() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const res = await queryProductSku({
|
const res = await queryProductSku({
|
||||||
shopId: store.userInfo.shopId,
|
shopId: store.userInfo.shopId,
|
||||||
productId: goods.value.id,
|
productId: type.value == 'shop' ? goods.value.id : goods.value.productId,
|
||||||
spec_tag: selectedSkuTag.value
|
spec_tag: selectedSkuTag.value
|
||||||
})
|
})
|
||||||
goodsInfo.value = res
|
goodsInfo.value = res
|
||||||
|
if (type.value == 'cart') {
|
||||||
|
goods.value.skuId = res.id
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
@ -113,21 +125,37 @@ async function queryProductSkuAjax() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示规格
|
// 显示规格
|
||||||
function show(item) {
|
function show(item, t = 'shop') {
|
||||||
goodsInfo.value = {}
|
goodsInfo.value = {}
|
||||||
goods.value = {}
|
goods.value = {}
|
||||||
selectedSkuNum.value = 0
|
selectedSkuNum.value = 0
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
goods.value = ""
|
||||||
goods.value = item
|
goods.value = item
|
||||||
|
type.value = t
|
||||||
if (typeof goods.value.tbProductSpec.specList == 'string') {
|
if (typeof goods.value.tbProductSpec.specList == 'string') {
|
||||||
goods.value.tbProductSpec.specList = JSON.parse(goods.value.tbProductSpec.specList)
|
goods.value.tbProductSpec.specList = JSON.parse(goods.value.tbProductSpec.specList)
|
||||||
goods.value.tbProductSpec.specList.map(item => {
|
goods.value.tbProductSpec.specList.map(item => {
|
||||||
let arr = []
|
let arr = []
|
||||||
item.value.map(val => {
|
item.value.map(val => {
|
||||||
arr.push({
|
switch (type.value) {
|
||||||
active: false,
|
case 'shop':
|
||||||
name: val
|
arr.push({
|
||||||
})
|
active: false,
|
||||||
|
name: val
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case 'cart':
|
||||||
|
// 如果从购物车选择规格需要做选中效果
|
||||||
|
arr.push({
|
||||||
|
active: goods.value.skuName.includes(val),
|
||||||
|
name: val
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
item.value = arr
|
item.value = arr
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -13,31 +13,31 @@
|
||||||
<CloseBold />
|
<CloseBold />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" :class="{ disabled: !props.item.tbProductSpec }" @click="showSkuModal">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<Filter />
|
<Filter />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text class="t">规格</el-text>
|
<el-text class="t">规格</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" :class="{ disabled: props.item.isGift == 'true' }" @click="giftPackHandle('isGift')">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<ShoppingBag />
|
<ShoppingBag />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text class="t">赠送</el-text>
|
<el-text class="t">赠送</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" :class="{ disabled: props.item.isPack == 'true' }" @click="giftPackHandle('isPack')">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<Box />
|
<Box />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text class="t">打包</el-text>
|
<el-text class="t">打包</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" @click="emit('delete', props.item)">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<Delete />
|
<Delete />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text class="t">删除</el-text>
|
<el-text class="t">删除</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" @click="emit('pending', props.item)">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<Sell />
|
<Sell />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
|
|
@ -51,25 +51,40 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<takeFoodCode ref="takeFoodCodeRef" title="修改商品数量" placeholder="请输入商品数量" @success="updateNumber" />
|
<takeFoodCode ref="takeFoodCodeRef" title="修改商品数量" placeholder="请输入商品数量" @success="updateNumber" />
|
||||||
|
<!-- 购物车选择规格 -->
|
||||||
|
<skuModal ref="skuModalRef" @success="skuConfirm" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||||
|
import skuModal from '@/components/skuModal.vue'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['confirm'])
|
const emit = defineEmits(['confirm', 'delete', 'pending'])
|
||||||
|
|
||||||
const takeFoodCodeRef = ref(null)
|
const takeFoodCodeRef = ref(null)
|
||||||
|
const skuModalRef = ref([])
|
||||||
|
|
||||||
|
// 赠送打包操作
|
||||||
|
function giftPackHandle(key) {
|
||||||
|
if (props.item[key] == 'true') {
|
||||||
|
props.item[key] = false
|
||||||
|
} else {
|
||||||
|
props.item[key] = true
|
||||||
|
}
|
||||||
|
emit('confirm', props.item)
|
||||||
|
}
|
||||||
|
|
||||||
// 加减修改数量
|
// 加减修改数量
|
||||||
function numberChange(t) {
|
function numberChange(t) {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case 'sub':
|
case 'sub':
|
||||||
|
if (props.item.number <= 1) return
|
||||||
props.item.number--
|
props.item.number--
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
|
|
@ -86,6 +101,19 @@ function updateNumber(num) {
|
||||||
props.item.number = num
|
props.item.number = num
|
||||||
emit('confirm', props.item)
|
emit('confirm', props.item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 显示规格
|
||||||
|
function showSkuModal() {
|
||||||
|
if (props.item.tbProductSpec && props.item.tbProductSpec.specList) {
|
||||||
|
skuModalRef.value.show(props.item, 'cart')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改规格
|
||||||
|
function skuConfirm(e) {
|
||||||
|
console.log(e)
|
||||||
|
emit('confirm', e)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
@ -104,6 +132,17 @@ function updateNumber(num) {
|
||||||
background-color: #efefef;
|
background-color: #efefef;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
|
||||||
|
.t {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.number {
|
&.number {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
<div class="shop_list" :class="{ img: shopListType == 'img' }">
|
<div class="shop_list" :class="{ img: shopListType == 'img' }">
|
||||||
<div class="item_wrap" v-for="item in goodsList" :key="item.id" @click="showSkuHandle(item)">
|
<div class="item_wrap" v-for="item in goodsList" :key="item.id" @click="showSkuHandle(item)">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="dot">2</div>
|
<div class="dot" v-if="item.orderCount">{{ item.orderCount }}</div>
|
||||||
<div class="cover" v-if="shopListType == 'img'">
|
<div class="cover" v-if="shopListType == 'img'">
|
||||||
<el-image :src="item.coverImg" style="width: 100%;height: 100%;" fit="cover"></el-image>
|
<el-image :src="item.coverImg" style="width: 100%;height: 100%;" fit="cover"></el-image>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -63,6 +63,14 @@ import skuModal from '@/components/skuModal.vue'
|
||||||
import { queryCategory, productqueryCommodityInfo, queryProductSku } from '@/api/product'
|
import { queryCategory, productqueryCommodityInfo, queryProductSku } from '@/api/product'
|
||||||
import { useUser } from "@/store/user.js"
|
import { useUser } from "@/store/user.js"
|
||||||
const store = useUser()
|
const store = useUser()
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
masterId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
const skuModalRef = ref(null)
|
const skuModalRef = ref(null)
|
||||||
|
|
@ -164,12 +172,14 @@ async function queryCategoryAjax() {
|
||||||
// 查询商品信息
|
// 查询商品信息
|
||||||
async function productqueryCommodityInfoAjax() {
|
async function productqueryCommodityInfoAjax() {
|
||||||
try {
|
try {
|
||||||
|
console.log(props.masterId)
|
||||||
const res = await productqueryCommodityInfo({
|
const res = await productqueryCommodityInfo({
|
||||||
shopId: store.userInfo.shopId,
|
shopId: store.userInfo.shopId,
|
||||||
categoryId: categorys.value[categorysActive.value].id,
|
categoryId: categorys.value[categorysActive.value].id,
|
||||||
commdityName: commdityName.value,
|
commdityName: commdityName.value,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 1000
|
pageSize: 1000,
|
||||||
|
masterId: props.masterId
|
||||||
})
|
})
|
||||||
originalGoods.value = res
|
originalGoods.value = res
|
||||||
goodsList.value = res
|
goodsList.value = res
|
||||||
|
|
@ -178,9 +188,17 @@ async function productqueryCommodityInfoAjax() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新商品数据
|
||||||
|
function updateData() {
|
||||||
|
productqueryCommodityInfoAjax()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
updateData
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await queryCategoryAjax()
|
await queryCategoryAjax()
|
||||||
await productqueryCommodityInfoAjax()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog title="恢复挂起的订单" width="800" v-model="dialogVisible">
|
||||||
|
<div class="pending_carts">
|
||||||
|
<div class="item" v-for="(item, index) in cartList" :key="index" @click="select(item)">
|
||||||
|
<div class="time">
|
||||||
|
<el-icon class="icon">
|
||||||
|
<Clock />
|
||||||
|
</el-icon>
|
||||||
|
<span>{{ dayjs(item.pendingAt).format('HH:mm') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info">
|
||||||
|
<span class="name">{{ item.productName }}</span>
|
||||||
|
<span class="p">¥{{ item.totalAmount }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { dayjs } from 'element-plus'
|
||||||
|
import { getCartList } from "@/api/product";
|
||||||
|
import { useUser } from "@/store/user"
|
||||||
|
|
||||||
|
const emit = defineEmits(['select'])
|
||||||
|
|
||||||
|
const store = useUser()
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const cartList = ref([])
|
||||||
|
|
||||||
|
// 恢复挂单
|
||||||
|
function select(item) {
|
||||||
|
emit('select', item)
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
dialogVisible.value = true
|
||||||
|
getCartListAjax()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取挂起购物车列表
|
||||||
|
async function getCartListAjax() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const res = await getCartList({
|
||||||
|
shopId: store.userInfo.shopId
|
||||||
|
})
|
||||||
|
cartList.value = res
|
||||||
|
loading.value = false
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.pending_carts {
|
||||||
|
height: 50vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #efefef;
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
padding: 20px 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: var(--el-color-warning);
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
font-size: calc(var(--el-font-size-base) + 6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
font-size: var(--el-font-size-base);
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: var(--el-font-size-base);
|
||||||
|
|
||||||
|
.p {
|
||||||
|
color: var(--el-color-warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="cart_wrap card">
|
<div class="cart_wrap card">
|
||||||
<div class="menu_top">
|
<div class="menu_top">
|
||||||
<div class="menu">
|
<div class="menu" @click="pendingCartModalRef.show()">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<TakeawayBox />
|
<TakeawayBox />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text class="t">(1)</el-text>
|
<el-text class="t">({{ pendingCartNum }})</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="number" @click="takeFoodCodeRef.show()">
|
<div class="number" @click="takeFoodCodeRef.show()">
|
||||||
<el-text class="t">{{ foodCode }}</el-text>
|
<el-text class="t">{{ masterId }}</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="select_user" @click="membershow = true">
|
<div class="select_user" @click="membershow = true">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
|
|
@ -22,39 +22,53 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="shop_operation">
|
<div class="shop_operation">
|
||||||
<div class="shop_list">
|
<div class="shop_list" v-loading="cartLoading">
|
||||||
<div class="item" :class="{ active: item.active }" v-for="item in cartList" :key="item.id"
|
<div class="item" :class="{ active: item.active }" v-for="item in cartList" :key="item.id"
|
||||||
@click="selectCartItemHandle(item)">
|
@click="selectCartItemHandle(item)">
|
||||||
<div class="name_wrap">
|
<div class="name_wrap">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
<span>¥{{ item.salePrice }}</span>
|
<span>¥{{ item.salePrice }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sku_list">
|
<div class="sku_list" v-if="item.skuName">
|
||||||
<div class="tag">默认1份</div>
|
<div class="tag" v-for="item in item.skuName.split(',')">{{ item }}</div>
|
||||||
<div class="tag">热</div>
|
|
||||||
<div class="tag">半糖</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="num">
|
<div class="num">
|
||||||
<el-text>X{{ item.number }}</el-text>
|
<div class="left">
|
||||||
|
<div class="icon_item" v-if="item.isGift == 'true'" @click="giftPackHandle('isGift', item)">
|
||||||
|
<el-icon class="icon">
|
||||||
|
<ShoppingBag />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
|
<div class="icon_item" v-if="item.isPack == 'true'" @click="giftPackHandle('isPack', item)">
|
||||||
|
<el-icon class="icon" style="color: var(--primary-color);">
|
||||||
|
<Box />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-text class="t">X{{ item.number }}</el-text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="empty">
|
||||||
|
<el-empty description="请选择商品" v-if="!cartList.length" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 购物车操作栏 -->
|
<!-- 购物车操作栏 -->
|
||||||
<cartOperation :item="selectCartItem" @confirm="addCart" />
|
<cartOperation :item="selectCartItem" @confirm="res => addCart(res, 'edit')" @delete="delCartHandle"
|
||||||
|
@pending="pendingCart" />
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<div class="left" @click="allSelected = !allSelected">
|
<div class="left" @click="allSelectedHandle">
|
||||||
<div class="selected">
|
<div class="selected">
|
||||||
<div class="selected_round" v-if="!allSelected"></div>
|
<div class="selected_round" v-if="!allSelected"></div>
|
||||||
<el-icon class="icon" v-else>
|
<el-icon class="icon" v-else>
|
||||||
<CircleCheckFilled />
|
<CircleCheckFilled />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
<el-text class="t">打包(¥0.00)</el-text>
|
<el-text class="t">打包(¥{{ cartInfo.packAmount || 0 }})</el-text>
|
||||||
</div>
|
</div>
|
||||||
<div class="num-wrap">
|
<div class="num-wrap">
|
||||||
<el-text>共6种商品,7件</el-text>
|
<el-text>共{{ cartInfo.productNum || 0 }}种商品,{{ cartInfo.productSum || 0 }}件</el-text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btm">
|
<div class="btm">
|
||||||
|
|
@ -62,7 +76,7 @@
|
||||||
<div class="button">
|
<div class="button">
|
||||||
<el-button type="primary" style="width: 100%;">
|
<el-button type="primary" style="width: 100%;">
|
||||||
<div class="js">
|
<div class="js">
|
||||||
<el-text class="t">¥3.09</el-text>
|
<el-text class="t">¥{{ cartInfo.totalAmount }}</el-text>
|
||||||
<el-text class="t" style="margin-left: 250px;">结算</el-text>
|
<el-text class="t" style="margin-left: 250px;">结算</el-text>
|
||||||
</div>
|
</div>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -72,19 +86,21 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="shop_manage card">
|
<div class="shop_manage card">
|
||||||
<!-- 分类/商品列表 -->
|
<!-- 分类/商品列表 -->
|
||||||
<goods @success="addCart" />
|
<goods ref="goodsRef" :masterId="masterId" @success="addCart" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 备注 -->
|
<!-- 备注 -->
|
||||||
<remarkModal ref="remarkRef" />
|
<remarkModal ref="remarkRef" />
|
||||||
<!-- 修改取餐号 -->
|
<!-- 修改取餐号 -->
|
||||||
<takeFoodCode />
|
<takeFoodCode />
|
||||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员" >
|
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||||
<member></member>
|
<member></member>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
|
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
|
||||||
<!-- 结算订单 -->
|
<!-- 结算订单 -->
|
||||||
<settleAccount />
|
<settleAccount />
|
||||||
|
<!-- 挂起订单 -->
|
||||||
|
<pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
@ -94,8 +110,9 @@ import remarkModal from '@/components/remarkModal.vue'
|
||||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||||
import cartOperation from '@/views/home/components/cartOperation.vue'
|
import cartOperation from '@/views/home/components/cartOperation.vue'
|
||||||
import settleAccount from '@/components/settleAccount.vue'
|
import settleAccount from '@/components/settleAccount.vue'
|
||||||
|
import pendingCartModal from '@/views/home/components/pendingCartModal.vue'
|
||||||
|
|
||||||
import { createCart, queryCart, createCode } from '@/api/product'
|
import { createCart, queryCart, createCode, packall, delCart, cartStatus } from '@/api/product'
|
||||||
|
|
||||||
// 商品列表
|
// 商品列表
|
||||||
import goods from '@/views/home/components/goods.vue'
|
import goods from '@/views/home/components/goods.vue'
|
||||||
|
|
@ -104,17 +121,87 @@ const membershow = ref(false)
|
||||||
const store = useUser()
|
const store = useUser()
|
||||||
const remarkRef = ref(null)
|
const remarkRef = ref(null)
|
||||||
const takeFoodCodeRef = ref(null)
|
const takeFoodCodeRef = ref(null)
|
||||||
|
const goodsRef = ref(null)
|
||||||
|
const pendingCartModalRef = ref(null)
|
||||||
|
|
||||||
const allSelected = ref(false)
|
const allSelected = ref(false)
|
||||||
|
|
||||||
|
const cartLoading = ref(false)
|
||||||
const cartList = ref([])
|
const cartList = ref([])
|
||||||
|
const cartInfo = ref({})
|
||||||
|
|
||||||
// 取餐码
|
// 取餐码
|
||||||
const foodCode = ref('#006')
|
const masterId = ref('')
|
||||||
|
// 挂单量
|
||||||
|
const pendingCartNum = ref(0)
|
||||||
|
|
||||||
|
// 恢复挂单
|
||||||
|
async function pendingCartHandle(item) {
|
||||||
|
masterId.value = item.masterId
|
||||||
|
await pendingCart(item, false)
|
||||||
|
await queryCartAjax()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 挂单
|
||||||
|
async function pendingCart(params, status = true) {
|
||||||
|
try {
|
||||||
|
cartLoading.value = true
|
||||||
|
await cartStatus({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
masterId: params.masterId,
|
||||||
|
status: status
|
||||||
|
})
|
||||||
|
if (status) createCodeAjax()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除购物车
|
||||||
|
async function delCartHandle(params) {
|
||||||
|
try {
|
||||||
|
cartLoading.value = true
|
||||||
|
await delCart({
|
||||||
|
masterId: params.masterId,
|
||||||
|
cartId: params.id
|
||||||
|
})
|
||||||
|
queryCartAjax()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 赠送打包操作
|
||||||
|
function giftPackHandle(key, item) {
|
||||||
|
item[key] = false
|
||||||
|
addCart(item, 'edit')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打包全选
|
||||||
|
const allSelectedHandle = async () => {
|
||||||
|
if (allSelected.value) {
|
||||||
|
allSelected.value = false
|
||||||
|
cartList.value.map(item => {
|
||||||
|
item.isPack = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
allSelected.value = true
|
||||||
|
cartList.value.map(item => {
|
||||||
|
item.isPack = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await packall({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
status: allSelected.value,
|
||||||
|
masterId: masterId.value
|
||||||
|
})
|
||||||
|
queryCartAjax()
|
||||||
|
}
|
||||||
|
|
||||||
// 确认取餐号
|
// 确认取餐号
|
||||||
function takeFoodCodeSuccess(code) {
|
function takeFoodCodeSuccess(code) {
|
||||||
console.log('取餐号===', code)
|
masterId.value = `#${code}`
|
||||||
|
queryCartAjax()
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectCartItem = ref({})
|
const selectCartItem = ref({})
|
||||||
|
|
@ -128,16 +215,22 @@ function selectCartItemHandle(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择完规格开始添加购物车
|
// 选择完规格开始添加购物车
|
||||||
async function addCart(params) {
|
async function addCart(params, type = 'add') {
|
||||||
try {
|
try {
|
||||||
|
cartLoading.value = true
|
||||||
const res = await createCart({
|
const res = await createCart({
|
||||||
productId: params.productId,
|
productId: params.productId,
|
||||||
maskerId: foodCode.value,
|
masterId: masterId.value,
|
||||||
shopId: store.userInfo.shopId,
|
shopId: store.userInfo.shopId,
|
||||||
skuId: params.id,
|
skuId: type == 'add' ? params.id : params.skuId,
|
||||||
number: params.number || 1
|
number: params.number || 1,
|
||||||
|
isPack: params.isPack || false,
|
||||||
|
isGift: params.isGift || false,
|
||||||
|
cartId: type == 'add' ? '' : params.id
|
||||||
})
|
})
|
||||||
foodCode.value = res
|
masterId.value = res
|
||||||
|
goodsRef.value.updateData()
|
||||||
|
queryCartAjax(type)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
@ -146,10 +239,12 @@ async function addCart(params) {
|
||||||
// 获取购物车商品
|
// 获取购物车商品
|
||||||
async function queryCartAjax() {
|
async function queryCartAjax() {
|
||||||
try {
|
try {
|
||||||
|
cartLoading.value = true
|
||||||
const res = await queryCart({
|
const res = await queryCart({
|
||||||
masterId: foodCode.value,
|
masterId: masterId.value,
|
||||||
shopId: store.userInfo.shopId
|
shopId: store.userInfo.shopId
|
||||||
})
|
})
|
||||||
|
selectCartItem.value = {}
|
||||||
cartList.value = res.list.map((item, index) => {
|
cartList.value = res.list.map((item, index) => {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
item.active = true
|
item.active = true
|
||||||
|
|
@ -159,7 +254,12 @@ async function queryCartAjax() {
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
console.log(cartList.value)
|
cartInfo.value = res.amount
|
||||||
|
pendingCartNum.value = res.num
|
||||||
|
goodsRef.value.updateData()
|
||||||
|
setTimeout(() => {
|
||||||
|
cartLoading.value = false
|
||||||
|
}, 100)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('获取购物车商品', error)
|
console.log('获取购物车商品', error)
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +269,7 @@ async function queryCartAjax() {
|
||||||
async function createCodeAjax() {
|
async function createCodeAjax() {
|
||||||
try {
|
try {
|
||||||
const res = await createCode({ shopId: store.userInfo.shopId })
|
const res = await createCode({ shopId: store.userInfo.shopId })
|
||||||
foodCode.value = res
|
masterId.value = res.code
|
||||||
queryCartAjax()
|
queryCartAjax()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
|
@ -177,8 +277,7 @@ async function createCodeAjax() {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// createCodeAjax()
|
createCodeAjax()
|
||||||
queryCartAjax()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -293,9 +392,31 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.num {
|
.num {
|
||||||
padding-top: 10px;
|
padding-top: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.icon_item {
|
||||||
|
$size: 40px;
|
||||||
|
width: $size;
|
||||||
|
height: $size;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #e2e2e2;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.t {
|
||||||
|
font-size: var(--el-font-size-base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue