<!-- #Include File="Con_User.asp" -->
<!-- #Include File="../Include/Cls_pagecute.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Dim sTmp,chk,errs,is_converion,is_virement,is_card,is_pay,min_amount,buy_num,min_virement
Dim integral_unit,expression_unit,strength_unit,unit_strength,unit_expression,unit_integral,emoney_1,emoney_4,emoney_5,strength_1,strength_3,strength_4
pageurl="?action="&action&"&" 
integral_unit=UserGroup_Config(4)	'积分换货币系数
expression_unit=UserGroup_Config(27)	'经验换货币系数
strength_unit=UserGroup_Config(28)	'体力换货币系数

unit_strength=UserGroup_Config(20)	'货币换体力系数
unit_expression=UserGroup_Config(30)	'货币换经验系数
unit_integral=UserGroup_Config(29)	'货币换积分系数

buy_num=UserGroup_Config(11)		'人民币购买系数
min_amount=UserGroup_Config(12)		'最低消费额
min_virement=UserGroup_Config(6)	' 转帐手续费
If not isnumeric(min_amount) Then min_amount=1
If min_amount<1 Then min_amount=1
chk=Cls.chk()
errs=""
is_pay=true
If cstr(UserGroup_Config(10))<>"1" Then
	is_pay=false
End If
is_virement=true
If cstr(UserGroup_Config(5))<>"1" Then
	is_virement=false
End If
is_converion=true
If cstr(UserGroup_Config(3))<>"1" Then
	is_converion=false
End If
is_card=true
If cstr(UserGroup_Config(13))<>"1" Then
	is_card=false
End If
tit="理财中心"
'If action="usercard" Then tit="会员卡"

call DoWebHead(2,0)
'----------------------------左边 开始----------------------------
'----------------------------左边 结束----------------------------
'----------------------------中间 开始----------------------------
call emoney_main()
'----------------------------中间 结束----------------------------
call DoWebEnd()

sub emoney_main()
  dim emoney_pe,emoney_2,emoney_3,e_num,e_all,c_name,c_pass,c_power,c_id,c_day,f_day,ks_day,strength_2,c_powerok,tmp_otim
  dim emoney_ex,emoney_st,emoneys,emoneys_ex,emoneys_st,strengths,strengths_ex,strengths_in
  If int(login_estate)=true Then  
  tmp_otim="计时用户&nbsp;<font class=blue>（过期时间："&login_otim&"）</font>&nbsp;"
  Else
  tmp_otim="非计时用户&nbsp;<a href='Emoney.asp?action=usercard'><font class=blue>[开通计时]</font>&nbsp;</a>"
  End If
  strength_2=0
  emoney_2=0
  c_id=0
  emoney_1=login_integral\integral_unit
  emoney_4=login_expression\expression_unit
  emoney_5=login_strength\strength_unit
  strength_1=login_emoney*unit_strength
  strength_3=login_emoney*unit_expression
  strength_4=login_emoney*unit_integral
  If action<>"virement" and action<>"card" and action<>"converion" and action<>"usercard" Then action="pay"
  If action="converion" and chk=true Then
	e_num=trim(request.form("e_num"))
	e_all=trim(request.form("e_all"))
	emoneys=emoney_1
	emoneys_ex=emoney_4
	emoneys_st=emoney_5
	strengths=strength_1
	strengths_ex=strength_3
	strengths_in=strength_4
	If e_all="yes" Then
		emoney_2=emoneys
		emoney_ex=emoneys_ex
		emoney_st=emoneys_st
		strength_2=login_emoney
	Else
		If not(isnumeric(e_num)) Then
			errs="no"
		Else
			If instr(1,e_num,".")>0 Then
				errs="no"
			Else
				If trim(request.form("check_num"))=1 Then
					If int(e_num)<1 or int(e_num)>int(emoneys) Then
						errs="no"
					Else
						emoney_2=e_num
					End If
				ElseIf trim(request.form("check_num"))=2 Then
					If int(e_num)<1 or int(e_num)>int(emoneys_ex) Then
						errs="no"
					Else
						emoney_ex=e_num
					End If
				ElseIf trim(request.form("check_num"))=3 Then
					If int(e_num)<1 or int(e_num)>int(emoneys_st) Then
						errs="no"
					Else
						emoney_st=e_num
					End If
				Else
					If int(e_num)<1 or int(e_num)>int(login_emoney) Then
						errs="no"
					Else
						strength_2=e_num
					End If
				End If
			End If
		End If
	End If

	If action="converion" and int(emoney_2)>0 and trim(request.form("check_num"))=1 Then
		call Cls.exec("update AsaiMHUserData set integral=integral-"&emoney_2*integral_unit&",emoney=emoney+"&emoney_2&" where username='"&login_username&"'",0)
		login_integral=login_integral-emoney_2*integral_unit
		login_emoney=login_emoney+emoney_2
		emoney_1=emoney_1-emoney_2
		Response.write Cls.js_put("alert(""您已成功换算了 "&emoney_2&" "&Cls.web_unit&"！\n\n您的积分消耗了："&emoney_2*integral_unit&" 分\n\n目前的积分换算率为：每 "&integral_unit&" 分可换算 1 "&Cls.web_unit&""");",1)
	End If
	If action="converion" and int(emoney_ex)>0 and trim(request.form("check_num"))=2 Then
		call Cls.exec("update AsaiMHUserData set expression=expression-"&emoney_ex*expression_unit&",emoney=emoney+"&emoney_ex&" where username='"&login_username&"'",0)
		login_expression=login_expression-emoney_ex*expression_unit
		login_emoney=login_emoney+emoney_ex
		emoney_1=emoney_1-emoney_ex
		Response.write Cls.js_put("alert(""您已成功换算了 "&emoney_ex&" "&Cls.web_unit&"！\n\n您的经验消耗了："&emoney_ex*expression_unit&" 分\n\n目前的积分换算率为：每 "&expression_unit&" 分可换算 1 "&Cls.web_unit&""");",1)
	End If
	If action="converion" and int(emoney_st)>0 and trim(request.form("check_num"))=3 Then
		call Cls.exec("update AsaiMHUserData set strength=strength-"&emoney_st*strength_unit&",emoney=emoney+"&emoney_st&" where username='"&login_username&"'",0)
		login_strength=login_strength-emoney_st*strength_unit
		login_emoney=login_emoney+emoney_st
		emoney_1=emoney_1-emoney_st
		Response.write Cls.js_put("alert(""您已成功换算了 "&emoney_st&" "&Cls.web_unit&"！\n\n您的体力消耗了："&emoney_st*strength_unit&" 分\n\n目前的积分换算率为：每 "&strength_unit&" 分可换算 1 "&Cls.web_unit&""");",1)
	End If
	If action="converion" and int(strength_2)>0 and trim(request.form("check_num"))=4 Then
		call Cls.exec("update AsaiMHUserData set integral=integral+"&strength_2*unit_integral&",emoney=emoney-"&strength_2&" where username='"&login_username&"'",0)
		login_integral=login_integral+strength_2*unit_integral
		login_emoney=login_emoney-strength_2
		strength_3=strength_3+strength_2
		Response.write Cls.js_put("alert(""您已成功换算了 "&strength_2*unit_integral&" 点积分！\n\n您的"&Cls.web_unit&"消耗了："&strength_2&" 个\n\n目前的积分换算率为：每 1 "&Cls.web_unit&" 可换算"&unit_integral&" 点积分"");",1)
	End If
	If action="converion" and int(strength_2)>0 and trim(request.form("check_num"))=5 Then
		call Cls.exec("update AsaiMHUserData set expression=expression+"&strength_2*unit_expression&",emoney=emoney-"&strength_2&" where username='"&login_username&"'",0)
		login_expression=login_expression+strength_2*unit_expression
		login_emoney=login_emoney-strength_2
		strength_4=strength_4+strength_2
		Response.write Cls.js_put("alert(""您已成功换算了 "&strength_2*unit_expression&" 点经验！\n\n您的"&Cls.web_unit&"消耗了："&strength_2&" 个\n\n目前的经验换算率为：每 1 "&Cls.web_unit&" 可换算"&unit_expression&" 点经验"");",1)
	End If
	If action="converion" and int(strength_2)>0 and trim(request.form("check_num"))=6 Then
		call Cls.exec("update AsaiMHUserData set strength=strength+"&strength_2*unit_strength&",emoney=emoney-"&strength_2&" where username='"&login_username&"'",0)
		login_strength=login_strength+strength_2*unit_strength
		login_emoney=login_emoney-strength_2
		strength_1=strength_1+strength_2
		Response.write Cls.js_put("alert(""您已成功换算了 "&strength_2*unit_strength&" 点体力！\n\n您的"&Cls.web_unit&"消耗了："&strength_2&" 个\n\n目前的体力换算率为：每 1 "&Cls.web_unit&" 可换算"&unit_strength&" 点体力"");",1)
	End If
End If
  If action="virement" and chk=true Then
    e_num=trim(request.form("e_num"))
    e_all=trim(request.form("e_all"))
    emoneys=login_emoney
    'If action="virement" Then emoneys=login_emoney
    If e_all="yes" Then
      emoney_2=emoneys
    Else
      If not(isnumeric(e_num)) Then
        errs="no"
      Else
        If instr(1,e_num,".")>0 Then
          errs="no"
        Else
         If int(e_num)<1 or int(e_num)>int(emoneys) Then
           errs="no"
         Else
           emoney_2=e_num
         End If
        End If
      End If
    End If
      emoney_pe=emoney_2*min_virement/100
      emoney_pe=Cls.fix_num(emoney_pe,1)
      emoney_3=emoney_pe+emoney_2
      If int(login_emoney)<int(emoney_3) Then
        emoney_2=emoney_2-(emoney_3-login_emoney)
        emoney_3=login_emoney
      End If
    If  int(emoney_2)>0 Then
      dim username2
      username2=trim(request.form("username2"))
      If ChkName(username2)<>true Then
        errs="no"
      Else
        set rs=Cls.exec("select username from AsaiMHUserData where username='"&username2&"'",1)
        If rs.eof Then errs="no"
        rs.close
      End If
      If errs="" Then
        call Cls.exec("update AsaiMHUserData set emoney=emoney-"&emoney_3&" where username='"&login_username&"'",0)
        call Cls.exec("update AsaiMHUserData set emoney=emoney+"&emoney_2&" where username='"&username2&"'",0)
        login_emoney=login_emoney-emoney_3
        Response.write  Cls.js_put("alert(""您已成功的给 "&username2&" 转帐了 "&emoney_2&" "&Cls.web_unit&"！\n\n您拥有的"&tit&"也减少了："&emoney_3&" "&Cls.web_unit&"\n\n转帐手续费为："&emoney_pe&" "&Cls.web_unit&""");",1)
        sql="insert into AsaiMHUserMail(send_u,accept_u,topic,word,tim,types,isread) " & _
	    "values('"&login_username&"','"&username2&"','[系统]货币转帐信息提示','"&login_username&" 已成功的给 您 转帐了 "&emoney_2&" "&Cls.web_unit&"！','"&Cls.now_time&"',1,0)"
	call Cls.exec(sql,0)
      End If
    End If
  End If
  If action="usercard" and chk=true Then
  dim c_integral,c_emoney,c_expression,c_strength
      sql="select otim from AsaiMHuserdata where username='"&login_username&"'"
      set rs=Cls.exec(sql,1)
      If not rs.eof Then
      f_day=Cls.time_type(rs("otim"),4)
      End If
       If datediff("d",Cls.time_type(Cls.now_time,4),f_day)>0 Then 
	   ks_day=f_day
	   Else
	   ks_day=Cls.time_type(Cls.now_time,4)
	   End If
      rs.close
    c_id=Cls.Code_Var(trim(request.form("is_put")))
    If c_id="" or isnull(c_id) Then
    Response.write Cls.js_put("alert(""您没有选择要兑换的会员卡！\n\n点击返回。。。"");",1)
	Else
    SQL="select top 1 * from AsaiMHCards where c_id="&c_id
     set rs=Cls.exec(sql,1)
       If not rs.eof Then
        c_emoney=int(rs("c_emoney"))
        c_integral=int(rs("c_integral"))
        c_expression=int(rs("c_expression"))
        c_strength=int(rs("c_strength"))
		c_day=rs("c_day")
		c_power=rs("c_power")
		If c_power="vip" Then c_powerok="VIP会员"
		If c_power="puser" Then c_powerok="资深会员"
	  If int(login_emoney)<int(c_emoney) or int(login_integral)<int(c_integral) or int(login_expression)<int(c_expression) or int(login_strength)<int(c_strength)Then
         Response.write Cls.js_put("alert(""您的金币,积分或经验,体力不够兑换会员卡！\n\n点击返回。。。"");",1)
       Else
	   If int(login_modep)<4 Then
         Response.write Cls.js_put("alert(""您高于购买用户类型，您不可以兑换会员卡！\n\n点击返回。。。"");",1)
		 Else
	   If int(login_modep)=4 and c_power="puser" Then
         Response.write Cls.js_put("alert(""您已经是VIP会员，您不可以兑换资深会员卡！\n\n点击返回。。。"");",1)
		 Else
      sql="update AsaiMHUserData set otim='"&DateAdd("m",c_day,ks_day)&"',estate=1,emoney=emoney-"&c_emoney&",integral=integral-"&c_integral&",expression=expression-"&c_expression&",strength=strength-"&c_strength
      If int(login_modep)>4 Then
        sql=sql&",power='"&rs("c_power")&"'"
        Ok_msg="\n\n您也同时升级为 "&c_powerok&"！会员期 "&c_day&" 个月！"
		Else
        Ok_msg="\n\n您延长了会员期 "&c_day&" 个月！"
      End If
      sql=sql&" where username='"&login_username&"'"
      call Cls.exec(sql,0)
      call Cls.exec("update AsaiMHCards set c_hidden=1,c_pay='"&login_username&"',c_tim='"&Cls.now_time&"' where c_id="&c_id,0)
	  login_emoney=login_emoney-c_emoney
	  login_integral=login_integral-c_integral
	  login_expression=login_expression-c_expression
	  login_strength=login_strength-c_strength
     Response.write  Cls.js_put("alert(""您已成功的兑换会员卡！"&Ok_msg&""");",1)
       Call Cookies_Load()
	  End If
	End If
     End If
   End If
  End If
 End If
  If action="card" and chk=true Then
    c_name=Cls.Code_Var(trim(request.form("c_name")))
    c_pass=Cls.Code_Var(trim(request.form("c_pass")))
    If len(c_name)<1 or len(c_pass)<1 Then errs="no"
    If errs="" Then
      sql="select otim from AsaiMHuserdata where username='"&login_username&"'"
      set rs=Cls.exec(sql,1)
      If not rs.eof Then
      f_day=Cls.time_type(rs("otim"),4)
      End If
       If datediff("d",Cls.time_type(Cls.now_time,4),f_day)>0 Then 
	   ks_day=f_day
	   Else
	   ks_day=Cls.time_type(Cls.now_time,4)
	   End If
      rs.close
      sql="select c_id,c_day,c_power from AsaiMHCards where c_name='"&c_name&"' and c_pass='"&c_pass&"' and c_hidden=0"
      set rs=Cls.exec(sql,1)
      If rs.eof Then
        errs="no"
      Else
        c_id=rs("c_id")
		c_day=rs("c_day")
        c_power=rs("c_power")
		If c_power="vip" Then c_powerok="VIP会员"
		If c_power="puser" Then c_powerok="资深会员"
      End If
      rs.close
    End If
    If errs="" Then
      dim Ok_msg
      Ok_msg=""
      call Cls.exec("update AsaiMHCards set c_hidden=2,c_pay='"&login_username&"',c_tim='"&Cls.now_time&"' where c_id="&c_id,0)
      sql="update AsaiMHUserData set otim='"&DateAdd("m",c_day,ks_day)&"',estate=1"
      If int(login_modep)>4 Then
        sql=sql&",power='"&c_power&"'"
        Ok_msg="\n\n您也同时升级为 "&c_powerok&"！会员期 "&c_day&" 个月！"
		Else
        Ok_msg="\n\n您延长了会员期 "&c_day&" 个月！"
      End If
      sql=sql&" where username='"&login_username&"'"
      call Cls.exec(sql,0)
     Response.write Cls.js_put("alert(""您已成功的使用了会员卡（卡号："&c_name&"）！"&Ok_msg&""");",1)
    End If
  End If
  select case action
  case "converion"
    sTmp=sTmp& emoney_converion()
  case "virement"
    sTmp=sTmp& emoney_virement()
  case "card"
    sTmp=sTmp& emoney_card()
  case "usercard"
    sTmp=sTmp& emoney_usercard()
  case Else
    sTmp=sTmp& emoney_pay()
  end select
	Cls.HtmlRcod "body",Cls.ReadTemplate("user_Emoney")
	Cls.HtmlRcod "login_emoney",login_emoney
	Cls.HtmlRcod "web_unit",Cls.web_unit
	Cls.HtmlRcod "login_integral",login_integral
	Cls.HtmlRcod "login_strength",login_strength
	Cls.HtmlRcod "login_expression",login_expression
	Cls.HtmlRcod "emoney_1",emoney_1
	Cls.HtmlRcod "body",sTmp
	Cls.HtmlRcod "otim",tmp_otim
	Cls.HtmlRcod "dir_skin",Cls.web_skindir
	Cls.HtmlRcod "tit",tit
	Cls.OutPage
End Sub

Function emoney_pay()
dim sTmp,PaymentsTmp,PaymentStyle
PaymentsTmp = Split(Cls.Web_Payment,"|")
%>
<script language=javascript>
<!--
var min_amount=<%Response.Write min_amount%>;
var base_unit_num=<%Response.Write buy_num%>;
var strTemp="0123456789";
function emoney_pay_checkreturn()
{
  var num=document.emoney_frm_pay.pay_amount.value;
  if (num<min_amount)
  {
    alert('对不起，当前最低消费额为 '+min_amount+' 元！');
    return false;
  }
  else
  {
    return click_return('您确定要购买 '+(num*base_unit_num)+' '+m_unit+'吗？\n\n您将支付 '+num+' 元人民币！\n\n点击确定进行在线支付购买……',1)
  }
}
function emoney_pay_checknum()
{
  //var num=emoney_pay_nums(document.emoney_frm_pay.pay_amount.value,min_amount);
  var num=document.emoney_frm_pay.pay_amount.value;
  document.emoney_frm_pay.pay_unit_num.value=num*base_unit_num;
}
function emoney_pay_nums(nums,bnum)
{
  var i,j;
  var tmpnum=nums;
  if (tmpnum=="" || tmpnum==null) { return bnum; }
  for (i=0;i<tmpnum.length;i++)
  {
    j=strTemp.indexOf(tmpnum.charAt(i));
    if (j==-1) { return bnum; }
  }
  if (tmpnum<bnum) { tmpnum=bnum; }
  return tmpnum;
}
-->
</script>
<%
sTmp= "<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<tr><td class=td>&nbsp;购买"&Cls.web_unit&"</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>" & _
vbcrlf&"<table border=0 class=tablew>" & _
vbcrlf&"<tr><td height=20>目前的人民币购买"&Cls.web_unit&"的比率为：每&nbsp;<font class=red2><b>1</b></font>&nbsp;元人民币可购买&nbsp;<font class=red><b>"&buy_num&"</b></font>&nbsp;"&Cls.web_unit&"，当前最低消费额为&nbsp;<font class=red><b>"&min_amount&"</b></font>&nbsp;元</td></tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>"
if is_pay then
sTmp=sTmp&"<table border=0 class=tablew>"
  if chk=true then
	'PaymentStyle=trim(request.form("PaymentStyle"))
  	if trim(request.form("PaymentStyle"))="pay" then
    		call emoney_pay_chk()
	elseif trim(request.form("PaymentStyle"))="alipay" then
    		call emoney_alipay_chk()
	else
		call format_redirect("Emoney.asp")
	end if
  else
sTmp=sTmp&"<form name=emoney_frm_pay action='?' method=post onsubmit=""javascript:frm_submitonce(this);"">" & _
vbcrlf&"<input type=hidden name=chk value='yes'>"
sTmp=sTmp&"<tr><td><b>请选择在线支付平台：</b><select name=""PaymentStyle"">"
if PaymentsTmp(0)<>"" then
	sTmp=sTmp&"<option value=""pay"">网&nbsp;&nbsp;&nbsp;银</option>"
end if
if PaymentsTmp(5)<>"" then
	sTmp=sTmp&"<option value=""alipay"">支付宝</option>"
end if
if PaymentsTmp(0)="" And PaymentsTmp(5)="" then
	sTmp=sTmp&"<option value="""">当前未开放在线支付平台</option>"
end if
sTmp=sTmp&"</select></td></tr>" & _
vbcrlf&"<tr><td height=30>" & _
vbcrlf&"<table border=0>" & _
vbcrlf&"<tr>" & _
vbcrlf&"<td>请输入您要购买"&Cls.web_unit&"的人民币数额：</td>" & _
vbcrlf&"<td><input type=text class=txt name=pay_amount value='"&min_amount&"' size=6 maxlength=10 onKeyUp=""javascript:emoney_pay_checknum();"" style=""text-align: center"">&nbsp;元</td>" & _
vbcrlf&"<td>可购买&nbsp;<input type=text class=txt name=pay_unit_num value='"&min_amount*buy_num&"' size=6 maxlength=10 readonly style=""text-align: center"">&nbsp;"&Cls.web_unit&"</td>"
if PaymentsTmp(0)="" And PaymentsTmp(5)="" then
sTmp=sTmp&"<td><input class=btn type=submit value='警告：当前无支付平台' onclick=""javascript:return emoney_pay_checkreturn();""></td>"
else
sTmp=sTmp&"<td><input class=btn type=submit value='在线支付购买' onclick=""javascript:return emoney_pay_checkreturn();""></td>"
end if
sTmp=sTmp&"</tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"</form>"
  End If
sTmp=sTmp&"</table>"
else
sTmp=sTmp&"<table border=0 class=tablew>" & _
vbcrlf&"<tr align=center><td height=30><font class=red>在线 <b>购买"&Cls.web_unit&"</b> 功能暂时关闭！</font></td></tr>" & _
vbcrlf&"</table>"
End If
sTmp=sTmp&"</td></tr>" & _
vbcrlf&"</table>"
emoney_pay=sTmp
End Function

Function emoney_converion()
dim sTmp,check_num
sTmp=vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<form name=emoney_frm_converion action='?action=converion' method=post onsubmit=""javascript:frm_submitonce(this);"">" & _
vbcrlf&"<input type=hidden name=chk value='yes'>" & _
vbcrlf&"<tr><td class=td>&nbsp;个人分值换算</td></tr>" & _
vbcrlf&"<tr class=tr><td>" & _
vbcrlf&"<table border=0 class=tablew width='100%' align=left>" & _
vbcrlf&"<TR><TD><INPUT type=radio CHECKED value='1' name=check_num> " & _
vbcrlf&"<B>积分换<U>货币</U></B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>"&integral_unit&"</b></FONT>&nbsp;点积分可换算&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"，您可以换算&nbsp;<font class=red>"&emoney_1&"</font>&nbsp;"&Cls.web_unit&"；</TD></TR>" & _
vbcrlf&"<TR><TD><INPUT type=radio value='2' name=check_num> " & _
vbcrlf&"<B>经验换<U>货币</U></B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>"&expression_unit&"</b></FONT>&nbsp;点经验可换算&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"，您可以换算&nbsp;<font class=red>"&emoney_4&"</font>&nbsp;"&Cls.web_unit&"；</TD></TR>" & _
vbcrlf&"<TR><TD><INPUT type=radio value='3' name=check_num> " & _
vbcrlf&"<B>体力换<U>货币</U></B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>"&strength_unit&"</b></FONT>&nbsp;点体力可换算&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"，您可以换算&nbsp;<font class=red>"&emoney_5&"</font>&nbsp;"&Cls.web_unit&"；</TD></TR>" & _
vbcrlf&"<TR><TD><INPUT type=radio value='4' name=check_num> " & _
vbcrlf&"<B><U>货币</U>换积分</B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"可换算&nbsp;<FONT class=red><b>"&unit_integral&"</b></FONT>&nbsp;点积分，您可以换算&nbsp;<font class=red>"&strength_4&"</font>&nbsp;点积分；</TD></TR>" & _
vbcrlf&"<TR><TD><INPUT type=radio value='5' name=check_num> " & _
vbcrlf&"<B><U>货币</U>换经验</B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"可换算&nbsp;<FONT class=red><b>"&unit_expression&"</b></FONT>&nbsp;点经验，您可以换算&nbsp;<font class=red>"&strength_3&"</font>&nbsp;点经验；</TD></TR>" & _
vbcrlf&"<TR><TD><INPUT type=radio value='6' name=check_num> " & _
vbcrlf&"<B><U>货币</U>换体力</B>&nbsp;换算率为：每&nbsp;<FONT class=red><b>1</b></FONT>&nbsp;"&cls.web_unit&"可换算&nbsp;<FONT class=red><b>"&unit_strength&"</b></FONT>&nbsp;点体力，您可以换算&nbsp;<font class=red>"&strength_1&"</font>&nbsp;点体力；</TD></TR>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>"
If is_converion Then
sTmp=sTmp&"<table border=0 class=tablew>"
 If action="converion" and chk=true and errs<>"" Then
 If trim(request.form("check_num"))=1 Then check_num=emoney_1
 If trim(request.form("check_num"))=2 Then check_num=emoney_4
 If trim(request.form("check_num"))=3 Then check_num=emoney_5
 If trim(request.form("check_num"))=4 or trim(request.form("check_num"))=5 or trim(request.form("check_num"))=6 Then check_num=login_emoney
sTmp=sTmp&"<tr><td height=30><font class=red2>换算失败：</font>请输入一个不大于 <font class=red>"&check_num&"</font> 的正整数！&nbsp;&nbsp;<input class=btn type=button name=go_back value='返回上一页' onclick=""javascript:history.back(1);""></td></tr>"
Else
sTmp=sTmp&"<tr><td height=30>请输入您要换算的"&Cls.web_unit&"数值：&nbsp;" & _
vbcrlf&"<input type=text class=txt name=e_num size=12 maxlength=10 value=''>&nbsp;&nbsp;&nbsp;" & _
vbcrlf&"<input type=checkbox name=e_all value='yes' s>&nbsp;全部换算&nbsp;&nbsp;&nbsp;" & _
vbcrlf&"<input class=btn type=submit value='进行换算'></td></tr>" & _
vbcrlf&"</form>"
End If
sTmp=sTmp&"</table>"
Else
sTmp=sTmp&"<table border=0 class=tablew>" & _
vbcrlf&"<tr align=center><td height=30><font class=red><b>分值换算</b> 功能暂时关闭！</font></td></tr>" & _
vbcrlf&"</table>"
End If
sTmp=sTmp&"</td></tr>" & _
vbcrlf&"</table>"
emoney_converion=sTmp
End Function

Function emoney_virement()
dim sTmp
sTmp= "<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<tr><td class=td>&nbsp;货币转帐</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>" & _
vbcrlf&"<table border=0 class=tablew>" & _
vbcrlf&"<tr><td height=20>目前的转帐的手续费为：<font class=red2><b>"&min_virement&"%</b></font>，不足&nbsp;<font class=red><b>1</b></font>&nbsp;"&Cls.web_unit&"的按&nbsp;<font class=red><b>1</b></font>&nbsp;"&Cls.web_unit&"计算</td></tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>"
If is_virement Then
sTmp=sTmp&"<table border=0 class=tablew>"
If action="virement" and chk=true and errs<>"" Then
sTmp=sTmp&"<tr><td height=30><font class=red2>转帐失败：</font></td><td>请输入一个不大于 <font class=red>"&login_emoney&"</font> 的正整数&nbsp;或&nbsp;您要转入的注册用户不存在！&nbsp;&nbsp;<input class=btn type=button name=go_back value='返回上一页' onclick=""javascript:history.back(1);""></td></tr>"
Else
sTmp=sTmp&"<form name=emoney_frm_virement action='?action=virement' method=post onsubmit=""javascript:frm_submitonce(this);"">" & _
vbcrlf&"<input type=hidden name=chk value='yes'>" & _
vbcrlf&"<tr><td height=30>请输入您要转帐的注册用户：&nbsp;" & _
vbcrlf&"<input type=text class=txt name=username2 size=15 maxlength=20 value=''>&nbsp;&nbsp;&nbsp;" & _
vbcrlf&""&friend_select()&"" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr><td height=30>请输入您要转帐的"&Cls.web_unit&"数值：&nbsp;" & _
vbcrlf&"<input type=text class=txt name=e_num size=12 maxlength=10 value=''>&nbsp;&nbsp;&nbsp;" & _
vbcrlf&"<input type=checkbox name=e_all value='yes' s>&nbsp;全部转帐&nbsp;&nbsp;&nbsp;" & _
vbcrlf&"<input class=btn type=submit value='进行转帐'></td></tr>" & _
vbcrlf&"</form>"
End If
sTmp=sTmp&"</table>"
Else
sTmp=sTmp&"<table border=0 class=tablew>" & _
vbcrlf&"<tr align=center><td height=30><font class=red><b>货币转帐</b> 功能暂时关闭！</font></td></tr>" & _
vbcrlf&"</table>"
End If
sTmp=sTmp&"</td></tr>" & _
vbcrlf&"</table>"
emoney_virement=sTmp
End Function

Function emoney_card()
dim sTmp
sTmp= "<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<tr><td class=td>&nbsp;会员卡充值</td></tr>" & _
vbcrlf&"<tr class=tr><td align=center>"
If is_card Then
sTmp=sTmp&"<table border=0 class=tablew>"
 If action="card" and chk=true and errs<>"" Then
sTmp=sTmp&"<tr><td height=30><font class=red2>会员卡充值失败：</font></td><td>您输入的会员 <font class=red>卡号</font> 或 <font class=red>密码</font> 有错误！&nbsp;&nbsp;<input class=btn type=button name=go_back value='返回上一页' onclick=""javascript:history.back(1);""></td></tr>"
Else
sTmp=sTmp&"<form name=emoney_frm_card action='?action=card' method=post onsubmit=""javascript:frm_submitonce(this);"">" & _
vbcrlf&"<input type=hidden name=chk value='yes'>" & _
vbcrlf&"<tr><td height=30>" & _
vbcrlf&"<table border=0>" & _
vbcrlf&"<tr>" & _
vbcrlf&"<td>卡号：&nbsp;<input type=text class=txt name=c_name size=20 maxlength=20></td>" & _
vbcrlf&"<td>&nbsp;&nbsp;密码：&nbsp;<input type=password name=c_pass size=20 maxlength=20></td>" & _
vbcrlf&"<td>&nbsp;&nbsp;<input class=btn type=submit value='会员卡充值'></td>" & _
vbcrlf&"</tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td><tr>" & _
vbcrlf&"</form>"
   End If
sTmp=sTmp&"</table>"
Else
sTmp=sTmp&"<table border=0 class=tablew>" & _
vbcrlf&"<tr align=center><td height=30><font class=red><b>会员卡充值</b> 功能暂时关闭！</font></td></tr>" & _
vbcrlf&"</table>"
End If
sTmp=sTmp&"</td></tr>" & _
vbcrlf&"</table>"
emoney_card=sTmp
End Function

Function emoney_usercard()
dim stmp,c_power,c_id
sTmp=sTmp&"<table cellspacing=1 cellpadding=4 class=table>" & _
  vbcrlf&"<tr><td class=td>&nbsp;会员卡自助兑换</td></tr>" & _
  vbcrlf&"</table>" & _
  vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
  vbcrlf&"<form name=emoney_frm_usercard action='?action=usercard' method=post onsubmit=""javascript:frm_submitonce(this);"">" & _
  vbcrlf&"<input type=hidden name=chk value='yes'>" & _
  vbcrlf&"<tr align=center>" & _
  vbcrlf&"<td class=td width='7%'>序号</td>" & _
  vbcrlf&"<td class=td width='10%'>卡种</td>" & _
  vbcrlf&"<td class=td width='10%'>升级状态</td>" & _
  vbcrlf&"<td class=td width='10%'>有效期</td>" & _
  vbcrlf&"<td class=td width='10%'>扣取金币</td>" & _
  vbcrlf&"<td class=td width='10%'>扣取积分</td>" & _
  vbcrlf&"<td class=td width='10%'>扣取经验</td>" & _
  vbcrlf&"<td class=td width='10%'>扣取体力</td>" & _
  vbcrlf&"<td class=td width='10%'>我要兑换</td>" & _
  vbcrlf&"</tr>" 
	Dim obj_page
	Set obj_page=new Cls_PageCute
	obj_page.pageurl="Emoney.asp?action=usercard&"&pageurl		
	obj_page.nummer=15						
	obj_page.page_t=1									
	obj_page.page_p=5									
	obj_page.page_unit="条"
	obj_page.page_tit=tit
	obj_page.v_id="c_id"
	Call obj_page.p_init("*","AsaiMHCards","c_hidden=0","c_id desc")
	SQL = obj_page.sql_count
	Set rs=Cls.Exec(SQL,1)
	obj_page.rssum=rs(0)
	Rs.Close
	Call obj_page.p_main("*","AsaiMHCards","c_hidden=0","c_id desc")
	For i=1 To obj_page.page_num
   If rs("c_power")="vip" Then
   c_power="VIP会员"
   Else
   c_power="资深会员"
   End If
   c_id=rs("c_id")
  sTmp=sTmp&"<tr class=tr align=center>" & _
  vbcrlf&"<td>"&i+obj_page.page_now&"</td>" & _
  vbcrlf&"<td class=red2>["&rs("c_sort")&"]</td>" & _
  vbcrlf&"<td>"&c_power&"</td>" & _
  vbcrlf&"<td align=right><font color=red>"&rs("c_day")&"</font> 个月</td>" & _
  vbcrlf&"<td align=right><font color=red>"&rs("c_emoney")&"</font> 个</td>" & _
  vbcrlf&"<td align=right><font color=red>"&rs("c_integral")&"</font> 分</td>" & _
  vbcrlf&"<td align=right><font color=red>"&rs("c_expression")&"</font> 点</td>" & _
  vbcrlf&"<td align=right><font color=red>"&rs("c_strength")&"</font> 点</td>" & _
  vbcrlf&"<td><INPUT type=radio value='"&c_id&"' name=is_put></td>" & _
  vbcrlf&"</tr>" & _
    rs.movenext
  next
  rs.close
sTmp=sTmp&"<tr><td class=trs colspan=8>" & _
vbcrlf&"<table border=0 cellspacing=0 cellpadding=2>" & _
vbcrlf&"<tr>" & _
vbcrlf&"<td>"&obj_page.page_var&"</td>" & _
vbcrlf&"<td width=3></td>" & _
vbcrlf&"<td>分页：</td>" & _
vbcrlf&"<td>"&obj_page.page_cute&obj_page.page_shortcut&"</td>" & _
vbcrlf&"</tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td><td class=trs><input class=btn type=submit value='我要兑换'></td>" & _
vbcrlf&"</tr></form>"
  sTmp=sTmp&"</table>"
emoney_usercard=stmp
End Function

function friend_select()
  dim rsf,ttt,temp1
  temp1=vbcrlf&"<select name=friend_select size=1 onchange=""javascript:If (this.options[this.selectedIndex].value!='') { document.emoney_frm_virement.username2.value=this.options[this.selectedIndex].value; };"">" & _
	vbcrlf&"<option value='' >选择我的好友</option>"
  set rsf=conn.execute("select username2 from AsaiMHUserFriend where username1='"&login_username&"' order by id")
  do while not rsf.eof
    ttt=rsf(0)
    temp1=temp1&vbcrlf&"<option value='"&ttt&"'>"&ttt&"</option>"
    rsf.movenext
  loop
  rsf.close
  set rsf=nothing
  temp1=temp1&vbcrlf&"</select>"
  friend_select=temp1
End Function

sub emoney_pay_chk()
  dim pay_amount,pay_emoney,pay_ordernum,p_order_true,price_head
  price_head=""
  pay_amount=trim(request.form("pay_amount"))
  If not Cls.Is_Int(pay_amount) Then
Call Cls.Out_Msg("购买失败：请输入一个大于0的正整数！","Emoney.asp?action=pay")
    exit sub
  End If
  If csng(pay_amount)<csng(min_amount) Then
Call Cls.Out_Msg("购买失败：您输入的人民币数额（"&pay_amount&"元）低于当前的最低消费额（"&min_amount&"元） ","Emoney.asp?action=pay")
    exit sub
  End If
  pay_emoney=pay_amount*buy_num
 If pay_emoney>10000 Then
  Call Cls.Out_Msg("购买失败：目前本站每次最多只能购买10000个金币！","Emoney.asp?action=pay")
 End If
  pay_emoney=clng(pay_emoney)
  pay_ordernum=Cls.time_type(Cls.now_time,11)
  p_order_true=true
  sql="select top 1 e_id from AsaiMHNotesEmoney where e_ordernum='"&pay_ordernum&"'"
  set rs=Cls.exec(sql,1)
  If not rs.eof Then
    rs.close
    Cls.HtmlRcod "body",Found_Error("<font class=red>真对不起！当前购买"&Cls.web_unit&"的用户太多，请稍候再进行购买。</font>",460)
    Cls.OutPage
	exit sub
  End If
  rs.close
  sql="insert into AsaiMHNotesEmoney(e_ordernum,e_username,e_amount,e_emoney,e_tim,e_ispay) " & _
      "values('"&pay_ordernum&"','"&login_username&"',"&price_head&pay_amount&","&pay_emoney&",'"&Cls.now_time&"',0)"
  call Cls.exec(sql,0)
  dim obj_pay
  set obj_pay=new AsaiMHPay
  obj_pay.pay_sort="emoney"
  obj_pay.pay_username=login_username
  obj_pay.pay_carry=pay_emoney&Cls.web_unit&"，换算率：1:"&buy_num
  obj_pay.back_url=Cls.own_http()&"User/Pay_Return_Emoney.asp"
  obj_pay.pay_ordernum=pay_ordernum
  obj_pay.pay_amount=pay_amount
  obj_pay.frm_target=false
  call obj_pay.pay_frm(1)
  set obj_pay=nothing
   Cls.HtmlRcod "body","<TABLE cellspacing=1 cellpadding=4 class=table><TR><TD class=td> 信息</TD></TR><tr class=tr><td height=30>您支付的&nbsp;<font class=red2><b>"&fm_price(pay_amount,1)&"</b></font>&nbsp;元人民币可以购买&nbsp;<font class=red2><b>"&pay_emoney&"</b></font>&nbsp;"&Cls.web_unit&"&nbsp;&nbsp;<input class=btn type=button value='网银在线支付' onClick=""javascript:AsaiMHOnline_Pay();""></td></tr></table>"
    'Cls.OutPage
End Sub

sub emoney_alipay_chk()
  dim pay_amount,pay_emoney,pay_ordernum,p_order_true,price_head,return_url,show_url
  price_head=""
  pay_amount=trim(request.form("pay_amount"))
  If not Cls.Is_Int(pay_amount) Then
Call Cls.Out_Msg("购买失败：请输入一个大于0的正整数！","Emoney.asp?action=pay")
    exit sub
  End If
  If csng(pay_amount)<csng(min_amount) Then
Call Cls.Out_Msg("购买失败：您输入的现金数额（"&pay_amount&"元）低于当前的最低消费额（"&min_amount&"元） ","Emoney.asp?action=pay")
    exit sub
  End If
  pay_emoney=pay_amount*buy_num
 If pay_emoney>10000 Then
  Call Cls.Out_Msg("购买失败：目前本站每次最多只能购买10000个金币！","Emoney.asp?action=pay")
 End If
  pay_emoney=clng(pay_emoney)
  pay_ordernum=Cls.time_type(Cls.now_time,11)
  p_order_true=true
  return_url=Cls.own_http()&"User/Pay_Alipay_Notify.asp"
  show_url=Cls.own_http()&"User/Emoney.asp"
  sql="select top 1 e_id from AsaiMHNotesEmoney where e_ordernum='"&pay_ordernum&"'"
  set rs=Cls.exec(sql,1)
  If not rs.eof Then
    rs.close
    Cls.HtmlRcod "body",Found_Error("<font class=red>真对不起！当前购买"&Cls.web_unit&"的用户太多，请稍候再进行购买。</font>",460)
    Cls.OutPage
	exit sub
  End If
  rs.close
  sql="insert into AsaiMHNotesEmoney(e_ordernum,e_username,e_amount,e_emoney,e_tim,e_ispay) " & _
      "values('"&pay_ordernum&"','"&login_username&"',"&price_head&pay_amount&","&pay_emoney&",'"&Cls.now_time&"',0)"
  call Cls.exec(sql,0)
  dim obj_pay
  set obj_pay=new AsaiMHalipay
  obj_pay.myAlipay_Initialize()
  call obj_pay.CreatAlipayItemURL(Cls.Web_Name&"购买"&Cls.web_unit,"订单编号:"&pay_ordernum,pay_ordernum,pay_amount,show_url,1,"EMS","0","BUYER_PAY",return_url,return_url)
  set obj_pay=nothing
   Cls.HtmlRcod "body","<TABLE cellspacing=1 cellpadding=4 class=table><TR><TD class=td> 信息</TD></TR><tr class=tr><td height=30>您支付的&nbsp;<font class=red2><b>"&fm_price(pay_amount,1)&"</b></font>&nbsp;元人民币可以购买&nbsp;<font class=red2><b>"&pay_emoney&"</b></font>&nbsp;"&Cls.web_unit&"；&nbsp;&nbsp;<input class=btn type=button value='支付宝在线支付' onClick=""javascript:AsaiMHOnline_alipay();""></td></tr></table>"
    'Cls.OutPage
End Sub
%>
