function getThisWeek(str){
//按周日为一周的最后一天计算
var date = new Date(str);
var thisday = date.getDay(); //今天是这周的第几天
var step_s = -thisday+1; //上周日距离今天的天数(负数表示)
if (thisday == 0) {
step_s = -7; // 如果今天是周日
}
var step_m = 7 - thisday; // 周日距离今天的天数(负数表示)
var thisTime = date.getTime();
var monday = new Date(thisTime + step_s * 24 * 3600* 1000);
var sunday = new Date(thisTime + step_m * 24 * 3600* 1000);
//默认统计一周的时间
var starttime = new Date(monday); //本周一的日期 (起始日期)
var endtime = new Date(sunday); //本周日的日期 (结束日期)
var thisYear=starttime.getFullYear();
var thisMonth=starttime.getMonth()+1;
thisMonth=thisMonth<'10'?'0'+thisMonth:thisMonth;
var thisDate=starttime.getDate();
thisDate=thisDate<'10'?'0'+thisDate:thisDate;
console.log('您输入的当前日期,周一的日期是'+thisYear+'-'+thisMonth+'-'+thisDate)
var endYear=endtime.getFullYear();
var endMonth=endtime.getMonth()+1;
endMonth=endMonth<'10'?'0'+endMonth:endMonth;
var endDate=endtime.getDate();
endDate=endDate<'10'?'0'+endDate:endDate;
console.log('您输入的当前日期,周日的日期是'+endYear+'-'+endMonth+'-'+endDate)
}
getThisWeek("2017-05-11")