index.page.js 1.03 KB
var yoho = require('yoho');
var $ = require('jquery');
var util = require('common/util');

yoho.ready(() => {
    if (!yoho.isLogin) {
        $('.auth').addClass('no-intercept');
        $('.auth').on('click', function() {
            yoho.goLogin();
            return false;
        });
    } else {
        // 地址管理
        $('#address').on('click', function() {
            yoho.goAddress({
                type: '2'
            });
            return false;
        });
    }

    // 系统设置
    $('#setting').on('click', function() {
        yoho.goSetting();
        return false;
    });

    yoho.showLoading(false);

    window.addEventListener('touchmove', function() {
        var topHeight = document.body.scrollTop;

        if (topHeight > 50) {
            $('#header').addClass('top-change');
        } else {
            $('#header').removeClass('top-change');
        }
    });

    document.addEventListener('visibilitychange', () => {
        if (!document.hidden) {
            location.reload();
        }
    });
});