<!--#include file="General.inc.asp"-->
<%
'on error resume next
strCart = Request.Cookies("Joyes_ShopCart")&""
strCount = Request.Cookies("Joyes_ShopCount")&""
if strCart&""<>"" and right(strCart,1)="," then strCart = left(strCart,len(strCart)-1)
if strCount&""<>"" and right(strCount,1)="," then strCount = left(strCount,len(strCount)-1)
newCart = ""
newCount = ""
bRefresh = false
set rs = server.createobject("adodb.recordset")
%>

<html>

<head>
<title>商品购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="robots" content="all">
<script language="javascript" src="../js/Joyes_Shop.js"></script>
<link href="../css/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function scroll()
{
	window.resizeTo(600,400);
	setTimeout("scroll();",6000);
}
</script>
</head>

<body leftmargin="0" topmargin="2" onload="scroll();">
<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCC99" align="center">
  <tr>
	<td align="center" height="25" bgcolor="#F2F2D3"><font color="#996600" style="font-size:14px;font-weight:bold">商品购物车</font></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF" valign="top">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td bgcolor="#FFFFFF" valign="top" height="100%" valign="top">
			<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D6D6C0">
			  <form name="CartForm" action="SaveCount.asp" method="post">
			  <input type="hidden" name="uid" value="<%=Request("uid")%>">
			  <input type="hidden" name="cid" value="<%=Request("cid")%>">
              <tr bgcolor="#EFEFE7" height="22"> 
                <td align="center" nowrap>编号</td>
                <td align="center" nowrap>商品名称</td>
                <!--<td align="center" nowrap>市场价</td>-->
                <td align="center" nowrap>价　格</td>
                <td align="center">数　量</td>
                <td align="center">金　额</td>
                <!--<td align="center" nowrap>资料</td>-->
                <td align="center" nowrap>删除</td>
			  </tr>
			  <%
			  totalmoney = 0
			  strcode = ""
			  strmoney = ""
			  iCount = 0
			  for cart_index=0 to ubound(split(strCart,","))
			  if split(strCart,",")(cart_index)&""<>"" then
			  rs.open "select a.MobileID,MobileName,OutPrice,JoyesPrice,b.ClassName from Mobile a,MobileClass b where a.MobileID='" & split(strCart,",")(cart_index) & "' and a.IsShow=1 and b.ClassCode=a.ClassCode and b.isshow=1 order by left(b.ClassCode,2) asc,b.ClassOrder asc,b.ClassCode asc,a.MobileOrder asc,a.MobileID desc",conn,1,1
			  if not rs.eof then
			  newCart = newCart & rs("MobileID") & ","
			  if cint("0"&split(strCount,",")(cart_index))<=0 then
				newCount = newCount & "1,"
				bRefresh = true
			  else
				newCount = newCount & cint("0"&split(strCount,",")(cart_index)) & ","
			  end if
			  totalmoney = totalmoney + rs("JoyesPrice") * cint("0"&split(strCount,",")(cart_index))
			  strcode = strcode & rs("MobileID") & "*"
			  strmoney = strmoney & cstr(rs("JoyesPrice") * cint("0"&split(strCount,",")(cart_index))) & "*"%>
			  <tr bgcolor="<%if iCount mod 2 = 0 then Response.write "#FFFFFF" else Response.write "#FAFAFA" end if%>" height="25">
                <td align="center" class="entxt"><%=rs("MobileID")%></td>
                <td align="center"><a href="../Mobile/show.asp?uid=<%=Request("uid")%>&id=<%=rs("MobileID")%>" target="_blank"><%=rs("MobileName")%></a></td>
                <!--<td align="center" class="entxt"><%=formatcurrency(rs("OutPrice"),2)%></td>-->
                <td align="center" class="entxt"><%=formatcurrency(rs("JoyesPrice"),2)%><input type="hidden" name="JoyesPrice_<%=replace(rs("MobileID"),"-","_")%>" value="<%=cdbl(rs("JoyesPrice"))%>"></td>
                <td align="center"><input type="text" name="MobileCount_<%=replace(rs("MobileID"),"-","_")%>" value="<%=split(strCount,",")(cart_index)%>" onchange="this.value=this.value.replace(/\D/gi,'');document.CartForm.eMoney_<%=replace(rs("MobileID"),"-","_")%>.value=FormatMoney(parseInt(this.value) * parseFloat(document.CartForm.JoyesPrice_<%=replace(rs("MobileID"),"-","_")%>.value));Total_Money();" onunload="this.value=this.value.replace(/\D/gi,'');document.CartForm.eMoney_<%=replace(rs("MobileID"),"-","_")%>.value=FormatMoney(parseInt(this.value) * parseFloat(document.CartForm.JoyesPrice_<%=replace(rs("MobileID"),"-","_")%>.value));Total_Money();" onmouseout="this.value=this.value.replace(/\D/gi,'');document.CartForm.eMoney_<%=replace(rs("MobileID"),"-","_")%>.value=FormatMoney(parseInt(this.value) * parseFloat(document.CartForm.JoyesPrice_<%=replace(rs("MobileID"),"-","_")%>.value));Total_Money();" size="4" maxlength="5" class="entxt" onmouseover="this.select();"></td>
                <td align="center"><input type="text" name="eMoney_<%=replace(rs("MobileID"),"-","_")%>" value="<%=formatcurrency(cdbl("0"&rs("JoyesPrice"))*cint("0"&split(strCount,",")(cart_index)),2)%>" onchange="this.value=this.value.replace(/\D/gi,'');" readonly class="entxt" style="color:#888888;cursor:default" size="8"></td>
                <!--<td align="center"><a style="cursor:hand" onclick="winopen('','show','width=775,height=550,top=0,left=0,scrollbars=yes');">查看</a></td>-->
                <td align="center"><a style="cursor:hand" onclick="if(confirm('你确定要删除此商品！'))document.location.href='ClearCart.asp?uid=<%=Request("uid")%>&id=<%=rs("MobileID")%>&cid=<%=request("cid")%>';">删除</a></td>
			  </tr>
			  <%iCount = iCount + 1
			  end if
			  rs.close
			  end if
			  next
			  Response.Cookies("Joyes_ShopCart") = newCart
			  Response.Cookies("Joyes_ShopCount") = newCount%>
			  <input type="hidden" name="TotalCode" value="<%=strcode%>">
			  <input type="hidden" name="TotalPrice" value="<%=strmoney%>">
			  <input type="hidden" name="TotalCount" value="<%=iCount%>">
			  <input type="hidden" name="TotalMoney" value="<%=totalmoney%>">
			  <%set rs = nothing
			  if cart_index < 1 then%>
			  <tr>
				<td height="50" style="font-size:14px;color:red" align="center" bgcolor="#FFFFFF" colspan="8">你还没有选择商品！</td>
			  </tr>
			  <%end if%>
			  </form>
			</table>
		  </td>
		</tr>
		<tr>
		  <td bgcolor="#FFFFFF" align="right" height="28" style="padding-bottom:5">
			<center><hr size="1" width="99%" color="#888888"></center>
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
			  <tr>
				<td style="padding-left:10"><div id="TotalDiv">合计：<span class="entxt"><%=formatcurrency(totalmoney,2)%></span></div></td>
				<td align="right"><input type="button" value="清空购物车" class="in3" onclick="window.location.href='clearcart.asp'" ID="Button1" NAME="Button1">　　<input type="button" value="更改数量" class="in3" onclick="CartForm.submit();" ID="Button1" NAME="Button1">　　<%if Request("cid")&""<>"1" then%><input type="button" value="去收银台" class="in3" onclick="window.opener.focus(); window.opener.location.href='../mobile/pay.asp?uid=<%=Request("uid")%>';window.close();">　　<%end if%><input type="button" value="关闭窗口" class="in3" onclick="window.opener.focus();window.close();">&nbsp;&nbsp;</td>
			  </tr>
			</table>
		  </td>
		</tr>
	  </table>
	</td>
  </tr>
</table>
</body>

</html>
<%set rs=nothing
if bRefresh=true then Response.redirect "CartList.asp?uid=" & Request("uid")
CloseConnection()%>