From b65cfbfc9e09515bcfd735b3a14aafee273c3b3e Mon Sep 17 00:00:00 2001 From: Bowen Date: Sun, 23 Sep 2018 21:14:32 +0800 Subject: [PATCH] feat: add storage for analysis page --- src/store/actions.js | 11 ++++++++++- src/store/mutations/index.js | 20 +++++++++++++++++-- src/store/mutations/type.js | 3 --- src/store/mutations/types.js | 7 +++++++ src/store/state.js | 37 +++++++++++++++++++++++++++++++++++- 5 files changed, 71 insertions(+), 7 deletions(-) delete mode 100644 src/store/mutations/type.js create mode 100644 src/store/mutations/types.js diff --git a/src/store/actions.js b/src/store/actions.js index 2f91a6b..1405d50 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -1,3 +1,12 @@ +import types from './mutations/types' + export default { - change ({ commit, state }) {} + getAnalysisData ({ commit, state }, { + sales + }) { + commit(types.SET_SALES, sales) + commit(types.SET_VISITORS, visitors) + commit(types.SET_PAYMENTS, payments) + commit(types.SET_OPERATIONS, operations) + } } diff --git a/src/store/mutations/index.js b/src/store/mutations/index.js index 8e87e5f..201d553 100644 --- a/src/store/mutations/index.js +++ b/src/store/mutations/index.js @@ -1,7 +1,23 @@ -import type from './type' +import types from './types' export default { - [type.TOGGLE_ASIDE] (state) { + [types.TOGGLE_ASIDE] (state) { state.isCollapse = !state.isCollapse + }, + + [types.SET_SALES] (state, sales) { + state.sales = sales + }, + + [types.SET_VISITORS] (state, visitors) { + state.visitors = visitors + }, + + [types.SET_PAYMENTS] (state, payments) { + state.payments = payments + }, + + [types.SET_OPERATIONS] (state, operations) { + state.operations = operations } } diff --git a/src/store/mutations/type.js b/src/store/mutations/type.js deleted file mode 100644 index 7bf31cc..0000000 --- a/src/store/mutations/type.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - 'TOGGLE_ASIDE': 'TOGGLE_ASIDE' -} diff --git a/src/store/mutations/types.js b/src/store/mutations/types.js new file mode 100644 index 0000000..a0c7c7e --- /dev/null +++ b/src/store/mutations/types.js @@ -0,0 +1,7 @@ +export default { + 'TOGGLE_ASIDE': 'TOGGLE_ASIDE', + 'SET_SALES': 'SET_SALES', + 'SET_VISITORS': 'SET_VISITORS', + 'SET_PAYMENTS': 'SET_PAYMENTS', + 'SET_OPERATIONS': 'SET_OPERATIONS' +} diff --git a/src/store/state.js b/src/store/state.js index aa0d60d..c3d8e73 100644 --- a/src/store/state.js +++ b/src/store/state.js @@ -1,3 +1,38 @@ export default { - isCollapse: false + isCollapse: false, + dailyVisitor: 1234, + totalVisitor: 8846, + dailySelling: 10000, + totalSelling: 126566, + totalPayment: 6560, + influenceRate: 0.78, + conversionRate: 0.6, + sales: { + trend: [ + { + key: '同周比', + value: 0.12 + }, + { + key: '日环比', + value: -0.11 + } + ], + daily: 10000, + total: 126566 + }, + visitors: { + daily: 1234, + trend: '', // chart + total: 8846 + }, + payments: { + total: 6560, + rate: 0.6 + }, + operations: { + influence: 0.78, + trend: '', // chart + conversion: 0.6 + } }