完善用户地址列表

master
hequan_waynaqua 4 years ago
parent 4aaabb1d1c
commit 35858be6e5

@ -21,7 +21,6 @@ export default [
address: '浙江省杭州市拱墅区莫干山路 50 号' address: '浙江省杭州市拱墅区莫干山路 50 号'
}, },
{ {
id: '2',
name: '李四', name: '李四',
tel: '1310000000', tel: '1310000000',
country: '', country: '',

@ -6,3 +6,19 @@ export function getAddress() {
method: 'get' method: 'get'
}) })
} }
export function addAddress(data) {
return request({
url: '/address',
method: 'post',
data
})
}
export function updateAddress(data) {
return request({
url: '/address',
method: 'put',
data
})
}

@ -20,7 +20,7 @@ const actions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getAddress() getAddress()
.then(res => { .then(res => {
const data = res.entry const { data } = res.map
commit('SET_ADDRESS_LIST', data) commit('SET_ADDRESS_LIST', data)
resolve(data) resolve(data)
}) })

@ -21,6 +21,7 @@ import { mapGetters } from 'vuex'
import NavBar from '@/components/NavBar' import NavBar from '@/components/NavBar'
import areaList from '@/utils/area.js' import areaList from '@/utils/area.js'
import { addAddress } from '@/api/address.js'
export default { export default {
name: 'AddressEdit', name: 'AddressEdit',
@ -43,7 +44,10 @@ export default {
methods: { methods: {
onSave(value) { onSave(value) {
console.log('保存地址', value) console.log('保存地址', value)
this.$toast.success('保存成功') addAddress(value).then(res => {
this.$toast.success('保存成功')
this.$router.go(-1)
}).catch(e => {})
}, },
onDelete(value) { onDelete(value) {
console.log('删除地址', value) console.log('删除地址', value)

@ -61,12 +61,17 @@ export default {
data() { data() {
return { return {
defaultId: '', defaultId: '',
list: [] list: [],
exhibitionSettlementItemDTOs: []
} }
}, },
async mounted() { async mounted() {
this.$toast.loading('加载中...') this.$toast.loading('加载中...')
this.list = await this.$store.dispatch('address/getList') 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() this.$toast.clear()
}, },
methods: { methods: {

@ -91,6 +91,9 @@ export default {
// all select // all select
handleAllSelect(value) { handleAllSelect(value) {
const data = this.list.map(item => { const data = this.list.map(item => {
const data = { id: item.id, checked: value }
updateCart(data).then(res => {
}).catch(e => {})
item.checked = value item.checked = value
return item return item
}) })

@ -8,7 +8,5 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.order-list {
}
</style> </style>

Loading…
Cancel
Save