<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $P["P_title"];?>-<?php echo $webtitle;?></title>
    <meta name="keywords" content="<?php echo $keyword;?>">
    <meta name="description" content="<?php echo $description;?>">
    <link rel="shortcut icon" type="image/x-icon" href="../media/<?php echo $ico;?>">
    <script src="template/s5/static/js/jquery.min.js"></script>
    <script src="template/s5/static/js/message.min.js"></script>
    <link href="template/s5/static/css/message.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        body{background:url('template/s5/static/images/background.png')}
        .main{width: 100%;max-width: 1200px;margin:0 auto;}
        .shop_img{width: 60px;height:60px;border-radius: 60px;background: #fff;vertical-align:top;border: solid 2px #EEE}
        .header{padding:10px 0;}
        .shopinfo{display: inline-block;margin-left: 20px;}
        .shop_title{font-size: 16px;font-weight: bold;color: #545454;margin-bottom: 10px;margin-top: 5px}
        .contact_info{font-size: 14px;color: #999}
        .contact_btn{padding: 2px 10px;border-radius: 10px;border:solid 1px #492DD9;background: #492DD9;color: #fff;font-size: 12px;display: inline-block;box-shadow: 0 2px 3px 0 rgba(73, 45, 217,.22);text-decoration: none;cursor: pointer;}
        .contact_btn:hover{background: #fff;color: #492DD9;}
        .right{float: right;}
        .rbtn1{border:solid 1px #492DD9;background: #492DD9;color: #fff;font-size: 15px;border-radius: 20px;padding: 5px 15px;display: inline-block;margin-right: 10px;box-shadow: 0 5px 6px 0 rgba(73, 45, 217,.22);cursor: pointer;text-decoration: none}
        .rbtn1:hover{background: #fff;color: #492DD9;}
        .rbtn2{border:solid 1px #E4E2FA;background: #E4E2FA;color: #492DD9;font-size: 15px;border-radius: 20px;padding: 5px 15px;display: inline-block;box-shadow: 0 5px 6px 0 rgba(73, 45, 217,.22);cursor: pointer;}
        .rbtn2:hover{background: #fff;color: #492DD9;}
        .notice{margin-top: 20px;line-height: 25px;}
        .ntitle{color: #545454;font-size: 14px;font-weight: 700;}
        .ninfo{font-size: 12px;color: #515a6e}
        .box{background: #fff;border-radius: 10px;min-height: 100px;padding: 20px 30px;box-shadow: 0 7px 29px 0 rgba(18,52,91,.11);margin-top: 20px}
        .btitle{color: #545454;font-size: 16px;font-weight: 700;}
        .btitle img{margin-right: 7px;width: 17px;vertical-align: top;margin-top: 3px;}


        @media screen and (min-width: 768px) { 
        .sort_active{width: calc(25% - 10px);height: 68px;border-radius: 7px;background: url("template/s5/static/images/bg2.png");color:#fff;padding: 14px;display: inline-block;margin-right: 10px;position: relative;overflow: hidden;box-sizing: border-box;box-shadow: 0 5px 6px 0 rgba(73, 45, 217,.22);}
        .sort{width: calc(25% - 10px);height: 68px;border-radius: 7px;background: #f8f8f8;color:#333;padding: 14px;display: inline-block;margin-right: 10px;overflow: hidden;box-sizing: border-box;text-decoration: none}
        .product_active{width: calc(25% - 10px);height: 68px;border-radius: 7px;padding: 14px;display: inline-block;margin-right: 10px;position: relative;border:solid 2px #492DD9;overflow: hidden;color: #492DD9;box-sizing: border-box;box-shadow: 0 4px 10px 0 rgba(135,142,154,.14);}
        .product{width: calc(25% - 10px);height: 68px;border-radius: 7px;color:#333;padding: 14px;display: inline-block;margin-right: 10px;border:2px solid #f1f4fb;overflow: hidden;box-sizing: border-box;box-shadow: 0 4px 10px 0 rgba(135,142,154,.14);}
        }

        @media screen and (max-width: 768px) { 
        .sort_active{width: calc(50% - 10px);height: 68px;border-radius: 7px;background: url("template/s5/static/images/bg2.png");color:#fff;padding: 14px;display: inline-block;margin-right: 10px;position: relative;overflow: hidden;box-sizing: border-box;box-shadow: 0 5px 6px 0 rgba(73, 45, 217,.22);}
        .sort{width: calc(50% - 10px);height: 68px;border-radius: 7px;background: #f8f8f8;color:#333;padding: 14px;display: inline-block;margin-right: 10px;overflow: hidden;box-sizing: border-box;text-decoration: none}
        .product_active{width: 100%;height: 68px;border-radius: 7px;padding: 14px;display: inline-block;margin-right: 10px;position: relative;border:solid 2px #492DD9;overflow: hidden;color: #492DD9;box-sizing: border-box;box-shadow: 0 4px 10px 0 rgba(135,142,154,.14);}
        .product{width: 100%;height: 68px;border-radius: 7px;color:#333;padding: 14px;display: inline-block;margin-right: 10px;border:2px solid #f1f4fb;overflow: hidden;box-sizing: border-box;box-shadow: 0 4px 10px 0 rgba(135,142,154,.14);}
        }
        .sort_active .fl_img{width: 50px;position: absolute;right: -5px;bottom:-17px;}
        .sort_title{font-size: 14px;font-weight: bold;margin-bottom: 5px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
        .sort_info{font-size: 12px;opacity:0.6}
        .product_active .fl_img{width: 20px;position: absolute;right:0;bottom:0;}
        .product_title{font-size: 12px;margin-bottom: 7px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
        .product_info{font-size: 12px;font-weight: bold;}
        .hr{border-bottom: solid 1px #f7f7f7;margin-top: 30px;margin-bottom: 30px}

        .pcontent{margin: 10px 0;}
        .pcontent img{width: 100%;display: inherit;}

        .pay_box{width: 150px;height: 50px;border-radius: 7px;color:#333;display: inline-block;margin-right: 10px;border:solid 2px #EEE;overflow: hidden;box-sizing: border-box;background: #f7f7f7;font-size: 12px;text-align: center;line-height: 50px;cursor:pointer;position: relative;}
    .checked{border: solid 2px #492DD9 !important; background: #F8F8FE !important; color: #492DD9 !important;}
    .checked_img{width: 20px;position: absolute;right:0;bottom:0;}
    .pay_box input[type="radio"] {
        display: none;
    }
    .pay_pic{width: 20px;margin-bottom: -5px}

    .card7 {
        width:100%;
        text-align:center;
        color:#999;
        font-size:12px;
    }
    .card7 div {
        letter-spacing:1px;
    }

    .card7 a,#card7_xb .card7 a:link {
        color:#492DD9
    }
    .bottom{height: 62px;width: 100%;position: fixed;left: 0px;bottom: 0px;z-index: 999;background: #fff;box-shadow: 0 -1px 0 0 hsla(0,0%,71%,.18);}
    .buy_btn{background: #492DD9;color: #fff;border-radius: 20px;border:solid 2px #492DD9;float: right;padding: 10px 30px;margin-top: 10px;font-size: 14px;cursor: pointer;margin-right: 10px}
    .buy_btn:hover{background: #fff;color: #492DD9;}
    .buy_btn2{background: #EEEEEE;color: #666;border-radius: 20px;border:solid 2px #DDDDDD;float: right;padding: 10px 30px;margin-top: 10px;font-size: 14px;cursor: pointer;margin-right: 10px}
    .bprice{display: inline-block;float: right;margin-top: 15px;margin-right: 20px;font-size: 14px;font-weight: bold;color: #545454}
    .bprice span{font-size: 22px;color:#492DD9 }
    .clac{font-size: 15px;display: inline-block;font-weight: bold;width: 30px;height:30px;line-height:30px;text-align: center;vertical-align: top;cursor: pointer; user-select:none;border:solid 2px #EEE;border-radius: 30px;background: #f7f7f7;margin: 0 10px;color: #999;cursor: pointer;}
    .clac:hover{background: #EEE}
    </style>

</head>
<body>
<form id="form">
<input type="hidden" value="<?php echo $id?>" name="id">
<input type="hidden" value="<?php echo "card".date("Ymdhmi").rand(11111,99999)?>" name="no">
<div class="main">
    <div class="header">
        <img src="../media/<?php echo $logo;?>" class="shop_img">
        <div class="shopinfo">
            <div class="shop_title"><?php echo $webtitle;?> <a class="contact_btn"
                href="<?php 
                            switch($maincontact){
                                case 0:
                                    echo "http://wpa.qq.com/msgrd?v=3&uin=".$qq."&site=qq&menu=yes";
                                break;
                                case 1:
                                    echo "javascript:Qmsg.info('卖家手机号码：".$mobile."',{})";
                                break;
                                case 2:
                                    echo "javascript:Qmsg.loading('<p style=\'text-align:center;margin-bottom:20px\'>使用微信扫码联系卖家</p><p><img src=\'../media/".$wechatcode."\' style=\'width:200px\'></p>',{html:true,showClose:true})";
                                break;
                            }
                            ?>"

                >在线咨询</a></div>
            <div class="contact_info">
                        <?php
                            switch($maincontact){
                                case 0:
                                    echo "<span>卖家QQ：".$qq."</span>";
                                break;
                                case 1:
                                    echo "<span>卖家手机号码：".$mobile."</span>";
                                break;
                                case 2:
                                    echo "<span>卖家微信：".$wechat."</span>";
                                break;
                            }
                        ?>
                    </div>
        </div>
        <div class="right">
            <a class="rbtn1" href="query.php"><i class="fa fa-search"></i> 查询订单</a>
            <div class="rbtn2"><i class="fa fa-warning"></i> 投诉订单</div>
        </div>
        <div class="notice">
            <div class="ntitle"><img src="template/s5/static/images/notice.png" style="width:12px;"> 店铺公告</div>
            <div class="ninfo"><?php echo $notice;?></div>
        </div>
    </div>
    <div class="box">
        <div class="btitle">
            <img src="template/s5/static/images/sort.png"> 选择分类
        </div>

        <div style="margin-top:20px">
            <?php
                $list=getlist("select * from sl_psort where S_mid=".$P["P_mid"]." and S_on=1 and S_del=0 order by S_order asc,S_id desc");
                foreach($list as $row){
                    $P_count=getrs("select count(P_id) as P_count from sl_product where P_mid=".$P["P_mid"]." and P_sort=".$row["S_id"]." and P_del=0 and P_sh=1 and P_on=1","P_count");
                      if($row["S_id"]==$P["P_sort"]){
                          echo "<div class=\"sort_active\">
                                    <img src=\"template/s5/static/images/checked2.png\" class=\"fl_img\">
                                    <div class=\"sort_title\">".$row["S_title"]."</div>
                                    <div class=\"sort_info\">包含".$P_count."种商品</div>
                                </div>";
                      }else{
                          $P_id=getrs("select * from sl_product where P_del=0 and P_sh=1 and P_on=1 and P_sort=".$row["S_id"]." order by P_order asc,P_id desc","P_id");
                          if($P_id==""){
                          }else{
                              if($C_html==1){
                                  $url=$P_id;
                              }else{
                                  $url="?id=".$P_id;
                              }

                              echo "<a class=\"sort\" href=\"".$url."\">
                                        <div class=\"sort_title\">".$row["S_title"]."</div>
                                        <div class=\"sort_info\">包含".$P_count."种商品</div>
                                    </a>";

                          }
                          
                      }
                }
            ?>
        </div>
        <div class="hr"></div>

        <div>
            <div class="btitle">
                <img src="template/s5/static/images/product.png"> 选择商品
            </div>
                <div style="margin-top:20px">
                    <?php
                            $list=getlist("select * from sl_product where P_sort=".$P["P_sort"]." and P_del=0 and P_sh=1 and P_on=1 and P_mid=".$P["P_mid"]." order by P_order asc,P_id desc");
                            foreach($list as $row){
                                if($row["P_selltype"]==0){
        $r="<div style=\"color:#090;background:#EEFFEE;display:inline-block;padding:2px 5px;\"><div><span>库存充足</span></div></div>";
    }else{
        $r="<div style=\"color:#fb636b;background:#ffebe8;display:inline-block;padding:2px 5px;\"><div><span>剩余".get_json_num($row["P_card"],"sell","0")."件</span></div></div>";
    }

    if($row["P_id"]==$id){
        echo "<div class=\"product_active\">
                        <img src=\"../media/".$row["P_pic"]."\" style=\"width:68px;height:68px;margin:-14px 10px 14px -14px\">
                        <div style=\"display: inline-block;vertical-align: top;width:calc(100% - 70px)\">
                            <div class=\"product_title\">".$row["P_title"]."</div>
                            <div class=\"product_info\">￥ ".$row["P_price"]." ".$r."</div>
                        </div>
                        <img src=\"template/s5/static/images/checked.png\" class=\"fl_img\">
                        
                    </div>";
    }else{
        if($C_html==1){
              $url=$row["P_id"];
          }else{
              $url="?id=".$row["P_id"];
          }
                                          
        echo "<a class=\"product\" href=\"".$url."\">
                        <img src=\"../media/".$row["P_pic"]."\" style=\"width:68px;height:68px;margin:-14px 10px 14px -14px\">
                        <div style=\"display: inline-block;vertical-align: top;width:calc(100% - 70px)\">
                            <div class=\"product_title\">".$row["P_title"]."</div>
                            <div class=\"product_info\">￥ ".$row["P_price"]." ".$r."</div>
                        </div>
                    </a>";
    }
}

    
                            ?>


                </div>
            </div>

            <div class="hr"></div>

            <div style="margin-bottom:20px">
                <div class="btitle">
                <img src="template/s5/static/images/intro.png"> 商品介绍
            </div>
                <div style="background:#f8f8f8;padding: 20px;color: #888;font-weight: bold;font-size: 12px;margin-top: 10px;line-height: 20px;" id="content">
                    <?php echo str_replace("\r\n","<br>",htmlspecialchars($P["P_content"]));?>
                </div>
            </div>

            <div class="pcontent">
             <?php
                $p=explode("|",$P["P_piccontent"]);
                for($i=0;$i<count($p);$i++){
                    if($p[$i]!="" && $p[$i]!="nopic.png"){
                        echo "<img src=\"../media/".$p[$i]."\">";
                    }
                }
             ?>
            </div>   

    </div>

    <div class="box">
        <div class="btitle">
            <img src="template/s5/static/images/order.png"> 填写信息/购买方式
        </div>

        <div style="font-size:14px;color:#333;margin-top:20px;font-weight: bold;"><span style="color:#f00;margin-right: 10px;">*</span>请输入联系方式</div>
        <input type="text" name="address" placeholder="例如QQ、手机号、邮箱等" style="width:100%;max-width:500px;border:1px solid #ebebeb;border-radius: 5px;padding: 15px;margin-top: 20px;box-shadow: 0 4px 10px 0 rgba(135,142,154,.07);outline: none;">
                <div style="font-size: 12px;color:#999;margin-top:20px;padding-left:10px;display: block;">联系方式特别重要，可用来查询订单，如果填写的是邮箱，付款成功后商品自动发送到您的邮箱</div>

        <div style="font-size:14px;color:#999;margin-top:20px;font-weight: bold;">选择支付方式</div>
        <div style="margin-top: 20px;" class="pay_all">
            <?php
                if($P["P_mid"]==0 || $C_pay==1){
                    if($C_alipay_on==1){
                        echo "<label class=\"pay_box\"  aa=\"pay_type\">
                    <input type=\"radio\" value=\"alipay\" name=\"pay_type\">
                    <div>
                        <img src=\"template/s5/static/images/alipay.png\" class=\"pay_pic\">
                        <span>
                            支付宝
                        </span>
                    </div>
                </label>";
                    }
                    if($C_wxpay_on==1){
                        echo "<label class=\"pay_box\" aa=\"pay_type\">
                    <input type=\"radio\" value=\"wxpay\" name=\"pay_type\">
                    <div>
                        <img src=\"template/s5/static/images/wxpay.png\" class=\"pay_pic\">
                        <span>
                            微信支付
                        </span>
                    </div>
                </label>";
                    }
                }

                if($alipayon==1){
                    echo "<label class=\"pay_box\"  aa=\"pay_type\">
                    <input type=\"radio\" value=\"e_alipay\"  name=\"pay_type\">
                    <div>
                        <img src=\"template/s5/static/images/alipay.png\" class=\"pay_pic\">
                        <span>
                            支付宝
                        </span>
                    </div>
                </label>";
                }
                
                if($wxpayon==1){
                    echo "<label class=\"pay_box\" aa=\"pay_type\">
                    <input type=\"radio\" value=\"e_wxpay\" name=\"pay_type\">
                    <div>
                        <img src=\"template/s5/static/images/wxpay.png\" class=\"pay_pic\">
                        <span>
                            微信支付
                        </span>
                    </div>
                </label>";
                }
            ?>
        </div>

    </div>

    <div class="card7" style="padding:30px 0px 90px 0">
            <div><a href="http://beian.miit.gov.cn/" target="_blank"><?php echo $C_beian?></a></div>
            <div><?php echo $C_copyright?> | 技术支持：<a href="https://www.7-card.cn">发卡宝</a></div>
        </div>
</div>


<div class="bottom">
    <div class="main">

        <div style="margin-top: 15px;display: inline-block;">
            <div class="clac" id="minus"><i class="fa fa-minus"></i></div>
            <input type="number" name="amount" value="1" id="amount" style="width:50px;border:solid 2px #EEE;border-radius: 5px;padding: 8px;background: #f7f7f7;text-align: center;">
            <div class="clac" id="plus"><i class="fa fa-plus"></i></div>
        </div>


        <?php
        if($rest>0){
            echo "<div class=\"buy_btn\" onclick=\"pay(".$id.")\">确定订单</div>";
        }else{
            echo "<div class=\"buy_btn2\">暂时缺货</div>";
        }
        
        ?>


        <div class="bprice">支付金额：<span>￥<span id="price"><?php echo $P["P_price"];?></span></span></div>
    </div>
</div>
</form>
<script>
var $rest=<?php echo $rest?>;
var $price=<?php echo $P["P_price"];?>;
</script>
<script src="template/s5/static/js/main.js"></script>
</body>
</html>