|
@@ -5,25 +5,48 @@ |
|
@@ -5,25 +5,48 @@ |
5
|
*/
|
5
|
*/
|
6
|
|
6
|
|
7
|
var $ = require('jquery'),
|
7
|
var $ = require('jquery'),
|
8
|
- lazyLoad = require('yoho.lazyload');
|
8
|
+ lazyLoad = require('yoho.lazyload'),
|
|
|
9
|
+ Handlebars = require('yoho.handlebars'),
|
|
|
10
|
+ tip = require('../plugin/tip'),
|
|
|
11
|
+ chosePanel = require('./chose-panel');
|
9
|
|
12
|
|
10
|
-//var chosePanel = require('./chose-panel');
|
13
|
+var panelTmpl,
|
|
|
14
|
+ $page = $('.gift-advance-page'),
|
|
|
15
|
+ $chosePanel = $('#chose-panel');
|
11
|
|
16
|
|
12
|
lazyLoad($('.lazy'));
|
17
|
lazyLoad($('.lazy'));
|
13
|
|
18
|
|
14
|
-//$('.gift-advance-page').on('touchstart', '.chose', function() {
|
|
|
15
|
-// var id = $(this).closest('.gift-advance-good').data('id');
|
|
|
16
|
-//
|
|
|
17
|
-// $.ajax({
|
|
|
18
|
-// type: 'GET',
|
|
|
19
|
-// url: '/shoppingCart/goodinfo',
|
|
|
20
|
-// data: {
|
|
|
21
|
-// id: id
|
|
|
22
|
-// },
|
|
|
23
|
-// success: function(data) {
|
|
|
24
|
-// if (data.code === 200) {
|
|
|
25
|
-// chosePanel.show(data.data);
|
|
|
26
|
-// }
|
|
|
27
|
-// }
|
|
|
28
|
-// });
|
|
|
29
|
-//}); |
|
|
|
|
19
|
+$.get('/cart/index/giftinfoTpl', function(html) {
|
|
|
20
|
+ if (!html) {
|
|
|
21
|
+ tip.show('网络错误');
|
|
|
22
|
+ return;
|
|
|
23
|
+ }
|
|
|
24
|
+ panelTmpl = Handlebars.compile(html);
|
|
|
25
|
+}).fail(function() {
|
|
|
26
|
+ tip.show('网络错误');
|
|
|
27
|
+});
|
|
|
28
|
+
|
|
|
29
|
+function getProductInfo(skn, promotionId) {
|
|
|
30
|
+ $.get('/cart/index/giftinfo', {
|
|
|
31
|
+ skn: skn,
|
|
|
32
|
+ promotionId: promotionId
|
|
|
33
|
+ }).then(function(res) {
|
|
|
34
|
+ if (!res) {
|
|
|
35
|
+ tip.show('网络错误');
|
|
|
36
|
+ return;
|
|
|
37
|
+ }
|
|
|
38
|
+ console.log(res);
|
|
|
39
|
+ $chosePanel.html(panelTmpl(res));
|
|
|
40
|
+ chosePanel.show();
|
|
|
41
|
+ }).fail(function() {
|
|
|
42
|
+ tip.show('网络错误');
|
|
|
43
|
+ });
|
|
|
44
|
+}
|
|
|
45
|
+
|
|
|
46
|
+$page.on('touchend', '.chose', function() {
|
|
|
47
|
+ var $this = $(this),
|
|
|
48
|
+ id = $this.closest('.gift-advance-good').data('id'),
|
|
|
49
|
+ promotionId = $this.closest('.advance-block').data('promotion-id');
|
|
|
50
|
+
|
|
|
51
|
+ getProductInfo(id, promotionId);
|
|
|
52
|
+}); |