<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=gbk" />
<title>支付</title>
<link rel="shortcut icon" href="favicon.ico" />
<meta name="keywords" content="{cfg:(sys,site_keywords)}">
<meta name="description" content="{cfg:(sys,site_description)}">
<script src="{$web_url}/plus/js/init.php?act=init_js"></script>
<script src="{$web_url}/images/js/common.js"></script>
<script src="{$web_url}/images/js/ajax.js"></script>
<link rel="stylesheet" type="text/css" href="img/css.css"/>
<style>
body{width:auto;}
.me_div3{float:left;width:430px;padding-left:50px;text-align:left}
.me_div3 li{float:left;width:430px;padding:8px 0px 5px 0px}
</style>
<script>
var exchange_rate={cfg:(pay,exchange_rate)};
function gold_exchange(){
	var lng_gold=get_number(document.frmpost.gold_val.value);
	document.getElementById("id_score_val").innerHTML=lng_gold*exchange_rate;

}
function me_go_exchange(msg_act){
	if(msg_act=="exchange_gold"){
		var lng_gold=get_number(document.frmpost.gold_val.value);
		if(lng_gold<1){
			alert("请输入要兑换的金币数量");
			return;
		}
	}else{
		var lng_score=get_number(document.frmpost.score_val.value);
		var lng_gold=parseInt(lng_score/exchange_rate);
		if(lng_gold<1){
			alert("请输入要兑换的积分数量");
			return;
		}
		lng_gold=-1*lng_gold;
	}
	document.frmpost.act.value=msg_act;
	yj_ajax_post(document.frmpost,function(data){
		var obj_x=get_json_obj(data);
		if(!obj_x.isnull){
			if(obj_x.code==0){
				var lng_x=get_number(document.getElementById("id_gold").innerHTML);
				var lng_y=get_number(document.getElementById("id_score").innerHTML);
				document.getElementById("id_gold").innerHTML=lng_x-lng_gold;
				document.getElementById("id_score").innerHTML=parseInt(lng_y)+(lng_gold*exchange_rate);
				alert("兑换成功");
			}else{
				alert(obj_x.msg);
			}
		}else{
			alert("系统繁忙，稍后再试");
		}
	});
}
function score_exchange(){
	var lng_score=parseInt(get_number(document.frmpost.score_val.value));
	var now_score=parseInt(get_number(document.getElementById("id_score").innerHTML));
	if(lng_score>now_score){
		me_msg("兑换积分超出您当前拥有的积分!");
		document.frmpost.score_val.value=now_score;
		return;
	}
	var lng_gold=parseInt(lng_score/exchange_rate);
	document.getElementById("id_gold_val").innerHTML=lng_gold;
	if(lng_gold>0) document.frmpost.score_val.value=lng_gold*exchange_rate;
}
function me_msg(msg_x){
	document.getElementById("id_msginfo").innerHTML=msg_x;
	if(msg_x!="") setTimeout("me_msg('');",3000) 
}
</script>
</head>
<body>
<form name="frmpost" action="{$web_url}/plus/ajax/account.php?isajax=1" method="post">
<input type="hidden" name="act" value="">
<div class="me_div3">
	<li>您当前金币：<span id="id_gold">{$obj_ctl_user->get_gold()}</span></li>
	<li>您当前积分：<span id="id_score">{$obj_ctl_user->get_score()}</span></li>
	<li>兑换比例为：1金币={cfg:(pay,exchange_rate)}积分</li>
	<li><input type="text" name="gold_val" value="" onkeyup="gold_exchange();" size=10>&nbsp;金币&nbsp;&nbsp;兑&nbsp;&nbsp;<span id="id_score_val" style="color:#0000ff"></span>积分</a>&nbsp;&nbsp;<input type="button" name="btn1" value=" 确 认 " class="btn_67" onclick="me_go_exchange('exchange_gold');"></li>
	<li><input type="text" name="score_val" value="" onkeyup="score_exchange();" size=10>&nbsp;积分&nbsp;&nbsp;兑&nbsp;&nbsp;<span id="id_gold_val" style="color:#0000ff"></span>金币</a>&nbsp;&nbsp;<input type="button" name="btn1" value=" 确 认 " class="btn_67" onclick="me_go_exchange('exchange_score');"></li>
	<li id="id_msginfo" style="color:#ff0000"></li>
</div>
</form>
</body>
</html>