address-api.js 2.3 KB
/**
 * address api
 * @author: yyq<yanqing.yang@yoho.cn>
 * @date: 2016/09/27
 */
'use strict';

const api = global.yoho.API;

/**
 * 获取用户收货地址列表
 * @param uid [number] uid
 */
const getAddressListAsync = (uid) => api.get('', {
    method: 'app.address.gethidden',
    uid: uid
}, {code: 200});

/**
 * 省市区列表
 * @param id [number] 省市区id
 */
const getAreaListAsync = (id) => {
    return api.get('', {
        method: 'app.address.provinces',
        id: id || 0
    });
};

/**
 * 地址删除
 * @param uid [number] uid
 * @param id [string] address id
 */
const delAddressAsync = (uid, id) => api.get('', {
    method: 'app.address.del',
    uid: uid,
    id: id
});

/**
 * 新增地址api
 * @param uid [Number]
 * @param consignee [String] 收货人
 * @param areaCode [Number] 区号
 * @param address [String] 地址
 * @param mobile [String] 手机号
 * @param phone [String] 电话号码
 * @param zipCode [String] 邮编
 * @param email [String] 邮箱
 */
const addAddressAsync = (uid, consignee, areaCode, address, mobile, phone, zipCode, email) => api.get('', {
    method: 'app.address.add',
    uid: uid,
    consignee: consignee,
    area_code: areaCode,
    address: address,
    mobile: mobile,
    phone: phone,
    zip_code: zipCode,
    email: email
});

/**
 * 更新地址地址api
 * @param uid [Number]
 * @param id [Number] 地址id
 * @param consignee [String] 收货人
 * @param areaCode [Number] 区号
 * @param address [String] 地址
 * @param mobile [String] 手机号
 * @param phone [String] 电话号码
 * @param zipCode [String] 邮编
 * @param email [String] 邮箱
 */
const updateAddressAsync = (uid, id, consignee, areaCode, address, mobile, phone, zipCode, email) => api.get('', {
    method: 'app.address.update',
    uid: uid,
    id: id,
    consignee: consignee,
    area_code: areaCode,
    address: address,
    mobile: mobile,
    phone: phone,
    zip_code: zipCode,
    email: email
});

/**
 * 设置默认地址
 * @param uid [Number]
 * @param id [Number] 地址id
 */
const setDefaultAddressAsync = (uid, id) => api.get('', {
    method: 'app.address.setdefault',
    uid: uid,
    id: id
});


module.exports = {
    getAddressListAsync,
    getAreaListAsync,
    delAddressAsync,
    addAddressAsync,
    updateAddressAsync,
    setDefaultAddressAsync
};