order.js 1.16 KB
const api = global.yoho.API;
const camelCase = global.yoho.camelCase;

const _getUserOrder = () => {
    return api.get('', {
        method: 'app.SpaceOrders.get',
        uid: '10931021',
        type: 1,
        page: 1,
        limit: 10
    }).then(result => {
        const orderList = result && result.data && result.data.order_list || [];

        return camelCase(orderList);
    });
};

const getOrderData = () => {
    return _getUserOrder().then(result => {
        const fakeData = {
            title: '我的订单',
            tabs: [
                {
                    text: '全部订单',
                    isActive: true,
                    type: 'all'
                },
                {
                    text: '待付款',
                    type: 'paying'
                },
                {
                    text: '待发货',
                    type: 'delivering'
                }
            ],
            showSearch: true
        };

        const order = Object.assign(fakeData, {
            orderList: result
        });

        return {
            order: order
        };
    });
};

module.exports = {
    getOrderData: getOrderData
};