Commit a1bafdec26a3e7ac0d99e1c9197d416526bb6e08
1 parent
e7b075f9
vuex
Showing
3 changed files
with
52 additions
and
14 deletions
src/components/chinaMap/index.vue
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | <table class="parkTotalTb"> |
14 | 14 | <tr> |
15 | 15 | <td><div class="memberTotalImg"></div></td> |
16 | - <td><div class="infoBox"><div><countTo :startVal='memberParams.startVal' :endVal='memberParams.endVal' :duration='animationTime'></countTo></div><div>会员总数</div></div> </td> | |
16 | + <td><div class="infoBox"><div><countTo :startVal='memberParams.startVal' :endVal='$store.state.ParkingTotal' :duration='animationTime'></countTo></div><div>会员总数</div></div> </td> | |
17 | 17 | </tr> |
18 | 18 | </table> |
19 | 19 | </div> |
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | <script> |
33 | 33 | import echarts from 'echarts' |
34 | 34 | import countTo from 'vue-count-to';//通过设置:endVall 和 :startVall 会自动判断计数和倒数,:duration='3000'是指完成动画的时间。 |
35 | + import {mapGetters} from 'vuex' //use commit | |
35 | 36 | export default { |
36 | 37 | name: "chinaMap", |
37 | 38 | components: { countTo }, |
... | ... | @@ -53,7 +54,13 @@ |
53 | 54 | mapChart: {}, |
54 | 55 | } |
55 | 56 | }, |
57 | + computed: { | |
58 | + ...mapGetters(['getParkingTotal']) | |
59 | + }, | |
56 | 60 | mounted() { |
61 | + this.parkParams.endVal = this.$store.state.ParkingTotal | |
62 | + | |
63 | + console.log(this.getParkingTotal) | |
57 | 64 | this.mapChart= this.createPie(); |
58 | 65 | const _self=this; |
59 | 66 | //var tmpCount=0; |
... | ... | @@ -61,7 +68,7 @@ |
61 | 68 | let tmpCount =Math.floor(Math.random()*3+1);;//1-3随机数 |
62 | 69 | // _self.parkParams.startVal= _self.parkParams.endVal; |
63 | 70 | // _self.parkParams.endVal +=tmpCount; |
64 | - console.log(tmpCount); | |
71 | + //console.log(tmpCount); | |
65 | 72 | _self.dayParams.startVal=_self.dayParams.endVal; |
66 | 73 | _self.dayParams.endVal +=tmpCount; |
67 | 74 | },10000); | ... | ... |
src/components/memberNum/index.vue
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | </template> |
23 | 23 | |
24 | 24 | <script> |
25 | + import { mapActions } from 'vuex' | |
25 | 26 | import common from '../../api/common'; |
26 | 27 | import echarts from 'echarts' |
27 | 28 | export default { |
... | ... | @@ -37,18 +38,24 @@ |
37 | 38 | }, |
38 | 39 | mounted() { |
39 | 40 | //会员总数 |
40 | - | |
41 | 41 | this.axios.post('urban/intelligence/appuser/queryUserPersonStatistic').then((response)=>{ |
42 | 42 | let data = response.data.data |
43 | 43 | this.registerNum = data.registerNum |
44 | 44 | this.memberNumTotal = common.formatNumToStr(this.registerNum); |
45 | 45 | this.activeUserNum = data.todayActiveNum |
46 | 46 | this.newUerNum = data.todayRegisterNum |
47 | + this.$store.dispatch('transferParkingTotal', data.registerNum) | |
48 | + //this.$store.dispatch('transferParkingTotal',10000); | |
49 | + //this.transferParkingTotal( data.registerNum); | |
50 | + console.log(this.$store.state.ParkingTotal) | |
47 | 51 | }).catch((response)=>{ |
48 | 52 | console.log(response); |
49 | 53 | }) |
50 | 54 | }, |
51 | 55 | methods: { |
56 | + ...mapActions([ | |
57 | + 'transferParkingTotal' | |
58 | + ]) | |
52 | 59 | /* |
53 | 60 | * 格式化会员总数 |
54 | 61 | // * */ | ... | ... |
src/store/index.js
1 | 1 | import Vue from 'vue' |
2 | 2 | import Vuex from 'vuex' |
3 | -import weather from './modules/weather' | |
4 | -import weatherForecast from './modules/weatherForecast' | |
5 | -//import createLogger from '../../../src/plugins/logger' | |
3 | + | |
4 | +import createLogger from 'vuex/dist/logger' | |
6 | 5 | |
7 | 6 | Vue.use(Vuex) |
8 | 7 | |
9 | -//const debug = process.env.NODE_ENV !== 'production' | |
8 | +const state = { | |
9 | + ParkingTotal: 10000 | |
10 | + | |
11 | +} | |
12 | + | |
13 | +const getters = { | |
14 | + getParkingTotal: function (state) { | |
15 | + return state.ParkingTotal | |
16 | + } | |
17 | +} | |
18 | + | |
19 | +const mutations = { | |
20 | + changeParkingTotal(state,str){ | |
21 | + state.ParkingTotal = str | |
22 | + } | |
23 | + | |
24 | +} | |
25 | + | |
26 | +const actions = { | |
27 | + transferParkingTotal(context,obj){ | |
28 | + context.commit('changeParkingTotal',obj) | |
29 | + } | |
30 | +} | |
31 | + | |
32 | + | |
33 | +const debug = process.env.NODE_ENV !== 'production' | |
10 | 34 | |
11 | -export default new Vuex.Store({ | |
12 | - modules: { | |
13 | - weatherModule:weather, | |
14 | - weatherForecastModule:weatherForecast | |
15 | - }, | |
16 | - // strict: debug, | |
17 | - // plugins: debug ? [createLogger()] : [] | |
35 | +const store = new Vuex.Store({ | |
36 | + state, | |
37 | + getters, | |
38 | + mutations, | |
39 | + actions, | |
40 | + plugins: debug ? [createLogger()] : [] | |
18 | 41 | }) |
42 | +export default store; | ... | ... |