...
|
...
|
@@ -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; |
...
|
...
|
|