新增vuex,router
This commit is contained in:
43
store/index.js
Normal file
43
store/index.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
/**
|
||||
* Web唐明明
|
||||
* 匆匆数载恍如梦,岁月迢迢华发增。
|
||||
* 碌碌无为枉半生,一朝惊醒万事空。
|
||||
*/
|
||||
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
token : uni.getStorageSync('token') || '',
|
||||
code : uni.getStorageSync('wxCode') || '',
|
||||
coupongoods : []
|
||||
},
|
||||
getters: {
|
||||
getToken: state => {
|
||||
return state.token
|
||||
},
|
||||
getCoupongoods: state => {
|
||||
return state.coupongoods
|
||||
},
|
||||
getCode: state => {
|
||||
return state.code
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
setToken(state, tokenString) {
|
||||
state.token = tokenString
|
||||
uni.setStorageSync('token', tokenString)
|
||||
},
|
||||
setCoupongoods(state, value) {
|
||||
state.coupongoods = value
|
||||
},
|
||||
setCode(state, value) {
|
||||
state.code = value
|
||||
uni.setStorageSync('wxCode', value)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user