wdyy.js
5.07 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
layui.use('element', function () {
let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
});
$(function () {
_initData();
$('#zjhm').text(getCookie().zjhm);
$('#username').text(getCookie().username);
$(document).on("click", ".business", function (e) {
window.open("./businessGuideDeatil.html?ywid=" + $(this).attr('ywid') + "")
})
})
// 获取列表信息
function _initData(currentPage = 1) {
var appointment_list = $(".appointment_list");
appointment_list.empty();
var li;
$.ajax({
type: "post", //提交方式
url: portal.api_url + "/portal/WorkBoxService/bookingBusinessReord",//路径
dataType: "json",
data: {
"userId": dataList.userid,
"currentPage": currentPage,
"pageSize": 10
},
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
let records = result.data.records
for (var i = 0; i < records.length; i++) {
li = '<li>'
li += '<div class="item_content cardItem">'
if (records[i].state == '0') {
li += '<div class="item_title success">'
li += '<h3>预约成功</h3>'
li += '<a href="./yyjg.html">查看<i class="layui-icon layui-icon-right"></i></a>'
li += '</div>'
} else if (records[i].state == '1') {
li += '<div class="item_title success">'
li += '<h3>已赴约</h3>'
li += '</div>'
} else if (records[i].state == '2') {
li += '<div class="item_title overdue">'
li += '<h3>已逾期</h3>'
li += '</div>'
} else if (records[i].state == '3' || records[i].state == '4') {
li += '<div class="item_title cancel">'
li += '<h3>已取消预约</h3>'
li += '</div>'
}
li += '<ul class="item_info">'
li += '<li><span>预约人:</span><p>' + records[i].name + '</p></li>'
li += '<li><span>办事大厅:</span><p>' + records[i].organizationName + '</p></li>'
li += '<li><span>办理业务类型:</span><p>' + records[i].businessName + '</p><a class="business" ywid="' + records[i].ywid + '">办事指南</a></li>'
li += '<li><span>预约日期:</span><p>' + records[i].reserveTime + '</p></li>'
li += '<li><span>预约流水号:</span><p>' + records[i].reservationNumber + '</p></li>'
li += '</ul>'
if (records[i].state == '0') {
li += '<a periodRulesId="' + records[i].periodRulesId + '" jgid="' + records[i].jgid + '" appointmentId="' + records[i].appointmentId + '" class="cancel_reservation">取消预约</a>'
}
li += '</div>'
li += '</li>'
appointment_list.append(li);
}
}
paged(result.data.total, result.data.current);
}
});
}
// 用户取消预约
$(document).on("click", ".cancel_reservation", function (e) {
_cancleAppointment($(this).attr('appointmentId'), $(this).attr('jgid'), $(this).attr('periodRulesId'), getCookie('myCookie').userid)
})
function _cancleAppointment(appointmentId, jgid, periodRulesId, userid) {
$.ajax({
type: "post", //提交方式
url: portal.api_url + "/portal/appointmentmh/cancleAppointment",//路径
dataType: "json",
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
data: JSON.stringify({
'appointmentId': appointmentId,
'jgid': jgid,
'periodRulesId': periodRulesId,
'userid': userid
}),
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200) {
layer.msg('取消预约成功');
_initData();
}
}
});
}
// 分页
function paged(pageCount, curr) {
layui.use('laypage', function () {
let laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
, count: pageCount //数据总数,从服务端得到
, curr: curr
, prev: '<'
, next: '>'
, theme: '#0091FF'
, jump: function (obj, first) {
if (!first) {
_initData(obj.curr);
}
}
});
})
}
var dataList = {
"userid": getCookie().userid
};