detail.js 1.63 KB
import api from '../../common/api';
import formatDate from '../../common/formatDate';

export default {
    formatData(data) {
        let resu = {};
        let endDate = '';

        if (data.startDay.split('/')[0] === data.endDay.split('/')[0]) {
            endDate = formatDate.slashToString(data.endDay, 0);
            if (data.startDay.split('/')[1] === data.endDay.split('/')[1]) {
                endDate = formatDate.slashToString(data.endDay, 1);
            }
        } else {
            endDate = formatDate.slashToString(data.endDay);
        }

        resu = {
            name: data.activityName,
            startDate: formatDate.slashToString(data.startDay),
            endDate: data.startDay === data.endDay ? '' : endDate,
            startTime: data.startTime,
            endTime: data.endTime,
            free: data.price === '免费',
            price: data.price,
            storeAddress: data.storeAddress,
            tagName: data.trendClassTypeName
        };

        return resu;
    },
    getDetail(params) {
        return api.get({
            url: '/ActivityConfigController/getFrontDetailById',
            data: {
                activityId: params.id,
                isFront: params.isFront
            },
            api: 'store',
            code: 200
        }).then(result => {
            let resu = {
                detail: '',
                info: ''
            };

            if (result) {
                resu.detail = result.detail;
                resu.contentSection = result.contentSection;
                resu.info = this.formatData(result);
            }

            return resu;
        });
    }
};