2 Star 1 Fork 2

徐子玉/品贷网

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cart.html 48.86 KB
一键复制 编辑 原始数据 按行查看 历史
徐子玉 提交于 2017-07-05 11:21 . + pdw
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>购物车-品代网(pindai123.com)--国内首家建材行业供应链交易平台,F2B2C运营模式开创网络建材市场新纪元。</title>
<meta name="keywords" content="代理,加盟,招商,批发,零售,建材网上商城,PPR,PVC,PE,管材,管件,波纹管,缠绕管,卫浴,陶瓷,龙头,浴缸,地漏,吊顶,灯具,开关,插线板,插座,电线,电缆,水暖五金,地板,油漆,地暖,太阳能,净水器,装修材料" />
<meta name="description" content="品代网(pindai123.com)是中国首家采用云管理系统,互联网加实体营销管理为一体的交易平台。专业的建材行业综合网上购物平台,销售管材管件,水暖卫浴,厨卫洁具,灯具开关,板材五金,油漆涂料,电线电缆,家装材料,建筑材料,五金配件,防水等。正品低价,品质保证,便捷操作,诚信服务。">
<meta name="author" content="Administrator">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="css/indent.css" />
<link rel="stylesheet" href="css/cart.css" />
<link rel="stylesheet" href="css/add.css"/>
<!--右边栏-->
<link rel="stylesheet" href="css/right_side.css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/right-side/parabola.js"></script>
<script type="text/javascript" src="js/right-side/right_side.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript" src="js/cart.js"></script>
<script type="text/javascript" src="js/decode_base64.js"></script>
<script type="text/javascript" src="js/cartMenuFixed.js"></script>
<script type="text/javascript">
// ----------------------------------------------------------------------
// <summary>
// 限制只能输入数字
// </summary>
// ----------------------------------------------------------------------
$.fn.onlyNum = function () {
$(this).keypress(function (event) {
var eventObj = event || e;
var keyCode = eventObj.keyCode || eventObj.which;
if ((keyCode >= 48 && keyCode <= 57))
return true;
else
return false;
}).focus(function () {
//禁用输入法
this.style.imeMode = 'disabled';
}).bind("paste", function () {
//获取剪切板的内容
var clipboard = window.clipboardData.getData("Text");
if (/^\d+$/.test(clipboard))
return true;
else
return false;
});
};
</script>
<!-- city -->
</head>
<body>
<!-- 右侧固定导航链接 -->
<!--<div class="mui-mbar-tabs">
{$userright_html}
</div>-->
<!-- top_header 顶部 -->
{$user_head_html}
<!--top_logo -->
<div class="top_logo">
{$userinfo_head_html}
</div>
<!--
<div class="cart_total">
<div class="wrap_1200 clearfix">
<div class="cart_total_myCart">我的购物车</div>
<p class="zonge">
商品总额:
<em> ¥</em>
<span class="totalPrice">12.66</span>
</p>
</div>
</div>-->
<div class="cart_MyChat ">
<div class="wrap_1200 clearfix">
<div class="cart_total_myCart">我的购物车</div>
<!--<p id="glHd_wallet" class="hd_menu_tit" style="left: 450px;background: none;border-left: none;border-right: none">总件数 :<span id="maycount" style="background: none;" >' + itemCount + '</span></p>-->
<p class="cart_MyChat_zonge">已选商品:<em> &yen;</em><span class="allPrice">55555</span></p>
</div>
</div>
<!-- 进度 -->
<div class="cart_progress" >
<div class="wrap_1200 clearfix">
<div class="step1" style="display:none ;"> </div>
<div class="select_all"><div class="select_all_i"></div>全选</div>
<div class="cart_progress_line cart_line1">商品名称</div>
<div class="cart_progress_line cart_line2">参数规格</div>
<div class="cart_progress_line cart_line3">单价(元)</div>
<div class="cart_progress_line cart_line4">数量</div>
<div class="cart_progress_line cart_line5">总价(元)</div>
<div class="cart_progress_line cart_line6">操作</div>
<!--<div class="detele_all"><div class="detele_all_i">勾选删除</div></div>-->
</div>
</div>
<!-- 订单 -->
<div class="cart_main">
<div class="wrap_1200 clearfix">
<div class="cart_store"></div>
<div id="cart_heji" class="cart_heji cart_menu_nav">
<div class="select_all_bottom"><div class="select_all_i"></div>全选</div>
<div class="detele_all">删除</div>
<div class="cart_refresh">
<a href="javascript:;">刷新</a>
</div>
<p id="glHd_wallet" class="hd_menu_tit_num_total" >已选商品:<span id="maycountall" style="background: none;" ></span></p>
<p class="zonge_total">合计:<em> &nbsp; &yen;&nbsp;</em><span class="totalPrice" id="allItemprice"></span></p>
<div class="cart_tijiao ">
<a href="javascript:;">去结算</a>
</div>
</div>
<div class="cart_null" style="display: none;">
<div class="cart_null_img">
<img src="images/store/cart_bus.png" />
</div>
<div class="cart_null_text">
<div class="cart_null_info">购物车空空的哦~</br>赶紧去挑选心仪的产品吧~</div>
<div class="cart_null_btn"><a href="productList.php">去挑选</a></div>
</div>
</div>
</div>
</div>
<!--sidebar-->
{$sidebar_html}
<!-- 版权 -->
<div id="footermain">
{$foot_html}
</div>
<script type="text/javascript">
$(document).ready(function () {
var user_id ={$userId};
$.post("api.php?act=getPostAddress", {},
function (data) {
var html = '';
if (data != 'Failure') {
data = $.parseJSON(data);
var count = 0;
$.each(data, function (n, value) {
count++;
if (n == 0) {
html += '<div class="cr_addressBoxli cr_addressBoxli_Active">';
html += '<div class="cr_addressBox_name" id="cr_name"><span>' + value.postName + '</span> <i class="addDefaulti"></i></div>';
html += '<div class="cr_addressBox_address" id="cr_address">' + value.provinceName + '|' + value.cityName + '|' + value.districtName + '|' + value.postAddress + '|' + value.postCode + '</div>';
html += '<div class="cr_addressBox_phone" id="cr_tel">' + value.postTel + '</div>';
html += '</div>';
}
else {
html += '<div class="cr_addressBoxli cr_addressBoxli_Passive">';
html += '<div class="cr_addressBox_name "><span>' + value.postName + '</span> </div>';
html += '<div class="cr_addressBox_address">' + value.provinceName + '|' + value.cityName + '|' + value.districtName + '|' + value.postAddress + '|' + value.postCode + '</div>';
html += '<div class="cr_addressBox_phone">' + value.postTel + '</div>';
html += '</div>';
}
});
// if(count > 0){
// html += '<div class="cr_addressBoxliMore">更多地址 <i class="addr_i"></i></div>';
// }
}
html += '<div class="cr_addressBoxliAddaddress"><a href="addressAdmin.php">新增/修改地址</a></div>';
$('.cr_addressBox').html(html);
// //显示更多地址
// $('.cr_addressBoxliMore').on('click',function(){
// if($('.cr_addressBoxli_Passive').css('display')=="none"){
// $(this).siblings('.cr_addressBoxli_Passive').show();
// $(this).html('收起地址 <i class="addr_i"></i>');
// $(this).children('.addr_i').css('background-position','0 -10px');
// }else{
// $(this).siblings('.cr_addressBoxli_Passive').hide();
// $(this).html('更多地址 <i class="addr_i"></i>');
// $(this).children('.addr_i').css('background-position','0 0');
// }
// });
//选择要使用的地址
$('.cr_addressBox_name').on('click', function () {
var tempName = $(this).find('span').html();
var tempAddress = $(this).siblings('.cr_addressBox_address').html();
var tempTel = $(this).siblings('.cr_addressBox_phone').html();
$(this).find('span').html($('#cr_name span').html());
$(this).siblings('.cr_addressBox_address').html($('#cr_address').html());
$(this).siblings('.cr_addressBox_phone').html($('#cr_tel').html());
$('#cr_name span').html(tempName);
$('#cr_address').html(tempAddress);
$('#cr_tel').html(tempTel);
$('.cr_addressBoxliMore').click();
});
});
/*修改收货地址*/
$('.revise_consignee').click(function () {
// $('.add_newaddress-mask').fadeIn(100);
$('.new_consignee').slideDown(200);
});
$('.close').click(function () {
// $('.add_newaddress-mask').fadeOut(100);
$('.new_consignee').slideUp(200);
});
$('.save_btn').click(function () {
var p = ($('#sel1_til p').html().indexOf('请选择') == -1) ? $('#sel1_til p').html() : "";
var c = ($('#sel2_til p').html().indexOf('请选择') == -1) ? $('#sel2_til p').html() : "";
var a = ($('#sel3_til p').html().indexOf('请选择') == -1) ? $('#sel3_til p').html() : "";
var t = ($('#sel4_til p').html().indexOf('请选择') == -1) ? $('#sel4_til p').html() : "";
$('.addr_detail .addr_name').html($('#order_name').val())
$('.addr_detail .addr_tel').html($('#order_tel').val())
$('.addr_detail .addr_zip').html($('#order_zip').val())
$('.addr_detail .addr_info').html(p + a + c + t + $('#order_address').val())
});
//选择省
$.post("api.php?act=province", {},
function (data) {
var html = "";
//$('.prov .sel_con').show();
data = $.parseJSON(data);
html += ' <div class="provlist">';
html += ' <ul>';
$.each(data, function (n, value) {
html += ' <li value="' + value.name + '" pid="' + value.id + '">' + value.name + '</li>';
});
html += ' </ul>';
html += ' </div>';
$('.prov .sel_con').html(html);
});
//点击显示
$('#sel1_til').live('click', function () {
if ($(this).siblings().is(':hidden')) {
$(this).siblings().css('display', 'none');
$(this).siblings('.sel_con').slideDown(200);
$(this).siblings().css('display', 'block');
}
else {
$(this).siblings('.sel_con').slideUp(200);
}
;
});
$('#sel2_til').live('click', function () {
if ($(this).siblings().is(':hidden')) {
$(this).siblings().css('display', 'none');
$(this).siblings('.sel_con').slideDown(200);
$(this).siblings().css('display', 'block');
}
else {
$(this).siblings('.sel_con').slideUp(200);
}
;
});
$('#sel3_til').live('click', function () {
if ($(this).siblings().is(':hidden')) {
$(this).siblings().css('display', 'none');
$(this).siblings('.sel_con').slideDown(200);
$(this).siblings().css('display', 'block');
}
else {
$(this).siblings('.sel_con').slideUp(200);
}
;
});
$('#sel4_til').live('click', function () {
if ($(this).siblings().is(':hidden')) {
$(this).siblings().css('display', 'none');
$(this).siblings('.sel_con').slideDown(200);
$(this).siblings().css('display', 'block');
}
else {
$(this).siblings('.sel_con').slideUp(200);
}
;
});
//显示点击的省份
//选择市
$('.provlist li').live('click', function () {
$('#sel1_til p').html($(this).html());
$('.prov .sel_con').hide();
var pid = $(this).attr('pid');
$.post("api.php?act=city", {pid: pid},
function (data) {
$('.city .sel_con').slideDown(200);
var html = "";
data = $.parseJSON(data);
html += '<div class="citylist">';
html += '<ul>';
$.each(data, function (n, value) {
html += '<li value="' + value.name + '" cid="' + value.id + '">' + value.name + '</li>';
});
html += '</ul>';
html += '</div>';
$('.city .sel_con').html(html);
//显示点击的市
$('.citylist li').click(function () {
$('#sel2_til p').html($(this).html());
$('.city .sel_con').hide();
});
});
$('#sel2_til').click();
});
//选择区
$('.citylist li').live('click', function () {
var cid = $(this).attr('cid');
//console.log(cid);
$.post("api.php?act=district", {cid: cid},
function (data) {
$('.dist .sel_con').slideDown(200);
var html = "";
data = $.parseJSON(data);
html += '<div class="distlist">';
html += ' <ul>';
$.each(data, function (n, value) {
html += ' <li value="' + value.name + '" did="' + value.id + '">' + value.name + '</li>';
});
html += ' </ul>';
html += '</div>';
$('.dist .sel_con').html(html);
//显示点击的区
$('.distlist li').click(function () {
$('#sel3_til p').html($(this).html());
$('.dist .sel_con').hide();
});
});
$('#sel3_til').click();
});
//选择街道
$('.distlist li').live('click', function () {
var did = $(this).attr('did');
$.post("api.php?act=town", {did: did},
function (data) {
$('.street .sel_con').slideDown(200);
var html = "";
data = $.parseJSON(data);
html += '<div class="streetlist">';
html += ' <ul>';
$.each(data, function (n, value) {
html += ' <li value="' + value.name + '" tid="' + value.id + '">' + value.name + '</li>';
});
html += ' </ul>';
html += '</div>';
$('.street .sel_con').html(html);
//显示点击的区
$('.streetlist li').click(function () {
$('#sel4_til p').html($(this).html());
$('.street .sel_con').hide();
});
});
$('#sel4_til').click();
});
var user_id = {$userId};
$('.cart_refresh a').live('click', function () {
$('.cart_main .cart_store').html('');
$('.cart_null').show();
var shopping = new ShoppingCartList(user_id);
var list = shopping.Read();
var allItemCount = 0;
var allItemPrice = 0;
for (var i = 0; i < list.length; i++) {
var id = list[i];
var store = new ShoppingCartHelper(user_id, id);
var cart = store.Read();
var html = "";
if(cart.Items.length > 0){
$('.cart_null').hide();
html += '<div class="cart_list">';
var cartName = '';
if(cart.Name != 'undefined'){
cartName = cart.Name;
}
html += '<div class="cart_list_til" cartName="'+cart.Name+'"><div class="select_storeall_i"></div>' + cartName + '<a class="backtostorea" href="store.php?id=' + cart.Id + '" >返回厂商继续购物</a></div>';
var itemCount = 0
$.each(cart.Items, function (n, item) {
itemCount++;
html += '<div class="cart_good clearfix" name="goodnum">';
html += ' <ul>';
var specIndex = cart.Id + '-' + item.Id + '-' + n;
html += ' <li class="good_select"><i class="select_pro_i" specIndex="' + specIndex + '"></i></li> ';
html += ' <li class="good_pic"><a href="product.php?factoryId=' + cart.Id + '&productId=' + item.Id + '"><img src="' + item.Photo + '" /> </a></li>';
html += ' <li class="good_word">';
html += ' <ul>';
html += ' <li>' + item.Name + '</li>';
// html += ' <li class="danjia">单价 <span>' + item.Price + '</span>元</li>';
html += ' </ul>';
html += ' </li>';
html += ' <li class="good_standard">';
html += ' <ul>';
html += ' <li>规格:<span>' + item.Spec + '</span></br>单位:<span>' + item.Unit + '</span></br>颜色:<span>' + item.Color + '</span></li>';
html += ' </ul>';
html += ' </li>';
html += ' <li class="good_singlePrice">';
html += ' <ul>';
html += ' <li class="danjia">单价: <span>' + item.Price + '</span>元</li>';
html += ' </ul>';
html += ' </li>';
html += ' <li class="good_num">';
html += ' <div class="shoping_num">';
html += ' <input type="button" class="dec" value="-" />';
html += ' <input type="text" class="num" value="' + item.Count + '" />';
html += ' <input type="hidden" class="cart_id" value="' + cart.Id + '">';
html += ' <input type="hidden" class="item_id" value="' + item.Id + '">';
html += ' <input type="hidden" class="item_spec" value="' + item.Spec + '">';
html += ' <input type="hidden" class="item_unit" value="' + item.Unit + '">';
html += ' <input type="hidden" class="item_color" value="' + item.Color + '">';
html += ' <input type="button" class="inc" value="+" />';
html += ' </div>';
html += ' </li>';
html += ' <li class="good_price">&yen; <span class="hjval">' + store.GetTotal(item.Count, item.Price) + '</span></li>';
html += ' <li class="good_del">';
html += ' <ul>';
html += ' <li><a href="javascript:;">删除</a></li>';
// html += ' <li><a href="javascript:;">移入收藏夹</a></li>';
html += ' </ul>';
html += ' </li>';
html += ' </ul>';
html += '</div>';
});
html += '<div class="cart_zong clearfix">';
html += '<p id="glHd_wallet" class="hd_menu_tit" style="left: 700px;background: none;border-left: none;border-right: none">总件数 :<span id="maycount" style="background: none;" >' + itemCount + '</span></p>';
html += '<p class="zonge">商品总额:<em> &nbsp; &yen;</em><span class="totalPrice">' + cart.Total.toFixed(2) + '</span></p>';
html += '</div>';
html += '</div>';
allItemCount += itemCount;
allItemPrice = accAdd(allItemPrice,cart.Total.toFixed(2));
}
// else{
// html += '<div>';
// html += ''
// }
$('.cart_main .cart_store').append(html);
loadCart(user_id);
//2015年9月29日 缪杰修改
$('.num').onlyNum();
$('.num').on('blur', function () {
// var nowNum = $(this);
// var price = $(this).parents('.good_num').siblings('.good_word').find('.danjia span');
// var total = $(this).parents('.good_num').siblings('.good_price').find('.hjval');
// var result = parseFloat(price.html() * nowNum.val()).toFixed(2);
// total.html(result);
var o_cartId = $(this).siblings(".cart_id");
var o_itemId = $(this).siblings(".item_id");
var o_itemSpec = $(this).siblings(".item_spec");
var o_itemUnit = $(this).siblings(".item_unit");
var o_count = $(this);
var cartId = o_cartId.val();
var itemId = o_itemId.val();
var itemSpec = o_itemSpec.val();
var itemUnit = o_itemUnit.val();
if (o_count.val() < 1000)
{
var store = new ShoppingCartHelper(user_id, cartId);
store.Change(itemId, itemSpec, itemUnit, o_count.val());
}
$('.cart_refresh a').click();
});
}
$('.allPrice').html(allItemPrice);
$('#allItemprice').html(allItemPrice);
$('#maycountall').html(allItemCount);
$('.select_all_i').addClass('s_all');
$('.select_storeall_i').addClass('s_store');
$('.select_pro_i').addClass('s_goods');
$('.cart_good ').css('background','#fff6de');
$('.select_all_i , .select_storeall_i , .select_pro_i').css('background-position','0 -20px');
//2016年4月13日 玉洁添加
//全选框
$('.select_all_i').on('click',function(){
if($(this).hasClass('s_all')){
$('.select_all_i').removeClass('s_all');
$('.select_storeall_i').removeClass('s_store');
$('.select_pro_i').removeClass('s_goods');
$('.cart_good ').css('background','#fff');
$('.select_all_i , .select_storeall_i , .select_pro_i').css('background-position','0 0');
setTotal();
}
else{
$('.select_all_i').addClass('s_all');
$('.select_storeall_i').addClass('s_store');
$('.select_pro_i').addClass('s_goods');
$('.cart_good ').css('background','#fff6de');
$('.select_all_i , .select_storeall_i , .select_pro_i').css('background-position','0 -20px');
setTotal();
}
});
//店铺全选框
$('.select_storeall_i').on('click',function(){
if($(this).hasClass('s_store')){
$(this).removeClass('s_store');
$(this).css('background-position','0 0');
$(this).parents('.cart_list').find('.select_pro_i').removeClass('s_goods');
$(this).parents('.cart_list').find('.select_pro_i').css('background-position','0 0');
$(this).parents('.cart_list').children('.cart_good ').css('background','#fff');
setTotal();
}
else{
$(this).addClass('s_store');
$(this).css('background-position','0 -20px');
$(this).parents('.cart_list').find('.select_pro_i').addClass('s_goods');
$(this).parents('.cart_list').find('.select_pro_i').css('background-position','0 -20px');
$(this).parents('.cart_list').children('.cart_good ').css('background','#fff6de');
setTotal();
}
});
//商品选择
$('.select_pro_i').on('click',function(){
if($(this).hasClass('s_goods')){
$(this).removeClass('s_goods');
$(this).css('background-position','0 0');
$(this).parents('.cart_good ').css('background','#fff');
setTotal();
}
else{
$(this).addClass('s_goods');
$(this).css('background-position','0 -20px');
$(this).parents('.cart_good ').css('background','#fff6de');
setTotal();
}
});
// 删除框
// $('.detele_all_i').on('click',function(){
// if($(this).hasClass('s_all')){
// $(this).removeClass('s_all');
// $(this).css('background-position','0 0');
// }
// else{
// $(this).addClass('s_all');
// $(this).css('background-position','0 -20px');
// }
// });
$('.detele_all').die().live('click',function(){
if( confirm("确定删除勾选的商品吗?") ){
$('#cart_heji').removeClass('cart_menu_fixNav');
$('.s_goods').each(function(){
var o_cartId = $(this).parents(".good_select").siblings(".good_num").find(".cart_id");
var o_itemId = $(this).parents(".good_select").siblings(".good_num").find(".item_id");
var o_itemSpec = $(this).parents(".good_select").siblings(".good_num").find(".item_spec");
var o_itemUnit = $(this).parents(".good_select").siblings(".good_num").find(".item_unit");
var o_itemColor = $(this).parents(".good_select").siblings(".good_num").find(".item_color");
var cartId = o_cartId.val();
var itemId = o_itemId.val();
var itemSpec = o_itemSpec.val();
var itemUnit = o_itemUnit.val();
var itemColor = o_itemColor.val();
var cartName = $(this).parents('.cart_good').siblings('.cart_list_til').attr('cartName');
var store = new ShoppingCartHelper(user_id, cartId,cartName);
store.Remove(itemId, itemSpec, itemUnit,itemColor);
var cart1 = store.Read();
if(cart1.Items.length == 0){
store.Clear();
}
$('.cart_refresh a').click();
});
var user_id = {$userId};
if (user_id > 0)
{
var shopping = new ShoppingCartList(user_id);
var list = shopping.Read();
var goods_count = 0;
$.each(list, function (n, id) {
var store = new ShoppingCartHelper(user_id, id);
if (store.Count() > 0)
{
var cart = store.Read();
$.each(cart.Items, function (n, item) {
goods_count++;
});
}
});
$('.good-num-count').text(goods_count);
$('#maycount').html(goods_count);
}
}
else
{
return;
}
});
function setTotal(){
var allTotalCount = 0;
var allTotalPrice = 0;
var comparePrice = 0;
$('.cart_list').each(function(){
var itemCount = $(this).find('.s_goods').length;
allTotalCount = accAdd(allTotalCount,itemCount);
$(this).find('#maycount').html(itemCount);
var totalPrice = 0;
$(this).find('.s_goods').each(function(){
totalPrice = accAdd(totalPrice,$(this).parent().siblings('.good_price').find('.hjval').html());
});
var storeComparePirce = 0;
$(this).find('.select_pro_i').each(function(){
comparePrice = accAdd(comparePrice,$(this).parent().siblings('.good_price').find('.hjval').html());
storeComparePirce = accAdd(storeComparePirce,$(this).parent().siblings('.good_price').find('.hjval').html());
});
$(this).find('.totalPrice').html(totalPrice.toFixed(2));
allTotalPrice = accAdd(allTotalPrice,totalPrice);
if(totalPrice < storeComparePirce){
$(this).find('.select_storeall_i').removeClass('s_store');
$(this).find('.select_storeall_i').css('background-position','0 0');
}
else if(totalPrice == storeComparePirce){
$(this).find('.select_storeall_i').addClass('s_store');
$(this).find('.select_storeall_i').css('background-position','0 -20px');
}
});
if(allTotalPrice < comparePrice){
$('.select_all_i').removeClass('s_all');
$('.select_all_i').css('background-position','0 0');
}
else if(allTotalPrice == comparePrice){
$('.select_all_i').addClass('s_all');
$('.select_all_i').css('background-position','0 -20px');
}
$('#maycountall').html(allTotalCount);
$('#allItemprice').html(allTotalPrice);
$('.allPrice').html(allTotalPrice);
}
/**
** 加法函数,用来得到精确的加法结果
** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
** 调用:accAdd(arg1,arg2)
** 返回值:arg1加上arg2的精确结果
**/
function accAdd(arg1, arg2) {
var r1, r2, m, c;
try {
r1 = arg1.toString().split(".")[1].length;
}
catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
}
catch (e) {
r2 = 0;
}
c = Math.abs(r1 - r2);
m = Math.pow(10, Math.max(r1, r2));
if (c > 0) {
var cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", "")) * cm;
} else {
arg1 = Number(arg1.toString().replace(".", "")) * cm;
arg2 = Number(arg2.toString().replace(".", ""));
}
} else {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", ""));
}
return (arg1 + arg2) / m;
}
});
$('.cart_refresh a').click();
$('.cart_tijiao a').on('click', function () {
if (confirm("您确定提交吗?") == true){
// var postPhone = $('#cr_tel').html();
// var address = $('#cr_address').html();
// var postAddress = address.substr(0, address.lastIndexOf('|'));
// var zipCode = address.substr(address.lastIndexOf('|') + 1);
// var remark = $('.cr_addressBeizhuInput').val();
//
// var shopping = new ShoppingCartList(user_id);
// var list = shopping.Read();
// var trade = new Trade();
// var specInfoArr = new Array();
// $('.s_goods').each(function(){
// var specInfo = $(this).attr('specIndex');
// specInfoArr.push(specInfo);
// });
// $.each(list, function (n, id) {
// var store = new ShoppingCartHelper(user_id, id);
// if (store.Count() > 0)
// {
// var cart = store.Read();
// var order = new Order();
// var count = 0;
// var totalPrice = 0;
// $.each(cart.Items, function (n, item) {
// var spInfo = cart.Id + '-' + item.Id + '-' + n;
// if($.inArray(spInfo,specInfoArr) > -1){
// var orderDtl = new OrderDtl();
// orderDtl.ProductId = item.Id;
// orderDtl.Standard = item.Spec;
// orderDtl.OriginalPrice = item.OriginalPrice;
// orderDtl.Color = item.Color;
// orderDtl.Price = item.Price;
// totalPrice = accAdd(totalPrice,item.Price*item.Count);
// orderDtl.Unit = item.Unit;
// orderDtl.Num = item.Count;
// order.detailes.push(orderDtl);
// count++;
// store.Remove(item.Id,item.Spec,item.Unit);
// }
// });
// order.factoryId = cart.Id;
// order.postName = postName;
// order.postPhone = postPhone;
// order.postAddress = postAddress;
// order.zipCode = zipCode;
// order.remark = remark;
// order.totalPrice = totalPrice;
// order.orderPrice = totalPrice;
// if(count > 0){
// trade.orders.push(order);
// }
// if(cart.Items.length == 0){
// store.Clear();
// }
// }
// });
var specInfos = "";
$('.s_goods').each(function(){
var specInfo = $(this).attr('specIndex');
if(specInfos == ""){
specInfos = specInfo;
}
else{
specInfos += "," + specInfo;
}
});
if (specInfos != "")
{
specInfos = base64encode(specInfos);
window.location.href = "confirmOrder.php?specArr=" + specInfos;
// var jsons = JSON.stringify(trade);
// $.post("api.php?act=pushTrade", {userProxyId: user_id, strJson: jsons}, function (data) {
// if (data == "_ok")
// {
// $('.cart_refresh a').click();
// location.href = "cart_ok.php";
// }
// else
// {
// alert(data);
// }
// });
}
else {
alert('购物车中没有找到可以下单的商品');
}
}
});
/**
** 加法函数,用来得到精确的加法结果
** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
** 调用:accAdd(arg1,arg2)
** 返回值:arg1加上arg2的精确结果
**/
function accAdd(arg1, arg2) {
var r1, r2, m, c;
try {
r1 = arg1.toString().split(".")[1].length;
}
catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
}
catch (e) {
r2 = 0;
}
c = Math.abs(r1 - r2);
m = Math.pow(10, Math.max(r1, r2));
if (c > 0) {
var cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", "")) * cm;
} else {
arg1 = Number(arg1.toString().replace(".", "")) * cm;
arg2 = Number(arg2.toString().replace(".", ""));
}
} else {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", ""));
}
return (arg1 + arg2) / m;
}
//数量加
$('.inc').live('click', function () {
var o_cartId = $(this).siblings(".cart_id");
var o_itemId = $(this).siblings(".item_id");
var o_itemSpec = $(this).siblings(".item_spec");
var o_itemUnit = $(this).siblings(".item_unit");
var o_itemColor = $(this).siblings(".item_color");
var o_count = $(this).siblings(".num");
var cartId = o_cartId.val();
var itemId = o_itemId.val();
var itemSpec = o_itemSpec.val();
var itemUnit = o_itemUnit.val();
var itemColor = o_itemColor.val();
if (o_count.val() < 1000)
{
o_count.val(parseInt(o_count.val()) + 1);
var store = new ShoppingCartHelper(user_id, cartId);
store.Change(itemId, itemSpec, itemUnit,itemColor, o_count.val());
}
$('.cart_refresh a').click();
});
//数量减
$('.dec').live('click', function () {
var o_cartId = $(this).siblings(".cart_id");
var o_itemId = $(this).siblings(".item_id");
var o_itemSpec = $(this).siblings(".item_spec");
var o_itemUnit = $(this).siblings(".item_unit");
var o_itemColor = $(this).siblings(".item_color");
var o_count = $(this).siblings(".num");
var cartId = o_cartId.val();
var itemId = o_itemId.val();
var itemSpec = o_itemSpec.val();
var itemUnit = o_itemUnit.val();
var itemColor = o_itemColor.val();
if (o_count.val() > 1)
{
o_count.val(parseInt(o_count.val()) - 1);
var store = new ShoppingCartHelper(user_id, cartId);
store.Change(itemId, itemSpec, itemUnit,itemColor, o_count.val());
}
$('.cart_refresh a').click();
});
//删除
$('.good_del a').live('click', function () {
if( confirm("确定删除此商品吗?") ){
var o_cartId = $(this).parents(".good_del").siblings(".good_num").find(".cart_id");
var o_itemId = $(this).parents(".good_del").siblings(".good_num").find(".item_id");
var o_itemSpec = $(this).parents(".good_del").siblings(".good_num").find(".item_spec");
var o_itemUnit = $(this).parents(".good_del").siblings(".good_num").find(".item_unit");
var o_itemColor = $(this).parents(".good_del").siblings(".good_num").find(".item_color");
var cartId = o_cartId.val();
var itemId = o_itemId.val();
var itemSpec = o_itemSpec.val();
var itemUnit = o_itemUnit.val();
var itemColor = o_itemColor.val();
var cartName = $(this).parents('.cart_good').siblings('.cart_list_til').attr('cartName');
var store = new ShoppingCartHelper(user_id, cartId,cartName);
store.Remove(itemId, itemSpec, itemUnit,itemColor);
var cart1 = store.Read();
if(cart1.Items.length == 0){
store.Clear();
}
$('.cart_refresh a').click();
var user_id = {$userId};
if (user_id > 0)
{
var shopping = new ShoppingCartList(user_id);
var list = shopping.Read();
var goods_count = 0;
$.each(list, function (n, id) {
var store = new ShoppingCartHelper(user_id, id);
if (store.Count() > 0)
{
var cart = store.Read();
$.each(cart.Items, function (n, item) {
goods_count++;
});
}
});
$('.good-num-count').text(goods_count);
$('#maycount').html(goods_count);
}
}
});
});
</script>
<!-- <script type="text/javascript">
function loadCart(user_id) {
var goods_count = 0;
var shopping = new ShoppingCartList(user_id);
var list = shopping.Read();
$.each(list, function (n, id) {
var store = new ShoppingCartHelper(user_id, id);
if (store.Count() > 0)
{
var cart = store.Read();
$.each(cart.Items, function (n, item) {
goods_count++;
});
}
});
$('.good-num-count').text(goods_count);
}
</script>-->
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xuqipeter/pdw.git
git@gitee.com:xuqipeter/pdw.git
xuqipeter
pdw
品贷网
master

搜索帮助