From 0b8bf05b503b392ab2ec86384ec8bbb9d535b44a Mon Sep 17 00:00:00 2001 From: Suk1No <674874220@qq.com> Date: Sun, 17 Aug 2025 00:18:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order-app/src/pages.json | 7 +++ order-app/src/pages/car/car.vue | 89 +++++++-------------------- order-app/src/pages/detail/detail.vue | 41 +++++++++++- order-app/src/store/car.js | 22 +++++-- 4 files changed, 85 insertions(+), 74 deletions(-) diff --git a/order-app/src/pages.json b/order-app/src/pages.json index 3cc5663..35dcfbb 100644 --- a/order-app/src/pages.json +++ b/order-app/src/pages.json @@ -33,6 +33,13 @@ { "navigationBarTitleText" : "" } + }, + { + "path" : "pages/address/address", + "style" : + { + "navigationBarTitleText" : "" + } } ], "globalStyle": { diff --git a/order-app/src/pages/car/car.vue b/order-app/src/pages/car/car.vue index 978539d..74d9a11 100644 --- a/order-app/src/pages/car/car.vue +++ b/order-app/src/pages/car/car.vue @@ -39,14 +39,6 @@ 结算({{totalNum}}) - - - {{store.count}} - - - 新增 - - diff --git a/order-app/src/store/car.js b/order-app/src/store/car.js index f1bc4ac..06839a9 100644 --- a/order-app/src/store/car.js +++ b/order-app/src/store/car.js @@ -1,9 +1,14 @@ -// 引入 -import { defineStore } from 'pinia'; -//定义store +// stores/counter.js +import { + defineStore +} from 'pinia'; + export const carStore = defineStore('carStore', { state: () => { - return { count: 0 }; + return { + count: 0, + carList: [] + }; }, // 也可以这样定义 // state: () => ({ count: 0 }) @@ -11,5 +16,14 @@ export const carStore = defineStore('carStore', { increment() { this.count++; }, + addCar(goods) { + //查找是否存在,返回位置 + const index = this.carList.findIndex(item => goods.goodsId == item.goodsId); + //存在,删除 + if (index > -1) { + this.carList.splice(index, 1); + } + this.carList.push(goods); + } }, }); \ No newline at end of file