新增增加打印机
This commit is contained in:
@@ -23,24 +23,39 @@
|
||||
</div>
|
||||
<div class="shop_operation" v-loading="cartLoading">
|
||||
<div class="shop_list">
|
||||
<div class="item" :class="{ active: cartListActive == index }" v-for="(item, index) in cartList"
|
||||
:key="item.id" @click="selectCartItemHandle(item, index)">
|
||||
<div
|
||||
class="item"
|
||||
:class="{ active: cartListActive == index }"
|
||||
v-for="(item, index) in cartList"
|
||||
:key="item.id"
|
||||
@click="selectCartItemHandle(item, index)"
|
||||
>
|
||||
<div class="name_wrap">
|
||||
<span>{{ item.name }}</span>
|
||||
<span>¥{{ item.salePrice }}</span>
|
||||
</div>
|
||||
<div class="sku_list" v-if="item.skuName">
|
||||
<div class="tag" v-for="item in item.skuName.split(',')">{{ item }}</div>
|
||||
<div class="tag" v-for="item in item.skuName.split(',')">
|
||||
{{ item }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="num">
|
||||
<div class="left">
|
||||
<div class="icon_item" v-if="item.isGift == 'true'" @click="giftPackHandle('isGift', item)">
|
||||
<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);">
|
||||
<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>
|
||||
@@ -53,8 +68,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 购物车操作栏 -->
|
||||
<cartOperation :item="cartList[cartListActive]" @confirm="res => addCart(res, 'edit')" @delete="delCartHandle"
|
||||
@pending="pendingCart" @clearCart="clearCartHandle" />
|
||||
<cartOperation
|
||||
:item="cartList[cartListActive]"
|
||||
@confirm="(res) => addCart(res, 'edit')"
|
||||
@delete="delCartHandle"
|
||||
@pending="pendingCart"
|
||||
@clearCart="clearCartHandle"
|
||||
/>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="top">
|
||||
@@ -68,15 +88,26 @@
|
||||
<el-text class="t">打包(¥{{ cartInfo.packAmount || 0 }})</el-text>
|
||||
</div>
|
||||
<div class="num-wrap">
|
||||
<el-text>共{{ cartInfo.productNum || 0 }}种商品,{{ cartInfo.productSum || 0 }}件</el-text>
|
||||
<el-text
|
||||
>共{{ cartInfo.productNum || 0 }}种商品,{{
|
||||
cartInfo.productSum || 0
|
||||
}}件</el-text
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btm">
|
||||
<el-button icon="Edit" @click="remarkRef.show()"></el-button>
|
||||
<div class="button">
|
||||
<el-button type="primary" style="width: 100%;" :disabled="!cartList.length" v-loading="createOrderLoading"
|
||||
@click="createOrderHandle">
|
||||
<span v-if="!createOrderLoading">结算(¥{{ cartInfo.totalAmount || 0 }})</span>
|
||||
<el-button
|
||||
type="primary"
|
||||
style="width: 100%"
|
||||
:disabled="!cartList.length"
|
||||
v-loading="createOrderLoading"
|
||||
@click="createOrderHandle"
|
||||
>
|
||||
<span v-if="!createOrderLoading"
|
||||
>结算(¥{{ cartInfo.totalAmount || 0 }})</span
|
||||
>
|
||||
<span v-else>下单中...</span>
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -90,82 +121,106 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<remarkModal ref="remarkRef" @success="e => remark = e" />
|
||||
<remarkModal ref="remarkRef" @success="(e) => (remark = e)" />
|
||||
<!-- 修改取餐号 -->
|
||||
<takeFoodCode />
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||
<el-drawer
|
||||
v-model="membershow"
|
||||
:with-header="true"
|
||||
size="90%"
|
||||
title="选择会员"
|
||||
>
|
||||
<member :membershow="'1'"></member>
|
||||
</el-drawer>
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
|
||||
<takeFoodCode
|
||||
ref="takeFoodCodeRef"
|
||||
title="修改取餐号"
|
||||
placeholder="请输入取餐号"
|
||||
@success="takeFoodCodeSuccess"
|
||||
/>
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
|
||||
:masterId="masterId" :orderInfo="orderInfo" @paySuccess="createCodeAjax(1)" />
|
||||
<settleAccount
|
||||
ref="settleAccountRef"
|
||||
:cart="cartList"
|
||||
:amount="cartInfo.totalAmount"
|
||||
:remark="remark"
|
||||
:masterId="masterId"
|
||||
:orderInfo="orderInfo"
|
||||
@paySuccess="createCodeAjax(1)"
|
||||
/>
|
||||
<!-- 挂起订单 -->
|
||||
<pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'home'
|
||||
}
|
||||
name: "home",
|
||||
};
|
||||
</script>
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useUser } from "@/store/user.js"
|
||||
import remarkModal from '@/components/remarkModal.vue'
|
||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||
import cartOperation from '@/views/home/components/cartOperation.vue'
|
||||
import settleAccount from '@/views/home/components/settleAccount.vue'
|
||||
import pendingCartModal from '@/views/home/components/pendingCartModal.vue'
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import remarkModal from "@/components/remarkModal.vue";
|
||||
import takeFoodCode from "@/components/takeFoodCode.vue";
|
||||
import cartOperation from "@/views/home/components/cartOperation.vue";
|
||||
import settleAccount from "@/views/home/components/settleAccount.vue";
|
||||
import pendingCartModal from "@/views/home/components/pendingCartModal.vue";
|
||||
|
||||
import { createCart, queryCart, createCode, packall, delCart, cartStatus, clearCart, createOrder } from '@/api/product'
|
||||
import {
|
||||
createCart,
|
||||
queryCart,
|
||||
createCode,
|
||||
packall,
|
||||
delCart,
|
||||
cartStatus,
|
||||
clearCart,
|
||||
createOrder,
|
||||
} from "@/api/product";
|
||||
|
||||
// 商品列表
|
||||
import goods from '@/views/home/components/goods.vue'
|
||||
import member from '@/views/member/index.vue'
|
||||
import goods from "@/views/home/components/goods.vue";
|
||||
import member from "@/views/member/index.vue";
|
||||
|
||||
// import packageData from '../../../package.json'
|
||||
const membershow = ref(false);
|
||||
const store = useUser();
|
||||
const remarkRef = ref(null);
|
||||
const takeFoodCodeRef = ref(null);
|
||||
const goodsRef = ref(null);
|
||||
const pendingCartModalRef = ref(null);
|
||||
const settleAccountRef = ref(null);
|
||||
|
||||
const membershow = ref(false)
|
||||
const store = useUser()
|
||||
const remarkRef = ref(null)
|
||||
const takeFoodCodeRef = ref(null)
|
||||
const goodsRef = ref(null)
|
||||
const pendingCartModalRef = ref(null)
|
||||
const settleAccountRef = ref(null)
|
||||
const allSelected = ref(false);
|
||||
|
||||
const allSelected = ref(false)
|
||||
const remark = ref("");
|
||||
const cartListActive = ref(0);
|
||||
const cartList = ref([]);
|
||||
const cartInfo = ref({});
|
||||
const cartLoading = ref(false);
|
||||
|
||||
const remark = ref('')
|
||||
const cartListActive = ref(0)
|
||||
const cartList = ref([])
|
||||
const cartInfo = ref({})
|
||||
const cartLoading = ref(false)
|
||||
|
||||
const orderInfo = ref({})
|
||||
const createOrderLoading = ref(false)
|
||||
const orderInfo = ref({});
|
||||
const createOrderLoading = ref(false);
|
||||
|
||||
// 取餐码
|
||||
const masterId = ref('')
|
||||
const masterId = ref("");
|
||||
|
||||
// 挂单量
|
||||
const pendingCartNum = ref(0)
|
||||
const pendingCartNum = ref(0);
|
||||
|
||||
// 生成订单
|
||||
async function createOrderHandle() {
|
||||
try {
|
||||
createOrderLoading.value = true
|
||||
createOrderLoading.value = true;
|
||||
const res = await createOrder({
|
||||
masterId: masterId.value,
|
||||
shopId: store.userInfo.shopId,
|
||||
remark: remark.value
|
||||
})
|
||||
orderInfo.value = res
|
||||
settleAccountRef.value.show()
|
||||
createOrderLoading.value = false
|
||||
remark: remark.value,
|
||||
});
|
||||
orderInfo.value = res;
|
||||
settleAccountRef.value.show();
|
||||
createOrderLoading.value = false;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
createOrderLoading.value = false
|
||||
console.log(error);
|
||||
createOrderLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,119 +229,121 @@ async function clearCartHandle() {
|
||||
try {
|
||||
await clearCart({
|
||||
shopId: store.userInfo.shopId,
|
||||
masterId: masterId.value
|
||||
})
|
||||
queryCartAjax()
|
||||
masterId: masterId.value,
|
||||
});
|
||||
queryCartAjax();
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复挂单
|
||||
async function pendingCartHandle(item) {
|
||||
const nItem = { ...item }
|
||||
const nItem = { ...item };
|
||||
if (cartList.value.length) {
|
||||
// 当购物车有数据时,先挂起当前购物车
|
||||
await pendingCart({ masterId: masterId.value })
|
||||
await pendingCart({ masterId: masterId.value });
|
||||
}
|
||||
masterId.value = nItem.masterId
|
||||
await pendingCart(nItem, false)
|
||||
await queryCartAjax()
|
||||
masterId.value = nItem.masterId;
|
||||
await pendingCart(nItem, false);
|
||||
await queryCartAjax();
|
||||
}
|
||||
|
||||
// 挂单
|
||||
async function pendingCart(params, status = true) {
|
||||
try {
|
||||
cartLoading.value = true
|
||||
cartLoading.value = true;
|
||||
await cartStatus({
|
||||
shopId: store.userInfo.shopId,
|
||||
masterId: params.masterId,
|
||||
status: status,
|
||||
uuid: params.uuid
|
||||
})
|
||||
uuid: params.uuid,
|
||||
});
|
||||
if (status && cartList.value.length) {
|
||||
await createCodeAjax()
|
||||
cartLoading.value = false
|
||||
await createCodeAjax();
|
||||
cartLoading.value = false;
|
||||
} else {
|
||||
cartLoading.value = false
|
||||
cartLoading.value = false;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除购物车
|
||||
async function delCartHandle(params) {
|
||||
try {
|
||||
cartLoading.value = true
|
||||
cartLoading.value = true;
|
||||
await delCart({
|
||||
masterId: params.masterId,
|
||||
cartId: params.id
|
||||
})
|
||||
await queryCartAjax()
|
||||
cartLoading.value = false
|
||||
cartListActive.value = 0
|
||||
cartId: params.id,
|
||||
});
|
||||
await queryCartAjax();
|
||||
cartLoading.value = false;
|
||||
cartListActive.value = 0;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 赠送打包操作
|
||||
function giftPackHandle(key, item) {
|
||||
item[key] = false
|
||||
addCart(item, 'edit')
|
||||
item[key] = false;
|
||||
addCart(item, "edit");
|
||||
}
|
||||
|
||||
// 打包全选
|
||||
const allSelectedHandle = async () => {
|
||||
if (!cartList.value.length) return
|
||||
allSelected.value = !allSelected.value
|
||||
if (!cartList.value.length) return;
|
||||
allSelected.value = !allSelected.value;
|
||||
await packall({
|
||||
shopId: store.userInfo.shopId,
|
||||
status: allSelected.value,
|
||||
masterId: masterId.value
|
||||
})
|
||||
queryCartAjax()
|
||||
}
|
||||
masterId: masterId.value,
|
||||
});
|
||||
queryCartAjax();
|
||||
};
|
||||
|
||||
// 确认取餐号
|
||||
async function takeFoodCodeSuccess(code) {
|
||||
if (cartList.value.length) {
|
||||
await pendingCart({ masterId: masterId.value, uuid: cartList.value[0].uuid })
|
||||
await pendingCart({
|
||||
masterId: masterId.value,
|
||||
uuid: cartList.value[0].uuid,
|
||||
});
|
||||
}
|
||||
masterId.value = `#${code}`
|
||||
queryCartAjax()
|
||||
masterId.value = `#${code}`;
|
||||
queryCartAjax();
|
||||
}
|
||||
|
||||
// 从购物车选择商品
|
||||
function selectCartItemHandle(item, index) {
|
||||
cartListActive.value = index
|
||||
cartListActive.value = index;
|
||||
}
|
||||
|
||||
// 选择完规格开始添加购物车
|
||||
async function addCart(params, type = 'add') {
|
||||
async function addCart(params, type = "add") {
|
||||
try {
|
||||
cartLoading.value = true
|
||||
cartLoading.value = true;
|
||||
const res = await createCart({
|
||||
productId: params.productId,
|
||||
masterId: masterId.value,
|
||||
shopId: store.userInfo.shopId,
|
||||
skuId: type == 'add' ? params.id : params.skuId,
|
||||
skuId: type == "add" ? params.id : params.skuId,
|
||||
number: params.number || 1,
|
||||
isPack: params.isPack || false,
|
||||
isPack: allSelected.value ? true : params.isPack || false,
|
||||
isGift: params.isGift || false,
|
||||
cartId: type == 'add' ? '' : params.id,
|
||||
cartId: type == "add" ? "" : params.id,
|
||||
uuid: params.uuid || store.userInfo.uuid,
|
||||
type: type
|
||||
})
|
||||
cartLoading.value = false
|
||||
masterId.value = res
|
||||
goodsRef.value.updateData()
|
||||
queryCartAjax()
|
||||
type: type,
|
||||
});
|
||||
cartLoading.value = false;
|
||||
masterId.value = res;
|
||||
goodsRef.value.updateData();
|
||||
queryCartAjax();
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
cartLoading.value = false
|
||||
console.log(error);
|
||||
cartLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,19 +352,29 @@ async function queryCartAjax() {
|
||||
try {
|
||||
const res = await queryCart({
|
||||
masterId: masterId.value,
|
||||
shopId: store.userInfo.shopId
|
||||
})
|
||||
cartList.value = res.list
|
||||
cartInfo.value = res.amount
|
||||
pendingCartNum.value = res.num
|
||||
goodsRef.value.updateData()
|
||||
shopId: store.userInfo.shopId,
|
||||
});
|
||||
cartList.value = res.list;
|
||||
cartInfo.value = res.amount;
|
||||
pendingCartNum.value = res.num;
|
||||
goodsRef.value.updateData();
|
||||
|
||||
let i = 0;
|
||||
res.list.map((item) => {
|
||||
if (item.isPack == "true") {
|
||||
i++;
|
||||
}
|
||||
});
|
||||
if (i == res.list.length) {
|
||||
allSelected.value = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('获取购物车商品', error)
|
||||
console.log("获取购物车商品", error);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取取餐码
|
||||
async function createCodeAjax(type = '0') {
|
||||
async function createCodeAjax(type = "0") {
|
||||
try {
|
||||
// if (!process.env.VITE_DEV_SERVER_URL) {
|
||||
// masterId.value = '#20'
|
||||
@@ -319,18 +386,18 @@ async function createCodeAjax(type = '0') {
|
||||
// }
|
||||
const res = await createCode({
|
||||
shopId: store.userInfo.shopId,
|
||||
type: type
|
||||
})
|
||||
masterId.value = res.code
|
||||
queryCartAjax()
|
||||
type: type,
|
||||
});
|
||||
masterId.value = res.code;
|
||||
queryCartAjax();
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
createCodeAjax()
|
||||
})
|
||||
createCodeAjax();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -537,9 +604,7 @@ onMounted(() => {
|
||||
.button {
|
||||
flex: 1;
|
||||
|
||||
|
||||
.js {
|
||||
|
||||
.t {
|
||||
color: #fff;
|
||||
font-size: var(--el-font-size-base);
|
||||
|
||||
Reference in New Issue
Block a user