<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->

<%

webtitle="去收银台结帐"
webkeywords="去收银台结帐"
webdescription="去收银台结帐|"&webname
%> 


<!--#include file="include/header.asp"-->
<%
action=FormatSQL(SafeRequest("action",0))
If Session("ProductList") = "" Then
Response.write "<script language=javascript>alert('对不起，您的购物车中还没有商品！');location.href='index.asp';</script>"
Conn.Close
Set Conn = Nothing
Response.End
End IF
Dim YourPrice,strprice2,strvipprice,ProScore
select case action
Case "1"
If LngUserID=0 Then %>
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<tr><td colspan="3" align="center"  height="40"    style='padding-left:40px;color:#930000;font-weight: bold;FONT-SIZE:13px;LINE-HEIGHT: 20px;BORDER-TOP: #f1f1f1 1px solid;  BORDER-BOTTOM: #f1f1f1 1px solid;BACKGROUND-COLOR: #dbdbdb;'>下单第一步（确认订单资料和会员注册）</td></tr>
<tr align="center" height="40" >


<td valign="top" width="40%" align="center"><!--#include file="login_reg.asp"--></td>

<td valign="top" width="20%" align="center"><% If webimg6 = 1 Then %><!--#include file="onreg_pay.asp"--><% End IF %></td>
<td width="40%" valign="top" align="center"><!--#include file="loginpay.asp"--></td>

</tr>
<tr><td colspan="3" align="center"><!--#include file="details.asp"--><br></td></tr>
</table>
<%
Else 
Response.Redirect"payment.asp?action=2"
End IF
Case "2"
IF LngUserID=0 and webimg6 = 0 Then
response.write "<script language=javascript>alert('对不起，匿名购物被关闭，请先注册或登录！');location.href='index.asp';</script>" 
Conn.Close
Set Conn = Nothing
response.End()
end if

set rs=server.CreateObject("adodb.recordset")
rs.open "select receipt,userid,UserSex,useremail,city,address,postcode,usertel,usermobile,paymethord,deliverymethord,realname from DV_User where username='"&strUserName&"'",conn,1,1
%> 
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<tr><td  align="center"  height="40"    style='padding-left:40px;color:#930000;font-weight: bold;FONT-SIZE:13px;LINE-HEIGHT: 20px;BORDER-TOP: #f1f1f1 1px solid;  BORDER-BOTTOM: #f1f1f1 1px solid;BACKGROUND-COLOR: #eaeaea;'>下单第二步（填写收货人等资料）</td></tr>
<tr><td align="center"><!--#include file="details.asp"-->
<br></td></tr>
<tr><td align="center">
<table width="80%" border="0" align="center"  cellpadding="0" cellspacing="1" bgcolor="#ffffff" >
<form name="receiveaddr" method="post" action="payment.asp?action=3">
          <tr bgcolor=#ffffff> 
		    <input type=hidden name=realname value=<%=strUserName %>>
            <td width="150" style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>收货人姓名：</font></b></td>
            <td  height="28">  
              <input name="receipt" type="text" id="receipt" size="12" value=<%=trim(rs("receipt"))%>>
              &nbsp;<b><FONT COLOR=#333333>性 别：</font></b><select name="UserSex" id="UserSex">
			    <option value="0" <% if rs("UserSex")=0 Then Response.write("Selected") %>>男</option>
                <option value="1" <% if rs("UserSex")=1 Then Response.write("Selected") %>>女</option>
              </select>
              </td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>详细地址：</font></b></td>
            <td height="28"><input name="address" type="text" id="address" size="40" value=<%=trim(rs("address"))%>></td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>邮　　编：</font></b></td>
            <td height="28"><input name="postcode" type="text" id="postcode" size="10" value=<%=rs("postcode")%>></td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>电　　话：</font></b></td>
            <td height="28"><input name="usertel" type="text" id="usertel" size="12" value=<%=trim(rs("usertel"))%>></td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>手    机：</b></td>
            <td height="28"><input name="usermobile" type="text" id="usermobile" size="12" value=<%=trim(rs("usermobile"))%>></td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>电子邮件：</font></b></td>
            <td height="28"><input name="useremail" type="text" id="useremail" value=<%=trim(rs("useremail"))%>></td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>送货方式：</font></b></td>
            <td height="28">
          <%
          set rs3=server.CreateObject("adodb.recordset")
          rs3.Open "select * from delivery where methord=0 order by deliveryidorder",conn,1,1
          response.Write "<select name=deliverymethord  id=deliverymethord>"
          do while not rs3.EOF
          response.Write "<option value="&rs3("deliveryid")
          if int(rs("deliverymethord"))=int(rs3("deliveryid")) then 
          response.Write " selected>"
          else
          response.Write ">"
          end if
          response.Write trim(rs3("subject"))&"</option>"
          rs3.MoveNext
          loop
          response.Write "</select>"
          rs3.Close
          set rs3=nothing
         %>
            </td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>支付方式：</font></b></td>
            <td height="28">
           <%
          set rs3=server.CreateObject("adodb.recordset")
          rs3.open "select * from delivery where methord=1 order by deliveryidorder",conn,1,1
          response.Write "<select name=paymethord  id=paymethord>" %>
		  <%
          do while not rs3.eof
          response.Write "<option value="&rs3("deliveryid")
          if int(rs("paymethord"))=int(rs3("deliveryid")) then
          response.Write " selected>"
          else
          response.Write ">"
          end if
          response.Write trim(rs3("subject"))&"</option>"
          rs3.movenext
          loop
          response.Write "</select>"
          rs3.close
		   set rs3=nothing
	  rs.close
	  set rs=nothing

%>
             </td>
          </tr>
          <tr bgcolor=#ffffff> 
            <td style='PADDING-LEFT: 6px'><b><FONT COLOR=#333333>简单留言:</font></b></td>
            <td height="28"><input name="comment" type="text" id="comment" size="70" value=<%=trim(rs("comment"))%>></td>
          </tr>
          <tr #ffffff> 
		    <td></td>
            <td><input type="submit" name="Submit3"  value="提交订单" onClick="return ssother();"></td>
          </tr>
        </form>
      </table> </td>
  </tr> </table><br>
  <SCRIPT LANGUAGE="JavaScript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function ssother()
{
   if(checkspace(document.receiveaddr.receipt.value)) {
	document.receiveaddr.receipt.focus();
    alert("对不起，请填写收货人姓名！");
	return false;
  }
 
  if(checkspace(document.receiveaddr.address.value)) {
	document.receiveaddr.address.focus();
    alert("对不起，请填写收货人详细收货地址！");
	return false;
  }
  if(checkspace(document.receiveaddr.postcode.value)) {
	document.receiveaddr.postcode.focus();
    alert("对不起，请填写邮编！");
	return false;
  }
 
    if(checkspace(document.receiveaddr.usertel.value)) {
	document.receiveaddr.usertel.focus();
    alert("对不起，请留下您的电话！");
	return false;
  }
  if(checkspace(document.receiveaddr.usermobile.value)) {
	document.receiveaddr.usermobile.focus();
    alert("对不起，请留下您的手机！");
	return false;
  }
      if(checkspace(document.receiveaddr.deliverymethord.value)) {
	document.receiveaddr.deliverymethord.focus();
    alert("对不起，您还没有选择送货方式！");
	return false;
  }
      if(checkspace(document.receiveaddr.paymethord.value)) {
	document.receiveaddr.paymethord.focus();
    alert("对不起，您还没有选择支付方式！");
	return false;
  }
  if(document.receiveaddr.useremail.value.length!=0)
  {
    if (document.receiveaddr.useremail.value.charAt(0)=="." ||        
         document.receiveaddr.useremail.value.charAt(0)=="@"||       
         document.receiveaddr.useremail.value.indexOf('@', 0) == -1 || 
         document.receiveaddr.useremail.value.indexOf('.', 0) == -1 || 
         document.receiveaddr.useremail.value.lastIndexOf("@")==document.receiveaddr.useremail.value.length-1 || 
         document.receiveaddr.useremail.value.lastIndexOf(".")==document.receiveaddr.useremail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.receiveaddr.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.receiveaddr.useremail.focus();
   return false;
   }
   if(checkspace(document.receiveaddr.comment.value)) {
	document.receiveaddr.comment.focus();
    alert("对不起，请填写简单留言！");
	return false;
  } 
}
//-->
</script> 
  <% 
Case "3"
Function GetOrderNo(dDate)
    GetOrderNo = RIGHT("0000"+Trim(Year(dDate)),4)+RIGHT("00"+Trim(Month(dDate)),2)+RIGHT("00"+Trim(Day(dDate)),2)+RIGHT("00" + Trim(Hour(dDate)),2)+RIGHT("00"+Trim(Minute(dDate)),2)+RIGHT("00"+Trim(Second(dDate)),2)
End Function
goods=GetOrderNo(Now())

Dim strMth,LngMth,strMian,Message,strtxtdeposit,LngState
strMian = ""
Message = ""
strtxtdeposit = ""
LngState = 2
Message="<html>"
Message=message &"<table border=0 cellspacing=1 cellpadding=4 align=center width=100% bgcolor=#cccccc>"
Message=message &"<tr BGCOLOR=#ffffff height=25 align=center>"
Message=message &"<td width=40>编 号</td>"
Message=message &"<td width=300>商 品 名 称</td>"
Message=message &" <td width=40>数量</td>"
Message=message &"<td width=40>积分</td>"
Message=message &"<td width=40>邮费</td>"
Message=message &"<td width=60>您的价格</td>"
Message=message &"<td width=70>总 计</td>"
Message=message &"</tr>"
%>  
<table width="980" border="0" cellspacing="0" cellpadding="0" align="center" class="table-zuoyou"  bgcolor="#FFFFFF"> 
<tr><td  align="center"  height="40"   style='padding-left:40px;color:#930000;font-weight: bold;FONT-SIZE:13px;LINE-HEIGHT: 20px;BORDER-TOP: #f1f1f1 1px solid;  BORDER-BOTTOM: #f1f1f1 1px solid;BACKGROUND-COLOR: #eaeaea;'>下单第三步（完成订单，开始支付款）</td></tr>
<tr><td>

<!--#include file="details.asp"-->


</td></tr>
</table>
<!--#INCLUDE FILE="include/sendmail.asp"-->
<%
MailType = webbj4
smtpserver = webbj7
sendusername = webbj8
sendpassword = webbj9
SendName = webbj3
SendTO = trim(request.form("useremail"))
SendFrom = webbj8
subject="您在"&webname&"的订单信息！"
Select Case MailType
Case "Nothing"

Case "CDONTS"
call sendemail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message)
Case "Jmail"
call SendJmail(SendFrom,SendTO,smtpserver,sendusername,sendpassword,subject,Message,SendName)
End Select

Session("ProductList") = ""
%>
<br>
<% 
end select  %>
<!--#include file="include/footer.asp"-->
<%
Conn.Close
Set Conn = Nothing
%> 


<script language=javascript>
<!--
function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

   //-->
</script>
