
import {req} from "../request"

//我的地址列表
const index = () => req({url: "addresses"})

//获取省
const create = () => req({url: "addresses/create"})

// 获取市级列表
const children = (psn) => req({url: "areas/children", data: {psn: psn}})

// 获取已有地址信息
const edit = (addressId) => req({url: "addresses/" + addressId + '/edit'})


// 创建地址保存
const add = (name, mobile, province_id, city_id, district_id, address, def) => req({url: "addresses/store", method: "POST", data: {name: name, mobile: mobile, province_id: province_id, city_id: city_id, district_id: district_id, address: address, def: def}})

// 编辑地址保存
const keep = (addressId,name, mobile, province_id, city_id, district_id, address) => req({url: "addresses/" + addressId + '/update', method: "POST", data: {name: name, mobile: mobile, province_id: province_id, city_id: city_id, district_id: district_id, address: address}})

// 设为默认地址
const setdef = (addressId) => req({url: "addresses/" + addressId + '/setdef', method: "POST"})

// 删除地址
const remove = (addressId) => req({url: "addresses/" + addressId + '/destroy', method: "DELETE"})


export default({
	index,
	create,
	children,
	edit,
	add,
	keep,
	setdef,
	remove
})
