Files
houyi-uniapp/store/modules/location.js
PC-202306242200\Administrator 85b89ccea7 first commit
2026-03-28 23:27:25 +08:00

63 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const getDefaultState = () => {
return {
data: {
city: '郑州市',
city_code: '410100',
lat: '34.789049',
lng: '113.684792',
time: ''
},
current: {
lat: '34.789049',
lng: '113.684792',
city: '郑州市',
city_code: '410100',
time: ''
}
}
}
export default {
namespaced: true,
state: getDefaultState(),
mutations: {
//通俗的理解mutations 里面装着改变数据的方法集合,处理数据逻辑的方法全部放在 mutations 里,使数据和视图分离。
setStateData(state, value) { //更新当前时间戳
state.data = value;
},
resetStateData(state) {
},
setStateCurrent(state, value) { //更新当前时间戳
state.current = value;
},
resetStateCurrent(state) {
},
},
actions: {
/**
* action 类似于 mutation ,不同在于:
action 提交的是 mutation通过 mutation 来改变 state ,而不是直接变更状态。
action 可以包含任意异步操作。
*/
setStateDataAction(context, value) {
context.commit('setStateData', value);
},
resetStateDataAction: (state) => {
context.commit('resetStateData');
},
setStateCurrentAction(context, value) {
context.commit('setStateCurrent', value);
},
resetStateCurrentAction: (state) => {
context.commit('resetStateCurrent');
},
},
getters: {
},
}