;(function ($) { var showDateDom1 = $('#mobIn1'); var showDateDom2 = $('#mobIn2'); var showDateDom3 = $('#mobIn3'); var showDateDom4 = $('#mobIn4'); var showDateDom5 = $('#mobIn5'); var showDateDom6 = $('#mobIn6'); var showDateDom7 = $('#mobIn7'); var iosSelect1 = null; var iosSelect2 = null; var iosSelect3 = null; var iosSelect4 = null; var iosSelect5 = null; var iosSelect6 = null; var iosSelect7 = null; var starNum1 = 0; var starNum2 = 0; // 初始化时间 var now = new Date(); var nowHours = now.getHours(); var nowSeconds = now.getMinutes(); showDateDom1.attr('data-hours', cN(nowHours)); showDateDom1.attr('data-seconds', cN(nowSeconds)); showDateDom1.attr('data-thours', cN(nowHours)); showDateDom1.attr('data-tseconds', cN(nowSeconds)); // 数据初始化 function cN (v) { return v < 10 ? '0' + v : v; } function formatHours (s) { var arr = []; for (var i = s; i <= 23; i++) { arr.push({ id: cN(i) + '', value: cN(i) }); } return arr; } function formatSeconds (s) { var arr = []; for (var i = s; i <= 59; i++) { arr.push({ id: cN(i) + '', value: cN(i) }); } return arr; } var hoursData = function (callback) { callback(formatHours(starNum1)); }; var secondData = function(h,callback) { callback(formatSeconds(starNum2)) }; var hoursTData = function (h,s,callback) { h = parseInt(h); callback(formatHours(h)); }; var secondTData = function(h,s,h1,callback) { s = parseInt(s); callback(formatSeconds(0)) }; for (var i = 1; i <= 7; i++) { $('#mobIn' + i).on('click', function () { var $me = $(this); var oneLevelId = $me.attr('data-hours'); var twoLevelId = $me.attr('data-seconds'); var threeLevelId = $me.attr('data-thours'); var fourLevelId = $me.attr('data-tseconds'); var $n = $me.closest('.time-item').next(), $p = $me.closest('.time-item').prev(), ind = $me.closest('.time-item').index(); if ($p.length) { if (!$p.find('input').val()) { dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'请先选择上一个时间段!'}).show(); return; } } if (ind == 0) { starNum1 = 0; starNum2 = 0; } else { starNum1 = parseInt(oneLevelId); starNum2 = parseInt('00'); } new IosSelect(4, [ hoursData, secondData, hoursTData, secondTData], { title: '', itemHeight: 35, relation: [ 1, 1, 1, 1], oneLevelId: oneLevelId, twoLevelId: twoLevelId, threeLevelId: threeLevelId, fourLevelId: fourLevelId, showLoading: true, callback: function (selectOneObj, selectTwoObj, selectThreeObj, selectFourObj) { $n.find('input').attr('data-hours', selectThreeObj.id); $n.find('input').attr('data-seconds', selectFourObj.id); $n.find('input').attr('data-thours', selectThreeObj.id); $n.find('input').attr('data-tseconds', selectFourObj.id); $me.attr('data-hours', selectOneObj.id); $me.attr('data-seconds', selectTwoObj.id); $me.attr('data-thours', selectThreeObj.id); $me.attr('data-tseconds', selectFourObj.id); starNum1 = parseInt(selectThreeObj.id); starNum2 = parseInt(selectFourObj.id); $me.val(selectOneObj.value + ':' + selectTwoObj.value + '-' + selectThreeObj.value + ':' + selectFourObj.value); } }); }); } })(jQuery);