tide-command.page.js 1.76 KB
require('scss/home/tide-command.page.scss');

let yoho = require('js/yoho-app');

let tip = require('js/plugin/tip');
let trendWord;

$('.tide-command-page').css('min-height', function() {
    return $(window).height();
});

$('.close').click(function() {
    $('.command-textarea').val('');
});

$('.command-textarea').bind('input propertychange', function() {
    $('.world-number').html(15 - $('.command-textarea').val().length);

    if ($('.command-textarea').val().length >= 15) {
        $(this).val($(this).val().substring(0, 14));
    }
});

$('.save').click(function() {
    trendWord = $('.command-textarea').val();

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

            if (result.code && result.code === 200) {
                if (window._yas && window._yas.sendCustomInfo) {
                    window._yas.sendCustomInfo({
                        op: 'YB_MYTREND_TREND_SET_C',
                        param: JSON.stringify({
                            TREND: trendWord
                        })
                    }, true);
                }

                if (yoho && yoho.isApp) {
                    yoho.invokeMethod('go.refreshUserInfomation');

                    setTimeout(function() {
                        yoho.invokeMethod('go.back');
                    }, 1000);
                }
            }
        }
    });
});

(function() {
    $('.world-number').html(15 - $('.command-textarea').val().length);

    if (yoho && yoho.isApp) {

        if (yoho.isMarsApp) {
            yoho.ready(() => {
                yoho.invokeMethod('set.removeTopRightButton');
            });
        }
    }
}());