Authored by Rock Zhang

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

framework @ 75bbc3b0
Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -5,46 +5,53 @@
* @date: 2015/10/21
*/
var $ = require('jquery'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
// Handlebars = require('yoho.handlebars');
// bikai
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
// var $page = $('.yoho-page');
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
var $num,
var panelTmpl,
$chosePanel = $('#chose-panel'),
$num,
$chosed,
re = /\d+/,
leftNum,
$colorList = $('.color-list ul>li'),
$sizeList = $('.size-list ul>li'),
firstColorId = $colorList.eq(0).data('id'),
$colorList,
$sizeList,
firstColorId,
colorIndex,
confirming;
//初始化购物车面板显示
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === firstColorId) {
$(this).removeClass('hide');
// 读取模板
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
//初始化购物车面板显示
function init() {
$colorList = $('.chose-panel .color-list ul>li');
$sizeList = $('.chose-panel .size-list ul>li');
firstColorId = $colorList.eq(0).data('id');
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === firstColorId) {
$(this).removeClass('hide');
}
});
}
// var tpl;
//读取partials
// $.ajax({
// type: 'GET',
// url: '/shoppingCart/tpl',
// success: function(data) {
// tpl = Handlebars.compile(data);
// }
// });
init();
//显示
// function show(data) {
... ... @@ -57,7 +64,12 @@ $sizeList.each(function() {
function show() {
function show(data) {
if (data) {
$chosePanel.html(panelTmpl(data));
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
... ... @@ -112,16 +124,18 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
isEdit: isEdit
}
}).done(function(res) {
loading.hideLoadingMask();
if (res.code === 200) {
loading.hideLoadingMask();
$('.num-tag').html(numInCart + buyNumber);
$('.num-tag').removeClass('hide');
confirming = false;
remove();
}
if (res.message) {
tip.show(res.message);
}
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
confirming = false;
});
}
... ... @@ -241,5 +255,5 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$num.val(num + 1);
});
exports.show = show;
\ No newline at end of file
exports.init = init;
exports.show = show;
... ...
... ... @@ -6,27 +6,14 @@
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
chosePanel = require('./chose-panel');
var panelTmpl,
$page = $('.gift-advance-page'),
$chosePanel = $('#chose-panel');
var $page = $('.gift-advance-page');
lazyLoad($('.lazy'));
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
$.get('/cart/index/giftinfo', {
... ... @@ -37,14 +24,10 @@ function getProductInfo(skn, promotionId) {
tip.show('网络错误');
return;
}
if (!panelTmpl) {
return;
}
if (res.code === 200) {
$chosePanel.html(panelTmpl({
cartInfo: res.data
}));
chosePanel.show();
chosePanel.show({
cartInfo: res.data
});
} else {
tip.show(res.message || '网络错误');
}
... ...
... ... @@ -8,8 +8,8 @@
right: 0;
background: rgba(0,0,0,.3);
z-index:3;
.main {
position: absolute;
height: pxToRem(610px);
... ... @@ -86,7 +86,7 @@
top: 20rem / $pxConvertRem;
}
}
.size-list li.hide {
display: none;
}
... ... @@ -94,7 +94,9 @@
.block {
float: left;
display: block;
width: 80rem / $pxConvertRem;
box-sizing: border-box;
padding: 0 20rem / $pxConvertRem;
min-width: 80rem / $pxConvertRem;
height: 80rem / $pxConvertRem;
border: 1px solid #000;
margin-right: 30rem / $pxConvertRem;
... ... @@ -112,10 +114,10 @@
&.zero-stock {
color: #e0e0e0;
border-color: #e0e0e0;
border-color: #e0e0e0;
}
&.zero-stock.chosed {
border-color: #e0e0e0;
border-color: #e0e0e0;
background: none;
color: #e0e0e0;
background-color: #c0c0c0;
... ... @@ -168,4 +170,4 @@
border: none;
}
}
}
\ No newline at end of file
}
... ...
... ... @@ -55,7 +55,7 @@
margin-left: 135rem / $pxConvertRem;
}
.name {
.gift-advance-good .name {
margin-bottom: 20rem / $pxConvertRem;
width: 440rem / $pxConvertRem;
font-size: 28rem / $pxConvertRem;
... ...
... ... @@ -6,6 +6,7 @@
.shopping-cart-page {
padding-bottom: 120rem / $pxConvertRem;
overflow-x: hidden;
.cart-nav {
color: #c6c6c6;
... ... @@ -208,8 +209,8 @@
border:1px solid #505050;
border-radius:.2rem;
display: block;
margin: 0 auto;
margin: 0 auto;
text-align: center;
}
}
}
\ No newline at end of file
}
... ...