0528087d by 任超

Merge branch 'master' of yun.pashanhoo.com:renchao/portalStaticPage

2 parents 393d12a3 c1822b35
1 $(function () {
2 var Date = undefined;
3 var appuintText = undefined;
4 var bustime = undefined; 1 var bustime = undefined;
2 $(function () {
3 var Date = undefined;
4 var appuintText = undefined;
5
5 6
6 // 国有房屋无业点击选中记录 7 // 国有房屋无业点击选中记录
7 var busIndex = undefined; 8 var busIndex = undefined;
8 // 机构id 9 // 机构id
9 var jgid = undefined; 10 var jgid = undefined;
10 getAppointmentDay(); 11 getAppointmentDay();
11 layui.use("element", function () { 12 layui.use("element", function () {
12 let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块 13 let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
...@@ -45,39 +46,8 @@ var jgid = undefined; ...@@ -45,39 +46,8 @@ var jgid = undefined;
45 prevEl: ".swiper-button-prev", 46 prevEl: ".swiper-button-prev",
46 }, 47 },
47 }); 48 });
48 function handle() { 49
49 layui.use("layer", function () { 50 function detailHandle() {
50 layer.open({
51 type: 1,
52 title: "请确认以下信息",
53 shadeClose: false,
54 area: ["500px", "320px"],
55 scrollbar: false,
56 skin: "confimInfo",
57 content:
58 '<div class="infoContent">' +
59 "<ul>" +
60 "<li><span>姓名</span>:" + getCookie().username +"</li>" +
61 "<li><span>身份证号</span>:"+getCookie().zjhm+"</li>" +
62 "<li><span>联系电话</span>:"+getCookie().phone +"</li>" +
63 "</ul>" +
64 '<div class="listItem"><h3>大厅名称:</h3>' +
65 hallname +
66 "</div>" +
67 '<div class="listItem"><h3>预约业务:</h3>' +
68 appuintText +
69 "</div>" +
70 '<div class="listItem"><h3>预约时间:</h3>' +
71 Date +
72 "&nbsp;&nbsp;" +
73 bustime +
74 "</div>" +
75 '<div class="confimButton"><button type="button" class="layui-btn cancel layui-btn-primary">取消</button><button type="button" class="layui-btn confim layui-btn-normal">确定</button></div>' +
76 "</div>",
77 });
78 });
79 }
80 function detailHandle(){
81 layui.use("layer", function () { 51 layui.use("layer", function () {
82 layer.open({ 52 layer.open({
83 type: 1, 53 type: 1,
...@@ -86,53 +56,30 @@ var jgid = undefined; ...@@ -86,53 +56,30 @@ var jgid = undefined;
86 area: ["500px", "320px"], 56 area: ["500px", "320px"],
87 scrollbar: false, 57 scrollbar: false,
88 skin: "confimInfo", 58 skin: "confimInfo",
89 content:'123', 59 content: '123',
90 }); 60 });
91 }); 61 });
92 } 62 }
93 // 业务选择 63
94 $(document).on("click", ".business_item ul .item_appoint ", function (e) {
95 console.log(5555)
96 jgid = GetRequest();
97 appuintText = $(this).find("h3").text();
98 periodRulesId = $(this).data('id')
99 console.log('aaa',periodRulesId)
100 checkAppointment()
101 handle();
102 });
103 $(document).on("click", ".cancel", function () { 64 $(document).on("click", ".cancel", function () {
104 layer.closeAll(); 65 layer.closeAll();
105 }); 66 });
106 $(document).on("click", ".confim", function () { 67 $(document).on("click", ".confim", function () {
107 if(flag){
108 var paramsobj = {} 68 var paramsobj = {}
109 paramsobj.jgid = GetRequest() 69 paramsobj.jgid = GetQueryString("jgid");
110 paramsobj.periodRulesId = periodRulesId 70 paramsobj.periodRulesId = periodRulesId
111 paramsobj.userid = getCookie().userid 71 paramsobj.userid = getCookie().userid
112 makeAppointment(paramsobj) 72 makeAppointment(paramsobj)
113 }
114 }); 73 });
115 }); 74 });
116 function GetRequest() { 75
117 var url = location.search; //获取url中"?"符后的字串 76 //获取当前页面预约日期
118 var theRequest = new Object();
119 if (url.indexOf("?") != -1) {
120 var str = url.substr(1);
121 strs = str.split("?");
122 for (var i = 0; i < strs.length; i++) {
123 theRequest[strs[i].split("=")[0]] = decodeURIComponent(
124 strs[i].split("=")[1]
125 );
126 }
127 }
128 return theRequest.jgid;
129 }
130 function getAppointmentDay() { 77 function getAppointmentDay() {
131 $.ajax({ 78 $.ajax({
132 type: "get", //提交方式 79 type: "get", //提交方式
133 url: portal.api_url + "/portal/appointmentmh/getAppointmentDay", //路径 80 url: portal.api_url + "/portal/appointmentmh/getAppointmentDay", //路径
134 data: { 81 data: {
135 jgid: GetRequest(), 82 jgid: GetQueryString("jgid"),
136 }, 83 },
137 dataType: "json", 84 dataType: "json",
138 success: function (result) { 85 success: function (result) {
...@@ -151,14 +98,14 @@ function getAppointmentDay() { ...@@ -151,14 +98,14 @@ function getAppointmentDay() {
151 }, 98 },
152 }); 99 });
153 } 100 }
154 // 根据办事大厅机构ID、日期、用户ID,查询可预约的业务 GET 101 // 根据办事大厅机构ID、日期、用户ID,获取对应日期的业务列表 GET
155 function getAppointmentPeriodAndBusiness() { 102 function getAppointmentPeriodAndBusiness() {
156 $.ajax({ 103 $.ajax({
157 type: "get", //提交方式 104 type: "get", //提交方式
158 url: 105 url:
159 portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", // 106 portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", //
160 data: { 107 data: {
161 jgid: GetRequest(), 108 jgid: GetQueryString("jgid"),
162 userid: getCookie().userid, 109 userid: getCookie().userid,
163 bookingDate: bookingDate, 110 bookingDate: bookingDate,
164 }, 111 },
...@@ -168,98 +115,205 @@ function getAppointmentPeriodAndBusiness() { ...@@ -168,98 +115,205 @@ function getAppointmentPeriodAndBusiness() {
168 //返回数据根据结果进行相应的处理 115 //返回数据根据结果进行相应的处理
169 if (result.code == 200 && result.data != null) { 116 if (result.code == 200 && result.data != null) {
170 console.log(result.data) 117 console.log(result.data)
171 data.busList = result.data.appointmentPeriodBusinessList 118 data.busList = result.data.appointmentPeriodBusinessList;
172 // console.log(2222,data.busList) 119 RenderBusinessList(result.data);
173 // if(result.data.choosePeriodRulesId!==null){ 120
174 // if(2){ 121 if (data.busList.length > 0) {
175 // // for循环找到对应的id 打开,其余都设置为禁用 122 data.busList.forEach((item, index) => {
176 // }
177 // }else if(result.data.choosePeriodRulesId ==null){
178 // // step 1: 如果等于0
179 // for(var i =0;i<result.data.appointmentPeriodBusinessList.length;i++){
180 // for(var j=0;j<result.data.appointmentPeriodBusinessList[i].orgBusinessList.length; j++){
181 // if(result.data.appointmentPeriodBusinessList[i].orgBusinessList[j].residueNumber ==0){
182 // result.data.appointmentPeriodBusinessList[i].orgBusinessList[j].disabled = true
183 // }
184 // }
185 // }
186 // data.busList = result.data.appointmentPeriodBusinessList
187 // console.log(11111, data.busList)
188 // }
189 if(data.busList.length >0){
190 data.busList.forEach((item,index)=>{
191 hallname = item.orgBusinessList[0].jgName 123 hallname = item.orgBusinessList[0].jgName
192 }) 124 })
193 } 125 }
194 layui.use("laytpl", function () { 126
195 laytpl = layui.laytpl;
196 var getTpl1 = document.getElementById("business_item").innerHTML,
197 view1 = document.getElementById("business_list");
198 laytpl(getTpl1).render(data, function (html) {
199 view1.innerHTML = html;
200 });
201 });
202 } 127 }
203 }, 128 },
204 }); 129 });
205 } 130 }
206 // 根据办事大厅机构ID、用户ID检查用户是否可预约抢号 131
207 function checkAppointment(){ 132
133
134 var bookingDate = undefined;
135 var flag = undefined;
136 var msg = undefined;
137 var hallname = undefined;
138 var periodRulesId = undefined
139 var appointmentId = undefined
140 var periodRulesId = undefined
141 var data = {
142 dateList: [],
143 busList: [
144 {
145 startTime: "",
146 endTime: "",
147 orgBusinessList: [],
148 },
149 ],
150 };
151
152 //渲染业务信息列表
153 function RenderBusinessList(data) {
154 //获取业务列表DIV容器ID
155 let businessDiv = $("#business_list");
156 //是否存在预约记录(默认为否)
157 let existRecord = false;
158 if (data.choosePeriodRulesId != null && data.choosePeriodRulesId != "") {
159 existRecord = true;
160 }
161 let businessContent = "";
162 $.each(data.appointmentPeriodBusinessList, function (index, item) {
163 businessContent += '<div class="business_item">';
164 businessContent += '<div class="item_time"><span>上午</span> <span>' + item.startTime + '</span><span>-</span><span>' + item.endTime + '</span></div>';
165 businessContent += '<ul>';
166 $.each(item.orgBusinessList, function (childIndex, childItem) {
167 //存在预约记录
168 if (existRecord) {
169 if (data.choosePeriodRulesId == childItem.periodRulesId) {
170 businessContent += '<li class="isAppoint" style="border: 1px solid red ;" data-id="' + childItem.periodRulesId + '">';
171 businessContent += '<h3>' + childItem.shortName + '</h3>';
172 businessContent += '<input type="button" value="查看详情" id="' + childItem.periodRulesId + '" dataName="' + childItem.shortName + '" onclick="appointmentDetail(this.id)"/>';
173 }
174 else {
175 businessContent += '<li class="isAppoint">';
176 businessContent += '<h3>' + childItem.shortName + '</h3>';
177 }
178 businessContent += '<p style="color:#5FB878">(剩' + childItem.residueNumber + '票)</p></li>';
179 } else {
180 businessContent += '<li class="isAppoint" data-id="' + childItem.periodRulesId + '">';
181 businessContent += '<h3>' + childItem.shortName + '</h3>';
182 if (childItem.residueNumber > 0) {
183 businessContent += '<input type="button" value="立即预约" id="' + childItem.periodRulesId + '" dataName="' + childItem.shortName + '" onclick="handle(this.id)"/>';
184 }
185 businessContent += '<p style="color:#5FB878">(剩' + childItem.residueNumber + '票)</p></li>';
186 }
187
188 });
189 businessContent += '</ul>';
190 businessContent += '</div>';
191
192 });
193 businessDiv.html(businessContent);
194 }
195
196 // 根据办事大厅机构ID、用户ID检查用户是否存在预约限制
197 function checkAppointment() {
198 let msg;
208 $.ajax({ 199 $.ajax({
209 type: "get", //提交方式 200 type: "get", //提交方式
210 async:false, 201 async: false,
211 url: 202 url:
212 portal.api_url + "/portal/appointmentmh/checkAppointment", 203 portal.api_url + "/portal/appointmentmh/checkAppointment",
213 data: { 204 data: {
214 jgid: GetRequest(), 205 jgid: GetQueryString("jgid"),
215 userid: getCookie().userid, 206 userid: getCookie().userid,
216 }, 207 },
217 dataType: "json", 208 dataType: "json",
218 //数据,这里使用的是Json格式进行传输 209 //数据,这里使用的是Json格式进行传输
219 success: function (result) { 210 success: function (result) {
220 //返回数据根据结果进行相应的处理 211 //返回数据根据结果进行相应的处理
221 if (result.code == 200) { 212 // if (result.code == 200) {
222 return flag = result.data 213 // return flag = result.data
223 }else if(result.code ==210){ 214 // }
224 return layer.msg( result.message) 215 if (result.code == 210) {
216 msg = result.message;
225 } 217 }
226 }, 218 },
227 }); 219 });
220 return msg;
221 }
222
223 var yyrq;
224 function handle(id) {
225
226 let msg = checkAppointment();
227 if (msg != undefined) {
228 //layer.msg('hello');
229 alert(msg);
230 return;
231 };
232 var input = $("#" + id);
233 layui.use("layer", function () {
234 layer.open({
235 type: 1,
236 title: "请确认以下信息",
237 shadeClose: false,
238 area: ["500px", "320px"],
239 scrollbar: false,
240 skin: "confimInfo",
241 content:
242 '<div class="infoContent">' +
243 "<ul>" +
244 "<li><span>姓名</span>:" + getCookie().username + "</li>" +
245 "<li><span>身份证号</span>:" + getCookie().zjhm + "</li>" +
246 "<li><span>联系电话</span>:" + getCookie().phone + "</li>" +
247 "</ul>" +
248 '<div class="listItem"><h3>大厅名称:</h3>' +
249 hallname +
250 "</div>" +
251 '<div class="listItem"><h3>预约业务:</h3>' +
252 input.attr("dataName") +
253 "</div>" +
254 '<div class="listItem"><h3>预约时间:</h3>' +
255 bookingDate +
256 "&nbsp;&nbsp;" +
257 bustime +
258 "</div>" +
259 '<div class="confimButton"><button type="button" class="layui-btn cancel layui-btn-primary">取消</button><button type="button" class="layui-btn confim layui-btn-normal">确定</button></div>' +
260 "</div>",
261 });
262 });
228 } 263 }
264
229 // 用户预约抢号 POST 265 // 用户预约抢号 POST
230 function makeAppointment(data){ 266 function makeAppointment(data) {
231 $.ajax({ 267 $.ajax({
232 type: "post", //提交方式 268 type: "post", //提交方式
233 async:false, 269 async: false,
234 url: portal.api_url + "/portal/appointmentmh/makeAppointment",//路径 270 url: portal.api_url + "/portal/appointmentmh/makeAppointment",//路径
235 headers:{//***关键****** 271 headers: {//***关键******
236 'Content-Type': 'application/json;charset=UTF-8', 272 'Content-Type': 'application/json;charset=UTF-8',
237 }, 273 },
238 dataType: "json", 274 dataType: "json",
239 data:JSON.stringify(data),//***关键****** 275 data: JSON.stringify(data),//***关键******
240 success: function (result) {//返回数据根据结果进行相应的处理 276 success: function (result) {//返回数据根据结果进行相应的处理
241 if(result.code ==200 && result.data!==null){ 277 if (result.code == 200 && result.data !== null) {
242 appointmentId = result.data 278 appointmentId = result.data
243 window.location.href = "./yyjg.html?appointmentId="+ appointmentId 279 window.location.href = "./yyjg.html?appointmentId=" + appointmentId
244 } 280 }
245 } 281 }
246 }); 282 });
247 } 283 }
248 284
249 var bookingDate = undefined; 285 //预约详情
250 var flag = undefined; 286 function appointmentDetail(id) {
251 var msg = undefined; 287 var input = $("#" + id);
252 var hallname = undefined; 288 layui.use("layer", function () {
253 var periodRulesId = undefined 289 layer.open({
254 var appointmentId = undefined 290 type: 1,
255 var periodRulesId = undefined 291 title: "预约详情信息",
256 var data = { 292 shadeClose: false,
257 dateList: [], 293 area: ["500px", "320px"],
258 busList: [ 294 scrollbar: false,
259 { 295 skin: "confimInfo",
260 startTime: "", 296 content:
261 endTime: "", 297 '<div class="infoContent">' +
262 orgBusinessList: [], 298 "<ul>" +
263 }, 299 "<li><span>姓名</span>:" + getCookie().username + "</li>" +
264 ], 300 "<li><span>身份证号</span>:" + getCookie().zjhm + "</li>" +
265 }; 301 "<li><span>联系电话</span>:" + getCookie().phone + "</li>" +
302 "</ul>" +
303 '<div class="listItem"><h3>预约编号:</h3>' +
304 hallname +
305 "</div>" +
306 '<div class="listItem"><h3>预约业务:</h3>' +
307 input.attr("dataName") +
308 "</div>" +
309 '<div class="listItem"><h3>预约时间:</h3>' +
310 bookingDate +
311 "&nbsp;&nbsp;" +
312 bustime +
313 "</div>" +
314 '<div class="confimButton"><button type="button" class="layui-btn cancel layui-btn-primary">取消预约</button></div>' +
315 "</div>",
316 });
317 });
318 }
319
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
62 </ul> 62 </ul>
63 </div> 63 </div>
64 <div class="appoint_time"> 64 <div class="appoint_time">
65 <div class="swiper-container"> 65 <div class="swiper-container" >
66 <div class="swiper-wrapper" id="swiperDate"></div> 66 <div class="swiper-wrapper" id="swiperDate"></div>
67 </div> 67 </div>
68 <!-- Add Arrows --> 68 <!-- Add Arrows -->
...@@ -112,65 +112,3 @@ ...@@ -112,65 +112,3 @@
112 </ul> 112 </ul>
113 {{# } }} {{# }); }} 113 {{# } }} {{# }); }}
114 </script> 114 </script>
...\ No newline at end of file ...\ No newline at end of file
115
116 <script id="business_item" type="text/html">
117 {{# layui.each(d.busList, function(index, item){ }}
118 <div class="business_item">
119 <div class="item_time">
120 <span>上午</span>
121 <span>{{item.startTime}}</span>
122 <span>-</span>
123 <span>{{item.endTime}}</span>
124 </div>
125 <ul>
126 {{# layui.each(item.orgBusinessList, function(index1, item1){ }}
127 {{# if(!item.choosePeriodRulesId && item1.residueNumber==0){ }}
128 <li class="isAppoint" data-id="{{item1.periodRulesId}}">
129 <h3>{{item1.shortName}}</h3>
130 <p style="color:#5FB878">({{item1.residueNumber}})</p>
131 </li>
132 {{# } }}
133
134 {{# if(!item.choosePeriodRulesId && item1.residueNumber!=0){ }}
135 <li class="item_appoint" data-id="{{item1.periodRulesId}}">
136 <h3>{{item1.shortName}}</h3>
137 <p style="color:#5FB878">({{item1.residueNumber}})</p>
138 </li>
139 {{# } }}
140 <!-- 表示预约的是该时间段 且是最后一个号 -->
141 {{# if(item.choosePeriodRulesId && item1.periodRulesId ==item.choosePeriodRulesId && item1.residueNumber==0){ }}
142 <li class="isAppoint" data-id="{{item1.periodRulesId}}">
143 <h3>{{item1.shortName}}</h3>
144 <input type="button" value='取消预约'>
145 <input type="button" value='查看详情'>
146 <p style="color:#5FB878">({{item1.residueNumber}})</p>
147 </li>
148 {{# } }}
149 <!-- 表示预约的是该时间段,且该时间段的号不为0 -->
150 {{# if(item.choosePeriodRulesId && item1.periodRulesId ==item.choosePeriodRulesId && item1.residueNumber!=0){ }}
151 <li class="isAppoint" data-id="{{item1.periodRulesId}}">
152 <h3>{{item1.shortName}}</h3>
153 <input type="button" value='取消预约'>
154 <input type="button" value='查看详情'>
155 <p style="color:#5FB878">({{item1.residueNumber}})</p>
156 </li>
157 {{# } }}
158 <!-- 表示预约的不是该时间段且剩余号为0 -->
159 {{# if(item.choosePeriodRulesId && item1.periodRulesId !=item.choosePeriodRulesId && item1.residueNumber==0){ }}
160 <li class="isAppoint" data-id="{{item1.periodRulesId}}">
161 <h3>{{item1.shortName}}</h3>
162 <p style="color:#5FB878">({{item1.residueNumber}})</p>
163 </li>
164 {{# } }}
165 <!-- 表示预约的不是该时间段且剩余数不为0-->
166 {{# if(item.choosePeriodRulesId && item1.periodRulesId !=item.choosePeriodRulesId && item1.residueNumbe!=0){ }}
167 <li class="isAppoint" data-id="{{item1.periodRulesId}}">
168 <h3>{{item1.shortName}}</h3>
169 <p style="color:#5FB878">({{item1.residueNumber}})</p>
170 </li>
171 {{# } }}
172 {{# }) }}
173 </ul>
174 </div>
175 {{# }); }}
176 </script>
......