tide-command.page.js 1.75 KB
require('home/tide-command.page.css');

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

let tip = require('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');
            });
        }
    }
}());