yu_studycar_2.html 11.0 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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="yes" name="apple-touch-fullscreen">
	<meta name="viewport"
	      content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
	<title>预约学车</title>
	<link rel="stylesheet" href="/static/css/common.css">
	<link rel="stylesheet" href="/static/css/style.css">
	<link rel="stylesheet" href="/static/css/swiper.min.css">
	<style>
		.btn_yuyue {
			margin-bottom: 1rem;
		}

		.yu_tan .yu_tan_box .tan_text {
			width: 6.533333rem;
		}
	</style>
</head>
<body style="background-color: #f6f6f6;">
<div class="box">
	<div class="swiper-container">
		<div class="swiper-wrapper">
			<div class="swiper-slide">
				<div class="day_list day_bg">
					<b>周一</b>
					<i>06-25</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
			<div class="swiper-slide">
				<div class="day_list">
					<b>周二</b>
					<i>06-26</i>
				</div>
			</div>
		</div>
	</div>
	<div class="yu_container">
		<div class="time_list">
			<b>06:00-07:00</b>
			<i></i>
		</div>
		<div class="time_list">
			<b>07:00-08:00</b>
			<i></i>
		</div>
		<div class="time_list">
			<b>08:00-09:00</b>
			<i></i>
		</div>
		<div class="time_list">
			<b>09:00-10:00</b>
			<i></i>
		</div>
		<div class="time_list">
			<b>10:00-11:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>11:00-12:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>12:00-13:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor time_bg_icon">
			<b>13:00-14:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>14:00-15:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>15:00-16:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>16:00-17:00</b>
			<i></i>
		</div>
		<div class="time_list time_bor">
			<b>17:00-18:00</b>
			<i></i>
		</div>
		<div style="clear: both"></div>
		<div class="btn_yuyue" style="display: block;margin-top:3.73rem" id="btn_yuyue">
			<img src="/static/image/btn_yuyue.png"/>
		</div>
	</div>

</div>

<!--弹跳框-->
<div class="full_bg"></div>
<div class="yu_tan" data-qr="1">
	<div class="yu_tan_box">
		<img src="/static/image/tan_car1.png" class="tan_car"/>
		<h1 class="tan_text">您确定要预约<span id="time_duan"></span>{$data.user_nickname}的课程吗</h1>
		<h2 class="btn_qr">确认</h2>
	</div>
	<div class="syudy_cancel"></div>
</div>
<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/jquery.sliderPro.min.js"></script>
<script src="/static/js/swiper.min.js"></script>
<script type="text/javascript" src="/static/js/study_car.js"></script>
<script>
	var swiper = new Swiper('.swiper-container', {
		slidesPerView: 7,
		pagination: {
			el: '.swiper-pagination',
			clickable: true,
		},
	});
	$('.day_list').click(function () {
		$(this).addClass('day_bg').parent().siblings().children().removeClass('day_bg');
	});
	$(function () {
		function get_ok_list(day) {
			$.ajax({
				url: "/portal/tool/get_relax_time",
				type: "post",
				data: {
					day: day.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3"),
					uid: {$id}
				}, success: function (res) {
					if (res.code == "1") {
						var date = new Date();
						var year = date.getFullYear();
						var mon = date.getMonth() + 1;
						var days = date.getDate();
						var hour = date.getHours() + 3;
						var list = $('.time_list');
						if (day == '' + year + check_num(mon) + check_num(days)) {
							var time_list = [];
							var lists = JSON.parse(res.data);
							for (var i = 0; i < list.find('b').length; i++) {
								time_list.push(list.find('b')[i].innerHTML.split('-'));
							}
							for (var j = 0; j < time_list.length; j++) {
								if (parseInt(time_list[j][0]) < hour) {
									lists[j] = "no";
								}
								list[j].setAttribute('data-index', j);
							}
							var tiem_list = $('.time_list');
							for (var i = 0; i < lists.length; i++) {
								if (lists[i] == "yes") {
									tiem_list[i].setAttribute('class', 'time_list time_bor');
								} else {
									tiem_list[i].setAttribute('class', 'time_list');
								}
								tiem_list[i].setAttribute("data-index", i);
							}
						} else {
							for (var i = 0; i < list.length; i++) {
								list[i].setAttribute('data-index', i);
								list[i].setAttribute('class', 'time_list time_bor');
							}
							var listss = JSON.parse(res.data);
							var tiem_list = $('.time_list');
							for (var i = 0; i < listss.length; i++) {
								if (listss[i] == "yes") {
									tiem_list[i].setAttribute('class', 'time_list time_bor');
								} else {
									tiem_list[i].setAttribute('class', 'time_list');
								}
								tiem_list[i].setAttribute("data-index", i);
							}
						}

					}
				}
			});
		}

		function check_num(num) {
			if (num < 10) {
				return "0" + num;
			} else {
				return num
			}
		}

		function checkToday() {

		}

		(function () {
			var date = new Date();
			var year = date.getFullYear();
			var mon = check_num(date.getMonth() + 1);
			var da = check_num(date.getDate());
			var day = "" + year + mon + da;
			get_ok_list(day);
		})()
		var cells = $('.day_list');
		var clen = cells.length;
		var currentFirstDate;
		var formatDate = function (date) {
			var year = date.getFullYear();
			var month = (date.getMonth() + 1);
			if (month < 10) {
				month = "0" + month;
			}
			var day = date.getDate();
			if (day < 10) {
				day = "0" + day;
			}
			var month_day = month + '-' + day;
			var week = ['周天', '周一', '周二', '周三', '周四', '周五', '周六'][date.getDay()];
			return '<b>' + week + '</b>' + '<i data-day="' + year + '' + month + day + '">' + month_day + '</i>';
		};
		var addDate = function (date, n) {
			date.setDate(date.getDate() + n);
			return date;
		};
		var setDate = function (date) {
			var week = date.getDay() - 1;
			date = addDate(date, week * +0);
			currentFirstDate = new Date(date);
			for (var i = 0; i < clen; i++) {
				cells[i].innerHTML = formatDate(i == 0 ? date : addDate(date, 1));
			}
		};
		setDate(new Date());
		$('.day_list').click(function () {
			var day = $(this).children('i').attr('data-day');
			get_ok_list(day);
		});
		$('.yu_container .time_list').click(function () {
			if ($(this).hasClass('time_bor')) {
				if ($('.time_bg_icon').length < 3) {
					if ($(this).hasClass('time_bg_icon')) {
						$(this).removeClass('time_bg_icon');
					} else {
						$(this).addClass('time_bg_icon');
					}
				} else {
					if ($(this).hasClass('time_bg_icon')) {
						$(this).removeClass('time_bg_icon');
					} else {
						layer.msg("选择的时间段不能超过3小时");
						return;
					}
				}
				var list = $('.time_bg_icon');
				var acvList = [];
				var boo = false;
				for (var i = 0; i < list.length; i++) {
					acvList.push(parseInt(list[i].getAttribute("data-index")));
				}
				var degin = acvList[0];
				for (var j = 0; j < acvList.length; j++) {
					if (acvList[j] != degin) {
						boo = true;
						break;
					} else {
						degin++;
					}
				}
				if (boo) {
					alert("请选择连续的时间段");
					$(this).attr("class", "time_list time_bor");
				}
			}
		});
		var day1 = $('.day_bg i').text();
		var week = $('.day_bg b').text();
		var hour1 = $('.time_bg_icon b').text();
		var data_day = $('.day_bg i').attr("data-day");
		var data_index = $('.time_bg_icon').length == 0 ? null : $('.time_bg_icon').attr("data-index");
		$("#btn_yuyue").click(function () {
			var list = $('.time_bg_icon');
			var acvList = [];
			var boo = false;
			for (var i = 0; i < list.length; i++) {
				acvList.push(parseInt(list[i].getAttribute("data-index")));
			}
			var degin = acvList[0];
			for (var j = 0; j < acvList.length; j++) {
				if (acvList[j] != degin) {
					boo = true;
					break;
				} else {
					degin++;
				}
			}
			if (boo) {
				alert("请选择连续的时间段");
			} else {
				var hour1 = $('.time_bg_icon b').text();
				$('.tan_car').css({"width": "4.97rem", "height": "2.88rem"});
				$('#time_duan').text(hour1);
				tankuang();
			}
		});
		$('.btn_qr').click(function () {
			var data_qr = $('.yu_tan').attr("data-qr");
			var list = $('.time_bg_icon');
			var acvList = [];
			var boo = false;
			for (var i = 0; i < list.length; i++) {
				acvList.push(parseInt(list[i].getAttribute("data-index")));
			}
			var degin = acvList[0];
			for (var j = 0; j < acvList.length; j++) {
				if (acvList[j] != degin) {
					boo = true;
					break;
				} else {
					degin++;
				}
			}
			if (data_qr == 1) {
				$.ajax({
					url: "{:url('yuyue_coach_do')}",
					type: "post",
					data: {
						day: data_day.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3"),
						week: week,
						begin: parseInt(list[0].getElementsByTagName('b')[0].innerHTML.split("-")[0]),
						end: parseInt(list[list.length - 1].getElementsByTagName('b')[0].innerHTML.split('-')[1]),
						id: {$id}
					},
					success: function (res) {
						console.log(res);
					}
				});
				$('.tan_text').html("恭喜您,预约成功");
				tankuang();
				$('.yu_tan').attr("data-qr", "2")
			} else if (data_qr == 2) {
				window.location.href = "/user/profile/percenter";
			}
		});
		$('.syudy_cancel').click(function () {
			var data_qr = $('.yu_tan').attr("data-qr");
			if (data_qr == 1) {
				$("html").css("overflow", "auto");
				$("body").css("overflow", "auto");
				$(".full_bg").hide();
				$(".yu_tan").hide();
			} else if (data_qr == 2) {
				window.location.href = "/user/profile/percenter";
			}
		});
	});
</script>
</body>
</html>