优化首页添加购物车

This commit is contained in:
gyq 2024-03-13 17:14:48 +08:00
parent 5e5d854849
commit e058c97016
7 changed files with 44 additions and 26 deletions

View File

@ -2,6 +2,6 @@
ENV = development
# 本地环境接口地址
# VITE_API_URL = 'http://192.168.2.87:10587/cashier-client'
VITE_API_URL = 'http://192.168.2.27:10587/cashier-client'
# VITE_API_URL = 'https://cashiernew.sxczgkj.cn/cashier-client'
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/'
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/'

View File

@ -0,0 +1 @@
"use strict";const o=require("path"),e=require("electron");let n;e.app.whenReady().then(()=>{n=new e.BrowserWindow({title:"银收客",width:1024,height:768,fullscreenable:!0,fullscreen:!process.env.VITE_DEV_SERVER_URL,simpleFullscreen:!0,frame:!!process.env.VITE_DEV_SERVER_URL,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}),process.env.VITE_DEV_SERVER_URL?(n.loadURL(process.env.VITE_DEV_SERVER_URL),n.webContents.openDevTools()):n.loadFile(o.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(t,r)=>{e.app.quit()}),e.ipcMain.on("printStart",(t,r)=>{})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});

View File

@ -1,7 +1,7 @@
{
"name": "vite-electron",
"private": true,
"version": "0.0.11",
"version": "1.0.13",
"main": "dist-electron/main.js",
"scripts": {
"dev": "chcp 65001 && vite",
@ -36,7 +36,7 @@
},
"build": {
"appId": "com.cashierdesktop.app",
"productName": "cashier_desktop",
"productName": "银收客",
"asar": true,
"files": [
"./dist/**/*",

View File

@ -6,9 +6,6 @@ const routes = [
{
path: "/",
name: "home",
meta: {
keepAlive: true
},
component: home,
},
{

View File

@ -1,5 +1,4 @@
<!-- 商品列表 -->
<template>
<div class="header">
<div class="menus scroll-x">
@ -115,7 +114,7 @@ function showSkuHandle(item) {
}
//
async function queryProductSkuAjax(goods) {
const queryProductSkuAjax = _.throttle(async function (goods) {
try {
const res = await queryProductSku({
shopId: store.userInfo.shopId,
@ -126,7 +125,7 @@ async function queryProductSkuAjax(goods) {
} catch (error) {
console.log(error)
}
}
}, 1500)
//
function changeShopListType() {
@ -288,7 +287,7 @@ defineExpose({
}
.shop_list {
max-height: calc(100vh - 40px - 80px - 60px);
max-height: calc(100vh - 40px - 80px - 40px);
overflow-y: auto;
display: flex;
flex-wrap: wrap;

View File

@ -21,7 +21,7 @@
</el-icon>
</div> -->
</div>
<div class="shop_operation">
<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)">
@ -99,7 +99,7 @@
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
<!-- 结算订单 -->
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
:orderId="orderId" :masterId="masterId" @paySuccess="createCodeAjax" />
:orderId="orderId" :masterId="masterId" @paySuccess="createCodeAjax(1)" />
<!-- 挂起订单 -->
<pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" />
</template>
@ -140,6 +140,7 @@ const remark = ref('')
const cartListActive = ref(0)
const cartList = ref([])
const cartInfo = ref({})
const cartLoading = ref(false)
const orderId = ref('')
const createOrderLoading = ref(false)
@ -196,13 +197,20 @@ async function pendingCartHandle(item) {
//
async function pendingCart(params, status = true) {
try {
cartLoading.value = true
await cartStatus({
shopId: store.userInfo.shopId,
masterId: params.masterId,
status: status,
uuid: params.uuid
})
if (status && cartList.value.length) createCodeAjax()
if (status && cartList.value.length) {
await createCodeAjax()
cartLoading.value = false
} else {
cartLoading.value = false
}
} catch (error) {
console.log(error)
}
@ -211,11 +219,13 @@ async function pendingCart(params, status = true) {
//
async function delCartHandle(params) {
try {
cartLoading.value = true
await delCart({
masterId: params.masterId,
cartId: params.id
})
await queryCartAjax()
cartLoading.value = false
cartListActive.value = 0
} catch (error) {
console.log(error)
@ -241,7 +251,10 @@ const allSelectedHandle = async () => {
}
//
function takeFoodCodeSuccess(code) {
async function takeFoodCodeSuccess(code) {
if (cartList.value.length) {
await pendingCart({ masterId: masterId.value, uuid: cartList.value[0].uuid })
}
masterId.value = `#${code}`
queryCartAjax()
}
@ -254,6 +267,7 @@ function selectCartItemHandle(item, index) {
//
async function addCart(params, type = 'add') {
try {
cartLoading.value = true
const res = await createCart({
productId: params.productId,
masterId: masterId.value,
@ -266,11 +280,13 @@ async function addCart(params, type = 'add') {
uuid: params.uuid || store.userInfo.uuid,
type: type
})
cartLoading.value = false
masterId.value = res
goodsRef.value.updateData()
queryCartAjax()
} catch (error) {
console.log(error)
cartLoading.value = false
}
}
@ -291,16 +307,21 @@ async function queryCartAjax() {
}
//
async function createCodeAjax() {
async function createCodeAjax(type = '0') {
try {
if (process.env.VITE_DEV_SERVER_URL) {
masterId.value = '#10'
} else {
const res = await createCode({
shopId: store.userInfo.shopId
})
masterId.value = res.code
}
// if (!process.env.VITE_DEV_SERVER_URL) {
// masterId.value = '#20'
// } else {
// const res = await createCode({
// shopId: store.userInfo.shopId
// })
// masterId.value = res.code
// }
const res = await createCode({
shopId: store.userInfo.shopId,
type: type
})
masterId.value = res.code
queryCartAjax()
} catch (error) {
console.log(error)

View File

@ -9,8 +9,8 @@ export default defineConfig({
server: {
proxy: {
'/api': {
target: 'https://cashierclient.sxczgkj.cn/cashier-client', // 测试
// target: 'http://192.168.2.87:10587/cashier-client', // 国成
// target: 'https://cashierclient.sxczgkj.cn/cashier-client', // 测试
target: 'http://192.168.2.27:10587/cashier-client', // 国成
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}