优化店铺切换商品展示

This commit is contained in:
gyq 2025-03-26 09:48:23 +08:00
parent 4245b5a098
commit 95ab7730f5
12 changed files with 100 additions and 34 deletions

View File

@ -5,10 +5,10 @@ ENV = development
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss' # VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
# 正式ws # 正式ws
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss' VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
# 本地ws # 本地ws
VITE_API_WSS = 'ws://192.168.1.43:2348' # VITE_API_WSS = 'ws://192.168.1.43:2348'
# 正式 php # 正式 php
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api' VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
@ -35,11 +35,11 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# VITE_API_URL = 'http://192.168.1.35/' # VITE_API_URL = 'http://192.168.1.35/'
# 阿伟 # 阿伟
VITE_API_URL = 'http://192.168.1.21:8000/' # VITE_API_URL = 'http://192.168.1.21:8000/'
# 测试 # 测试
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn' # VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
# 正式 # 正式
# VITE_API_URL = 'https://cashier.sxczgkj.com' VITE_API_URL = 'https://cashier.sxczgkj.com'

View File

@ -382,3 +382,14 @@ export function calcDeductionAmount(params) {
params, params,
}); });
} }
/**
* 获取店铺用户详情
*/
export function shopUserDetail(params) {
return request({
method: "get",
url: "/account/admin/shopUser/detail",
params,
});
}

View File

@ -226,7 +226,7 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 选择会员 --> <!-- 选择会员 -->
<SelectVipUser ref="SelectVipUserRef" @success="selectUserHandle" /> <SelectVipUser ref="SelectVipUserRef" :amount="0.01" @success="selectUserHandle" />
<!-- 选择优惠券 --> <!-- 选择优惠券 -->
<CouponModal ref="CouponModalRef" :orderList="props.orderList" @success="CouponModalSuccess" /> <CouponModal ref="CouponModalRef" :orderList="props.orderList" @success="CouponModalSuccess" />
</template> </template>
@ -708,8 +708,10 @@ async function selectUserHandle(row) {
goodsStore.vipUserInfo = { ...row } goodsStore.vipUserInfo = { ...row }
// //
if (store.shopInfo.isMemberPrice && row.isVip) { if (store.shopInfo.isMemberPrice && row.isVip) {
console.log('选择会员后重新计算会员价===', row);
goodsStore.showVipPrice = 1 goodsStore.showVipPrice = 1
} }
goodsStore.calcCartInfo() goodsStore.calcCartInfo()
emit('reset') emit('reset')
@ -717,11 +719,10 @@ async function selectUserHandle(row) {
couponForm.value.discountRatio = '' couponForm.value.discountRatio = ''
discountInput('') discountInput('')
setTimeout(() => {
couponDialogOpen()
}, 100)
if (showCoupon.value) { if (showCoupon.value) {
setTimeout(() => {
couponDialogOpen()
}, 100)
couponFormUserList.value = [ couponFormUserList.value = [
{ {
id: row.userId, id: row.userId,
@ -737,7 +738,9 @@ async function selectUserHandle(row) {
} }
} else { } else {
if (payList.value[payActive.value].payType == 'member-account') { if (payList.value[payActive.value].payType == 'member-account') {
vipPayAjax(row) setTimeout(() => {
vipPayAjax(row)
}, 500)
} }
} }
} catch (error) { } catch (error) {

View File

@ -5,7 +5,7 @@
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" /> <el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select v-model="tableData.isVips" placeholder="是否为会员" style="width: 150px;" @change="resetTable"> <el-select v-model="tableData.isVips" placeholder="是否为会员" style="width: 150px;" @change="changeIsVips">
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="是" :value="1"></el-option> <el-option label="是" :value="1"></el-option>
<el-option label="否" :value="0"></el-option> <el-option label="否" :value="0"></el-option>
@ -43,6 +43,13 @@ import { ref, reactive } from 'vue'
import { shopUserList } from "@/api/account.js"; import { shopUserList } from "@/api/account.js";
import { formatDecimal } from '@/utils/index.js' import { formatDecimal } from '@/utils/index.js'
const props = defineProps({
amount: {
type: Number,
default: 0
}
})
const emits = defineEmits(['success']) const emits = defineEmits(['success'])
const showDialog = ref(false) const showDialog = ref(false)
const tableData = reactive({ const tableData = reactive({
@ -68,6 +75,12 @@ async function toHomeMember(row) {
// //
function resetTable() { function resetTable() {
tableData.phone = '' tableData.phone = ''
tableData.isVips = ''
tableData.page = 1
getMemberList()
}
function changeIsVips() {
tableData.page = 1 tableData.page = 1
getMemberList() getMemberList()
} }
@ -80,14 +93,17 @@ async function getMemberList() {
key: tableData.phone, key: tableData.phone,
isVips: tableData.isVips, isVips: tableData.isVips,
page: tableData.page, page: tableData.page,
size: tableData.size size: tableData.size,
amount: props.amount
}) })
tableData.list = res.records tableData.list = res.records
tableData.total = res.totalRow tableData.total = res.totalRow
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
tableData.loading = false setTimeout(() => {
tableData.loading = false
}, 500);
} }
// //

View File

@ -7,6 +7,7 @@ import { useUser } from "@/store/user.js";
import { useSocket } from "@/store/socket.js"; import { useSocket } from "@/store/socket.js";
import useStorage from "@/utils/useStorage.js"; import useStorage from "@/utils/useStorage.js";
import { formatDecimal } from "@/utils/index.js"; import { formatDecimal } from "@/utils/index.js";
import { shopUserDetail } from "@/api/account.js";
// 商品store + 购物车store // 商品store + 购物车store
export const useGoods = defineStore("goods", { export const useGoods = defineStore("goods", {
@ -15,10 +16,10 @@ export const useGoods = defineStore("goods", {
allSelected: 0, // 是否整单打包 allSelected: 0, // 是否整单打包
vipUserInfo: {}, // 会员信息 vipUserInfo: {}, // 会员信息
// tableInfo: { // tableInfo: {
// name: "A1", // name: "测试A1",
// id: 1, // id: 185,
// num: 4, // num: 1,
// tableCode: "66666666", // tableCode: "3000101010",
// }, // 台桌信息 // }, // 台桌信息
tableInfo: { tableInfo: {
id: "", id: "",
@ -52,6 +53,15 @@ export const useGoods = defineStore("goods", {
pendingList: useStorage.get("pendingList") || [], pendingList: useStorage.get("pendingList") || [],
}), }),
actions: { actions: {
// 清除所有商品信息
clearAllGoods() {
this.categoryIndex = 0;
this.categoryList = [];
this.originCategoryList = [];
this.goodsListLoading = false;
this.goodsList = [];
this.originGoodsList = [];
},
// 清除会员信息 // 清除会员信息
clearVipUserInfo() { clearVipUserInfo() {
this.vipUserInfo = {}; this.vipUserInfo = {};
@ -171,6 +181,19 @@ export const useGoods = defineStore("goods", {
}); });
if (res) { if (res) {
if (res.userId) {
const userInfo = await shopUserDetail({
userId: res.userId,
});
if (userInfo.id) {
this.vipUserInfo = userInfo;
if (userInfo.isVip) {
this.showVipPrice = 1;
}
}
}
this.orderListInfo = res; this.orderListInfo = res;
let arr = []; let arr = [];
@ -353,7 +376,7 @@ export const useGoods = defineStore("goods", {
// ) { // ) {
// await this.historyOrderAjax(this.tableInfo.tableCode); // await this.historyOrderAjax(this.tableInfo.tableCode);
// } // }
// this.calcCartInfo(); this.calcCartInfo();
console.log("getCartList.cartList===", this.cartList); console.log("getCartList.cartList===", this.cartList);
} catch (error) { } catch (error) {
console.log("getCartList===", error); console.log("getCartList===", error);
@ -598,17 +621,15 @@ export const useGoods = defineStore("goods", {
} }
// 清空商品列表的角标 // 清空商品列表的角标
// this.goodsList.map((item) => { if (!this.cartList.length && !this.orderList.length) {
// item.map((val) => { this.updateGoodsNumber();
// val.number = 0; }
// });
// });
}, },
// 下单成功清除购物车,重新加载订单 // 下单成功清除购物车,重新加载订单
async updateOrderList() { async updateOrderList() {
await this.historyOrderAjax(this.cartList[0].table_code); await this.historyOrderAjax(this.cartList[0].table_code);
this.cartList = []; this.cartList = [];
// this.calcCartInfo(); this.calcCartInfo();
}, },
// 计算购物车信息 // 计算购物车信息
calcCartInfo() { calcCartInfo() {
@ -643,13 +664,15 @@ export const useGoods = defineStore("goods", {
console.log("arr===11111", arr); console.log("arr===11111", arr);
arr.map((val, index) => { arr.map((val, index) => {
console.log("val===", val);
let lowPrice = 0; let lowPrice = 0;
let number = val.number - (val.returnNum || 0); let number = val.number - (val.returnNum || 0);
if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) { if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) {
lowPrice = val.memberPrice; if (!+val.memberPrice) {
lowPrice = val.lowPrice;
} else {
lowPrice = +val.memberPrice;
}
} else { } else {
lowPrice = val.lowPrice; lowPrice = val.lowPrice;
} }

View File

@ -117,6 +117,11 @@ export const useSocket = defineStore("socket", {
break; break;
case "cleanup": case "cleanup":
// 清空购物车 // 清空购物车
if (
data.data.table_code == goodsStore.orderListInfo.tableCode &&
!data.type
)
return;
goodsStore.successClearCart(); goodsStore.successClearCart();
break; break;
case "batch": case "batch":
@ -169,7 +174,7 @@ export const useSocket = defineStore("socket", {
startheartbeat() { startheartbeat() {
this.heartbeatTimer = setInterval(() => { this.heartbeatTimer = setInterval(() => {
if (this.log) console.log("发送心跳"); if (this.log) console.log("发送心跳");
this.ws.send(JSON.stringify({ type: "ping_interval" })); this.ws.send(JSON.stringify({ type: "ping_interval", set: "cashier" }));
}, 10000); }, 10000);
}, },
// 清除心跳 // 清除心跳
@ -190,7 +195,10 @@ export const useSocket = defineStore("socket", {
} else { } else {
const orderInfo = await getOrderByIdAjax(this.orderList[0]); const orderInfo = await getOrderByIdAjax(this.orderList[0]);
if (orderInfo.status == "done" && orderInfo.platformType != "PC") { if (orderInfo.status == "done" && orderInfo.platformType != "PC") {
// 打印小票
printStore.pushReceiptData(commOrderPrintData(orderInfo)); printStore.pushReceiptData(commOrderPrintData(orderInfo));
// 打印标签小票
printStore.labelPrint(commOrderPrintData(orderInfo));
} }
this.orderList.splice(0, 1); this.orderList.splice(0, 1);
} }

View File

@ -70,7 +70,7 @@
<el-table :data="tableData.list" height="540px" v-loading="tableData.loading" <el-table :data="tableData.list" height="540px" v-loading="tableData.loading"
v-if="tableData.type == 2"> v-if="tableData.type == 2">
<el-table-column label="抖音订单号" prop="d_order_id" width="240"></el-table-column> <el-table-column label="抖音订单号" prop="d_order_id" width="240"></el-table-column>
<el-table-column label="总金额" prop="pay_amount" width="100"> <el-table-column label="总金额" prop="pay_amount">
<template v-slot="scope"> <template v-slot="scope">
<span style="color: var(--primary-color);">{{ scope.row.pay_amount }}</span> <span style="color: var(--primary-color);">{{ scope.row.pay_amount }}</span>
</template> </template>

View File

@ -9,7 +9,8 @@
{{ formatDecimal(+props.item.discount_sale_amount, 2, true) }} {{ formatDecimal(+props.item.discount_sale_amount, 2, true) }}
</span> </span>
<span class="dis" v-else> <span class="dis" v-else>
{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice : +props.item.lowPrice, 2, {{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice || +props.item.lowPrice :
+props.item.lowPrice, 2,
true) }} true) }}
</span> </span>
<span v-if="props.item.discount_sale_amount"> <span v-if="props.item.discount_sale_amount">
@ -26,7 +27,7 @@
<div class="price" v-else> <div class="price" v-else>
<template v-if="+props.item.discount_sale_amount"> <template v-if="+props.item.discount_sale_amount">
<span class="dis"> <span class="dis">
{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice : +props.item.lowPrice, {{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice || +props.item.lowPrice : +props.item.lowPrice,
2, true) }} 2, true) }}
</span> </span>
<span> <span>
@ -40,7 +41,7 @@
</span> </span>
</template> </template>
<span> <span>
{{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice : +props.item.lowPrice, {{ formatDecimal(goodsStore.showVipPrice ? +props.item.memberPrice || +props.item.lowPrice : +props.item.lowPrice,
2, 2,
true) }} true) }}
</span> </span>

View File

@ -89,7 +89,7 @@
<template v-else> <template v-else>
<el-text tag="del" class="del" size="small">{{ item.skuList[0].salePrice <el-text tag="del" class="del" size="small">{{ item.skuList[0].salePrice
}}</el-text> }}</el-text>
<el-text>{{ item.skuList[0].memberPrice }}</el-text> <el-text>{{ +item.skuList[0].memberPrice || item.skuList[0].salePrice }}</el-text>
</template> </template>
</div> </div>
<div class="show_more_btn" v-if="showEditor"> <div class="show_more_btn" v-if="showEditor">

View File

@ -243,7 +243,6 @@ function show(t) {
setTimeout(() => { setTimeout(() => {
payCardRef.value.reset() payCardRef.value.reset()
}, 100) }, 100)
// if (t = 1) cartList.value = [...goodsStore.cartList];
} }
defineExpose({ defineExpose({

View File

@ -270,6 +270,8 @@ async function createOrderHandle(t = 0) {
goodsStore.orderListInfo = res goodsStore.orderListInfo = res
if (t == 1) { if (t == 1) {
//
goodsStore.operateCart({ table_code: goodsStore.orderListInfo.tableCode }, "cleanup");
settleAccountRef.value.show(t) settleAccountRef.value.show(t)
} else { } else {
goodsStore.clearCart() goodsStore.clearCart()

View File

@ -149,8 +149,10 @@ import { useRouter } from "vue-router";
import { useUser } from "@/store/user.js"; import { useUser } from "@/store/user.js";
import { formatDecimal } from '@/utils/index.js' import { formatDecimal } from '@/utils/index.js'
import { usePrint } from "@/store/print.js"; import { usePrint } from "@/store/print.js";
import { useGoods } from "@/store/goods.js";
import { staffPermission } from '@/api/user.js' import { staffPermission } from '@/api/user.js'
const goodsStore = useGoods();
const printStore = usePrint(); const printStore = usePrint();
const store = useUser(); const store = useUser();
const router = useRouter(); const router = useRouter();
@ -200,6 +202,7 @@ async function logoutHandle() {
try { try {
loading.value = true; loading.value = true;
await store.logout() await store.logout()
goodsStore.clearAllGoods()
ElMessage.success("交班成功"); ElMessage.success("交班成功");
setTimeout(() => { setTimeout(() => {
router.replace({ router.replace({