文件目录html/user/buy.html
在线充值表单示例:
<div class="line40">
<p>充值的金额:<input type="text" name="price" value="{$config.min}" class="jifen-input"></p>
<p><input type="button" class="jifen2-button" value="确认"></p>
<p class="hui">友情提示:最小充值金额为{$config.min}元,1元可以兑换{$config.scale}个积分</p>
</div>
<script>
$('#btn_submit_pay').click(function(){
var that=$(this);
var price = $("input[name='price']").val();
if(Number(price)<1){
return;
}
if(confirm('确定要在线充值吗')) {
$.ajax({
url: "{:url('user/buy')}",
type: "post",
dataType: "json",
data: {price: price,flag:'pay'},
beforeSend: function () {
$("#btn_submit_pay").css("background","#fd6a6a").val("loading...");
},
success: function (r) {
if (r.code == 1) {
//生成订单后跳转支付页面
location.href="{:url('user/pay')}?order_code=" + r.data.order_code;
}
else{
alert(r.msg);
}
},
complete: function () {
$("#btn_submit_pay").css("background","#fa4646").val("提交");
}
});
}
});
</script>卡密充值表单示例:
<div class="line40">
<p>充值卡号:<input type="text" name="card_no" value="" class="jifen-input">
{if condition="$GLOBALS['config']['pay']['card']['url'] neq ''"}
<a target="_blank" href="{$GLOBALS['config']['pay']['card']['url']}">点击购买卡密</a>
{/if}
</p>
<p>充值密码:<input type="text" name="card_pwd" value="" class="jifen-input"></p>
<p><input type="button" class="jifen2-button" value="确认"></p>
<p class="hui">友情提示:请到卡密平台购买充值卡</p>
</div>
<script>
$('#btn_submit_card').click(function(){
var that=$(this);
var no = $('input[name="card_no"]').val();
var pwd = $('input[name="card_pwd"]').val();
if(no=='' || pwd==''){
alert('请输入充值卡号和密码');
return;
}
if(confirm('确定要使用充值卡充值吗')) {
$.ajax({
url: "{:url('user/buy')}",
type: "post",
dataType: "json",
data: {card_no: no,card_pwd:pwd,flag:'card'},
beforeSend: function () {
$("#btn_submit_card").css("background","#fd6a6a").val("loading...");
},
success: function (r) {
alert(r.msg);
},
complete: function () {
$("#btn_submit_card").css("background","#fa4646").val("提交");
}
});
}
});
</script>
