123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="format-detection" content="telephone=no">
- <title>购物车</title>
- <link rel="stylesheet" href="/static/index/css/cart.css" />
- <link rel="stylesheet" href="/static/css/Font-Awesome/css/font-awesome.min.css">
- <link rel="stylesheet" href="/static/css/common.css" />
- <link rel="stylesheet" href="/static/index/css/cartStyle.css" />
- <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
- </head>
- <style>
- .cart2-middle-goods:last-child{
- margin-bottom: 10rem;
- }
- .cart2-bottom-total span{
- height: 3rem!important;
- line-height: 3rem!important;
- font-size: 0.95rem!important;
- }
- .cart2-bottom-total{
- height: 3rem!important;
- border-bottom: 0!important;
- }
- .base-price em,.base-price i{
- font-weight: bold;
- }
- .cart2-bottom-total em{
- font-size: 0.95rem!important;
- font-weight: bold;
- }
- .product_name{
- display: inline-block;
- width: 13.45rem;
- font-size: 0.9rem;
- color: #666;
- }
- .quantity {
- display: inline-block;
- min-width: 6.86rem;
- height: 2.24rem;
- background-color: #F5F5F5;
- float: right!important;
- border: 1px solid #ccc;
- text-align: center;
- line-height: 2.24rem;
- font-size: 1.09rem;
- border-radius: 0.08rem;
- }
- .quantity em:first-child {
- border-right: 1px solid #ccc;
- background: url('/static/images/minus1.svg') no-repeat center center;
- background-size: 1.51rem 1.51rem;
- background-color: #fff;
- /* background-size: contain; */
- float: left;
- cursor: pointer;
- background-size: 50% 100%;
- display: inline-block;
- width: 2.18rem;
- height: 100%;
- font-size: 1.09rem;
- letter-spacing: -0.06rem;
- color: #ff0000;
- justify-content: center;
- align-items: center;
- }
- .quantity em:last-child {
- border-left: 1px solid #ccc;
- background: url('/static/images/plus1.svg') no-repeat center center;
- background-size: 1.51rem 1.51rem;
- background-color: #fff;
- float: right;
- cursor: pointer;
- background-size: 50% 100%;
- display: inline-block;
- width: 2.18rem;
- height: 100%;
- font-size: 1.09rem;
- letter-spacing: -0.06rem;
- color: #ff0000;
- justify-content: center;
- align-items: center;
- }
- .cart2-middle .cart2-middle-goods .goods-right,.cart2-middle .cart2-middle-goods .goods-left{
- height: 6.3rem!important;
- }
- .base-price{
- line-height: 2.24rem;
- padding: 0.4rem;
- }
- .cart2-middle-goods .goods-left img{
- border-radius: 0!important;
- }
- .cart2-bottom-total .select{
- font-size: 0.95rem;
- }
- .cart2-bottom-total .pay{
- font-size: 0.9rem!important;
- }
- .cart2-middle{
- margin: 0!important;
- padding-bottom: 7rem;
- }
- .cart2-middle-goods .goods-right>span:nth-child(1) em{
- width: 3rem!important;
- height: 3rem!important;
- background-size: 1.5rem!important;
- }
- .cart2-bottom-nav{
- box-shadow: none;
- }
- .cart2-middle .cart2-middle-goods{
- border-top: 0!important;
- border-bottom: 1px solid #eee!important;
- }
- </style>
- <body>
- <div class="dialog" style="position: fixed;top: 0rem;width: 25rem;height: 56rem;background: rgba(0,0,0,0.2);z-index: 999;display: none"></div>
- <!--cart1购物车1页面-->
- <div class="cart1" style="display:block;">
- <!--<div class="cart1-top"></div>-->
- <div class="cart2-middle">
- </div>
- <div class="cart1-middle" style="display: none">
- <div class="cart1-middle-icon"><em></em></div>
- <div class="cart1-middle-tips">购物车空着呢,快去挑选商品吧</div>
- <div class="cart1-middle-btn"><a href="/index/index/commodity">去本店逛逛→</a></div>
- </div>
- <div class="cart1-bottom" style="box-shadow: 0 1px 4px rgba(55, 55, 55, 0.1);">
- <div class="cart2-bottom" style="margin-bottom: 3.8rem;">
- <div class="cart2-bottom-total">
- <span class="select selected"><em></em>全选</span>
- <span>商品合计:<em>¥<e class="total_price">0.00</e></em></span>
- <span class="pay" style="box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);">结算(<em class="count" style="color: #fff">0</em>)</span>
- </div>
- </div>
- </div>
- {include file='Index/footer'}
- </div>
- <ul style=" position: fixed;
- top: 14rem;
- left: 2rem;
- width: 21rem;
- height: 11rem;display: none;z-index: 10000;border-radius: 1rem;
- background: #fff;" class="dialogs">
- <li style=" text-align: center;
- height: 4rem;
- line-height: 4rem;border-top-left-radius: 1rem;
- border-top-right-radius: 1rem; color: #EB3E2D;">确定删除?</li>
- <li class="product-name" style=" width: 80%;
- margin-left: 10%;
- text-align: center;
- height: 4rem; "></li>
- <li style=" height: 3rem;">
- <p style="width: 50%;
- text-align: center;
- border-top: 1px solid #ccc;
- height: 3rem;
- line-height: 3rem;border-right: 1px solid #ccc;color: #EB3E2D;" data-action="1" class="chooses">确定</p>
- <p style=" width: 50%;
- float: right;
- position: relative;
- top: -3rem;
- text-align: center;
- height: 3rem;
- border-top: 1px solid #ccc;
- line-height: 3rem;" data-action="2" class="chooses">取消</p>
- </li>
- </ul>
- <script src="/static/index/js/common.js"></script>
- <script src="/static/layer/layer.js"></script>
- </body>
- </html>
- <script>
- $(".bot3").attr("src","/static/index/images/nav_icon33.png");
- $(".bottom3 span").css('color','#dc3b32');
- $(function(){
- // alert(11);
- $("span.select").trigger("click");
- });
- /*单击删除图标删除效果*/
- $(function(){
- var id;
- // var len = $('.cart2-middle').children('.cart2-middle-goods').length;
- $("body").on("click",".delete",function(){
- $('.dialog').show();
- $('.dialogs').show();
- var producNaem = $(this).parent().find('.product_name').html();
- $(".product-name").html(producNaem);
- id = $(this).data('id');
- });
- $(".chooses").click(function () {
- var action = $(this).data('action');
- var len = $('.cart2-middle').children('.cart2-middle-goods').length;
- if(action == 1){
- if(len == 1){
- $('.cart2-middle').hide();
- $('.cart1-bottom').hide();
- $('.cart1-middle').show();
- }
- $.ajax({
- url: '/index/OrderInterfaces/deleteCar',
- type: 'GET',
- async:false,
- data:{id:id},
- dataType:'json',
- success: function (res) {
- if(res.code==400){
- layer.msg("<span style='color: #fff'>"+res.msg+"</span>");
- setTimeout(function () {
- window.location.reload();
- },1000);
- }
- if(res.code == 200){
- layer.msg("<span style='color: #fff'>"+res.msg+"</span>");
- setTimeout(function () {
- window.location.reload();
- },1000);
- }
- }
- });
- }
- $('.dialog').hide();
- $('.dialogs').hide();
- })
- $.ajax({
- url: '/index/OrderInterfaces/car',
- type: 'GET',
- async:false,
- data:{},
- dataType:'json',
- success: function (res) {
- var html="";
- var data = res.data;
- // console.log(data);
- if(data.length == 0){
- $('.cart2-middle').hide();
- $('.cart1-bottom').hide();
- $('.cart1-middle').show();
- }else{
- $.each(data,function (i,v) {
- html+="<div class='cart2-middle-goods'>";
- html+="<div class='goods-left'>";
- html+="<em class='select selected'></em>";
- if(v.images!=null&&v.images!=""){
- $.each(v.images,function (is,vs) {
- if(is==0){
- html+="<img src={$host}"+vs+" alt='' />";
- }
- })
- }else{
- html+="<img src='' alt='' />";
- }
- html+="</div>";
- html+="<div class='goods-right'>";
- if(v.type_name==11){
- html+="<span><span class='product_name'>"+v.product_name+"</span><em class='delete' data-doctorno='"+v.doctor_no+"' data-id="+v.id+" data-productid="+v.product_id+"></em></span>";
- }else{
- html+="<span><span class='product_name'>"+"【"+v.type_name+"】"+v.product_name+"</span><em class='delete' data-doctorno='"+v.doctor_no+"' data-id="+v.id+" data-productid="+v.product_id+"></em></span>";
- }
- html+="<div class='base-price' style='width: 9rem;'><i style='font-size:0.9rem;line-height:2.24rem;color:#FE2A36;'>¥</i><em class='price' style='width: 8rem;font-size: 0.9rem;color:#FE2A36;'>"+v.sales_price+"</em></div>";
- html+="<span style='border:0;height: 0;'>";
- html+="<em class='hidePrice' hidden=''>"+v.sales_price+"</em>";
- html+="</span>";
- html+="</div>";
- html+="<div style='clear: both;'></div>";
- html+="<div style='padding:0.4rem 1rem;border-top: 1px solid #eee;overflow:hidden;'>";
- html+="<span class='quantity'><em class='minus'></em><i class='chooseNum'>"+v.number+"</i><em class='plus'></em></span>";
- html+="</div>";
- html+="</div>";
- })
- $('.cart2-middle').html(html);
- }
- }
- });
- })
- var arr = new Array();
- function car() {
- arr = new Array();
- var le = $('.selected').length;
- var total_price = 0;
- var count = 0;
- if(le!=0){
- for (var i=0 ;i<le;i++){
- var price = $('.selected').eq(i).parent().parent().find('.price').html();
- var coun = $('.selected').eq(i).parent().parent().find('.chooseNum').html();
- var id = $('.selected').eq(i).parent().parent().find('.delete').data('productid');
- var doctorNo = $('.selected').eq(i).parent().parent().find('.delete').data('doctorno');
- if(price != undefined){
- total_price = price*coun*1+total_price*1;
- total_price = total_price.toFixed(2);
- count = coun*1+count*1;
- arr[id]=coun+"/"+doctorNo+"/"+price;
- }
- }
- }
- var count = parseFormatNum(count,0);
- var trotal_price = parseFormatNum(total_price,2);
- $('.total_price').html(trotal_price);
- $('.count').html(count);
- }
- /*商品加减计件*/
- $(function(){
- car();
- var price;
- $("body").on("click",".plus",function(){
- price = $(this).parent().siblings(".hidePrice").text();
- var num = $(this).siblings("i").html();
- // if(num > 10 || num == 10){
- // layer.msg('单次购买不可超过10');
- // return false;
- // }
- num++;
- $(this).siblings("i").html(num);
- car();
- /*console.log(num);*/
- });
- $("body").on("click",".minus",function(){
- price = $(this).parent().siblings(".hidePrice").text();
- var num = $(this).siblings("i").html();
- if(num==1){
- return false;
- }
- num--;
- // $(this).parent().siblings(".price").html(num*price);
- $(this).siblings("i").html(num);
- car();
- });
- });
- /*点击选中效果*/
- $(function(){
- $('span.select').find('em').trigger('click');
- $("span.select").click(function(){
- if($(this).hasClass("selected")){
- $(".select").removeClass("selected");
- }else{
- $(".select").addClass("selected");
- }
- car();
- });
- $("em.select").click(function(){
- $(this).toggleClass("selected");
- if($("em.selected").length == $("em.select").length){
- $("span.select").addClass("selected");
- }else{
- $("span.select").removeClass("selected");
- }
- car();
- });
- });
- /**
- * 付款
- */
- $('.pay').click(function () {
- var total_price = $('.total_price').html();
- var count = $('.count').html();
- $.ajax({
- url: '/index/OrderInterfaces/insertOrder',
- type: 'GET',
- async:false,
- data:{total_price:total_price,arr:arr,count:count},
- dataType:'json',
- success: function (res) {
- if(res.code == 200){
- window.location.href="{:url('/index/order/orderDetail')}";//订单详情页面
- }else{
- layer.msg("<span style='color: #fff'>"+res.msg+"</span>");
- }
- }
- });
- console.log(arr);
- })
- // function checkcar() {
- // var len = $('.chooseNum').length;
- // for (var i = 0;i<len ;i++){
- // var num = $('.chooseNum').eq(i).html();
- // var nums = parseFormatNum(num,0);
- // $('.chooseNum').eq(i).html(nums);
- // }
- // }
- function parseFormatNum(number,n){
- if(n != 0 ){
- n = (n > 0 && n <= 20) ? n : 2;
- }
- number = parseFloat((number + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
- var sub_val = number.split(".")[0].split("").reverse();
- var sub_xs = number.split(".")[1];
- var show_html = "";
- for (i = 0; i < sub_val.length; i++){
- show_html += sub_val[i] + ((i + 1) % 3 == 0 && (i + 1) != sub_val.length ? "," : "");
- }
- if(n == 0 ){
- return show_html.split("").reverse().join("");
- }else{
- return show_html.split("").reverse().join("") + "." + sub_xs;
- }
- }
- </script>
|