Merge pull request '7.15' (#64) from zhy into master
Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/64
This commit is contained in:
		
						commit
						da9967405a
					
				@ -1,41 +1,20 @@
 | 
				
			|||||||
// 商品相关
 | 
					import Vue from 'vue'
 | 
				
			||||||
const moduleA = {
 | 
					import Vuex from 'vuex'
 | 
				
			||||||
	state: () => ({
 | 
					Vue.use(Vuex)
 | 
				
			||||||
		count: 0
 | 
					 | 
				
			||||||
	}),
 | 
					 | 
				
			||||||
	mutations: {
 | 
					 | 
				
			||||||
		increment (state) {
 | 
					 | 
				
			||||||
			// 这里的 `state` 对象是模块的局部状态
 | 
					 | 
				
			||||||
			state.count++
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	getters: {
 | 
					 | 
				
			||||||
		doubleCount (state) {
 | 
					 | 
				
			||||||
			return state.count * 2
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
// 用户相关
 | 
					 | 
				
			||||||
const moduleB = {
 | 
					 | 
				
			||||||
	state: () => ({
 | 
					 | 
				
			||||||
		count: 0
 | 
					 | 
				
			||||||
	}),
 | 
					 | 
				
			||||||
	mutations: {
 | 
					 | 
				
			||||||
		increment (state) {
 | 
					 | 
				
			||||||
			// 这里的 `state` 对象是模块的局部状态
 | 
					 | 
				
			||||||
			state.count++
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	getters: {
 | 
					 | 
				
			||||||
		doubleCount (state) {
 | 
					 | 
				
			||||||
			return state.count * 2
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const store = new Vuex.Store({
 | 
					const store = new Vuex.Store({
 | 
				
			||||||
	modules: {
 | 
						state: {
 | 
				
			||||||
		shop: moduleA,
 | 
							count: 0
 | 
				
			||||||
		user: moduleB
 | 
						},
 | 
				
			||||||
 | 
						getters: {
 | 
				
			||||||
 | 
							doubleCount (state) {
 | 
				
			||||||
 | 
								return state.count * 2
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						mutations: {
 | 
				
			||||||
 | 
							increment (state) {
 | 
				
			||||||
 | 
								state.count++
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					export default store;
 | 
				
			||||||
							
								
								
									
										8
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.js
									
									
									
									
									
								
							@ -1,17 +1,17 @@
 | 
				
			|||||||
import Vue from 'vue'
 | 
					import Vue from 'vue'
 | 
				
			||||||
import App from './App'
 | 
					import App from './App'
 | 
				
			||||||
import uView from "uview-ui";
 | 
					import uView from "uview-ui";
 | 
				
			||||||
// import Vuex from 'vuex'
 | 
					 | 
				
			||||||
Vue.config.productionTip = false
 | 
					Vue.config.productionTip = false
 | 
				
			||||||
Vue.use(uView);
 | 
					Vue.use(uView);
 | 
				
			||||||
// Vue.use(Vuex);
 | 
					 | 
				
			||||||
App.mpType = 'app'
 | 
					App.mpType = 'app'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// import store from '@/common/store/index.js'
 | 
					import store from '@/common/store/index.js'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Vue.prototype.$store = store;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const app = new Vue({
 | 
					const app = new Vue({
 | 
				
			||||||
	...App,
 | 
						...App,
 | 
				
			||||||
	// store
 | 
						store
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
 | 
					// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
 | 
				
			||||||
import httpInterceptor from '@/common/http.interceptor.js'
 | 
					import httpInterceptor from '@/common/http.interceptor.js'
 | 
				
			||||||
 | 
				
			|||||||
@ -41,8 +41,8 @@
 | 
				
			|||||||
        <view class="hr" style="margin-top:40rpx"></view>
 | 
					        <view class="hr" style="margin-top:40rpx"></view>
 | 
				
			||||||
        <seckill v-if="spikeList.length"></seckill>
 | 
					        <seckill v-if="spikeList.length"></seckill>
 | 
				
			||||||
        <view v-if="spikeList.length" class="hr" style="margin-top:40rpx"></view>
 | 
					        <view v-if="spikeList.length" class="hr" style="margin-top:40rpx"></view>
 | 
				
			||||||
        <!-- <recommend></recommend> -->
 | 
					        <recommend v-if="0"></recommend>
 | 
				
			||||||
        <!-- <view class="hr" style="margin-top:40rpx"></view> -->
 | 
					        <view class="hr" style="margin-top:40rpx" v-if="0"></view>
 | 
				
			||||||
        <group></group>
 | 
					        <group></group>
 | 
				
			||||||
        <image class="lingquan"></image>
 | 
					        <image class="lingquan"></image>
 | 
				
			||||||
        <youhq></youhq>
 | 
					        <youhq></youhq>
 | 
				
			||||||
@ -95,7 +95,6 @@ export default {
 | 
				
			|||||||
		this.getGoodsRecommend();
 | 
							this.getGoodsRecommend();
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	onShow() {
 | 
						onShow() {
 | 
				
			||||||
		// console.log(this.$store.shop.state.count);
 | 
					 | 
				
			||||||
		this.getRecommendedSpike();
 | 
							this.getRecommendedSpike();
 | 
				
			||||||
		this.getSpikeList();
 | 
							this.getSpikeList();
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user