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