bundle.page.js
3.3 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* Created by targaryen on 2016/11/28.
*/
require('product/bundle/detail.page.css');
let $ = require('yoho-jquery'),
tip = require('plugin/tip');
require('common');
let share = require('common/share');
let chosePanelRender = require('common/chose-panel'),
chosePanel = require('cart/chose-panel');
let $selectBtn = $('.select-btn'),
$buyNowBtn = $('#bundle-buy-now');
// cookie 参数
let actCkOpthn = {
path: '/cart/index'
};
$(function() {
window.setCookie('activity-info', '', actCkOpthn);
share({
imgUrl: 'https://feature.yoho.cn/300x300.png',
title: '会搭是成为潮流ICON的第一步,搭配购买还有优惠折扣!',
link: window.location.href,
desc: '超高性价比,开启省钱大作战!'
});
});
/**
* 选择商品颜色等
*/
$selectBtn.on('touchend', function() {
let self = $(this);
$.post('/product/detail/info', {
id: self.data('id'),
productSkn: self.data('skn')
}, function(data) {
chosePanelRender(data);
chosePanel.init();
chosePanel.setBundleModeWithSknId(self.data('skn'));
chosePanel.show('', (productData) => {
var product = $('#gskn-' + productData.skn);
product.data('sku', productData.sku);
product.html('颜色:' + productData.color + ' 尺码:' + productData.size);
});
});
});
$('.goods-img').on('touchend', function() {
let packGood = $(this).parent().find('.select-btn');
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_PACKAGE_GOODS_C',
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')],
PRD_ID: window.queryString.gid,
PACKAGE_GOODS: packGood.data('id'),
PACKAGE_INDEX: packGood.data('index') + 1
})
}, true);
}
});
/**
* 立即购买
*/
$buyNowBtn.on('click', function() {
let bundleGoods = [],
bundleId = $('#activityId').val(),
gskn = $('span[id^="gskn"]'),
gsknSelected = false,
yasGid = [];
if (gskn.length < 1) {
tip.show('非法请求!');
return;
}
gskn.each(function() {
if (!$(this).data('sku')) {
gsknSelected = false;
tip.show('请为套餐商品选择属性');
return;
}
gsknSelected = true;
bundleGoods.push({
type: 'bundle',
sku: $(this).data('sku'),
buy_number: 1
});
yasGid.push($(this).data('id'));
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_PACKAGE_BUY_NOW_C',
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')],
PRD_ID: window.queryString.id,
PACKAGE_GOODS: yasGid.join(',')
})
}, true);
}
if (gsknSelected) {
window.setCookie('_cartType', 'bundle', actCkOpthn);
window.setCookie('activity-info', JSON.stringify({
product_sku_list: bundleGoods,
activity_id: bundleId
}), actCkOpthn);
window.location.href = '/cart/index/new/orderEnsure?cartType=bundle&activityType=bundle';
}
});