set-trend-world.js 1.86 KB
let tip = require('plugin/tip');
let dialog = require('plugin/dialog');

$('.show-explain').on('click', function() {
    $('.show-explain').hide();
    $('.explain-main').css({height: 'auto'});
});

$('.hide-explain').on('click', function() {
    $('.show-explain').show();
    $('.explain-main').css({height: 0});
});

// 埋点
function point(type, trend) {
    let pointJosn = {
        TYPE: type
    };

    if (trend) {
        pointJosn.TREND = trend;
    }

    if ($('.yoho-page').hasClass('my-page')) {
        if (window._yas && window._yas.sendCustomInfo) {
            window._yas.sendCustomInfo({
                op: 'YB_HOMEPOP_TREND_SET_C',
                param: JSON.stringify(pointJosn)
            }, true);
        }
    }
}

$('.set-world').click(function() {

    $.ajax({
        type: 'GET',
        url: '/activity/set-trend-world',
        data: {
            trendWord: $('.trend-world-area').val()
        },
        success: function(result) {
            tip.show(result.message);

            if (result.code === 200) {

                point(1, $('.trend-world-area').val());

                $('.trend-code').html($('.trend-world-area').val());

                setTimeout(function() {
                    $('.set-trend-world').hide();
                }, 2500);
            }
        }
    });
});

$('.withhold').click(function() {

    if (!window.cookie('trend-path') || parseInt(window.cookie('trend-path'), 10) !== 1 &&
        /^\/home/.test(location.pathname)) {
        dialog.showDialog({
            dialogText: '您还可以在“个人中心-基本资料-我的潮流口令”中进行设置',
            hasFooter: {
                centerBtnText: '我知道了'
            }
        });

        window.setCookie('trend-path', 1);
    }
    point(2);
    $('.set-trend-world').hide();
});

$('.back').click(function() {
    $('.set-trend-world').hide();
});