yysj.js
11 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
var bustime = undefined;
$(function () {
var Date = undefined;
var appuintText = undefined;
getAppointmentDay();
layui.use("element", function () {
let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
//监听导航点击
element.on("nav(demo)", function (elem) {
layer.msg(elem.text());
});
});
// function a(i) {
// Date = data.dateList[i].jyjh;
// bookingDate = data.dateList[i].bookingDate;
// bustime = data.dateList[i].week;
// //getAppointmentPeriodAndBusiness()
// $(".swiper-slide")
// .eq(i)
// .addClass("active1")
// .siblings()
// .removeClass("active1");
// }
var swiper = new Swiper(".swiper-container", {
slidesPerView: 5,
spaceBetween: 20,
slidesPerGroup: 1,
observer: true,
observeParents: true,
on: {
click: function (swiper) {
var index = swiper["clickedIndex"];
//a(index);
},
},
loopFillGroupWithBlank: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
$(document).on("click", ".cancel", function () {
layer.closeAll();
});
});
//获取当前页面预约日期
function getAppointmentDay() {
$.ajax({
type: "get", //提交方式
url: portal.api_url + "/portal/appointmentmh/getAppointmentDay", //路径
data: {
jgid: GetQueryString("jgid"),
},
dataType: "json",
success: function (result) {
//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
RenderbookingDateList(result.data);
bookingDateClick(result.data.listTime[0].bookingDate);
}
},
});
}
//渲染预约日期列表
function RenderbookingDateList(data) {
let DateConnect = "";
$.each(data.listTime, function (index, item) {
DateConnect += '<ul id="' + item.bookingDate + '" class="swiper-slide layui-bg-gray" onclick="bookingDateClick(this.id)">';
DateConnect += '<li>' + item.week + '</li><li>' + item.jyjh + '</li>';
DateConnect += '</ul>';
});
$("#swiperDate").html(DateConnect);
}
//预约日期点击事件
function bookingDateClick(id) {
$(".layui-bg-gray").removeClass("active1");
$("#" + id).addClass("active1");
getAppointmentPeriodAndBusiness(id);
}
// 根据办事大厅机构ID、日期、用户ID,获取对应日期的业务列表 GET
function getAppointmentPeriodAndBusiness(bookingDate) {
$.ajax({
type: "get", //提交方式
url:
portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", //
data: {
jgid: GetQueryString("jgid"),
userid: getCookie().userid,
bookingDate: bookingDate,
},
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {
//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
RenderBusinessList(result.data);
if (result.data.appointmentPeriodBusinessList.length > 0) {
hallname = result.data.appointmentPeriodBusinessList[0].orgBusinessList[0].jgName;
}
}
},
});
}
//渲染业务信息列表
function RenderBusinessList(data) {
//获取业务列表DIV容器ID
let businessDiv = $("#business_list");
//是否存在预约记录(默认为否)
let existRecord = false;
if (data.choosePeriodRulesId != null && data.choosePeriodRulesId != "") {
existRecord = true;
}
let businessContent = "";
$.each(data.appointmentPeriodBusinessList, function (index, item) {
businessContent += '<div class="business_item">';
businessContent += '<div class="item_time">'
if(getTime(item.startTime)){
businessContent += '<h3 class="timeTitle">下午</h3>'
}else {
businessContent += '<h3 class="timeTitle">上午</h3>'
}
businessContent += '<span>' + item.startTime + '</span><span>-</span><span>' + item.endTime + '</span></div>';
businessContent += '<ul>';
$.each(item.orgBusinessList, function (childIndex, childItem) {
//存在预约记录
if (existRecord) {
if (data.choosePeriodRulesId == childItem.periodRulesId) {
businessContent += '<li class="isAppoint" style="border: 1px solid red ;" data-id="' + childItem.periodRulesId + '">';
businessContent += '<h3>' + childItem.shortName + '</h3>';
businessContent += '<input type="button" value="查看详情" id="' + data.appointmentId + '" dataName="' + childItem.shortName + '" onclick="getAppointmentDetail(this.id)"/>';
}
else {
businessContent += '<li class="isAppoint">';
businessContent += '<h3>' + childItem.shortName + '</h3>';
}
businessContent += '<p style="color:#5FB878">(剩' + childItem.residueNumber + '票)</p></li>';
} else {
businessContent += '<li class="isAppoint" data-id="' + childItem.periodRulesId + '">';
businessContent += '<h3>' + childItem.shortName + '</h3>';
if (childItem.residueNumber > 0) {
businessContent += '<input type="button" value="立即预约" id="' + childItem.periodRulesId + '" periodRulesId="' + childItem.periodRulesId + '" onclick="handle(this.id)"/>';
}
businessContent += '<p style="color:#5FB878">(剩' + childItem.residueNumber + '票)</p></li>';
}
});
businessContent += '</ul>';
businessContent += '</div>';
});
businessDiv.html(businessContent);
}
function getTime(time){
var isTime;
if((time.split(":")[0]-0)>12) {
isTime = true;
}else {
isTime = false;
}
return isTime;
}
// 根据办事大厅机构ID、用户ID检查用户是否存在预约限制
function checkAppointment() {
let msg;
$.ajax({
type: "get", //提交方式
async: false,
url:
portal.api_url + "/portal/appointmentmh/checkAppointment",
data: {
jgid: GetQueryString("jgid"),
userid: getCookie().userid,
},
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {
//返回数据根据结果进行相应的处理
if (result.code == 210) {
msg = result.message;
}
},
});
return msg;
}
function del(a){
layui.use('layer',function(){
var layer = layui.layer;
layer.msg(a);
})
}
function handle(id) {
let bookingDateUL = $(".active1");
let msg = checkAppointment();
if (msg != undefined) {
del(msg)
return false
};
var input = $("#" + id);
layui.use("layer", function () {
layer.open({
type: 1,
title: "请确认以下信息",
shadeClose: false,
area: ["500px", "320px"],
scrollbar: false,
skin: "confimInfo",
content:
'<div class="infoContent">' +
"<ul>" +
"<li><span>姓名</span>:" + getCookie().username + "</li>" +
"<li><span>身份证号</span>:" + getCookie().zjhm + "</li>" +
"<li><span>联系电话</span>:" + getCookie().phone + "</li>" +
"</ul>" +
'<div class="listItem"><h3>大厅名称:</h3>' +
hallname +
"</div>" +
'<div class="listItem"><h3>预约业务:</h3>' +
input.val() +
"</div>" +
'<div class="listItem"><h3>预约时间:</h3>' +
bookingDateUL.children("li").get(1).innerHTML +
" " +
bookingDateUL.children("li").get(0).innerHTML +
"</div>" +
'<div class="confimButton"><button type="button" class="layui-btn cancel layui-btn-primary">取消</button><button type="button" class="layui-btn confim layui-btn-normal" onclick="makeAppointment(\'' + input.attr("periodRulesId") + '\')">确定</button></div>' +
"</div>",
});
});
}
// 提交预约记录
function makeAppointment(id) {
var paramsobj = {}
paramsobj.jgid = GetQueryString("jgid");
paramsobj.periodRulesId = id;
paramsobj.userid = getCookie().userid;
$.ajax({
type: "post", //提交方式
async: false,
url: portal.api_url + "/portal/appointmentmh/makeAppointment",//路径
headers: {//***关键******
'Content-Type': 'application/json;charset=UTF-8',
},
dataType: "json",
data: JSON.stringify(paramsobj),//***关键******
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data !== null) {
appointmentId = result.data
window.location.href = "./yyjg.html?appointmentId=" + appointmentId
}else {
del(result.message)
}
}
});
}
// 根据预约信息标识码appointmentId查看预约详情接口数据
function getAppointmentDetail(id) {
$.ajax({
type: "get", //提交方式
url:
portal.api_url + "/portal/appointmentmh/getAppointmentDetail",
data: {
appointmentId: id,
},
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {
//返回数据根据结果进行相应的处理
if (result.code == 200) {
appointmentDetail(result.data);
}
else {
layer.msg(result.message, {icon: 6})
}
},
});
}
//预约详情展示页面
function appointmentDetail(data) {
layui.use("layer", function () {
layer.open({
type: 1,
title: "预约详情信息",
shadeClose: false,
area: ["500px", "320px"],
scrollbar: false,
skin: "confimInfo",
content:
'<div class="infoContent">' +
"<ul>" +
"<li><span>姓名</span>:" + data.username + "</li>" +
"<li><span>身份证号</span>:" + data.zjhm + "</li>" +
"<li><span>联系电话</span>:" + data.phone + "</li>" +
"</ul>" +
'<div class="listItem"><h3>预约编号:</h3>' +
data.reservationNumber +
"</div>" +
'<div class="listItem"><h3>预约业务:</h3>' +
data.hbShortname +
"</div>" +
'<div class="listItem"><h3>预约时间:</h3>' +
data.bookingDate.substr(0, 4) + '年' + data.bookingDate.substr(4, 2) + '月' + data.bookingDate.substr(6, 2) + '日' + data.startTime + '至' + data.endTime +
"</div>" +
'<div class="confimButton"><button type="button" class="layui-btn cancel layui-btn-primary" onclick="cancleAppointment(\'' + data.aid + '\',\'' + data.jgid + '\',\'' + data.periodRulesId + '\',\'' + data.userid + '\')">取消预约</button></div>' +
"</div>",
});
});
}
// 用户取消预约
function cancleAppointment(aid, jgid, periodRulesId, userid) {
$.ajax({
type: "post", //提交方式
url: portal.api_url + "/portal/appointmentmh/cancleAppointment",//路径
headers: {//***关键******
'Content-Type': 'application/json;charset=UTF-8',
},
dataType: "json",
data: JSON.stringify({
"appointmentId": aid,
"jgid": jgid,
"periodRulesId": periodRulesId,
"userid": userid
}),//***关键******
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200) {
bookingDateClick($(".active1").attr('id'));
}
}
});
}