<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<%
Dim KSCls
Set KSCls = New TaskBinDing
KSCls.Run()
Set KSCls = Nothing

Class TaskBinDing
	Private KS,KSUser
	Private ComeUrl,LoginTF,Action,ID
	Private Sub Class_Initialize()
		Set KS=New PublicCls
		Set KSUser = New UserCls
	End Sub
	Private Sub Class_Terminate()
		Set KS=Nothing
		Set KSUser=Nothing
		Call CloseConn()
	End Sub

	Public Sub Run()
		ComeUrl=Request.ServerVariables("HTTP_REFERER")
		LoginTF=Cbool(KSUser.UserLoginChecked)
		IF LoginTF=false  Then
		  GCls.ComeUrl=ComeUrl	'GCls.GetUrl()
		  Response.Redirect("/user/login/")
		  Exit Sub
		End If
		IF KS.ChkClng(KSUser.GetUserInfo("KS_IDAuthentication")) <> 1 And SMS_IDAuthentication_Enabled = 1 Then
			KS.Die "<script>alert('抱歉！\n\n为了营造一个真实、安全、高效的信誉互动平台，要求所有用户必需通过手机认证确认真实身份后，才可\n\n以接发任务等，由于您的账号尚未通过手机认证，暂时不能操作，请点击“确定”按钮跳转到认证页面。');top.location.href='/User/User_IDAuthentication.asp';</script>"
		End IF

	'================= Action 动作、ID 判断START =================================
	Action = KS.CheckXSS(KS.R(KS.S("Action")))
	ID = KS.ChkClng(KS.S("ID"))
	If Action = "Check" Then
	IF ID <> 0 Then
		Dim Code: Code = KS.CheckXSS(KS.R(KS.S("Code")))
		IF Not Conn.Execute("Select Top 1 ID From MaiMaiUser Where UserName = '" & KSUser.UserName & "' And ID = " & ID).Eof Then
			IF Not Conn.Execute("Select Top 1 UserID From KS_User Where CheckNum = '" & Code & "' And UserName = '" & KSUser.UserName & "'").Eof Then
				Conn.Execute("UPDate MaiMaiUser Set IsActivate = 1 Where UserName = '" & KSUser.UserName & "' And ID = " & ID)
				Conn.Execute("Update KS_User Set CheckNum = '" & KS.MakeRandom(6) & "' Where UserName = '" & KSUser.UserName & "'")
				KS.Die "<script>alert('恭喜！掌柜号激活成功！');parent.location.reload();parent.closeWindow();</script>"
			Else
				KS.AlertHistory "抱歉！激活码不对，请返回核实输入或联系客服人员处理!","-1"
			End IF
		Else
			KS.AlertHistory "抱歉！没有找到该掌柜号!","-1"
		End IF
	End If

	End If
	Dim Rs
	Set Rs = Conn.Execute("Select Top 1 * From MaiMaiUser Where (UserName = '"& KSUser.UserName &"') And ID=" & ID)
	If Rs.Eof Then
		KS.Die "<div class=""border"">抱歉！没有找到该掌柜号!</div>"
	End If
	%>
<!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" />
<title>激活掌柜号</title>
<link href="/style/css/task.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="/HSK_JS/jquery.js"></script>
<script type="text/javascript" src="/style/js/common_def.js"></script>
<style type="text/css">
body {background:#ffffff url(/style/images/body_bg.gif) repeat-x 0 0;}
</style>
</head>
<body>
<script type="text/javascript">
function Confirm(){
var Code = document.myform.Code.value ;
if (Code==""){
alert('请输入手机短信中的验证码(即激活码)，如尚未收到，请稍候片刻...');
document.myform.Code.focus();
return false;}
}

function SendSMS(){
	var ajaxchk;
	var ajaxstr;
	document.myform.Sendbt.disabled = true;
	$.ajax({type:"post",url:"/Plus/Ajax_SMS.asp",data:"Action=SendSMS&Mobile=<%=KSUser.GetUserInfo("Mobile")%>&Flag=ActivateShop_<%=ID%>&N=1&anticache=" + Math.floor(Math.random()*1000),cache:false,dataType:"html",success:function(d){
	var s=unescape(d);
	ajaxchk=s.split('|')[0];
	ajaxstr=s.split('|')[1];
	if (ajaxstr!=null){
		if (ajaxchk=='ok'){alert(ajaxstr);document.myform.Sendbt.value = '请注意查收手机短信';
		}else{alert(ajaxstr);document.myform.Sendbt.disabled = false;}
	}
} });
}
</script>

<div id="tips" style="border:1px #A7DDFE solid; width:auto; height:40px; padding:8px; margin:6px;background:url(/style/images/msg_bg.png) #ECF8FF no-repeat 10px -490px; padding-left: 55px;"><strong>激活掌柜号</strong><br />
    <span class="orange">为了您的账户资金安全，新绑定的掌柜号需验证激活方可发布任务！</span>
</div>
  <form name="myform" method="post" action="?Action=Check" id="myform" onSubmit="return Confirm();">
    <table width="98%" border="0" cellspacing="3" cellpadding="8">
      <tr>
        <td height="10"></td>
        <td></td>
      </tr>
      <tr>
        <td width="130" height="30" align="right" class="color2 rough">掌柜名称：</td>
        <td class="orange"><%=Rs("ShopName")%></td>
      </tr>
      <tr>
        <td width="130" height="30" align="right" class="color2 rough">接收手机号：</td>
        <td class="orange"><%=Left(KSUser.GetUserInfo("Mobile"),3) & "*****" & Right(KSUser.GetUserInfo("Mobile"),3)%></td>
      </tr>
      <tr>
        <td height="30" align="right" class="color2 rough">激活码：</td>
        <td><input name="Code" type="text" id="Code" class="textbox" size="15" maxlength="6" title="填写手机短信收到的验证码(即激活码)" />&nbsp; <input class="button" name="Sendbt" type="button" id="Sendbt" value=" 免费获取激活码 " onclick="SendSMS()" title="点击后向你的接收手机号发送一条短信" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="btnSubmit" type="submit" class="button" id="btnSubmit" value=" 确 定 " />
          &nbsp; <input name="btnCancel" type="button" class="button" onClick="parent.closeWindow();" id="btnCancel" value=" 取 消 " /><input type="hidden" name="id" value="<%=ID%>" /></td>
      </tr>
    </table>
  </form>
</body>
</html>
<%
Set Rs = Nothing
End Sub

End Class
%>