Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

framework @ 75bbc3b0
1 -Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec 1 +Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
@@ -5,46 +5,53 @@ @@ -5,46 +5,53 @@
5 * @date: 2015/10/21 5 * @date: 2015/10/21
6 */ 6 */
7 7
8 -var $ = require('jquery'),  
9 - tip = require('../plugin/tip'),  
10 - loading = require('../plugin/loading');  
11 -  
12 -// Handlebars = require('yoho.handlebars'); 8 +// bikai
  9 +// 增加init函数,异步请求的接口需要重新初始化一下选择列表
  10 +// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
13 11
14 -// var $page = $('.yoho-page'); 12 +var $ = require('jquery'),
  13 + Handlebars = require('yoho.handlebars'),
  14 + tip = require('../plugin/tip'),
  15 + loading = require('../plugin/loading');
15 16
16 -var $num, 17 +var panelTmpl,
  18 + $chosePanel = $('#chose-panel'),
  19 + $num,
17 $chosed, 20 $chosed,
18 re = /\d+/, 21 re = /\d+/,
19 leftNum, 22 leftNum,
20 - $colorList = $('.color-list ul>li'),  
21 - $sizeList = $('.size-list ul>li'),  
22 - firstColorId = $colorList.eq(0).data('id'), 23 + $colorList,
  24 + $sizeList,
  25 + firstColorId,
23 colorIndex, 26 colorIndex,
24 confirming; 27 confirming;
25 28
26 -//初始化购物车面板显示  
27 -$sizeList.each(function() {  
28 - colorIndex = $(this).data('colorid');  
29 -  
30 - if (colorIndex === firstColorId) {  
31 - $(this).removeClass('hide'); 29 +// 读取模板
  30 +$.get('/cart/index/giftinfoTpl', function(html) {
  31 + if (!html) {
  32 + tip.show('网络错误');
  33 + return;
32 } 34 }
  35 + panelTmpl = Handlebars.compile(html);
  36 +}).fail(function() {
  37 + tip.show('网络错误');
33 }); 38 });
34 39
  40 +//初始化购物车面板显示
  41 +function init() {
  42 + $colorList = $('.chose-panel .color-list ul>li');
  43 + $sizeList = $('.chose-panel .size-list ul>li');
  44 + firstColorId = $colorList.eq(0).data('id');
  45 + $sizeList.each(function() {
  46 + colorIndex = $(this).data('colorid');
  47 +
  48 + if (colorIndex === firstColorId) {
  49 + $(this).removeClass('hide');
  50 + }
  51 + });
  52 +}
35 53
36 -  
37 -// var tpl;  
38 -  
39 -//读取partials  
40 -// $.ajax({  
41 -// type: 'GET',  
42 -// url: '/shoppingCart/tpl',  
43 -// success: function(data) {  
44 -// tpl = Handlebars.compile(data);  
45 -// }  
46 -// });  
47 - 54 +init();
48 55
49 //显示 56 //显示
50 // function show(data) { 57 // function show(data) {
@@ -57,7 +64,12 @@ $sizeList.each(function() { @@ -57,7 +64,12 @@ $sizeList.each(function() {
57 64
58 65
59 66
60 -function show() { 67 +function show(data) {
  68 + if (data) {
  69 + $chosePanel.html(panelTmpl(data));
  70 + init();
  71 + }
  72 +
61 $('.chose-panel').show(); 73 $('.chose-panel').show();
62 74
63 $('body').css('overflow', 'hidden'); 75 $('body').css('overflow', 'hidden');
@@ -112,16 +124,18 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -112,16 +124,18 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
112 isEdit: isEdit 124 isEdit: isEdit
113 } 125 }
114 }).done(function(res) { 126 }).done(function(res) {
  127 + loading.hideLoadingMask();
115 if (res.code === 200) { 128 if (res.code === 200) {
116 - loading.hideLoadingMask();  
117 $('.num-tag').html(numInCart + buyNumber); 129 $('.num-tag').html(numInCart + buyNumber);
118 $('.num-tag').removeClass('hide'); 130 $('.num-tag').removeClass('hide');
119 - confirming = false;  
120 remove(); 131 remove();
121 } 132 }
  133 + if (res.message) {
  134 + tip.show(res.message);
  135 + }
122 }).fail(function() { 136 }).fail(function() {
123 tip.show('网络出了点问题~'); 137 tip.show('网络出了点问题~');
124 - 138 + }).always(function() {
125 confirming = false; 139 confirming = false;
126 }); 140 });
127 } 141 }
@@ -241,5 +255,5 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -241,5 +255,5 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
241 $num.val(num + 1); 255 $num.val(num + 1);
242 }); 256 });
243 257
244 -  
245 -exports.show = show;  
  258 +exports.init = init;
  259 +exports.show = show;
@@ -6,27 +6,14 @@ @@ -6,27 +6,14 @@
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'), 9 tip = require('../plugin/tip'),
11 loading = require('../plugin/loading'), 10 loading = require('../plugin/loading'),
12 chosePanel = require('./chose-panel'); 11 chosePanel = require('./chose-panel');
13 12
14 -var panelTmpl,  
15 - $page = $('.gift-advance-page'),  
16 - $chosePanel = $('#chose-panel'); 13 +var $page = $('.gift-advance-page');
17 14
18 lazyLoad($('.lazy')); 15 lazyLoad($('.lazy'));
19 16
20 -$.get('/cart/index/giftinfoTpl', function(html) {  
21 - if (!html) {  
22 - tip.show('网络错误');  
23 - return;  
24 - }  
25 - panelTmpl = Handlebars.compile(html);  
26 -}).fail(function() {  
27 - tip.show('网络错误');  
28 -});  
29 -  
30 function getProductInfo(skn, promotionId) { 17 function getProductInfo(skn, promotionId) {
31 loading.showLoadingMask(); 18 loading.showLoadingMask();
32 $.get('/cart/index/giftinfo', { 19 $.get('/cart/index/giftinfo', {
@@ -37,14 +24,10 @@ function getProductInfo(skn, promotionId) { @@ -37,14 +24,10 @@ function getProductInfo(skn, promotionId) {
37 tip.show('网络错误'); 24 tip.show('网络错误');
38 return; 25 return;
39 } 26 }
40 - if (!panelTmpl) {  
41 - return;  
42 - }  
43 if (res.code === 200) { 27 if (res.code === 200) {
44 - $chosePanel.html(panelTmpl({  
45 - cartInfo: res.data  
46 - }));  
47 - chosePanel.show(); 28 + chosePanel.show({
  29 + cartInfo: res.data
  30 + });
48 } else { 31 } else {
49 tip.show(res.message || '网络错误'); 32 tip.show(res.message || '网络错误');
50 } 33 }
@@ -8,8 +8,8 @@ @@ -8,8 +8,8 @@
8 right: 0; 8 right: 0;
9 background: rgba(0,0,0,.3); 9 background: rgba(0,0,0,.3);
10 z-index:3; 10 z-index:3;
11 -  
12 - 11 +
  12 +
13 .main { 13 .main {
14 position: absolute; 14 position: absolute;
15 height: pxToRem(610px); 15 height: pxToRem(610px);
@@ -86,7 +86,7 @@ @@ -86,7 +86,7 @@
86 top: 20rem / $pxConvertRem; 86 top: 20rem / $pxConvertRem;
87 } 87 }
88 } 88 }
89 - 89 +
90 .size-list li.hide { 90 .size-list li.hide {
91 display: none; 91 display: none;
92 } 92 }
@@ -94,7 +94,9 @@ @@ -94,7 +94,9 @@
94 .block { 94 .block {
95 float: left; 95 float: left;
96 display: block; 96 display: block;
97 - width: 80rem / $pxConvertRem; 97 + box-sizing: border-box;
  98 + padding: 0 20rem / $pxConvertRem;
  99 + min-width: 80rem / $pxConvertRem;
98 height: 80rem / $pxConvertRem; 100 height: 80rem / $pxConvertRem;
99 border: 1px solid #000; 101 border: 1px solid #000;
100 margin-right: 30rem / $pxConvertRem; 102 margin-right: 30rem / $pxConvertRem;
@@ -112,10 +114,10 @@ @@ -112,10 +114,10 @@
112 114
113 &.zero-stock { 115 &.zero-stock {
114 color: #e0e0e0; 116 color: #e0e0e0;
115 - border-color: #e0e0e0; 117 + border-color: #e0e0e0;
116 } 118 }
117 &.zero-stock.chosed { 119 &.zero-stock.chosed {
118 - border-color: #e0e0e0; 120 + border-color: #e0e0e0;
119 background: none; 121 background: none;
120 color: #e0e0e0; 122 color: #e0e0e0;
121 background-color: #c0c0c0; 123 background-color: #c0c0c0;
@@ -168,4 +170,4 @@ @@ -168,4 +170,4 @@
168 border: none; 170 border: none;
169 } 171 }
170 } 172 }
171 -}  
  173 +}
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 margin-left: 135rem / $pxConvertRem; 55 margin-left: 135rem / $pxConvertRem;
56 } 56 }
57 57
58 - .name { 58 + .gift-advance-good .name {
59 margin-bottom: 20rem / $pxConvertRem; 59 margin-bottom: 20rem / $pxConvertRem;
60 width: 440rem / $pxConvertRem; 60 width: 440rem / $pxConvertRem;
61 font-size: 28rem / $pxConvertRem; 61 font-size: 28rem / $pxConvertRem;
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 6
7 .shopping-cart-page { 7 .shopping-cart-page {
8 padding-bottom: 120rem / $pxConvertRem; 8 padding-bottom: 120rem / $pxConvertRem;
  9 + overflow-x: hidden;
9 10
10 .cart-nav { 11 .cart-nav {
11 color: #c6c6c6; 12 color: #c6c6c6;
@@ -208,8 +209,8 @@ @@ -208,8 +209,8 @@
208 border:1px solid #505050; 209 border:1px solid #505050;
209 border-radius:.2rem; 210 border-radius:.2rem;
210 display: block; 211 display: block;
211 - margin: 0 auto; 212 + margin: 0 auto;
212 text-align: center; 213 text-align: center;
213 } 214 }
214 } 215 }
215 -}  
  216 +}