-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
184 lines (177 loc) · 5.29 KB
/
index.html
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>jQuery价格日历控件 - 显示价格日历、修改价格日历</title>
<link href="css/datepicker.css" rel="stylesheet"/>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/zlDate.js"></script>
<style type="text/css">
* {
margin: 0;
padding: 0px;
}
.calendar_btn {
margin-top: 10px;
padding: 0px 5px;
height: 30px;
line-height: 30px;
border-radius: 3px;
border: 1px solid #ccc;
cursor: pointer;
text-align: center;
}
</style>
</head>
<body>
<div style="margin: 50px">
<input style="width: 124px" location="right" class="calendar_btn" name="calendar" readonly="readonly"
onclick="showCalendar(this,'232');" placeholder="酒店价格日历1"/>
</div>
<div style="margin: 50px">
<input style="width: 124px" location="right" class="calendar_btn" name="calendar" readonly="readonly"
onclick="showCalendar(this,'233');" placeholder="酒店价格日历2"/>
</div>
<script>
var hotelId = null;//酒店ID
/**
* 显示价格日历
* @param e 按钮元素对象
* @param id 资源ID(酒店ID)
*/
function showCalendar(e, id) {
hotelId = id; // 根据自己的业务逻辑可以适当调整
// // 接口获取价格日历数据【接入项目是请使用这里的代码】
// $.get('data.json?hotel_id=' + hotelId, function (data) {
// console.log(data);
// pickerEvent.setPriceArr(data);// 设置数据
// pickerEvent.Init(e);// 开始初始化组件
// });
// 这里为了演示,我直接js赋值了,接入项目时请使用上面ajax请求接口动态获取数据
var myDate = new Date();
var y = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
var m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
var ym = y+'-'+m;
var data = [
{
"day": ym+"-07",
"price": "200"
},
{
"day": ym+"-11",
"price": "300"
},
{
"day": ym+"-12",
"price": "100"
},
{
"day": ym+"-13",
"price": "158"
},
{
"day": ym+"-14",
"price": "1000"
},
{
"day": ym+"-16",
"price": "2500"
},
{
"day": ym+"-17",
"price": "800"
},
{
"day": y+"-11-15",
"price": "500"
},
{
"day": y+"-12-15",
"price": "158"
},
{
"day": y+"-01-15",
"price": "500"
},
{
"day": y+"-01-15",
"price": "158"
},
{
"day": y+"-02-15",
"price": "700"
},
{
"day": y+"-03-15",
"price": "59"
},
{
"day": y+"-04-15",
"price": "666"
},
{
"day": y+"-05-15",
"price": "59"
},
{
"day": y+"-06-15",
"price": "888"
},
{
"day": y+"-07-15",
"price": "450"
},
{
"day": y+"-08-15",
"price": "59"
},
{
"day": y+"-09-15",
"price": "600"
},
{
"day": y+"-07-15",
"price": "59"
},
{
"day": y+"-11-15",
"price": "59"
},
{
"day": y+"-12-15",
"price": "100"
}
];
console.log(data);
pickerEvent.setPriceArr(data);// 设置数据
pickerEvent.Init(e);// 开始初始化组件
}
/**
* 修改价格
* @param date
* @param newPrice
* @param calendarPrice
*/
function changePrice(date, newPrice, calendarPrice) {
alert('修改价格' + date + "天的价格为" + newPrice);
// // 接口修改价格日历数据【接入项目是请使用这里的代码】
// var params = {
// hotelId: hotelId,
// date: date,
// price: newPrice
// };
// $.post('change.json?hotel_id=' + hotelId, params, function (data, status) {
//
// if (data.code == 100) {
// calendarPrice.show();
// } else {
// alert("修改失败!");
// }
// });
// 这里为了演示,我直接模拟成功,接入项目时请使用上面ajax请求接口动态修改数据
calendarPrice.show();
}
</script>
</body>
</html>