address.js 971 Bytes
'use strict';

// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/地址管理.md';

const _ = require('lodash');

class AddressModel extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    /**
     *  地址数据
     *  @param uid
     *  @return
     */
    addressData(uid) {
        return this.get({
            data: {
                method: 'app.address.gethidden',
                uid
            },
            param: {
                cache: false
            }
        }).then(result => {
            // 在接口返回处统一编码
            _.set(result, 'data', _.map(_.get(result, 'data', []), item => {
                return Object.assign(item, {address_id: encodeURIComponent(item.address_id)});
            }));

            return result;
        }, () => {
            return {code: 500, data: [], message: '地址获取失败'};
        });
    }
}

module.exports = AddressModel;