/** * Created by wj49476 on 2018/1/10. */ /*http://iservice.10010.com/e4/query/smss/sms_sms-iframe.html?menuCode=000100030002 提取短信记录 * * */ function extractSmsRecords() { function getNear6Montgh(){ var near6MonthArray = []; for (var i=0;i<6;i++){ var d = new Date(); d.setMonth(d.getMonth() - i); var yy1 = d.getFullYear(); var mm1 = d.getMonth() + 1;//因为getMonth()返回值是 0(一月) 到 11(十二月) 之间的一个整数。所以要给其加1 var dd1 = d.getDate(); if (dd1 < 10) { dd1 = '0' + dd1; } //console.info(yy1 + '-' + mm1 + '-' + dd1); near6MonthArray.push([yy1,mm1]); } return near6MonthArray; } //按照年月,获取一个月有多少天 mGetDate(2004,2) function mGetDate(year, month){ var d = new Date(year, month, 0); return d.getDate(); } var smsRecordsArray = []; function extractSmsRecordsInner() { var near6MonthArray = getNear6Montgh(); var j = 0; for (var i=0; i< near6MonthArray.length; i++) { var dates = mGetDate(near6MonthArray[i][0], near6MonthArray[i][1]); if ( j === 0){ var myDate = new Date(); dates = myDate.getDate(); if (dates < 10) { dates= '0' + dates; } } j++; var mm1 = near6MonthArray[i][1]; if (mm1 < 10) { mm1 = '0' + mm1; } var yearMonth = near6MonthArray[i][0] + '' + mm1; var smsRecordsObj = {}; smsRecordsObj.pagelist = []; smsRecordsObj.yearMonth = yearMonth; function extractSmsRecordByPage(page) { var page = page || 1; var url = 'http://iservice.10010.com/e3/static/query/sms?_=1515572703231&accessURL=http://iservice.10010.com/e4/query/calls/call_sms-iframe.html?menuCode=000100030002&menuid=000100030002'; var data = { pageNo: page, pageSize: 200, begindate: yearMonth + '01', enddate: yearMonth + dates }; console.debug('data:',data); var htmlObj = $.ajax({ type: 'POST', url: url, data: data, async: false }); var htmlStr = htmlObj.responseText; console.debug('htmlStr:',htmlStr); var smsRecordsRawObj = JSON.parse(htmlStr); if (smsRecordsRawObj.pageMap && smsRecordsRawObj.pageMap.result){ smsRecordsObj.pagelist = smsRecordsObj.pagelist.concat(smsRecordsRawObj.pageMap.result); smsRecordsObj.mmsCount = smsRecordsRawObj.mmsCount; smsRecordsObj.totalfee = smsRecordsRawObj.totalfee; console.debug('result:',smsRecordsRawObj.pageMap.result); var totalpage = smsRecordsRawObj.pageMap.totalPages; if (page < totalpage) { extractSmsRecordByPage(page + 1); //翻页回调自己 } } } extractSmsRecordByPage(); smsRecordsArray.push(smsRecordsObj); } smsRecordsInfoObj = { smsRecordsInfo:smsRecordsArray }; return JSON.stringify(smsRecordsInfoObj); } return extractSmsRecordsInner(); } //extractSmsRecords();
js获取联通短信记录