var base_api="http://wxsct.zhizhuchuxing.com/"; base_api=""; //设置字符串类型的本地缓存 function setStorage(objName, objValue){ var sto = window.localStorage; if (sto) sto.setItem(objName, objValue); } //读取字符串类型的本地缓存 function getStorage(objName){ var ret = ''; var sto = window.localStorage; if (sto) ret = sto.getItem(objName); return ret; } //清除本地缓存,如没指定名称则为清空所有缓存 function clearStorage(objName){ var sto = window.localStorage; if (sto) { if (objName) sto.removeItem(objName); else sto.clear(); } } //设置Json类型的本地缓存 function setStorJson(objName, json){ if (json) setStorage(objName, JSON.stringify(json)); } //读取Json类型的本地缓存 function getStorJson(objName){ var ret = null; var str = getStorage(objName); if (str) ret = JSON.parse(str); return ret; } function iflogin(){ $.ajax({ type:"post", url:base_api+"./zz-fx/control.php", data:{type:"distribut_iflogin"}, dataType: "json", success: function (data) { console.log(data); if(data.iflogin == 1){ //alert("用户未登录,请先登录"); window.wxc.xcConfirm("用户未登录,请先登录", window.wxc.xcConfirm.typeEnum.info,{ onOk:function(){ window.location.href="login.html" } }); }else{ return; } }, fail: function (date) { // 此处放失败后执行的代码 } }); } //打印日志 function ZZLog(str){ var isLog=true; if(isLog){ console.log(str); } } //获取时间 function getDateTime(nTypeFlag) { var tNowTime = new Date(); var myYear = ';' + tNowTime.getFullYear() + ';'; var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';'; var myDay = ';' + tNowTime.getDate() + ';'; var myHour = ';' + tNowTime.getHours() + ';'; var myMinu = ';' + tNowTime.getMinutes() + ';'; var mySecond = ';' + tNowTime.getSeconds() + ';'; if(myMonth.length < 4) myMonth = '0' + myMonth; if(myDay.length < 4) myDay = '0' + myDay; if(myHour.length < 4) myHour = '0' + myHour; if(myMinu.length < 4) myMinu = '0' + myMinu; if(mySecond.length < 4) mySecond = '0' + mySecond; var cNewTimeStr; switch(nTypeFlag + 1 - 1) { case 0: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay; break; case 1: cNewTimeStr = myYear + myMonth + myDay; break; case 2: cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond; break; case 3: cNewTimeStr = myHour + myMinu + mySecond; break; case 4: cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond; break; case 5: cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日'; break; case 6: cNewTimeStr = myYear; break; case 7: cNewTimeStr = myYear + '-' + myMonth; break; case 8: //得到上一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中月的天数 var year2 = year; var month2 = parseInt(month) - 1; if(month2 == 0) { year2 = parseInt(year2) - 1; month2 = 12; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if(day2 > days2) { day2 = days2; } if(month2 < 10) { month2 = '0' + month2; } cNewTimeStr = year2 + '-' + month2 + '-' + day2; break; case 9: //得到下一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中的月的天数 var year2 = year; var month2 = parseInt(month) + 1; if(month2 == 13) { year2 = parseInt(year2) + 1; month2 = 1; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if(day2 > days2) { day2 = days2; } if(month2 < 10) { month2 = '0' + month2; } var t2 = year2 + '-' + month2 + '-' + day2; return t2; break; case 10: cNewTimeStr = myYear +'/' +myMonth +'/'+ myDay; break; case 11: if (myMonth != 10 || myMonth != 11 || myMonth != 12) { myMonth = myMonth.substring(1,myMonth.length-1); } cNewTimeStr = myMonth +'月'+ myDay+'日'; break; default: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond; break; } cNewTimeStr = cNewTimeStr.replace(/;/g, ""); return cNewTimeStr; } //得到url上的参数 function getPar(par){ var local_url = document.location.href; local_url = decodeURI(local_url); var get = local_url.indexOf(par +"="); if(get == -1){ return ""; } var get_par = local_url.slice(par.length + get + 1); var nextPar = get_par.indexOf("&"); if(nextPar != -1){ get_par = get_par.slice(0, nextPar); } return get_par; } //js判断一个日期是星期几 传入 年/月/日 function getWeekDay(day){ var a = new Array("日", "一", "二", "三", "四", "五", "六"); var week = new Date(day).getDay(); var str = "星期"+ a[week]; return str; } //截取日期参数 function getMonthAndDayByDate(datestr,info){ var dateAry = datestr.split('-'); var cNewTimeStr; switch(info){ case 'year': cNewTimeStr = dateAry[0]; break; case 'month': cNewTimeStr = dateAry[1]; break; default: cNewTimeStr = dateAry[2]; break; } return cNewTimeStr; }