first
This commit is contained in:
4
src/store/getters.js
Normal file
4
src/store/getters.js
Normal file
@ -0,0 +1,4 @@
|
||||
const getters = {
|
||||
order: state => state.order
|
||||
}
|
||||
export default getters
|
24
src/store/index.js
Normal file
24
src/store/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
||||
const modulesFiles = require.context('./modules', true, /\.js$/)
|
||||
|
||||
|
||||
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
|
||||
// set './app.js' => 'app'
|
||||
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
|
||||
const value = modulesFiles(modulePath)
|
||||
modules[moduleName] = value.default
|
||||
return modules
|
||||
}, {})
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules,
|
||||
getters
|
||||
})
|
||||
|
||||
export default store
|
73
src/store/modules/order.js
Normal file
73
src/store/modules/order.js
Normal file
@ -0,0 +1,73 @@
|
||||
const state = {
|
||||
orderInfo: {},
|
||||
address: {}, // 事发地
|
||||
destAddress: {}, // 目的地
|
||||
localAddress: { // 定位地址
|
||||
lat: 31.184102,
|
||||
lng: 121.506799,
|
||||
address: '中道汽车救援股份有限公司',
|
||||
localCityCode: '',
|
||||
},
|
||||
serverCity: '',
|
||||
localCityCode: '',
|
||||
// serviceId: '',
|
||||
// isAppoint: 0, // 是否预约
|
||||
// appointTime: '', // 预约时间
|
||||
// positionEnvironment: '', // 车辆位于
|
||||
|
||||
// startPoiAddress: '',
|
||||
// startLat: '',
|
||||
// startLng: '',
|
||||
// endPoiAddress: '',
|
||||
// endLat: '',
|
||||
// endLng: '',
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_LOCAL_ADDRESS: (state, data) => {
|
||||
state.localAddress = data
|
||||
},
|
||||
SET_ORDER_INFO: (state, data) => {
|
||||
state.orderInfo = data
|
||||
},
|
||||
SET_ADDRESS: (state, data) => {
|
||||
state.address = data
|
||||
},
|
||||
SET_DEST_ADDRESS: (state, data) => {
|
||||
state.destAddress = data
|
||||
},
|
||||
SET_SERVER_CITY: (state, data) => {
|
||||
state.serverCity = data
|
||||
},
|
||||
SET_LOCAL_CITY: (state, data) => {
|
||||
state.localCityCode = data
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setLocalAddress({ commit }, data) {
|
||||
commit('SET_LOCAL_ADDRESS', data)
|
||||
},
|
||||
setAddress({ commit }, data) {
|
||||
commit('SET_ADDRESS', data)
|
||||
},
|
||||
setDestAddress({ commit }, data ) {
|
||||
commit('SET_DEST_ADDRESS', data)
|
||||
},
|
||||
setOrderInfo({ commit }, data) {
|
||||
commit('SET_ORDER_INFO', data)
|
||||
},
|
||||
setServerCity({ commit }, data) {
|
||||
commit('SET_SERVER_CITY', data)
|
||||
},
|
||||
setLocalCity({ commit }, data) {
|
||||
commit('SET_LOCAL_CITY', data)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
Reference in New Issue
Block a user