You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.3 KiB
HTML

<extend name="Public/bases" />
<block name="css">
<link href="__CSS__/shop.css" rel="stylesheet" >
</block>
<block name="body">
<body class="shop">
<header class="header index-header">
<div class="">
<a href="{:U('index')}" class="hbtn back"><i class="iconfont icon-drop-left"></i></a>
<h1 class="caption">兑换平台币</h1>
</div>
</header>
<div class="occupy"></div>
<section class="trunker">
<section class="container">
<div class="banner">
<div class="wrap">
<i class="iconfont icon-money-pile"></i>
<span>可用积分:{$point}</span>
<p></p>
</div>
</div>
<div class="ex-coin-form">
<form id="form" action="" method="post">
<ul class="inputbox">
<li><span class="mark">兑换比例</span><span class="text"><input type="text" name="" id="rate" data-value="100" value="100:1" readonly></span></li>
<li>
<span class="mark">兑换数量</span><span class="text"><input type="text" name="num" id="num" data-total="{$point}" placeholder="请输入需要兑换的平台币数量"></span>
</li>
<li><span class="mark">消耗积分数</span><span class="text"><input type="text" id="integral" name="integral" readonly></span></li>
</ul>
<div class="btnbox">
<input type="button" class="submit" value="立即兑换" >
</div>
</form>
</div>
</section>
</section>
<div class="pop pop-dialog"></div>
<script src="__JS__/pop.lwx.min.js"></script>
<script>
$(function() {
var rate = $('#rate').val().split(':');
var pop = $('.pop').pop();
$('#num').keyup(function(evel) {
var that = $(this),val=$.trim(that.val());
var integral =$('#integral');
var tatol = that.attr('data-total');
if(val =="" ){integral.val('');return true;}
if(evel.keywords == 67){return true;}
if (val && val>0 && /^(0|[1-9][0-9]*)$/.test(val)) {
var sum = val*rate[0]/rate[1];
if (sum<=tatol) {
integral.val(sum);
}else {
pop.msg('可用积分不足,请重新输入');
that.select();
}
} else {
pop.msg('请输入非零开头的正整数');
that.val('');integral.val('');
}
return false;
});
$(".submit").click(function(){
if($.trim($("#num").val()) == '' || $.trim($("#num").val()) == 0){
pop.msg('请输入非零开头的正整数');
return false;
}
$.ajax({
url:"{:U('Shop/exchangecoin')}",
type:"post",
dataType:"json",
async:false,
data:$("form").serialize(),
success:function(result){
pop.msg(result.info);
if(result.status == 1){
setTimeout(function () {
window.location.href = "{:U('Shop/exchangerecord')}";
}, 1000);
}
},
error:function(){
alert('服务器异常');
}
})
})
});
</script>
</body>
</block>
<block name="footer"></block>