优化首页添加购物车

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

View File

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

View File

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

View File

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

View File

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