diff --git a/src/components/Vant/index.js b/src/components/Vant/index.js index 5c4742e..b9c8e0e 100644 --- a/src/components/Vant/index.js +++ b/src/components/Vant/index.js @@ -42,7 +42,10 @@ import { Grid, GridItem, DropdownMenu, - DropdownItem + DropdownItem, + ContactCard, + ContactList, + ContactEdit } from 'vant' Vue.use(Toast) @@ -86,3 +89,6 @@ Vue.use(Toast) .use(GridItem) .use(DropdownMenu) .use(DropdownItem) + .use(ContactCard) + .use(ContactList) + .use(ContactEdit) diff --git a/src/router/index.js b/src/router/index.js index 4cb8249..8f53a75 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -33,7 +33,8 @@ const routes = [ component: () => import('@/views/category'), meta: { title: '分类', - showTab: true + showTab: true, + keepAlive: true } }, // 购物车 @@ -80,7 +81,7 @@ const routes = [ { path: '/address', name: 'Address', - component: () => import('@/views/address'), + component: () => import('@/views/address/list'), meta: { title: '地址管理' } @@ -111,6 +112,24 @@ const routes = [ meta: { title: '搜索结果' } + }, + // 确认订单 + { + path: '/order/confirm', + name: 'OrderConfirm', + component: () => import('@/views/order/confirm'), + meta: { + title: '确认订单' + } + }, + // 订单列表 + { + path: '/order/list', + name: 'OrderList', + component: () => import('@/views/order/list'), + meta: { + title: '订单列表' + } } ] diff --git a/src/store/getters.js b/src/store/getters.js index a27a89f..7994bf3 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -3,10 +3,14 @@ const getters = { id: state => state.user.id, name: state => state.user.name, userInfo: state => state.user.userInfo, + // address + defaultId: state => state.address.defaultId, + addressList: state => state.address.addressList, selectedAddress: state => state.address.selectedAddress, + // search - searchKey: (state) => { + searchKey: state => { if (state.search.searchKey.length <= 0) { return JSON.parse(localStorage.getItem('searchKey')) || [] } else { diff --git a/src/store/modules/address.js b/src/store/modules/address.js index fab58b3..1ae9181 100644 --- a/src/store/modules/address.js +++ b/src/store/modules/address.js @@ -1,14 +1,39 @@ +import { getAddress } from '@/api/address' + const state = { + defaultId: '', + addressList: [], selectedAddress: {} } const mutations = { - SET_ADDRESS: (state, list) => { - state.selectedAddress = list + SET_DEFAULT_ID: (state, id) => { + state.defaultId = id + }, + SET_ADDRESS_LIST: (state, list) => { + state.addressList = list + }, + SET_SELECTED_ADDRESS: (state, item) => { + state.selectedAddress = item } } -const actions = {} +const actions = { + // 获取地址列表 + getList({ commit }) { + return new Promise((resolve, reject) => { + getAddress() + .then(res => { + const data = res.entry + commit('SET_ADDRESS_LIST', data) + resolve(data) + }) + .catch(error => { + reject(error) + }) + }) + } +} export default { namespaced: true, diff --git a/src/views/address/edit.vue b/src/views/address/edit.vue index 5baef3d..36c2b8c 100644 --- a/src/views/address/edit.vue +++ b/src/views/address/edit.vue @@ -3,53 +3,50 @@ - - diff --git a/src/views/address/list.vue b/src/views/address/list.vue new file mode 100644 index 0000000..3bd0b75 --- /dev/null +++ b/src/views/address/list.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/src/views/order/confirm/index.vue b/src/views/order/confirm/index.vue new file mode 100644 index 0000000..7ddbdc6 --- /dev/null +++ b/src/views/order/confirm/index.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/src/views/order/list/index.vue b/src/views/order/list/index.vue new file mode 100644 index 0000000..a34f103 --- /dev/null +++ b/src/views/order/list/index.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/src/views/search/modules/Words.vue b/src/views/search/modules/Words.vue index f5061d9..ee3ff42 100644 --- a/src/views/search/modules/Words.vue +++ b/src/views/search/modules/Words.vue @@ -65,8 +65,7 @@ export default { this.$router.push({ path: '/search/list', query: { - key: value, - t: +new Date() + key: value } }) }