🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### WeUI移动页面实现时间选择器(年-月-日-时-分) ```javascript $('.ma_expect_date').click(function(event) { var _this = this; weui.datePicker({ start: new Date(), end: 2030, defaultValue: [new Date().getFullYear(), new Date().getMonth()+1, new Date().getDate()], onConfirm: function(result){ // 二级调用:时间 $('.ma_expect_date_picker .weui-picker').on('animationend webkitAnimationEnd', function() { show_expect_time_picker(_this, result); }); }, id: 'ma_expect_date', className: 'ma_expect_date_picker' }); }); // -----------------------二级调用:时间 var hours = [], minites = [], symbol = [{ label: ':', value: 0 }]; function show_expect_time_picker(_this, date) { var date = date[0].label + date[1].label + date[2].label; if (!hours.length) { for (var i = 0; i< 24; i++) { var hours_item = {}; hours_item.label = ('' + i).length === 1 ? '0' + i : '' + i; hours_item.value = i; hours.push(hours_item); } } if (!minites.length) { for (var j= 0; j < 60; j++) { var minites_item = {}; minites_item.label = ('' + j).length === 1 ? '0' + j : '' + j; minites_item.value = j; minites.push(minites_item); } } weui.picker(hours, symbol, minites, { defaultValue: [new Date().getHours()+1, 0, 0], onConfirm: function(result) { var time = result[0].label + ':' + result[2].label; var expect_date = date + ' ' + time; $(_this).find('.weui-cell__ft').text(expect_date); }, id: 'ma_expect_time' }); } ```