<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <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/s1/static/js/jquery.min.js"></script>
	<script src="template/s1/static/js/message.min.js"></script>
    <link href="template/s1/static/css/message.css" rel="stylesheet">
    <link href="template/s1/static/css/main.css" rel="stylesheet">
</head>
<body style="background:#f7f7f7">
	<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">
			<div class="left">
				<img src="../media/<?php echo $logo;?>" class="shop_img">
				<div class="shop">
					<div class="shop_title"><?php echo $webtitle;?></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>
			<div class="right">
				<a class="btn1" 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>
				<a class="btn2" href="query.php">订单查询</a>
			</div>
		</div>

		<div class="body">
			<div style="margin-bottom:20px">
				<img src="template/s1/static/images/notice.png" style="width:16px;margin-right:5px;vertical-align:top">
	            <span style="font-weight: bold;">店铺公告：</span>
	            <marquee direction="left" style="background: #f9f9f9;padding:10px;border-radius:10px;color:#333;margin-top:10px;font-size: 12px;" onMouseOver="this.stop()" onMouseOut="this.start()"><?php echo $notice;?></marquee>
        	</div>
        	<div style="margin-bottom:20px">
            	<img src="template/s1/static/images/sort.png" style="width:16px;margin-right:5px;vertical-align:top">
            	<span style="font-weight: bold;">选择分类</span>
            	<div style="margin-top:10px">
            		<?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/s1/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>

        	<div style="margin-bottom:20px">
            	<img src="template/s1/static/images/product.png" style="width:16px;margin-right:5px;vertical-align:top">
            	<span style="font-weight: bold;">选择商品</span>
            	<div style="margin-top:10px">
            		<?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/s1/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 style="margin-bottom:20px">
            	<img src="template/s1/static/images/intro.png" style="width:16px;margin-right:5px;vertical-align:top">
            	<span style="font-weight: bold;">商品介绍</span>
            	<div style="background:#f7f7f7;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 style="margin-bottom:30px;margin-top:30px">
        		<span style="color: #f00;">*</span> <span style="font-weight: bold;">购买数量</span> <span style="font-size: 12px;color:#492DD9">(<?php echo $rest_title;?>)<span>
        		<div style="float: right;margin-top: -5px;">
        			<div class="clac" id="minus">-</div>
        			<input type="number" name="amount" value="1" id="amount" style="width:50px;border:solid 1px #CCC;border-radius: 5px;padding: 8px;background: #f7f7f7;text-align: center;">
        			<div class="clac" id="plus">+</div>
        		</div>
        	</div>
        	<div>
        		<div><span style="color: #f00;">*</span> <span style="font-weight: bold;">联系方式</span> </div>
        		<input type="text" name="address" placeholder="例如QQ、手机号、邮箱等" style="width:200px;float:right;margin-top:-25px;border:solid 1px #CCC;border-radius: 5px;padding: 8px;">
        		<div style="font-size: 12px;color:#999;margin-top:20px;padding-left:10px;display: block;">联系方式特别重要，可用来查询订单，如果填写的是邮箱，付款成功后商品自动发送到您的邮箱</div>
        	</div>
		</div>
	</div>
	<div class="main" style="margin-top:10px">
		<div class="body">
		<span style="font-weight: bold;">支付方式</span>
		<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/s1/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/s1/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/s1/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/s1/static/images/wxpay.png\" class=\"pay_pic\">
                        <span>
                            微信支付
                        </span>
                    </div>
                </label>";
                }
            ?>
		</div>
		</div>

		<div class="card7" style="padding:70px 0px">
            <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>

        <?php
        if($rest>0){
            echo "<div class=\"btn_buy\" style=\"height:50px\">
          <div class=\"to_pay\" onclick=\"pay(".$id.")\" style=\"cursor:pointer\">
              <span>支付 ￥<span id=\"price\">".$P["P_price"]."</span></span>
            </div>
        </div>";
        }else{
            echo "<div class=\"btn_buy\" style=\"height:50px\">
          <div class=\"to_pay\">
              <span>库存不足，等待补货</span>
            </div>
        </div>";
        }
        
        ?>

	</div>
</form>
<script>
var $rest=<?php echo $rest?>;
var $price=<?php echo $P["P_price"];?>;
</script>
<script src="template/s1/static/js/main.js"></script>
</body>
</html>