作者 王晓刚
1 个管道 的构建 通过 耗费 6 秒

支付

... ... @@ -56,4 +56,12 @@ class PayView extends Backend
}
\PHPQRCode\QRcode::png($code_url);
}
public function order_pay(){
$order_id = $this->request->param('order_id',0,'intval');
$data = Db::name('order')->where(['id'=>$order_id])->find();
if($data['status'] != 2){
$this->error('');
}
$this->success();
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
var Controller = {
index: function () {
//定义全局变量
var order_id = '';
var order_status = 1;
//人民币转换红包券
$('.total').bind('input propertychange', function() {
var total = $(this).val();
... ... @@ -42,6 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
data:{'admin_id':admin_id,'total':total},
success:function(res){
if(res.code == 1){
order_id = res.data.order_id;
$('.qrcode').show().find('img').first().attr('src',window.location.protocol+"//"+window.location.host+"/admin/pay_view/pay/order_id/"+res.data.order_id);
}else{
top.window.Layer.open({
... ... @@ -58,6 +62,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
})
});
setInterval(function(){order_pay()},3000);
function order_pay() {
console.log(order_id);console.log(order_status);
if(order_id != '' && order_status != 2){
$.ajax({
url:"pay_view/order_pay",
type:"POST",
data:{'order_id':order_id},
success:function(res){
console.log(res);
if(res.code == 1){
order_id = '';
order_status = 2;
top.window.Layer.open({
title:'温馨提示',
content:'支付成功',
url:'http://www.baidu.com',
});
}
},
error:function(res){
top.window.Layer.open({
title:'温馨提示',
content:'与服务器连接失败'
});
}
})
}
}
Controller.api.bindevent();
},
... ...