
/**
 * 手太欠
 * 愿这世界都如故事里一样 美好而动人~
 */

import request from '../request.js'

// 我的地址列表
const index = () => {
    return request({
        url : 'addresses'
    })
}

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

// 删除地址
const setdef = (addressId) => {
    return request({
        url : 'addresses/' + addressId + '/setdef',
        method: "POST"
    })
}

// 获取省
const create = () => {
    return request({
        url : 'addresses/create'
    })
}

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

// 创建地址保存
const add = (data) => {
    return request({
        url : 'addresses/store',
        method: "POST",
        data: data
    })
}

// 编辑地址保存
const keep = (addressId, data) => {
    return request({
        url : 'addresses/' + addressId + '/update',
        method: "POST",
        data: data
    })
}

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

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