brand.js
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* 品牌页面
* @auhtor: bikai<kai.bi@yoho.cn>
* @date: 2016/1/21
*/
var $ = require('yoho.jquery');
var $brandFavor = $('#brand-favor'),
id = $brandFavor.data('id');
$brandFavor.on('click', function() {
$.ajax({
type: 'post',
url: '/product/index/favoriteBrand',
data: {
brandId: id
}
}).then(function(res) {
if (res.code === 200) {
$brandFavor.find('i').toggleClass('coled');
} else if (res.code === 403) {
location.href = '//www.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href);
}
});
});
//页面进入更新收藏状态
$.ajax({
type: 'POST',
url: '/product/index/isFavoriteBrand',
data: {
brandId: id
}
}).then(function(data) {
if (data.code === 200) {
//已收藏
$brandFavor.find('i').addClass('coled');
} else if (data.code === 404) {
//未收藏
$brandFavor.find('i').removeClass('coled');
}
});