weui.datePicker超限卡死问题

微信外包项目,测试通过,部署后发现某日期控件无法显示,界面卡死。
经过排查发现问题出在js上。
外包人员在调用weui.datePicker时给的起始日期超限导制。代码如下:
不应该日直接加7会导至4月35日出现,所以出现问题。

var start = new Date();
var hour  = start.getHours();
var year  = start.getFullYear();
var month = start.getMonth() + 1;
var day   = start.getDate();
if (hour<12) {
  var start_date  = year+'-'+month+'-'+(start.getDate());
  var end_date    = year+'-'+month+'-'+(start.getDate()+7);
} else {
  var start_date  = year+'-'+month+'-'+(start.getDate()+1);
  var end_date    = year+'-'+month+'-'+(start.getDate()+7);
}

weui.datePicker({
  start: start_date, 
  end: end_date,
  defaultValue: [year, month, day],
  onChange: function (result) {
    // console.log(result);
  },
  onConfirm: function (result) {
    var yearSelection   = result[0].value;
    var monthSelection  = result[1].value;
    var daySelection    = result[2].value;
    $('#txtBeginTime').val(`${yearSelection}-${monthSelection}-${daySelection}`);
  },
  id: 'datePicker'
});

正确的 end_date \ start_date 取值如下:

var date2 = new Date(start);
date2.setDate(start.getDate()+7);
var end_date = date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();

你可能感兴趣的:(weui.datePicker超限卡死问题)