brand.js 789 Bytes
/**
 * 品牌页面
 * @auhtor: bikai<kai.bi@yoho.cn>
 * @date: 2016/1/21
 */

var $ = require('yoho.jquery');

$('#brand-favor').on('click', function() {
    var $this = $(this),
        uid = window.getUid();

    $.ajax({
        type: 'post',
        url: '/product/index/favoriteBrand',
        data: {
            uid: uid,
            brandId: $this.data('id')
        }
    }).then(function(res) {
        if (res.code === 200) {
            if (res.message === 'add') {
                $this.find('i').addClass('coled');
            } else {
                $this.find('i').removeClass('coled');
            }
        } else if (res.code === 403) {
            location.href = 'http://www.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href);
        }
    });
});