var LayerOffset = '100px'; window.onload = function () { var region = _CTX_delregion; // 初始化标题 var titleDom = document.getElementById('zsj_title'); if (titleDom != null) { var srcText = titleDom.innerText; // 要替换的 文本标题 var dstTitle = srcText; if (srcText === '旅游基础资源维护') { if (region === '130000') { dstTitle = '文旅基础资源维护'; } } else if (srcText === '旅游地理信息系统') { dstTitle = '文旅地理信息系统'; } titleDom.innerText = dstTitle; document.title = dstTitle; } }; /** * http://weatherdt.com/help.html * 根据中国天气网 编码,获取中文的天气现象 * @param weatherPhenomenaCode * @returns {*} */ function getWeatherByCode(weatherPhenomenaCode){ var text = "晴"; switch (weatherPhenomenaCode) { case 0: text = "晴"; break; case 1: text = "多云"; break; case 2: text = "阴"; break; case 3: text = "阵雨"; break; case 4: text = "雷阵雨"; break; case 5: text = "雷阵雨伴有冰雹"; break; case 6: text = "雨夹雪"; break; case 7: text = "小雨"; break; case 8: text = "中雨"; break; case 9: text = "大雨"; break; case 10: text = "暴雨"; break; case 11: text = "大暴雨"; break; case 12: text = "特大暴雨"; break; case 13: text = "阵雪"; break; case 14: text = "小雪"; break; case 15: text = "中雪"; break; case 16: text = "大雪"; break; case 17: text = "暴雪"; break; case 18: text = "雾"; break; case 19: text = "冻雨"; break; case 20: text = "沙尘暴"; break; case 21: text = "小到中雨"; break; case 22: text = "中到大雨"; break; case 23: text = "大到暴雨"; break; case 24: text = "暴雨到大暴雨"; break; case 25: text = "大暴雨到特大暴雨"; break; case 26: text = "小到中雪"; break; case 27: text = "中到大雪"; break; case 28: text = "大到暴雪"; break; case 29: text = "浮尘"; break; case 30: text = "扬沙"; break; case 31: text = "强沙尘暴"; break; case 53: text = "霾"; break; case 99: text = "无"; break; case 32: text = "浓雾"; break; case 49: text = "强浓雾"; break; case 54: text = "中度霾"; break; case 55: text = "重度霾"; break; case 56: text = "严重霾"; break; case 57: text = "大雾"; break; case 58: text = "特强浓雾"; break; case 301: text = "雨"; break; case 302: text = "雪"; break; default: text = "晴"; break; } return text; } function getImgByWeatherCode(code) { var imgUrl = ''; switch (code) { case 0: imgUrl = '/weather/ico/00.png'; break; case 1: imgUrl = '/weather/ico/01.png'; break; case 2: imgUrl = '/weather/ico/02.png'; break; case 3: imgUrl = '/weather/ico/03.png'; break; case 4: imgUrl = '/weather/ico/04.png'; break; case 5: imgUrl = '/weather/ico/05.png'; break; case 6: imgUrl = '/weather/ico/06.png'; break; case 7: imgUrl = '/weather/ico/07.png'; break; case 8: imgUrl = '/weather/ico/08.png'; break; case 9: imgUrl = '/weather/ico/09.png'; break; case 10: imgUrl = '/weather/ico/10.png'; break; case 11: imgUrl = '/weather/ico/11.png'; break; case 12: imgUrl = '/weather/ico/12.png'; break; case 13: imgUrl = '/weather/ico/13.png'; break; case 14: imgUrl = '/weather/ico/14.png'; break; case 15: imgUrl = '/weather/ico/15.png'; break; case 16: imgUrl = '/weather/ico/16.png'; break; case 17: imgUrl = '/weather/ico/17.png'; break; case 18: imgUrl = '/weather/ico/18.png'; break; case 19: imgUrl = '/weather/ico/19.png'; break; case 20: imgUrl = '/weather/ico/20.png'; break; case 21: imgUrl = '/weather/ico/21.png'; break; case 22: imgUrl = '/weather/ico/22.png'; break; case 23: imgUrl = '/weather/ico/23.png'; break; case 24: imgUrl = '/weather/ico/24.png'; break; case 25: imgUrl = '/weather/ico/25.png'; break; case 26: imgUrl = '/weather/ico/26.png'; break; case 27: imgUrl = '/weather/ico/27.png'; break; case 28: imgUrl = '/weather/ico/28.png'; break; case 29: imgUrl = '/weather/ico/29.png'; break; case 30: imgUrl = '/weather/ico/30.png'; break; case 31: imgUrl = '/weather/ico/31.png'; break; case 53: imgUrl = '/weather/ico/53.png'; break; case 99: imgUrl = '/weather/ico/99.png'; break; case 32: imgUrl = '/weather/ico/32.png'; break; case 49: imgUrl = '/weather/ico/49.png'; break; case 54: imgUrl = '/weather/ico/54.png'; break; case 55: imgUrl = '/weather/ico/55.png'; break; case 56: imgUrl = '/weather/ico/56.png'; break; case 57: imgUrl = '/weather/ico/57.png'; break; case 58: imgUrl = '/weather/ico/58.png'; break; case 301: imgUrl = '/weather/ico/301.png'; break; case 302: imgUrl = '/weather/ico/302.png'; break; default: imgUrl = '/weather/ico/00.png'; break; } return imgUrl; } /** * 将 div 导出成 * 图片 */ function exportDivToImg() { } /** * 例子 dateFormat("YYYY-mm-dd HH:MM", date) * @param fmt * @param date * @returns {*} */ function dateFormat(fmt, date) { var ret; var opt = { 'Y+': date.getFullYear().toString(), // 年 'm+': (date.getMonth() + 1).toString(), // 月 'd+': date.getDate().toString(), // 日 'H+': date.getHours().toString(), // 时 'M+': date.getMinutes().toString(), // 分 'S+': date.getSeconds().toString() // 秒 // 有其他格式化字符需求可以继续添加,必须转化成字符串 }; for (var k in opt) { ret = new RegExp('(' + k + ')').exec(fmt); if (ret) { fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0'))); } ; } ; return fmt; } /** * 获取 相隔 月份 *
* getIntervalMonthStr('yyyyMM',new Date('2019-06'),12) * 返回 201807 (2019年6月 往前推 12 个月,包含 2019年6月) ** @param date {Date} 默认为当前日期。 * @param fmt {string} 默认为 yyyyMM * @param interval {number} 默认为 12 */ function get_interval_month_str(date, fmt, interval) { fmt = fmt || 'yyyyMM'; date = date || new Date(); var temp = new Date(date.getTime()); interval = interval || 12; while (interval-- > 0) { temp.setMonth(temp.getMonth() - 1); } return dateFormat(fmt, temp); } /** * 获取 相隔 天 * @param date * @param fmt * @param interval 1 获取昨天 ,2 获取前天,以此类推 * @returns {string} */ function get_interval_day_str(date, fmt, interval) { fmt = fmt || 'yyyyMM'; date = date || new Date(); var temp = new Date(date.getTime()); interval = interval == null ? 1 : interval; while (interval-- >= 1) { temp.setTime(temp.getTime() - 86400000); } return dateFormat(fmt, temp); } /** * 禁止 输入字符 * @param t */ function disallow_input(t) { t.value = ''; } function wrap_line(params, characterSize) { characterSize = characterSize || 3; var ifCut = false; if (params.length > 9) { params = params.substring(0, 8); ifCut = true; } var newParamsName = '';// 最终拼接成的字符串 var paramsNameNumber = params.length;// 实际标签的个数 var provideNumber = characterSize;// 每行能显示的字的个数 if (paramsNameNumber == 4) provideNumber = 2; var rowNumber = Math.ceil(paramsNameNumber / provideNumber);// 换行的话,需要显示几行,向上取整 /** * 判断标签的个数是否大于规定的个数, 如果大于,则进行换行处理 如果不大于,即等于或小于,就返回原标签 */ // 条件等同于rowNumber>1 if (paramsNameNumber > provideNumber) { /** 循环每一行,p表示行 */ for (var p = 0; p < rowNumber; p++) { var tempStr = '';// 表示每一次截取的字符串 var start = p * provideNumber;// 开始截取的位置 var end = start + provideNumber;// 结束截取的位置 // 此处特殊处理最后一行的索引值 if (p == rowNumber - 1) { // 最后一次不换行 tempStr = params.substring(start, paramsNameNumber); } else { // 每一次拼接字符串并换行 tempStr = params.substring(start, end) + '\n'; } newParamsName += tempStr;// 最终拼成的字符串 } } else { // 将旧标签的值赋给新标签 newParamsName = params; } //将最终的字符串返回 return ifCut ? (newParamsName + '...') : newParamsName; } function getNowFormatDate(days) { days = days || 0; var date = new Date(new Date().getTime() + 60 * 60 * 1000 * 24 * days); var seperator1 = '-'; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = '0' + month; } if (strDate >= 0 && strDate <= 9) { strDate = '0' + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; } function prefix_wrap_zero(num) { return num < 10 ? ('0' + num) : num; } /** * 求和 */ function add() { var total = 0; for (var i = 0; i < arguments.length; i++) { var j = arguments[i]; if (j == null) { j = 0; } total += j; } return total; } function cjy_percent(v1, v2, precision) { var num = v1 / v2 * 100; precision = precision || 2; return num.toFixed(precision); } function div(v1, v2, precision) { var out = ((v1 / v2) * 100).toFixed(2); return out; } /** * 获取 url 参数 * @param variable * @returns {string|null} */ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split('='); if (pair[0] == variable) { return pair[1]; } } return null; } /** * 向后补 0 , 返回补 0 后字符串 * @param num * @param n * @returns {string} */ function padR(num, n) { var len = num.toString().length; while (len < n) { num = num + '0'; len++; } return num; } /** * 渲染 进度条, 仅有 文旅厅 新 ui (v2) 页面可用 */ function renderProgressBar() { /* ======================================================================== 进度条 * ======================================================================== */ // 进度条 函数 $.fn.progressLoad = function () { $this = $(this); $this.each(function () { var _percent = $(this).data('percent') + '%'; $(this).children('[data-progress="text"]').text(_percent); $(this).animate({ width: _percent, }, 200); }); }; // 进度条 函数调用 // =============== $('[data-progress="bar"]').progressLoad(); }