rationNewConfig.js
1.69 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
/**
*
*/
var rationNewConfig = function() {
return {
formatNumberRgx : function(num) {
var parts = num.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
},
/** 配售信息 */
rationConfig : function(otcCode, otcName, num, price, rationNewConfigId) {
$.ajax({
url : '/user/ration/queryRationUserById',
type : 'post',
dataType : 'json',
data : {
id : rationNewConfigId
},
success : function(data) {
$("#otcCode").html(otcCode);
$("#otcName").html(otcName);
$("#stockNum").html(num);
$("#price").html((price * 1).toFixed(2) + "元");
var totalPercent = 0;
for (var i = 0; i < data.length; i++) {
totalPercent += data[i].percent;
}
var position = Math.round(num * totalPercent / 100);
$("#saleNum").html(position);
$("#totalPrice").html((price * (position)).toFixed(2) + "元");
$("#position").html(num - position);
$("#rationConfigId").val(rationNewConfigId);
}
});
easyDialog.open({
container : 'easyDialogConfig'
});
},
agreeRation : function() {
var isSubmit = false;
if (isSubmit == true) {
showMessage('请勿重复提交。');
return;
}
isSubmit = true;
$.ajax({
url : '/user/ration/toAgreeRation',
type : 'post',
dataType : 'json',
data : {
otcCode : $("#otcCode").html(), id:$("#rationConfigId").val()
},
success : function(data) {
if (data == 1) {
easyDialog.close();
window.location.reload();
}else if(data == 0){
isSubmit = false;
alert("对不起,此次配售已结束");
easyDialog.close();
}
}
});
}
}
}();