depositSwitch.html
4.36 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
</head>
<body class="easyui-layout">
<div region="north" style="height:1500px;">
<script>
document.write(addHead('订单管理', '寄存开关'));
</script>
<div style="padding:20px;">
<label style="font-size: 15px">现货寄存开关:</label>
<input class="easyui-switchbutton" onText="开启" offText="关闭" name="inStockDepositSwitch" id="inStockDepositSwitch">
</div>
<div style="padding:20px;">
<label style="font-size: 15px">闪购寄存开关:</label>
<input class="easyui-switchbutton" onText="开启" offText="关闭" name="quickDeliverDepositSwitch" id="quickDeliverDepositSwitch">
</div>
<div style="padding:20px;">
<label style="font-size: 15px">极速寄存开关:</label>
<input class="easyui-switchbutton" onText="开启" offText="关闭" name="fastDeliverDepositSwitch" id="fastDeliverDepositSwitch">
</div>
</div>
<script>
$(function() {
//展示开关当前状态
getDepositSwitchStatus();
//现货寄存开关
$("#inStockDepositSwitch").switchbutton({
width: 120,
height: 40,
onChange: function(switchStatus){
updateDepositSwitch("IN_STOCK", switchStatus);
}
});
//闪购寄存开关
$("#quickDeliverDepositSwitch").switchbutton({
width: 120,
height: 40,
onChange: function(switchStatus){
updateDepositSwitch("QUICK_DELIVER", switchStatus);
}
});
//极速寄存开关
$("#fastDeliverDepositSwitch").switchbutton({
width: 120,
height: 40,
onChange: function(switchStatus){
updateDepositSwitch("FAST_DELIVER", switchStatus);
}
});
});
//获取当前开关状态
function getDepositSwitchStatus(){
const inStockDepositSwitchBtn = $("#inStockDepositSwitch");
const quickDeliverDepositSwitchBtn = $("#quickDeliverDepositSwitch");
const fastDeliverDepositSwitchBtn = $("#fastDeliverDepositSwitch");
$.ajax({
type: "POST",
url: contextPath + '/storageDeposit/getDepositSwitchStatus',
async: false,
cache: false,
dataType: 'json',
success: function (result) {
if(result.code != 200) {
window.self.$.messager.show({
title : "提示",
msg : "获取当前开关状态失败"
});
}
const inStockSwitchStatus = result.data.IN_STOCK;
if(inStockSwitchStatus == true){
inStockDepositSwitchBtn.switchbutton("check");
}else {
inStockDepositSwitchBtn.switchbutton("uncheck");
}
const quickDeliverSwitchStatus = result.data.QUICK_DELIVER;
if(quickDeliverSwitchStatus == true){
quickDeliverDepositSwitchBtn.switchbutton("check");
}else {
quickDeliverDepositSwitchBtn.switchbutton("uncheck");
}
const fastDeliverSwitchStatus = result.data.FAST_DELIVER;
if(fastDeliverSwitchStatus == true){
fastDeliverDepositSwitchBtn.switchbutton("check");
}else {
fastDeliverDepositSwitchBtn.switchbutton("uncheck");
}
}
});
}
//更改开关状态
function updateDepositSwitch(switchType, switchStatus){
$.ajax({
type: "POST",
url: contextPath + '/storageDeposit/updateDepositSwitch?switchType='+switchType+'&switchStatus='+switchStatus,
async: false,
cache: false,
dataType: 'json',
success: function (result) {
const operateType = switchStatus == true ? "开启" : "关闭";
if(result.code == 200) {
window.self.$.messager.show({
title : "提示",
msg : operateType + "成功"
});
}
}
});
}
</script>
</body>
</html>