index.page.js 1.6 KB
/**
 * 个人中心首页
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/11/12
 */
var $ = require('yoho-jquery'),
    noticeScroll = require('../plugin/notice-scroll');

var $userAvatar = $('.user-avatar'),
    $listItem = $('.list-item');

var myImage = new Image(),
    avatar;

require('home/index.page.css');

require('../common');
if ($('.recommend-for-you').length) {
    require('./recommend-for-you-user-center');
}
require('../common/suspend-cart');
require('../common/footer');

window.reMarginFooter('.footer-tab');

// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
if (avatar) {
    myImage.src = avatar;
    myImage.onload = function() {
        $userAvatar.css('background-image', 'url(' + avatar + ')');
    };
}

noticeScroll('.notice', $('.notice').data('time') * 1000);

$('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() {
    $listItem.removeClass('highlight');
    $(this).addClass('highlight');
}).on('touchend touchcancel', '.list-item, .type-item, .order-title', function() {
    $(this).removeClass('highlight');
});

// 埋点
$('.res-c').on('click', 'a', function() {
    window._yas.sendCustomInfo({
        
        // op: 'YB_CHOOSE_FOR_YOU_Y',
        // appop: isAppOp ? 'YB_CHOOSE_FOR_YOU' : '', // app内打开wap的埋点场合
        // param: JSON.stringify(parameter),
        // REC_POSE: RECPOSE,
        // PRD_ID: $(this).closest('.good-info').data('id'),
        // PRD_NUM: index % pageNum === 0 ? pageNum : index % pageNum,
        // ACTION_ID: 1,
        // PAGE_NUM: Math.ceil(index / pageNum)
    }, true);
});