pay_view.js
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
//人民币转换红包券
$('.total').bind('input propertychange', function() {
var total = $(this).val();
if(total == ''){
$('.ticket').hide();
}else{
var ratio = $('.ratio').val();
var number = ratio/0.01*total;
$('.ticket').show().children('span').text(number);
}
});
//点击立即充值
$('.pay').click(function (){
var admin_id = $('.admin_id').val();
var total = $('.total').val();
if(total == ''){
top.window.Layer.open({
title:'温馨提示',
content:'请输入充值金额'
});
return false;
}else if(total<100){
top.window.Layer.open({
title:'温馨提示',
content:'充值金额不得小于100元'
});
return false;
}else if(!(/(^[1-9]\d*$)/.test(total))){
top.window.Layer.open({
title:'温馨提示',
content:'必须为整数'
});
return false;
}
$.ajax({
url:"pay_view/create_order",
type:"POST",
data:{'admin_id':admin_id,'total':total},
success:function(res){
if(res.code == 1){
$('.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({
title:'温馨提示',
content:'与服务器连接失败'
});
}
},
error:function(){
top.window.Layer.open({
title:'温馨提示',
content:'与服务器连接失败'
});
}
})
});
Controller.api.bindevent();
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});