From e058c970161191241be28b8d27f7f34bc4ab9abe Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Wed, 13 Mar 2024 17:14:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +-- dist-electron/main.js | 1 + package.json | 4 +-- src/router/index.js | 3 -- src/views/home/components/goods.vue | 7 ++--- src/views/home/index.vue | 47 +++++++++++++++++++++-------- vite.config.js | 4 +-- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/.env.development b/.env.development index ecd5881..6583432 100644 --- a/.env.development +++ b/.env.development @@ -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/' \ No newline at end of file +# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/' \ No newline at end of file diff --git a/dist-electron/main.js b/dist-electron/main.js index e69de29..fb9c23e 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -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()}); diff --git a/package.json b/package.json index 179e9f1..73a1754 100644 --- a/package.json +++ b/package.json @@ -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/**/*", diff --git a/src/router/index.js b/src/router/index.js index 0ac210a..d807a13 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -6,9 +6,6 @@ const routes = [ { path: "/", name: "home", - meta: { - keepAlive: true - }, component: home, }, { diff --git a/src/views/home/components/goods.vue b/src/views/home/components/goods.vue index a6d8045..63d6529 100644 --- a/src/views/home/components/goods.vue +++ b/src/views/home/components/goods.vue @@ -1,5 +1,4 @@ - @@ -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) diff --git a/vite.config.js b/vite.config.js index b278d75..3529b0a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -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/, '') }