Authored by 梁志锋

购物车逻辑修改

... ... @@ -10,50 +10,37 @@
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
var panelTmpl,
$chosePanel = $('#chose-panel'),
var $chosePanel = $('#chose-panel'),
$num,
$chosed,
// re = /\d+/,
leftNum,
confirming,
hasChooseColor,
hasChooseSize,
curColorIndex,
curSizeIndex,
$curSizeRow,
hasChooseColor,
hasChooseSize,
$curSizeBlock,
$sizeRowList;
// 读取模板
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
//初始化购物车面板显示
function init() {
var $firstRow;
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
$sizeRowList = $('.size-list ul');
$firstRow = $sizeRowList.eq(0);
$curSizeBlock = null,
hasChooseSize = false,
hasChooseColor = false,
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
}
init();
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
... ... @@ -69,9 +56,9 @@ function checkColorSizeNum() {
return true;
}
function show(data) {
if (data) {
$chosePanel.html(panelTmpl(data));
function show(html) {
if (html) {
$chosePanel.html(html);
init();
}
$('.chose-panel').show();
... ...
... ... @@ -19,18 +19,12 @@ function getProductInfo(skn, promotionId) {
$.get('/cart/index/giftinfo', {
skn: skn,
promotionId: promotionId
}).then(function(res) {
if (!res) {
}).then(function(html) {
if (!html) {
tip.show('网络错误');
return;
}
if (res.code === 200) {
chosePanel.show({
cartInfo: res.data
});
} else {
tip.show(res.message || '网络错误');
}
chosePanel.show(html);
}).fail(function() {
tip.show('网络错误');
}).always(function() {
... ...
... ... @@ -215,7 +215,9 @@ class IndexController extends AbstractAction
$result = CartModel::giftProductData($skn, $promotionId);
}
$this->_view->display('gift-info', $result);
$this->_view->display('gift-info', array(
'cartInfo' => $result['data']
));
}
/**
... ...