diff --git a/mock/address.js b/mock/address.js index caa7e74..4f5ca25 100644 --- a/mock/address.js +++ b/mock/address.js @@ -21,7 +21,6 @@ export default [ address: '浙江省杭州市拱墅区莫干山路 50 号' }, { - id: '2', name: '李四', tel: '1310000000', country: '', diff --git a/src/api/address.js b/src/api/address.js index c6e758a..7f83492 100644 --- a/src/api/address.js +++ b/src/api/address.js @@ -6,3 +6,19 @@ export function getAddress() { method: 'get' }) } + +export function addAddress(data) { + return request({ + url: '/address', + method: 'post', + data + }) +} + +export function updateAddress(data) { + return request({ + url: '/address', + method: 'put', + data + }) +} diff --git a/src/store/modules/address.js b/src/store/modules/address.js index f425e48..883d4f2 100644 --- a/src/store/modules/address.js +++ b/src/store/modules/address.js @@ -20,7 +20,7 @@ const actions = { return new Promise((resolve, reject) => { getAddress() .then(res => { - const data = res.entry + const { data } = res.map commit('SET_ADDRESS_LIST', data) resolve(data) }) diff --git a/src/views/address/edit.vue b/src/views/address/edit.vue index 98f68f4..ec7928d 100644 --- a/src/views/address/edit.vue +++ b/src/views/address/edit.vue @@ -21,6 +21,7 @@ import { mapGetters } from 'vuex' import NavBar from '@/components/NavBar' import areaList from '@/utils/area.js' +import { addAddress } from '@/api/address.js' export default { name: 'AddressEdit', @@ -43,7 +44,10 @@ export default { methods: { onSave(value) { console.log('保存地址', value) - this.$toast.success('保存成功') + addAddress(value).then(res => { + this.$toast.success('保存成功') + this.$router.go(-1) + }).catch(e => {}) }, onDelete(value) { console.log('删除地址', value) diff --git a/src/views/address/list.vue b/src/views/address/list.vue index 47ce418..a3e4ed2 100644 --- a/src/views/address/list.vue +++ b/src/views/address/list.vue @@ -61,12 +61,17 @@ export default { data() { return { defaultId: '', - list: [] + list: [], + exhibitionSettlementItemDTOs: [] } }, async mounted() { this.$toast.loading('加载中...') this.list = await this.$store.dispatch('address/getList') + console.log(this.list) + this.list.forEach(item => { + item.address = item.province + item.city + item.county + ' ' + item.addressDetail + }) this.$toast.clear() }, methods: { diff --git a/src/views/cart/index.vue b/src/views/cart/index.vue index 94e17e7..ad96fe0 100644 --- a/src/views/cart/index.vue +++ b/src/views/cart/index.vue @@ -91,6 +91,9 @@ export default { // all select handleAllSelect(value) { const data = this.list.map(item => { + const data = { id: item.id, checked: value } + updateCart(data).then(res => { + }).catch(e => {}) item.checked = value return item }) diff --git a/src/views/order/list/index.vue b/src/views/order/list/index.vue index a34f103..2867357 100644 --- a/src/views/order/list/index.vue +++ b/src/views/order/list/index.vue @@ -8,7 +8,5 @@ export default { } -