<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="goodsview.aspx.cs" Inherits="TW.UI.goodsview" %>

<!DOCTYPE html>
<html>
<head lang="en">
	<meta name="keywords" content=""/>
	<meta name="description" content=""/>
	<meta http-equiv=X-UA-Compatible content=IE=EmulateIE9 />
	<script type="text/javascript" src="/static/card/js/configweb.js"></script>
	<title><%=gdstit %>_<%=config.SiteName %></title>
	<link rel="stylesheet" href="/static/card/css/public.css" />
    <link rel="stylesheet" href="/static/card/css/trade.css" />
    <script type="text/javascript" src="/static/card/js/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="/static/card/js/tools.js"></script>
    <script type="text/javascript" src="/static/card/js/jquery.downCount.js"></script>

    
<meta charset="utf-8">
</head>

<body>
<asp:PlaceHolder ID="phScript" runat="server">
<script type="text/javascript">
    var protype = <%=tgdsprotype %>;
    $(function () {
        $("#goodsInfoGameListDivId span").click(function () {
            var goodsId = $(this).attr("value");
            location.href = "/goodsview.aspx?id=" + goodsId;
        });
        $("#goodsNum").bind("input propertychange", function () {
            var goodsNum = $("#goodsNum").val();
            if (isNaN(goodsNum) || goodsNum < 1) {
                goodsNum = 1;
            }
            limitnum(goodsNum,<%=id %>);
        });
        <%if(actvtime != ""){ %>
        $('.countdown').downCount({
            date: '<%=actvtime %>',
            offset: +8
        }, function () {
    
        });
        <%} %>
    
    });
    function checkCanBuy() {
        var goodsNum = $("#goodsNum").val();
        if (isNaN(goodsNum) || goodsNum < 1) {
            goodsNum = 1;
            $("#goodsNum").val(goodsNum);
            alert("数量至少为1");
            $("#goodsNum").focus();
            return false;
        }
        
        $.ajax({
            type:"post",
            dataType:"json",
            url: "/ajax/ajax.aspx?act=buygds&gdsid=<%=id %>&num="+goodsNum,
            success:function(a){
                if (!a.login) {
                    alert("您未登录，请登录");
                    $(".shade").show();
                    return false;
                }else if (!a.numerror) {
                    alert(a.msg);
                    $("#goodsNum").focus(a.correctnum);
                    return false;
                }else if (!a.flag){
                    alert(a.msg);
                    return false;
                }else if(a.flag){
                    $("#myForm").submit();
                }
            },
            error: function (e) {
                alert(e.responseText);
            }
        });
    }
    function goodsSub() {
        var goodsNum = $("#goodsNum").val();
        if (isNaN(goodsNum) || goodsNum<1) {
            goodsNum = 1;
        }
        goodsNum = parseInt(goodsNum);
        if (goodsNum>1) {
            goodsNum = goodsNum - 1;
        }
        $("#goodsNum").val(goodsNum);
    }
    function goodsAdd() {
        var goodsNum = $("#goodsNum").val();
        if (isNaN(goodsNum) || goodsNum < 1) {
            goodsNum = 1;
        }
        goodsNum = parseInt(goodsNum);
        goodsNum = goodsNum + 1;
        limitnum(goodsNum,<%=id %>);
    }
    function limitnum(goodsNum,id){
        $.ajax({
            type:"post",
            dataType:"json",
            url: "/ajax/ajax.aspx?act=limitnum&gdsid="+id,
            success:function(data){
                if (data.flag) {
                    if (goodsNum>data.num) {
                        alert("最大数量不能超过"+data.num);
                        goodsNum=data.num;
                    }
                }
                $("#goodsNum").val(goodsNum);
    
            },
            error: function (e) {
                alert(e.responseText);
            }
        });
    }
    function close() {
        $(".shade").hide();
    }
    function poplogin() {
        var loginId = $.trim($("#loginId").val());
        if (loginId == "") {
            alert("请输入用户名");
            $("#loginId").focus();
            return false;
        }

        var password = $.trim($("#password").val());
        if (password == "") {
            alert("请输入密码");
            $("#password").focus();
            return false;
        }

        var vcode = $.trim($("#vcode").val());
        if (vcode == "") {
            alert("请输入验证码");
            $("#vcode").focus();
            return false;
        }
        $.ajax({
            type: "post",
            url: "/ajax/ajax.aspx?act=login&loginId=" + loginId + "&password=" + password + "&vcode=" + vcode,
            dataType: "json",
            timeout: 60 * 1000,
            success: function (a) {
                if (a.flag) {
                    window.location.href = "goodsview.aspx?id=<%=id %>";
                } else {
                    alert(a.msg);
                    $("#checkImg").click();
                    return false;
                }
            }
        });
    }
    function setFavorite(){
    	var gdsid = <%=id %>;
    	$.ajax({
			type : "post",
			url : "/ajax/ajax.aspx?act=addcollection",
			data : {
				gdsid : gdsid
			},
			dataType : "json",
			timeout: 60*1000,
			success : function(a) {
				if(a.flag){
					alert(a.msg);
            	}else{
                    if (!a.login) {
            		    alert(a.msg);
            		    $(".shade").show();
                    }else{
            		    alert(a.msg);
                    }
            	}
			}
		});
    }

</script>
</asp:PlaceHolder>
<div class="shade" style="display: ;">
    <div class="login-box-wrap">
        <div class="login-box-title">
            账户登录
            <a class="close" href="javascript:close();">X 关闭</a>
        </div>
        <ul class="login-form">
            <li>
                <label>用户名：</label>
                <div class="inp">
                    <i class="icon icon-login-user"></i>
                    <input class="input-text" type="text" placeholder="用户名" id="loginId" name="loginId">
                </div>
            </li>
            <li>
                <label>密码：</label>
                <div class="inp">
                    <i class="icon icon-login-pwd"></i>
                    <input class="input-text" type="password" placeholder="密码" id="password" name="password">
                </div>
            </li>
            <li>
                <label>验证码：</label>
                <div class="inp">
                    <input class="input-text check" type="text" id="vcode">
                    <img class="check-img" id="checkImg" src="/inc/GetCode.aspx" title="看不清？点击换张图片" onclick="this.src=this.src + '?';" border="0" style="cursor:pointer;display:;width:90px;height:40px;">
                </div>
            </li>
            <li>
                <label></label>
                <div class="inp pull-left">
                    <button type="button" class="default-btn login-btn" onclick="poplogin();">登录</button>
                </div>
            </li>
        </ul>
        <div style="text-align: center">
            <a href="/reg.aspx" target="_blank">免费注册</a>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a href="/getpass.aspx" target="_blank">忘记密码？</a>
        </div>
    </div>
</div>
<TW:Header ID="Header1" runat="server" />
<asp:Panel ID="pnShowBox" CssClass="content" runat="server">
    <div class="container clearfix">
        <!--商品图片 促销倒计时 -->
        <div class="goods-left pull-left">
            <div class="goods-img">
            <asp:Image ID="imgGds" runat="server" />
            </div>
            <asp:Panel ID="plCXEffect" CssClass="activity-time" runat="server" Visible="False">
                <span class="label" id=""><%=gdstypetit%>火热进行中</span>
                <span style="font-size: 20px;font-weight: bold">距<%=gdstypetit %>结束</span>
                <ul class="countdown">
                    <li>
                        <span class="hours">00</span>
                    </li>
                    <li class="seperator">:</li>
                    <li>
                        <span class="minutes">00</span>
                    </li>
                    <li class="seperator">:</li>
                    <li>
                        <span class="seconds">00</span>
                    </li>
                </ul>
            </asp:Panel>
            <asp:Panel ID="plCXNoEffect" CssClass="activity-time" runat="server" Visible="False">
                <span class="label disbaled">秒杀已结束</span>
            </asp:Panel>
        </div>
        <!--商品信息 -->
        <form id="myForm" action="order.aspx" method="post" class="easyui-form"">
        <input type="hidden" id="stocknum" name="stocknum" value="<%=stocknum %>"/>
        <input type="hidden" id="ptmaxnum" name="ptmaxnum" value="<%=config.ProSglBuyMaxNum_PT %>"/>  
        <input type="hidden" id="cxmaxnum" name="cxmaxnum" value="<%=config.ProSglBuyMaxNum_CX %>"/>  
        <input type="hidden" id="cxmaxnum" name="cxmaxnum" value="<%=config.ProSglBuyMaxNum_MS %>"/>
        <div class="goods-right pull-left">
            <div class="goods-info">
                <h1><asp:Literal ID="litGdsTit" runat="server"></asp:Literal></h1>
                <div class="price-box">
                    <p class="goods-no">商品编码：<asp:Literal ID="litGdsNo" runat="server"></asp:Literal></p>
                    <p class="price">
                        VIP价：<span>￥<asp:Literal ID="litVIPPrice" runat="server"></asp:Literal></span>
                    </p>
                    <p class="price">
                        <asp:Literal ID="litBuyPrcTit" runat="server"></asp:Literal>：<span>￥<asp:Literal ID="litPTPrice" runat="server"></asp:Literal></span>
                        <del>原价：￥<asp:Literal ID="litOrgPrice" runat="server"></asp:Literal></del>
                    </p>
                </div>
                <ul class="goods-select-form">
                    <li class="clearfix">
                        <label>购买面值：</label>
                        <div class="select-box clearfix" id="goodsInfoGameListDivId">
                            <asp:Repeater ID="Repeater1" runat="server">
                            <ItemTemplate>
		                   	<span class="par<%#Convert.ToInt32(Eval("Id")) == id ? " current" : ""%>" value="<%#Eval("Id")%>"><%#Convert.ToInt32(Eval("Id")) == id ? " <i class='icon icon-select-orange'></i>" : ""%><%#Eval("ParVal")%></span>
                            </ItemTemplate>
                            </asp:Repeater>
					   		
                        </div>
                        <asp:Literal ID="litFeeStr" runat="server"></asp:Literal>
                        
                    </li>
                    <li class="clearfix">
                        <label>购买数量：</label>
                        <div class="select-box">
                            <a href="javascript:goodsSub();" class="operation-btn minus-btn"></a>
                            <input type="hidden" id="goodsid" name="goodsid" value="<%=id %>"/>
                            <input type="text" id="goodsNum" name="goodsNum" class="input-text value-text" value="1" />
                            <a href="javascript:goodsAdd();" class="operation-btn add-btn"></a>
                            &nbsp;&nbsp;&nbsp;&nbsp;库存：<asp:Literal ID="litGdsStockNum" runat="server"></asp:Literal>
                        </div>
                    </li>
                    <li class="clearfix">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <div class="check-icon">
                            <i class="icon icon-checked-green"></i>
                        </div>
                        &nbsp;&nbsp;
                        <span>同意<a href="<%=config.BuyFWTKUrl %>" target="_blank">“服务条款”</a>和<a href="<%=config.BuyYSUrl %>" target="_blank">“隐私相关政策”</a></span>
                    </li>
                    <li class="clearfix">
                        <asp:PlaceHolder ID="phBuy" runat="server">
                        <button type="button" class="default-btn buy-btn" onclick="checkCanBuy();">立即购买</button>
                        </asp:PlaceHolder>
                        <asp:PlaceHolder ID="phCollect" runat="server" Visible="False">
                        <button type="button" class="default-btn shopCar-btn" onclick="setFavorite();">收藏商品</button>
                        </asp:PlaceHolder>
                    </li>
                    <li class="clearfix">
                        <p style="color: #ea4444;margin-top: 20px;">如购买过程中遇到问题，请致电服务电话：<%=config.Phone %></p>
                    </li>
                </ul>
            </div>
        </div>
        </form>
        <!--商品简介 -->
        <div class="goods-description">
            <ul class="tab-ul clearfix">
                <li class="current">商品简介</li>
                <li>购买咨询</li>
            </ul>
            <div class="tab-div" style="display: block">
                <div class="des-wrap">
                    <ul class="clearfix">
                        <li>商品名称：<%=gdstit %></li>
                        <li>商品编号：<asp:Literal ID="litDesGdsNo" runat="server"></asp:Literal></li>
                        <li>类别：<asp:Literal ID="litDesGdsRcgType" runat="server"></asp:Literal></li>
                    </ul>
                </div>
                <div class="operator">
                    游戏描述：<br/>
                    <asp:Literal ID="litProContent" runat="server"></asp:Literal>
                </div>
            </div>
            <div class="tab-div">
                <asp:Literal ID="litBuyAdviso" runat="server"></asp:Literal>
            </div>
        </div>
    </div>
</asp:Panel>
<asp:Panel ID="plNoAdded" CssClass="content" runat="server" Visible="False">
    <div class="container clearfix">
        <div class="error-div">
            <div class="error-info">
                <h2>该商品已下架</h2>
                <div class="btn-group">
                    <button class="default-btn pull-left" type="button" onclick="javascript:history.back(-1);">返回上一页</button>
                    <button class="default-btn pull-right" type="button" onclick="javascript:window.location.href='/'">返回首页</button>
                </div>
            </div>
        </div>
    </div>
</asp:Panel>
<TW:Footer ID="Footer1" runat="server" />
</body>


