From 322041059e7bbabd32c5a881d42d80be313c9f78 Mon Sep 17 00:00:00 2001 From: 542634 <1322755174@qq.com> Date: Sun, 23 Dec 2018 16:49:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E8=B4=AD=E7=89=A9=E8=BD=A6=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E9=83=A8=E5=88=86=E7=9A=84=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/components/CartTabbar.vue | 118 +++++++++++++++++++++++++++++++ src/components/DetailsTabbar.vue | 73 ------------------- src/router/routes.js | 9 ++- src/store/getters.js | 16 +++++ 5 files changed, 139 insertions(+), 79 deletions(-) create mode 100644 src/components/CartTabbar.vue delete mode 100644 src/components/DetailsTabbar.vue diff --git a/src/App.vue b/src/App.vue index 55b88d2..608cdfe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,7 @@
diff --git a/src/components/CartTabbar.vue b/src/components/CartTabbar.vue new file mode 100644 index 0000000..e903d81 --- /dev/null +++ b/src/components/CartTabbar.vue @@ -0,0 +1,118 @@ + + + + + + + + diff --git a/src/components/DetailsTabbar.vue b/src/components/DetailsTabbar.vue deleted file mode 100644 index a78560f..0000000 --- a/src/components/DetailsTabbar.vue +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - diff --git a/src/router/routes.js b/src/router/routes.js index 4171c11..fc7a17b 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -1,5 +1,5 @@ import Tabbar from '@/components/Tabbar' -import DetailsTabbar from '@/components/DetailsTabbar' +import CartTabbar from '@/components/CartTabbar' import MallHead from '@/components/MallHead' import CHeader from '@/components/CHeader' import MHeader from '@/components/MHeader' @@ -55,8 +55,7 @@ const routes = [ name: 'details', components: { default: Details, - detailsheader: DetailHeader, - detailstabbar: DetailsTabbar + detailsheader: DetailHeader }, props: true }, @@ -77,8 +76,8 @@ const routes = [ isTabbar: true, components: { default: Cart, - tabbar: Tabbar, - cheader: CHeader + cheader: CHeader, + carttabbar: CartTabbar } }, { diff --git a/src/store/getters.js b/src/store/getters.js index 6ad5520..cd99374 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,5 +1,21 @@ export default { cartIsNotEmpty (state) { return Array.isArray(state.cart) && state.cart.length !== 0 + }, + cartCheckedCount (state) { + return state.cart.reduce((total, item) => { + if (item.isChecked === true) { + total += item.count + } + return total + }, 0) + }, + cartCheckedPrice (state) { + return state.cart.reduce((total, item) => { + if (item.isChecked === true) { + total += item.count * item.price + } + return total + }, 0.0) } } -- Gitee From c91b15a5ac8b1fb1864abffb908363e0c97b5957 Mon Sep 17 00:00:00 2001 From: 542634 <1322755174@qq.com> Date: Sun, 23 Dec 2018 17:12:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=92=8C=E9=80=89=E4=B8=AD=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/components/CartTabbar.vue | 1 + src/pages/Cart.vue | 31 +++++++++++++++++++++++++++++-- src/router/routes.js | 4 ++-- src/store/state.js | 6 +++--- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index 608cdfe..8514fa9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,7 @@ diff --git a/src/components/CartTabbar.vue b/src/components/CartTabbar.vue index e903d81..e092658 100644 --- a/src/components/CartTabbar.vue +++ b/src/components/CartTabbar.vue @@ -101,6 +101,7 @@ export default { } } .total { + position: absolute; height: 12vw; line-height: 12vw; background: #ffffff; diff --git a/src/pages/Cart.vue b/src/pages/Cart.vue index 7fcb5fa..c9082ef 100644 --- a/src/pages/Cart.vue +++ b/src/pages/Cart.vue @@ -16,7 +16,7 @@ v-for="item in cart" :key="item.id"> + :checked='item.isChecked'>{{item.title}}
@@ -55,6 +55,11 @@{{item.title}}
@@ -56,7 +59,9 @@