<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<%
Dim KSCls
Set KSCls = New User_Express_Buy
If Request("Action")="Mini" Then
	KSCls.MiniShow()
ElseIf Request("Action")="Del_Address" Then
	KSCls.Del_Address()
Else
	KSCls.HSK_Run()
End If
Set KSCls = Nothing

Class User_Express_Buy
        Private KS,KSUser
		Private CurrentPage,totalPut,TotalPages,SQL
		Private RS,MaxPerPage
		Private Para,SqlStr
		Private Price1,Price2,Point1,Point2
		Private Sub Class_Initialize()
			Set KS=New PublicCls
			Set KSUser = New UserCls
			
			'以下为快递单号价格
			'价格顺序：默认显示的单价 和 9个快递公司(根据快递公司的显示顺序填写价格)，分别有10个价格，英文逗号隔开，可自行修改，如要免费请把对应的快递价改成0
			Price1 = "[1.51, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.52, 1.5]"		'扣余额结算方式，凭任务编号订购价格，默认都是1.5元/单
			Price2 = "[21, 2, 2, 2, 2, 2, 2, 2, 22, 2]"						'扣余额结算方式，单独购买价格，默认都是2.0元/单
			
			Point1 = "[31, 3, 3, 3, 3, 3, 3, 3, 32, 3]"			'扣发布点结算方式，凭任务编号订购，默认都是3个发布点/单
			Point2 = "[41, 4, 4, 4, 4, 4, 4, 4, 42, 4]"			'扣发布点结算方式，单独购买价格，默认都是4个发布点元/单
			
			MaxPerPage =20
		End Sub
        Private Sub Class_Terminate()
		 Set KS=Nothing
		 Set KSUser=Nothing
		End Sub
		%>
		<!--#include file="../HSK_Cls/UserFunction.asp"-->
		<%		
       Public Sub loadMain()
		
		IF Cbool(KSUser.UserLoginChecked)=false Then
		  Response.Write "<script>top.location.href='Login';</script>"
		  Exit Sub
		End If
		Call KSUser.Head()
		Call KSUser.InnerLocation("订购真实快递")
		IF KS.ChkClng(KSUser.GetUserInfo("KS_IDAuthentication")) <> 1 Then
			KS.Alert "抱歉！\n\n您的账号尚未通过手机认证，暂时不能订购快递，请点击确定按钮跳转到认证页面。","User_IDAuthentication.asp"
		End IF
		%>
        <div class="tabs">
            <ul>
                <li><a href="User_Express.asp">快递单号中心</a></li>
                <li><a href="User_Express.asp?View=MyOrder">我领取的单号</a></li>
                <li<%If KS.S("Action")<>"MyOrder" Then KS.Echo " class=""select"""%>><a href="User_Express_Buy.asp">订购真实快递</a></li>
                <li<%If KS.S("Action")="MyOrder" Then KS.Echo " class=""select"""%>><a href="User_Express_Buy.asp?Action=MyOrder">我订购的单号</a></li>
            </ul>
        </div>
        <%
	   If KS.S("page") <> "" Then
			  CurrentPage = CInt(KS.S("page"))
		Else
			  CurrentPage = 1
		End If
		
		If KS.S("Action")="Buy" Then
			IF KS.CheckOuterUrl() Then	KS.AlertHistory "请不要非法提交，谢谢！","-1"
			Call DoBuy()
			Exit Sub
		ElseIf KS.S("Action")="MyOrder" Then
			Call DoMyOrder()
			Exit Sub
		Else
			Call Main()
		End If
	End Sub
	

Sub main()
%>
<style type="text/css">
a:hover{text-decoration:underline;}
.orange,.orange a{color:#FF5500;}
.center_tbl td {line-height:38px; height:38px; clear:both; background-color:#FFF}
.center_tbl tr:hover td{background-color:#EBF5FF}
</style>
<script type="text/javascript" src="/HSK_JS/Province_City_Area.js"></script>
<script type="text/javascript" src="/style/js/My97DatePicker/WdatePicker.js"></script>
<script language="javascript">
var price1=<%=price1%>;
var price2=<%=price2%>;
var point1=<%=point1%>;
var point2=<%=point2%>;
function ChangeComName(n){
		$('#price1').html(price1[n]);
		$('#price2').html(price2[n]);
		$('#point1').html(point1[n]);
		$('#point2').html(point2[n]);
		$('#txt_price1').val(price1[n]);
		$('#txt_price2').val(price2[n]);
		$('#txt_point1').val(point1[n]);
		$('#txt_point2').val(point2[n]);
}

function getRV(b){var d="";var a=document.getElementsByName(b);for(var c=0;c<a.length;c++){if(a[c].checked){d=a[c].value}}return d}
function CheckForm(){
	if (getRV('getType')=='1'){
		if($('#TaskID').val()==''){
			alert('请输入任务编号!');
			$('#TaskID').focus();
			return false;
		}
	}
	if ($('#BuyPayDate').val()==''){
		alert('请输入淘宝(拍拍)买家付款时间!');
		$('#BuyPayDate').focus(); 
		return false;
    }
	if ($('#ComName').val()==''){
		alert('请输入快递公司!');
		$('#ComName').focus(); 
		return false;
    }
	if ($('#address').val()==''){
		alert('请输入发货地址!');
		$('#s1').focus(); 
		return false;
	}
	else{
		if($('#address').val().indexOf('地级市')!=-1){
			alert('请选择 地级市!');
			$('#s2').focus(); 
			return false;
		}
		if($('#address').val().indexOf('县/区')!=-1){
			alert('请选择 县/区!');
			$('#s3').focus(); 
			return false;
		}
	}
	if ($('#FHUserName').val()==''){
		alert('请输入发货人!');
		$('#FHUserName').focus(); 
		return false;
	}
	if ($('#FHMobile').val()==''){
		alert('请输入发货人电话!');
		$('#FHMobile').focus(); 
		return false;
	}
	if (trim($('#MDCity').val())==''){
		alert('请输入收货地址!');
		$('#MDCity').focus(); 
		return false;
	}
	var regPatrn=(document.all)?/\r\n/mg:/\n/mg;
	var MDCity = trim(document.getElementById("MDCity").value).replace(/,/gm, "，");
	var arr_str = trim(MDCity).split(regPatrn);
	if (getRV('getType')=='1'){	
		//alert(arr_str.length);
		if(arr_str.length > 1){alert('抱歉！任务编号订购方式，一次只能填写一条订购信息!'); $('#MDCity').focus(); return false;}
		if(MDCity.split('，').length < 4 || (MDCity.split('，').length==4 && trim(MDCity.split('，')[2]).split(' ').length < 4) || (MDCity.split('，').length==5 && trim(MDCity.split('，')[3]).split(' ').length < 4)){
			alert('抱歉！收货地址填写的格式不对，请按页面提示的格式填写，谢谢！');
			$('#MDCity').focus();
			return false;
		}
	}else{
		if(arr_str.length > 1000){alert('抱歉！最多批量订购1000条，请分批提交，谢谢!'); $('#MDCity').focus(); return false;}
		for(var i = 0; i < arr_str.length; i++){
			if(arr_str[i] !=''){
				if(arr_str[i].split('，').length < 4 || 
				(arr_str[i].split('，').length==4 && trim(arr_str[i].split('，')[2]).split(' ').length < 4) || 
				(arr_str[i].split('，').length==5 && trim(arr_str[i].split('，')[3]).split(' ').length < 4)
				){
					alert('抱歉！收货地址框第' + (i + 1) + '行填写的格式不对，请按页面提示的格式填写，谢谢！');
					$('#MDCity').focus();
					return false;
				}
			}
		}

	}
	return confirm('您确定要订购了吗？\n\n 订购后不可撤销了哦！');
}
function trim(str){return str.replace(/(^\s*)|(\s*$)/g, ""); }
</script>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr>
  	<td align="center" bgcolor="#FFFEDF" style="height:70px; line-height:28px; color:red; font-weight:bold; border:1px solid #FC3;">
    好消息！凡是在平台发布实物任务，均可凭任务编号订购真实快递单号！<br />
	如果没有发布任务只想单独购买快递单也可以！欢迎选购！</td>
  </tr>
</table>

<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='center_tbl'>
<form action='?' method='post' name='myform' onsubmit='return(CheckForm())'>
<input type='hidden' value='Buy' name='Action'>
<input type='hidden' value='0' name='txt_price1' id='txt_price1'>
<input type='hidden' value='0' name='txt_price2' id='txt_price2'>
<input type='hidden' value='0' name='txt_point1' id='txt_point1'>
<input type='hidden' value='0' name='txt_point2' id='txt_point2'>
<tr class="tdbg" height="35">
  	<td width="24%" height="40" align="right"><strong>账户余额：</strong></td>
    <td>&nbsp;<span style="color:#FF5500; font-size:14px"><%=KS.GetN(KSUser.GetUserInfo("Money"),2)%></span> 元 &nbsp;<a href="User_Transfer.asp" target="_blank"><img src="images/fill.gif" align="absmiddle" border="0"></a> &nbsp; &nbsp;<strong>发布点：</strong><span style="color:#FF5500; font-size:14px"><%=KS.GetN(KSUser.GetUserInfo("Point"),2)%></span> <%=KS.Setting(46)%>
    </td>
</tr>
<tr class="tdbg" height="35">
  	<td width="24%" height="40" align="right"><strong>选择订购方式：</strong></td>
    <td><label for="getType"><input name="getType" type="radio" id="getType" value="1" checked="checked" onClick="tasktr.style.display=''" />我有任务编号</label>
    <label for="getType2"><input type="radio" name="getType" id="getType2" value="2" onClick="tasktr.style.display='none'" />我要单独购买</label>
    </td>
</tr>
	<tr class="tdbg" height="35" id="tasktr">
	<td width="24%" height="40" align="right"><strong>平台任务编号：</strong></td>
	<td><input name='TaskID' value='' type='text' id='TaskID' class='textbox' maxlength="20" title="只有实物任务编号才可以输入购买" /> <span style="color:red;">注：一个编号只可以购买一次</span></td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>淘宝(拍拍)买家付款时间：</strong></td>
	<td width="76%"><input name='BuyPayDate' type='text' onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" id='BuyPayDate' class='textbox' size="27"> <a href='#' onClick="BuyPayDate.click()"><img src='/Images/clock.gif' width="22" border='0' align='absmiddle' title='选择日期'></a> 日期格式：年-月-日 时：分：秒</td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>快递公司：</strong></td>
	<td><input name='ComName' type='text' id='ComName' class='textbox' readonly="readonly"> <select name="expressid" id="expressid" onChange="myform.ComName.value=this.options[this.selectedIndex].value;ChangeComName(this.selectedIndex)">
        <option selected="selected" value="">点这选择快递公司</option>
        <option value="顺丰快递">顺丰快递</option>
        <option value="韵达快递">韵达快递</option>
        <option value="圆通快递">圆通快递</option>
        <option value="EMS快递">EMS快递</option>
        <option value="中通快递">中通快递</option>
        <option value="天天快递">天天快递</option>
        <option value="汇通快递">汇通快递</option>
        <option value="申通快递">申通快递</option>
        <option value="宅急送快递">宅急送快递</option>
      </select></td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>发货地址：</strong></td>
	<td><select class="textbox" name="province" id="s1"><option></option></select> 
<select class="textbox" name="city" id="s2"><option></option></select> 
<select class="textbox" name="area" id="s3"><option></option></select> 
<input id="address" name="CFCity" type="hidden" value="">
<script language="javascript">setup();//preselect('广东省');promptinfo();
function SetAddress(address){
	if(address!=''){
		var tmpArray = address.split(' ');
		if(tmpArray.length==3){
			preselect(tmpArray[0]);
			document.getElementById("s2").value=tmpArray[1];
			document.getElementById("s3").options.add(new Option(tmpArray[2], tmpArray[2],false,true));
			promptinfo();
			$("#del_address").show();
		}
	}
	else{
		$("#del_address").hide();
	}
}
function del_address(){
	if($("#Deliver_Address").val()!=''){
		if(confirm('确定不保存这条发货地址吗？')){
			document.location.href="?Action=Del_Address&address=" + escape($("#Deliver_Address").val());
			}
		
		}
	}
</script>
<%
Dim RS_City
	Set RS_City = Server.CreateObject("ADODB.RECORDSET")
	RS_City.Open "Select Address From Express_Deliver_Address Where UserName='" & KSUser.UserName & "'", Conn, 1, 1
	IF Not RS_City.Eof Then
		KS.Echo "	 <select name=""Deliver_Address"" id=""Deliver_Address"" onChange=""SetAddress(this.options[this.selectedIndex].value)"">"
		KS.Echo "	     <option selected=""selected"" value="""">= 选之前用过的发货地址 =</option>"
		Do While Not RS_City.Eof
			KS.Echo "	     <option value=""" & RS_City("Address") & """>" & RS_City("Address") & "</option>"
			RS_City.MoveNext
		Loop
		KS.Echo "	 </select> <span id=""del_address"" style=""display:none""><a href=""javascript:del_address();"" style=""color:red"">删除</a></span>"
	End If
	RS_City.Close
	Set RS_City = Nothing
%>
</td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>发货人：</strong></td>
	<td><input name='FHUserName' type='text' id='FHUserName' class='textbox' maxlength="10"></td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>发货人电话：</strong></td>
	<td><input name='FHMobile' type='text' id='FHMobile' class='textbox' maxlength="20"></td>
</tr>
<tr class='tdbg'>
	<td width='24%' height='40' align='right'><strong>收货地址信息：</strong></td>
	<td><span style="line-height:22px; color:#09F">收货地址格式统一为：姓名，手机号，固定电话，详细地址，邮编<br />
例如1：李明，1340569xxxx，江苏省 苏州市 昆山市 先锋东路1607号，215300 <span style="color:#F00">(新格式)</span><br />
例如2：李明，1340569xxxx，，江苏省 苏州市 昆山市 先锋东路1607号，215300<br />
例如3：李明，，0773-2801xxx，江苏省 苏州市 昆山市 先锋东路1607号，215300</span><br />
<textarea name="MDCity" cols="80" rows="10" class="textarea" id="MDCity" style="width:550px" title="注：如选了“我要单独购买”可批量订购，一行一条收货信息；选了“我有任务编号”仅限填写一条收货信息！"></textarea></td>
</tr>

  <tr class="tdbg" height="35">
  	<td width="24%" height="40" align="right"><strong>订购结算方式：</strong></td>
    <td>&nbsp;<label for="PayType" class="orange"><input name="PayType" type="radio" id="PayType" value="1" checked="checked" />扣账户余额</label>&nbsp; &nbsp;价格：凭任务编号订购价格是：<strong class="orange" id="price1">￥0</strong> 元 &nbsp; &nbsp; 单独购买价格是：<strong class="orange" id="price2">￥0</strong> 元<br>
    &nbsp;<label for="PayType2" class="orange"><input type="radio" name="PayType" id="PayType2" value="2" />扣账户发布点</label>&nbsp; &nbsp;价格：凭任务编号订购发布点是：<strong class="orange" id="point1">0 </strong>点 &nbsp; &nbsp; 单独购买发布点是：<strong class="orange" id="point2">0 </strong>点
    </td>
  </tr>
  <tr>
  	<td colspan="2" align="center" bgcolor="#EEF1F1" style="height:60px; line-height:60px;"><input type="image" name="Save" src="/style/images/ConfirmButton.gif" /></td>
  </tr>
</form>
</table>

<%  
End Sub


Sub DoMyOrder()
%>
<script type="text/javascript" src="/style/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/HSK_JS/HSK.box.js"></script>
<script type="text/javascript">
function View(ID)
{
  new KesionPopup("#fff",4,true,"font-size:12px;background:url(/style/images/w_b_2.gif) #1B76B7 0 -4px;color:#20537A;height:22px;").popupIframe('&nbsp; 查看快递单号信息','User_Express_Buy.asp?Action=Mini&ID=' + ID ,620,490,'auto')
}

//复制内容进剪贴板
function copyToClipboard(txt,msg) {
	  if(window.clipboardData) {
			  window.clipboardData.clearData();		
			  window.clipboardData.setData("Text", txt);		
	  } else if (window.netscape) {		
		   try {		
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");		
		   } catch (e) {		
				alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");		
		   }		
		   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);		
		   if (!clip)		
				return;		
		   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);		
		   if (!trans)		
				return;		
		   trans.addDataFlavor('text/unicode');		
		   var str = new Object();		
		   var len = new Object();		
		   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);		
		   var copytext = txt;		
		   str.data = copytext;		
		   trans.setTransferData("text/unicode",str,copytext.length*2);		
		   var clipid = Components.interfaces.nsIClipboard;		
		   if (!clip)		
				return false;		
		   clip.setData(trans,null,clipid.kGlobalClipboard);
	  } else {	
			alert('抱歉！该浏览器(非IE内核)不支持复制，请用鼠标选中账号右键复制！');
			return;	
	  }			  
	  msg = (typeof(msg)=="undefined")?'复制成功！':msg;		
	  alert(msg);	
 }
</script>
<table width="100%" height="50" border="0" cellspacing="0" cellpadding="0" >
    <form name="myform" action="?Action=MyOrder&Action2=Search" method="post">
      <tr>
        <td width="200" align="left">发货时间：
         <input type="text" readonly name="AddDate" value="<%If Not KS.IsNul(KS.S("AddDate")) Then KS.Echo KS.S("AddDate") Else KS.Echo KS.DateFormat(Now,1)%>" size="13" onClick="WdatePicker()" /></td>
        <td width="150" align="left">发货地：
          <input type="text" name="CFCity" size="10" value="<%=KS.S("CFCity")%>" /></td>
        <td width="150" align="left">收货地：
          <input type="text" name="MDCity" size="10" value="<%=KS.S("MDCity")%>" /></td>
        <td width="180" align="left">快递类型：
         <select name="ComName">
         <option value="">不限</option>
        <option value="顺丰快递"<%If KS.S("ComName")="顺丰快递" Then KS.Echo " selected=""selected"""%>>顺丰快递</option>
        <option value="韵达快递"<%If KS.S("ComName")="韵达快递" Then KS.Echo " selected=""selected"""%>>韵达快递</option>
        <option value="圆通快递"<%If KS.S("ComName")="圆通快递" Then KS.Echo " selected=""selected"""%>>圆通快递</option>
        <option value="EMS快递"<%If KS.S("ComName")="EMS快递" Then KS.Echo " selected=""selected"""%>>EMS快递</option>
        <option value="中通快递"<%If KS.S("ComName")="中通快递" Then KS.Echo " selected=""selected"""%>>中通快递</option>
        <option value="天天快递"<%If KS.S("ComName")="天天快递" Then KS.Echo " selected=""selected"""%>>天天快递</option>
        <option value="汇通快递"<%If KS.S("ComName")="汇通快递" Then KS.Echo " selected=""selected"""%>>汇通快递</option>
        <option value="申通快递"<%If KS.S("ComName")="申通快递" Then KS.Echo " selected=""selected"""%>>申通快递</option>
        <option value="宅急送快递"<%If KS.S("ComName")="宅急送快递" Then KS.Echo " selected=""selected"""%>>宅急送快递</option>
        </select>
		</td>
        <td align="left"><button class="pn" id="submit1" type="submit"><strong> 筛 选</strong></button></td>
        <td></td>
      </tr>
    </form>
</table>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="border">
    <tr class="titlename">
    <td nowrap width="10%" height="25" align="center"><strong>快递公司</strong></td>
    <td nowrap width="17%" height="25" align="center"><strong>快递单号</strong></td>
    <td nowrap width="20%" height="25" align="center"><strong>发货地</strong></td>
    <td nowrap width="" height="25" align="center"><strong>收货地</strong></td>
    <td nowrap width="15%" align="center"><strong>订购时间</strong></td>
    <td nowrap width="13%" align="center"><strong>操作</strong></td>
  </tr>
    <%
	If KS.S("Action2")="Search" Then
		If Not KS.IsNul(KS.S("AddDate")) Then	Para = " And DATEDIFF(d,'" & KS.CheckXSS(KS.S("AddDate")) & "',AddDate) >= 0" 
		If Not KS.IsNul(KS.S("CFCity")) Then Para = Para &" And CFCity Like '%" & KS.CheckXSS(KS.S("CFCity")) & "%'"
		If Not KS.IsNul(KS.S("MDCity")) Then Para = Para &" And MDCity Like '%" & KS.CheckXSS(KS.S("MDCity")) & "%'"
		If Not KS.IsNul(KS.S("ComName")) Then Para = Para &" And ComName Like '%" & KS.CheckXSS(KS.S("ComName")) & "%'"
	End If
	 SqlStr="Select ID,ComName,KuaiDiNum,CFCity,MDCity,AddDate,ScanDate From Express_Buy Where BuyUserName ='" & KSUser.UserName & "'" & Para & " Order By ID Desc"
	 Set RS=Server.createobject("adodb.recordset")
	 RS.open SqlStr,conn,1,1

	 If RS.EOF And RS.BOF Then
			  Response.Write "<tr class='tdbg'><td align=center height=25 colspan=6 valign=top>暂时还没有订购快递!</td></tr>"
	 Else
		TotalPut=rs.recordcount
		if (TotalPut mod MaxPerPage)=0 then
			TotalPages = TotalPut \ MaxPerPage
		else
			TotalPages = TotalPut \ MaxPerPage + 1
		end if
		if CurrentPage > TotalPages then CurrentPage=TotalPages
		if CurrentPage < 1 then CurrentPage=1
		rs.move (CurrentPage-1)*MaxPerPage
		SQL = rs.GetRows(MaxPerPage)
		rs.Close:set rs=Nothing
		ShowContent
	End If
 %>
</table>
<%Call KS.ShowPage(totalput, MaxPerPage, "", CurrentPage,false,true)%>
<%
End Sub
    
Sub ShowContent
Dim i
For i=0 To Ubound(SQL,2)
	%>
  <tr height="25" class='tdbg' onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
    <td class="splittd" align="center"><%=SQL(1,I)%></td>
    <td class="splittd" align="center"><%If Not KS.IsNul(SQL(2,I)) Then KS.Echo "<font color=red><span title=""点击复制单号"" style=""cursor: pointer;"" onclick=""copyToClipboard('" & SQL(2,I) & "','单号已复制成功！')"">" & SQL(2,I) & "</span></font>" Else KS.Echo "<font color='blue'>待发快递</font>"%></td>
    <td class="splittd" align="center"><%=SQL(3,I)%></td>
    <td class="splittd" align="center"><%=SQL(4,I)%></td>
    <td class="splittd" align="center"><%=SQL(5,I)%></td>
    <td class="splittd" align="center"><%
	If KS.S("Action") = "MyOrder" Then
		KS.Echo "<a href=""javascript:;"" onclick=""View(" & SQL(0,I) & ")""><img src=""/style/images/view_bt.gif"" border=0 width=""90"" height=""28"" align=""absmiddle""></a>"
	Else
		KS.Echo "<a href=""javascript:;"" onclick=""View(" & SQL(0,I) & ")""><img src=""/style/images/get_bt.gif"" border=0 width=""90"" height=""32"" align=""absmiddle""></a>"
	End If
	%></td>
  </tr>
  <%Next%>

  <%  
End Sub


'订购保存
Sub DoBuy()
	Dim RS, D_RS, GetType, TaskID, Money, i, Num
	Dim BuyPayDate,ComName,CFCity,MDCity,FHUserName,FHMobile,PayType,tmpMDCity,tmpArray
	BuyPayDate = Left(KS.S("BuyPayDate"),30)
	ComName = Left(KS.S("ComName"),20)
	CFCity = Left(KS.S("CFCity"),40)
	MDCity = Trim(KS.CheckXSS(KS.S("MDCity")))
	FHUserName = Left(KS.S("FHUserName"),10)
	FHMobile = Left(KS.S("FHMobile"),20)
	TaskID = Left(KS.S("TaskID"),20)
	PayType = KS.ChkClng(KS.S("PayType"))
	GetType = KS.ChkClng(KS.S("GetType"))
	If KS.IsNul(BuyPayDate) Or KS.IsNul(ComName) Or KS.IsNul(CFCity) Or KS.IsNul(MDCity) Or KS.IsNul(FHUserName) Or KS.IsNul(FHMobile) Then
		KS.AlertHistory "抱歉！你提交的信息有误，请返回审核！","-1"
	End If
	MDCity = Replace(MDCity, ",", "，")
	tmpMDCity = Split(MDCity, vbCrlf)
	If GetType = 1 Then
		If KS.IsNul(TaskID) Then
			KS.AlertHistory "抱歉！请先填写任务编号再提交，要么选择单独购买单号！","-1"
		End If
		If Conn.Execute("Select Top 1 ID From KS_U_sxyrw Where Inputer='" & KSUser.UserName & "' And KS_TaskID = '" & TaskID & "'").Eof Then
			KS.AlertHistory "抱歉！该任务编号不存在或不是你所发布的，请返回核实再试！","-1"
		End If
		If Not Conn.Execute("Select Top 1 ID From KS_U_sxyrw Where KS_XuShiTF = 0 And KS_TaskID = '" & TaskID & "'").Eof Then
			KS.AlertHistory "抱歉！虚拟任务不可以订购快递单号，请返回核实再试！","-1"
		End If
		If Not Conn.Execute("Select Top 1 ID From Express_Buy Where TaskID = '" & TaskID & "'").Eof Then
			KS.AlertHistory "抱歉！该任务编号已经领取过了！","-1"
		End If
		If Ubound(tmpMDCity) > 1 Then
			KS.AlertHistory "抱歉！任务编号订购方式，一次只能填写一条订购信息！","-1"
		End If
		If Ubound(Split(tmpMDCity(0), "，")) < 3 Then
			KS.AlertHistory "抱歉！收货地址填写的格式不对，请按页面提示的格式填写，谢谢！","-1"
		End If
		tmpArray = Split(tmpMDCity(0), "，")
		
		If (Ubound(tmpArray) = 3 And Ubound(Split(Trim(tmpArray(2)), " ")) < 3) Or (Ubound(tmpArray) = 4 And Ubound(Split(Trim(tmpArray(3)), " ")) < 3) Then
			KS.AlertHistory "抱歉！收货地址填写的格式不对，请按页面提示的格式填写，谢谢！","-1"
		End If
		Num = 1
	Else
		For i = 0 To Ubound(tmpMDCity)
			If Not KS.IsNul(Trim(tmpMDCity(i))) Then
				Num = Num + 1	'记录有效收货地址的订购数量
				If Ubound(Split(tmpMDCity(i), "，")) < 3 Then
					KS.AlertHistory "抱歉！收货地址框第" & i & "行填写的格式不对，请按页面提示的格式填写，谢谢！","-1"
				End If
				tmpArray = Split(tmpMDCity(i), "，")
				If (Ubound(tmpArray) = 3 And Ubound(Split(Trim(tmpArray(2)), " ")) < 3) Or (Ubound(tmpArray) = 4 And Ubound(Split(Trim(tmpArray(3)), " ")) < 3) Then
					KS.AlertHistory "抱歉！收货地址框第" & i & "行填写的格式不对，请按页面提示的格式填写，谢谢！","-1"
				End If
			End If
		Next
	End If
	
	If PayType = 1 Then
		If GetType = 1 Then Money = Left(KS.S("txt_Price1"),5) Else Money = Left(KS.S("txt_Price2"),5) * Num
		If Round(Money, 2) > Round(KSUser.GetUserInfo("Money"),2) Then
			KS.AlertHistory "抱歉！您的账户余额不足，请充值后再来订购，或选择扣发布点方式结算！","-1"
		End If
		If Round(Money, 2) > 0 Then
			Call KS.MoneyInOrOut(KSUser.UserName, KSUser.GetUserInfo("RealName"), Money, 4, 2, now, 0, "系统","订购" & Num & "条" & ComName & "单！", 0, 0, 1)
		End If
	Else
		If GetType = 1 Then Money = Left(KS.S("txt_Point1"),5) Else Money = Left(KS.S("txt_Point2"),5) * Num
		If Round(Money, 2) > Round(KSUser.GetUserInfo("Point"),2) Then
			KS.AlertHistory "抱歉！您的账户发布点不足，请先购买发布点后再来订购，或选择扣余额方式结算！","-1"
		End If
		If Round(Money, 2) > 0 Then
			Call KS.PointInOrOut(0, 0, KSUser.UserName, 2, Round(Money,2), "系统","订购" & Num & "条" & ComName & "单！", 0)
		End If
	End If
	
	Set RS = Server.CreateObject("ADODB.RECORDSET")
	RS.Open "Select Top 1 * From Express_Buy", Conn, 1, 3
	For i = 0 To Ubound(tmpMDCity)
		If Not KS.IsNul(Trim(tmpMDCity(i))) Then
			Set D_RS = Conn.Execute("Select Top 1 ID, Express_Num, ScanDate From Express_Num Where Express_Com = '" & ComName & "' And IsBuy = 0")
			RS.AddNew
			If Not D_RS.Eof Then
				Conn.Execute("Update Express_Num Set IsBuy = 1, BuyUserName = '" & KSUser.UserName & "', BuyDate = GetDate(), BuyIP = '" & KS.GetIP() & "' Where ID = " & D_RS("ID"))
				RS("KuaiDiNum") = D_RS("Express_Num")
				RS("ScanDate") = D_RS("ScanDate")
			End If
			Set D_RS = Nothing
			RS("BuyUserName") = KSUser.UserName
			RS("BuyPayDate") = BuyPayDate
			RS("ComName") = ComName
			RS("CFCity") = CFCity
			RS("MDCity") = tmpMDCity(i)
			RS("FHUserName") = FHUserName
			RS("FHMobile") = FHMobile
			RS("PayType") = PayType
			If GetType = 1 Then
				RS("Money") = Money
				RS("TaskID") = TaskID
			Else
				RS("Money") = Round(Money / Num, 2)
			End If
			RS("AddDate") = Now()
			RS("IP") = KS.GetIP()
			RS.Update
			
		End If
	Next
	RS.Close
	Set RS = Nothing
	Call Deliver_Address(KSUser.UserName, CFCity, KS.GetIP())
	Call KSUser.AddLog(KSUser.UserName, "订购一条" & ComName & "单！", 1)
	KS.Alert "恭喜您！订购成功！", "?Action=MyOrder"

End Sub

Public Function Deliver_Address(UserName, CFCity, IP)
	Dim RS
	Set RS = Server.CreateObject("ADODB.RECORDSET")
	RS.Open "Select Top 1 * From Express_Deliver_Address Where UserName='" & UserName & "' And Address='" & CFCity & "'", Conn, 1, 3
	If RS.EOF Then
		RS.AddNew
		RS("UserName") = UserName
		RS("Address") = CFCity
		RS("IP") = IP
		RS.Update
	End If
	RS.Close
	Set RS = Nothing
End Function

Public Sub Del_Address()
	Dim Address
	Address = KS.S("Address")
	If Address <> "" Then
		IF Cbool(KSUser.UserLoginChecked)=false Then
			Response.Write "<script>alert('请登录后再操作！');top.location.href='Login';</script>"
			Exit Sub
		End If
		Conn.Execute("DELETE FROM Express_Deliver_Address Where UserName='" & KSUser.UserName & "' And Address = '" & Address & "'")
		KS.Alert "删除成功！", "User_Express_Buy.asp"
	End If
End Sub
	

		Public Sub MiniShow()
		IF Cbool(KSUser.UserLoginChecked)=false Then
		   Response.Write "<script>top.location.href='Login';</script>"
		   Exit Sub
		End If
		Dim ID:	ID = KS.ChkClng(KS.S("ID"))
		Set RS=Server.CreateObject("ADODB.RECORDSET")
		RS.Open "Select Top 1 * From Express_Buy Where BuyUserName = '" & KSUser.UserName & "' And ID="& ID,Conn,1,1
		If Not RS.Eof Then
		%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<style type="text/css">
body {background:#ffffff; color:#106899; font:12px/20px Arial,Verdana,Tahoma,"宋体";margin:0 auto;}
*{padding:0px;margin:0px;}
.clear{	clear: both;height:0px;display:block;*display:inline;}
a{text-decoration:none;color:#20537A;}
a:hover{text-decoration:underline;}
.orange,.orange a{color:#FF5500;}
.blue{color:#00F;}
.center_tbl td {border-bottom:1px #E5F5FF solid; line-height:32px; height:32px; clear:both; background-color:#FFF}
.center_tbl tr:hover td{background-color:#EBF5FF}
.button{cursor: pointer;height:23px;border:1px solid #cccccc;background:url(/style/images/button/button_bg.gif) left repeat-x;}
</style>
<body>
<script language="javascript">
//复制内容进剪贴板
function copyToClipboard(txt,msg) {
	  if(window.clipboardData) {
			  window.clipboardData.clearData();		
			  window.clipboardData.setData("Text", txt);		
	  } else if (window.netscape) {		
		   try {		
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");		
		   } catch (e) {		
				alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");		
		   }		
		   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);		
		   if (!clip)		
				return;		
		   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);		
		   if (!trans)		
				return;		
		   trans.addDataFlavor('text/unicode');		
		   var str = new Object();		
		   var len = new Object();		
		   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);		
		   var copytext = txt;		
		   str.data = copytext;		
		   trans.setTransferData("text/unicode",str,copytext.length*2);		
		   var clipid = Components.interfaces.nsIClipboard;		
		   if (!clip)		
				return false;		
		   clip.setData(trans,null,clipid.kGlobalClipboard);
	  } else {	
			alert('抱歉！该浏览器(非IE内核)不支持复制，请用鼠标选中账号右键复制！');
			return;	
	  }			  
	  msg = (typeof(msg)=="undefined")?'复制成功！':msg;		
	  alert(msg);	
 }
</script>
<table  width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="center_tbl">
<%If RS("TaskID")<>"" Then%>
 <tr class="tdbg">
  <td width="30%" height="35" align="right" class="clefttitle"><strong><span>任务编号：</span></strong></td>
  <td width="70%">&nbsp;<%=RS("TaskID")%></td>
 </tr>
<%End If%>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>淘宝(拍拍)买家付款时间：</strong></td>
    <td>&nbsp;<%=RS("BuyPayDate")%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>选购的快递公司：</strong></td>
    <td class="blue">&nbsp;<%=RS("ComName")%></td>
  </tr>
 <tr class="tdbg">
  <td width="28%" height="35" align="right" class="clefttitle"><strong><span>快递单号：</span></strong></td>
  <td width="72%" style="color:#F00; font-size:18px; font-weight:bold">&nbsp;<strong><%If Not KS.IsNul(RS("KuaiDiNum")) Then KS.Echo RS("KuaiDiNum") & " &nbsp;<input type=""button"" class=""button"" value="" 复制 "" onclick=""copyToClipboard('" & RS("KuaiDiNum") & "','单号已复制成功！')"" />" Else KS.Echo "待发快递"%></strong></td>
 </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>发快递时间：</strong></td>
    <td class="orange">&nbsp;<strong><font color=red><%If Not KS.IsNul(RS("ScanDate")) Then KS.Echo RS("ScanDate") Else KS.Echo "待发快递"%></font></strong></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>发货地址：</strong></td>
    <td class="orange">&nbsp;<%=RS("CFCity")%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>发货人：</strong></td>
    <td class="orange">&nbsp;<%=RS("FHUserName")%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>发货人电话：</strong></td>
    <td class="orange">&nbsp;<%=RS("FHMobile")%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>收货地址：</strong></td>
    <td class="orange">&nbsp;<%=RS("MDCity")%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>订购结算方式：</strong></td>
    <td class="blue">&nbsp;<%If RS("PayType")=1 Then KS.Echo "扣账户余额" Else KS.Echo "扣账户发布点"%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>本次订购价格：</strong></td>
    <td class="blue">&nbsp;<%=RS("Money")%>&nbsp;<%If RS("PayType")=1 Then KS.Echo "元" Else KS.Echo "点"%></td>
  </tr>
  <tr class="tdbg" height="35">
  	<td align="right" class="clefttitle"><strong>订购时间：</strong></td>
    <td>&nbsp;<%=RS("AddDate")%></td>
  </tr>
  <tr>
  	<td colspan="2" align="center" bgcolor="#EEF1F1" style="height:50px; line-height:50px;">
    <input type="image" name="Save" src="/style/images/CloseButton.gif" onClick="parent.closeWindow();" /></td>
  </tr>
</table>
</body>
</html>
        <%
			RS.Close
				Set RS = Nothing
			Else
				KS.AlertHistory "抱歉！该单号不存在或已被删除了！","-1"
			End If
		End Sub
		
End Class
%> 
