HOME Product SUPPORT ABOUT US Who We Are
Blog
Cooperation
News
Hubs Docking Station PD Power Charger Mouse Mouse Pad Sorry,there is no data on the page you visited!
Wired Venus Gaming Mouse User Manual Driver(EXE) Driver(RAR) Wireless VenusPro Gaming Mouse User Manual Driver(EXE) Driver(RAR) Sorry,there is no data on the page you visited!
'); }else{ for(var i in data) { //判断是否有规格 var skuStr = ''; if(data[i]['sku_id']>0){ var sku_arr = data[i]['sku_arr'];//数组 // console.log(sku_arr) for (var j in sku_arr) { skuStr +=sku_arr[j]['field'] +' : ' + sku_arr[j]['val'] + ''; } } str += '
'+ ' '+ ''+ ''+ data[i]['product_name'] + ' '+ //规格 '
'+skuStr+'
'+ '
'+ '
'+ ''+ ''+ ''+ '
'+ '$'+data[i]['price']+' '+ '
' '
'+ ' '; total_price+=Number(data[i]['amount'])*Number(data[i]['price']); } cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); localStorage.setItem('cartinfo',JSON.stringify(cartinfo)); $('#cartForm').html('
'); var priceBox = '
'+ '
'+ '
Subtotal '+ '
$'+ cartinfo.total_price+' '+ '
'+ '
Shipping, taxes, and discount codes calculated at checkout.
'+ ''+ '
'; $('#cartForm').append(priceBox); } $("#navbarCatr-collapse").addClass('animated fadeInRight').show(); }) $("#navbarCatr-collapse .close").click(function(){ $("#navbarCatr-collapse").hide(); }) //输入商品数量到购物车 $(document).on('blur','.amountInput',function(){ var liObj = $(this); var amount = liObj.val() var cartId = liObj.parent('.input').attr('data-id'); var product_id = liObj.prev().attr('data-productid'); var sku_id = liObj.prev().attr('data-skuid'); var cartinfo = localStorage.getItem('cartinfo'); cartinfo = JSON.parse(cartinfo); if(cartinfo==null || cartinfo == undefined){ cartinfo = new Object(); var data = []; var total_price = 0; var note = ''; }else{ var data = cartinfo.data; var total_price = cartinfo.total_price; var note = cartinfo.note; if(total_price==null || total_price==undefined){ total_price = 0; } if(note==null || note==undefined){ note = ''; } if(data==null || data==undefined){ data = [] ; } } $.ajax({ type: "post", dataType: "json", url: "/index/order/inputcart.html", data: { 'cartId':cartId, 'product_id': product_id, 'amount': amount, 'sku_id': sku_id, 'token':token }, success: function(result) { if(result.status==0){ //重新追加数据 cartinfo.data = result.data.cart; var total_price = result.data.total_price; cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); $('.total_price').text('$'+total_price.toFixed(2)); // alert(result.info); return; }else{ alert(result.info); window.location.reload(); return; } } }); })// localStorage.removeItem("data"); // localStorage.removeItem("total_price"); //增加购物车数量 $(document).on('click','.incNum',function(){ var token = localStorage.getItem('token'); var amount = parseInt($(this).prev().val()); var cartId = $(this).parent('.input').attr('data-id'); amount++; var product_id = $(this).attr('data-productid'); var sku_id = $(this).attr('data-skuid'); // console.log(sku_arr) // return false; // 重新获取数据 var cartinfo = localStorage.getItem('cartinfo'); cartinfo = JSON.parse(cartinfo); if(cartinfo==null || cartinfo == undefined){ cartinfo = new Object(); var data = []; var total_price = 0; var note = ''; }else{ var data = cartinfo.data; var total_price = cartinfo.total_price; var note = cartinfo.note; if(total_price==null || total_price==undefined){ total_price = 0; } if(note==null || note==undefined){ note = ''; } if(data==null || data==undefined){ data = [] ; } } total_price = Number(total_price); for(var i in data) { if(product_id==data[i]['product_id'] && sku_id==data[i]['sku_id']){ total_price += Number(data[i]['price']); data[i]['amount'] = amount;//更新数量 break; } } var memberid = 0; var liObj = $(this); // if(memberid>0){ $.ajax({ type: "post", dataType: "json", url: "/index/order/editcart.html", data: { 'cartId':cartId, 'product_id': product_id, 'amount': 1, 'sku_id': sku_id, 'type':1, 'token':token }, success: function(result) { if(result.status==0){ //重新追加数据 cartinfo.data = data; cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); $('.total_price').text('$'+total_price.toFixed(2)); liObj.prev().val(amount); // alert(result.info); return; }else{ alert(result.info); return; } } }); // }else{ // //重新追加数据 // cartinfo.data = data; // cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); // localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); // $('.total_price').text('$'+total_price.toFixed(2)); // // alert('Add to cart successfully'); // liObj.prev().val(amount); // } // 存储数据---不要 //重新追加数据 // cartinfo.data = data; // cartinfo.total_price = total_price.toFixed(2); // localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); // $('.total_price').text('$'+total_price.toFixed(2)); // alert('添加购物车成功'); // total_price }) // 减少购物车数量 $(document).on('click','.decNum',function(){ var token = localStorage.getItem('token'); var amount = parseInt($(this).next().val()); var cartId = $(this).parent('.input').attr('data-id'); amount--; var product_id = $(this).attr('data-productid'); var sku_id = $(this).attr('data-skuid'); // console.log(sku_arr) // 重新获取数据 var cartinfo = localStorage.getItem('cartinfo'); cartinfo = JSON.parse(cartinfo); if(cartinfo==null || cartinfo == undefined){ cartinfo = new Object(); var data = []; var total_price = 0; var note = ''; }else{ var data = cartinfo.data; var total_price = cartinfo.total_price; var note = cartinfo.note; if(total_price==null || total_price==undefined){ total_price = 0; } if(note==null || note==undefined){ note = ''; } if(data==null || data==undefined){ data = [] ; } } total_price = Number(total_price); for(var i in data) { if(product_id==data[i]['product_id'] && sku_id==data[i]['sku_id']){ total_price -= Number(data[i]['price']); data[i]['amount'] = amount;//更新数量 if(amount==0){ //清空商品 data.splice(i,1); } break; } } // console.log(data); // var memberid = 0; var liObj = $(this); // if(memberid>0){ $.ajax({ type: "post", dataType: "json", url: "/index/order/editcart.html", data: { 'cartId':cartId, 'product_id': product_id, 'amount': 1, 'sku_id': sku_id, 'type':2, 'token':token }, success: function(result) { if(result.status==0){ //重新追加数据 cartinfo.data = data; cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); $('.total_price').text('$'+total_price.toFixed(2)); if(amount==0){ liObj.parents('li').remove(); } if(data == [] || total_price<=0){ cartinfo.note = ''; cartinfo.data = []; //显示清空购物车 $('div#cartForm').html('
Your cart is currently empty, please go to the store to shop! '); } localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); liObj.next().val(amount); // alert(result.info); return; }else{ alert(result.info); return; } } }); // }else{ // //重新追加数据 // cartinfo.data = data; // cartinfo.total_price = cartinfo.allPrice = total_price.toFixed(2); // // localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); // $('.total_price').text('$'+total_price.toFixed(2)); // // alert('Add to cart successfully'); // if(amount==0){ // $(this).parents('li').remove(); // } // if(data == [] || total_price<=0){ // cartinfo.note = ''; // cartinfo.data = []; // //显示清空购物车 // $('div#cartForm').html('
Your cart is currently empty, please go to the store to shop! '); // } // localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); // liObj.next().val(amount); // } // 存储数据--不要 //重新追加数据 // cartinfo.data = data; // cartinfo.total_price = total_price.toFixed(2); // localStorage.setItem('cartinfo', JSON.stringify(cartinfo)); // $('.total_price').text('$'+total_price.toFixed(2)); // if(amount==0){ // $(this).parents('li').remove(); // } // if(data == [] || total_price<=0){ // //显示清空购物车 // $('div#cartForm').html('
Your cart is currently empty, please go to the store to shop! '); // } // alert('添加购物车成功'); }) $(document).on('click','.cart__checkout',function(){ var note = $('textarea[name="note"]').val(); var len = note.length; if(len>0){ if(note.length<15){ alert("Order note can’t less than 15 characters."); return false; }else if(note.length>4000){ alert("Order note can’t more than 4000 characters."); return false; } } var cartinfo = localStorage.getItem('cartinfo'); cartinfo = JSON.parse(cartinfo); if(cartinfo==null || cartinfo == undefined){ cartinfo = new Object(); } cartinfo.note = note; cartinfo.ordertype = 2; localStorage.setItem('cartinfo',JSON.stringify(cartinfo)); window.location.href="/index/shoporder/information.html"; })