me-gift-service.js 1.3 KB
/**
 * 我的礼品卡列表
 * @author xiaoxiao <xiaoxiao.hao@yoho.cn>
 * @date: 2017/9/1
 */
'use strict';
const Promise = require('bluebird');
const helpers = global.yoho.helpers;

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    headTab(params) {
        let type = params.type > -1 && params.type < 4 ? params.type : 0;
        let tabs = [{
            name: '使用中',
            url: helpers.urlFormat('/home/megift'),
            active: false
        }, {
            name: '已过期',
            url: helpers.urlFormat('/home/megift', {type: 1}),
            active: false
        }, {
            name: '已用完',
            url: helpers.urlFormat('/home/megift', {type: 2}),
            active: false
        }, {
            name: '已冻结',
            url: helpers.urlFormat('/home/megift', {type: 3}),
            active: false
        }, {
            name: '添加礼品卡',
            class: 'add-gift',
            active: false
        }];

        tabs[type].active = true;

        return tabs;
    }

    // 礼品卡列表
    getList(params) {
        return Promise.resolve({tabs: this.headTab(params)});
    }

    // 礼品卡列表
    detailList(params) {
        return Promise.resolve({tabs: this.headTab(params)});
    }

};