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
*/
// bikai
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
// Handlebars = require('yoho.handlebars');
// var $page = $('.yoho-page');
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;
// 读取模板
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
//初始化购物车面板显示
$sizeList.each(function() {
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) {
if (res.code === 200) {
loading.hideLoadingMask();
if (res.code === 200) {
$('.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.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({
chosePanel.show({
cartInfo: res.data
}));
chosePanel.show();
});
} else {
tip.show(res.message || '网络错误');
}
... ...
... ... @@ -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;
... ...
... ... @@ -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;
... ...