gift-advance.js
1.97 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
/**
* 赠品/加价购
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/23
*/
var $ = require('yoho-jquery'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload'),
Hammer = require('yoho-hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
chosePanel = require('./chose-panel');
var $page = $('.gift-advance-page'),
queryString = $.queryString();
require('../common');
lazyLoad($('.lazy'));
ellipsis.init();
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
$.post('/cart/index/new/giftinfo', {
skn: skn,
promotionId: promotionId
}).then(function(data) {
if (!data) {
tip.show('网络错误');
return;
}
let html = require('common/chose-panel.hbs')(data);
if (queryString.edit) {
// 删掉页面上原有的pannel
chosePanel.remove();
$(html).appendTo('#chose-panel');
chosePanel.init();
chosePanel.setEditModeWithSknId(skn, true, true);
chosePanel.disableNumEdit();
chosePanel.show('', function() {
window.location.href = '/cart/index/index';
});
} else {
chosePanel.show(html, function() {
window.location.href = '/cart/index/index';
});
}
}, function() {
tip.show('网络错误');
}).always(function() {
loading.hideLoadingMask();
});
}
$page.find('.chose').each(function(i, elem) {
var choseHammer = new Hammer(elem);
choseHammer.on('tap', function(e) {
var $this = $(e.target),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
getProductInfo(id, promotionId);
});
});
setTimeout(function() {
$('.gift-advance-good .name').each(function() {
this.mlellipsis(2);
});
}, 0);