修改预约加载
Showing
2 changed files
with
66 additions
and
161 deletions
| ... | @@ -60,49 +60,26 @@ $(function () { | ... | @@ -60,49 +60,26 @@ $(function () { | 
| 60 | }); | 60 | }); | 
| 61 | }); | 61 | }); | 
| 62 | } | 62 | } | 
| 63 | // 业务选择 | 63 | |
| 64 | // $(document).on("click", ".business_item ul .item_appoint ", function (e) { | ||
| 65 | // console.log(5555) | ||
| 66 | // jgid = GetRequest(); | ||
| 67 | // appuintText = $(this).find("h3").text(); | ||
| 68 | // periodRulesId = $(this).data('id') | ||
| 69 | // console.log('aaa', periodRulesId) | ||
| 70 | // checkAppointment() | ||
| 71 | // handle(); | ||
| 72 | // }); | ||
| 73 | $(document).on("click", ".cancel", function () { | 64 | $(document).on("click", ".cancel", function () { | 
| 74 | layer.closeAll(); | 65 | layer.closeAll(); | 
| 75 | }); | 66 | }); | 
| 76 | $(document).on("click", ".confim", function () { | 67 | $(document).on("click", ".confim", function () { | 
| 77 | if (flag) { | ||
| 78 | var paramsobj = {} | 68 | var paramsobj = {} | 
| 79 | paramsobj.jgid = GetRequest() | 69 | paramsobj.jgid = GetQueryString("jgid"); | 
| 80 | paramsobj.periodRulesId = periodRulesId | 70 | paramsobj.periodRulesId = periodRulesId | 
| 81 | paramsobj.userid = getCookie().userid | 71 | paramsobj.userid = getCookie().userid | 
| 82 | makeAppointment(paramsobj) | 72 | makeAppointment(paramsobj) | 
| 83 | } | ||
| 84 | }); | 73 | }); | 
| 85 | }); | 74 | }); | 
| 86 | function GetRequest() { | 75 | |
| 87 | var url = location.search; //获取url中"?"符后的字串 | 76 | //获取当前页面预约日期 | 
| 88 | var theRequest = new Object(); | ||
| 89 | if (url.indexOf("?") != -1) { | ||
| 90 | var str = url.substr(1); | ||
| 91 | strs = str.split("?"); | ||
| 92 | for (var i = 0; i < strs.length; i++) { | ||
| 93 | theRequest[strs[i].split("=")[0]] = decodeURIComponent( | ||
| 94 | strs[i].split("=")[1] | ||
| 95 | ); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | return theRequest.jgid; | ||
| 99 | } | ||
| 100 | function getAppointmentDay() { | 77 | function getAppointmentDay() { | 
| 101 | $.ajax({ | 78 | $.ajax({ | 
| 102 | type: "get", //提交方式 | 79 | type: "get", //提交方式 | 
| 103 | url: portal.api_url + "/portal/appointmentmh/getAppointmentDay", //路径 | 80 | url: portal.api_url + "/portal/appointmentmh/getAppointmentDay", //路径 | 
| 104 | data: { | 81 | data: { | 
| 105 | jgid: GetRequest(), | 82 | jgid: GetQueryString("jgid"), | 
| 106 | }, | 83 | }, | 
| 107 | dataType: "json", | 84 | dataType: "json", | 
| 108 | success: function (result) { | 85 | success: function (result) { | 
| ... | @@ -121,14 +98,14 @@ function getAppointmentDay() { | ... | @@ -121,14 +98,14 @@ function getAppointmentDay() { | 
| 121 | }, | 98 | }, | 
| 122 | }); | 99 | }); | 
| 123 | } | 100 | } | 
| 124 | // 根据办事大厅机构ID、日期、用户ID,查询可预约的业务 GET | 101 | // 根据办事大厅机构ID、日期、用户ID,获取对应日期的业务列表 GET | 
| 125 | function getAppointmentPeriodAndBusiness() { | 102 | function getAppointmentPeriodAndBusiness() { | 
| 126 | $.ajax({ | 103 | $.ajax({ | 
| 127 | type: "get", //提交方式 | 104 | type: "get", //提交方式 | 
| 128 | url: | 105 | url: | 
| 129 | portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", // | 106 | portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", // | 
| 130 | data: { | 107 | data: { | 
| 131 | jgid: GetRequest(), | 108 | jgid: GetQueryString("jgid"), | 
| 132 | userid: getCookie().userid, | 109 | userid: getCookie().userid, | 
| 133 | bookingDate: bookingDate, | 110 | bookingDate: bookingDate, | 
| 134 | }, | 111 | }, | 
| ... | @@ -139,84 +116,20 @@ function getAppointmentPeriodAndBusiness() { | ... | @@ -139,84 +116,20 @@ function getAppointmentPeriodAndBusiness() { | 
| 139 | if (result.code == 200 && result.data != null) { | 116 | if (result.code == 200 && result.data != null) { | 
| 140 | console.log(result.data) | 117 | console.log(result.data) | 
| 141 | data.busList = result.data.appointmentPeriodBusinessList; | 118 | data.busList = result.data.appointmentPeriodBusinessList; | 
| 142 | //bookingDate=result.data.bookingDate; | ||
| 143 | RenderBusinessList(result.data); | 119 | RenderBusinessList(result.data); | 
| 144 | // console.log(2222,data.busList) | 120 | |
| 145 | // if(result.data.choosePeriodRulesId!==null){ | ||
| 146 | // if(2){ | ||
| 147 | // // for循环找到对应的id 打开,其余都设置为禁用 | ||
| 148 | // } | ||
| 149 | // }else if(result.data.choosePeriodRulesId ==null){ | ||
| 150 | // // step 1: 如果等于0 | ||
| 151 | // for(var i =0;i<result.data.appointmentPeriodBusinessList.length;i++){ | ||
| 152 | // for(var j=0;j<result.data.appointmentPeriodBusinessList[i].orgBusinessList.length; j++){ | ||
| 153 | // if(result.data.appointmentPeriodBusinessList[i].orgBusinessList[j].residueNumber ==0){ | ||
| 154 | // result.data.appointmentPeriodBusinessList[i].orgBusinessList[j].disabled = true | ||
| 155 | // } | ||
| 156 | // } | ||
| 157 | // } | ||
| 158 | // data.busList = result.data.appointmentPeriodBusinessList | ||
| 159 | // console.log(11111, data.busList) | ||
| 160 | // } | ||
| 161 | if (data.busList.length > 0) { | 121 | if (data.busList.length > 0) { | 
| 162 | data.busList.forEach((item, index) => { | 122 | data.busList.forEach((item, index) => { | 
| 163 | hallname = item.orgBusinessList[0].jgName | 123 | hallname = item.orgBusinessList[0].jgName | 
| 164 | }) | 124 | }) | 
| 165 | } | 125 | } | 
| 166 | // layui.use("laytpl", function () { | 126 | |
| 167 | // laytpl = layui.laytpl; | ||
| 168 | // var getTpl1 = document.getElementById("business_item").innerHTML, | ||
| 169 | // view1 = document.getElementById("business_list"); | ||
| 170 | // laytpl(getTpl1).render(data, function (html) { | ||
| 171 | // view1.innerHTML = html; | ||
| 172 | // }); | ||
| 173 | // }); | ||
| 174 | } | ||
| 175 | }, | ||
| 176 | }); | ||
| 177 | } | ||
| 178 | // 根据办事大厅机构ID、用户ID检查用户是否存在预约限制 | ||
| 179 | function checkAppointment() { | ||
| 180 | $.ajax({ | ||
| 181 | type: "get", //提交方式 | ||
| 182 | async: false, | ||
| 183 | url: | ||
| 184 | portal.api_url + "/portal/appointmentmh/checkAppointment", | ||
| 185 | data: { | ||
| 186 | jgid: GetRequest(), | ||
| 187 | userid: getCookie().userid, | ||
| 188 | }, | ||
| 189 | dataType: "json", | ||
| 190 | //数据,这里使用的是Json格式进行传输 | ||
| 191 | success: function (result) { | ||
| 192 | //返回数据根据结果进行相应的处理 | ||
| 193 | if (result.code == 200) { | ||
| 194 | return flag = result.data | ||
| 195 | } else if (result.code == 210) { | ||
| 196 | return layer.msg(result.message) | ||
| 197 | } | 127 | } | 
| 198 | }, | 128 | }, | 
| 199 | }); | 129 | }); | 
| 200 | } | 130 | } | 
| 201 | // 用户预约抢号 POST | 131 | |
| 202 | function makeAppointment(data) { | 132 | |
| 203 | $.ajax({ | ||
| 204 | type: "post", //提交方式 | ||
| 205 | async: false, | ||
| 206 | url: portal.api_url + "/portal/appointmentmh/makeAppointment",//路径 | ||
| 207 | headers: {//***关键****** | ||
| 208 | 'Content-Type': 'application/json;charset=UTF-8', | ||
| 209 | }, | ||
| 210 | dataType: "json", | ||
| 211 | data: JSON.stringify(data),//***关键****** | ||
| 212 | success: function (result) {//返回数据根据结果进行相应的处理 | ||
| 213 | if (result.code == 200 && result.data !== null) { | ||
| 214 | appointmentId = result.data | ||
| 215 | window.location.href = "./yyjg.html?appointmentId=" + appointmentId | ||
| 216 | } | ||
| 217 | } | ||
| 218 | }); | ||
| 219 | } | ||
| 220 | 133 | ||
| 221 | var bookingDate = undefined; | 134 | var bookingDate = undefined; | 
| 222 | var flag = undefined; | 135 | var flag = undefined; | 
| ... | @@ -258,7 +171,7 @@ function RenderBusinessList(data) { | ... | @@ -258,7 +171,7 @@ function RenderBusinessList(data) { | 
| 258 | businessContent += '<h3>' + childItem.shortName + '</h3>'; | 171 | businessContent += '<h3>' + childItem.shortName + '</h3>'; | 
| 259 | businessContent += '<input type="button" value="查看详情" id="' + childItem.periodRulesId + '" dataName="' + childItem.shortName + '" onclick="appointmentDetail(this.id)"/>'; | 172 | businessContent += '<input type="button" value="查看详情" id="' + childItem.periodRulesId + '" dataName="' + childItem.shortName + '" onclick="appointmentDetail(this.id)"/>'; | 
| 260 | } | 173 | } | 
| 261 | else{ | 174 | else { | 
| 262 | businessContent += '<li class="isAppoint">'; | 175 | businessContent += '<li class="isAppoint">'; | 
| 263 | businessContent += '<h3>' + childItem.shortName + '</h3>'; | 176 | businessContent += '<h3>' + childItem.shortName + '</h3>'; | 
| 264 | } | 177 | } | 
| ... | @@ -280,8 +193,42 @@ function RenderBusinessList(data) { | ... | @@ -280,8 +193,42 @@ function RenderBusinessList(data) { | 
| 280 | businessDiv.html(businessContent); | 193 | businessDiv.html(businessContent); | 
| 281 | } | 194 | } | 
| 282 | 195 | ||
| 196 | // 根据办事大厅机构ID、用户ID检查用户是否存在预约限制 | ||
| 197 | function checkAppointment() { | ||
| 198 | let msg; | ||
| 199 | $.ajax({ | ||
| 200 | type: "get", //提交方式 | ||
| 201 | async: false, | ||
| 202 | url: | ||
| 203 | portal.api_url + "/portal/appointmentmh/checkAppointment", | ||
| 204 | data: { | ||
| 205 | jgid: GetQueryString("jgid"), | ||
| 206 | userid: getCookie().userid, | ||
| 207 | }, | ||
| 208 | dataType: "json", | ||
| 209 | //数据,这里使用的是Json格式进行传输 | ||
| 210 | success: function (result) { | ||
| 211 | //返回数据根据结果进行相应的处理 | ||
| 212 | // if (result.code == 200) { | ||
| 213 | // return flag = result.data | ||
| 214 | // } | ||
| 215 | if (result.code == 210) { | ||
| 216 | msg = result.message; | ||
| 217 | } | ||
| 218 | }, | ||
| 219 | }); | ||
| 220 | return msg; | ||
| 221 | } | ||
| 222 | |||
| 283 | var yyrq; | 223 | var yyrq; | 
| 284 | function handle(id) { | 224 | function handle(id) { | 
| 225 | |||
| 226 | let msg = checkAppointment(); | ||
| 227 | if (msg != undefined) { | ||
| 228 | //layer.msg('hello'); | ||
| 229 | alert(msg); | ||
| 230 | return; | ||
| 231 | }; | ||
| 285 | var input = $("#" + id); | 232 | var input = $("#" + id); | 
| 286 | layui.use("layer", function () { | 233 | layui.use("layer", function () { | 
| 287 | layer.open({ | 234 | layer.open({ | 
| ... | @@ -315,6 +262,26 @@ function handle(id) { | ... | @@ -315,6 +262,26 @@ function handle(id) { | 
| 315 | }); | 262 | }); | 
| 316 | } | 263 | } | 
| 317 | 264 | ||
| 265 | // 用户预约抢号 POST | ||
| 266 | function makeAppointment(data) { | ||
| 267 | $.ajax({ | ||
| 268 | type: "post", //提交方式 | ||
| 269 | async: false, | ||
| 270 | url: portal.api_url + "/portal/appointmentmh/makeAppointment",//路径 | ||
| 271 | headers: {//***关键****** | ||
| 272 | 'Content-Type': 'application/json;charset=UTF-8', | ||
| 273 | }, | ||
| 274 | dataType: "json", | ||
| 275 | data: JSON.stringify(data),//***关键****** | ||
| 276 | success: function (result) {//返回数据根据结果进行相应的处理 | ||
| 277 | if (result.code == 200 && result.data !== null) { | ||
| 278 | appointmentId = result.data | ||
| 279 | window.location.href = "./yyjg.html?appointmentId=" + appointmentId | ||
| 280 | } | ||
| 281 | } | ||
| 282 | }); | ||
| 283 | } | ||
| 284 | |||
| 318 | //预约详情 | 285 | //预约详情 | 
| 319 | function appointmentDetail(id) { | 286 | function appointmentDetail(id) { | 
| 320 | var input = $("#" + id); | 287 | var input = $("#" + id); | ... | ... | 
| ... | @@ -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> | ... | ... | 
- 
Please register or sign in to post a comment