标签:str width 时间 ssl ack doc resize end 扩展
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数以及解析中文乱码问题
if (r != null) return decodeURI(r[2]); return null; //返回参数值
}
调用:getUrlParam(参数名称) 注意:参数名称是一个字符串
//封装ajax请求、
function ajax_datatypeByXml(type, url, Xml_data, func) {//data数据可以为空
$.ajax({
type: type,
url: url,
async: false,
dataType: "json",
timeout: 30000, //超时时间:30秒
data: Xml_data,
beforeSend: function () {
mui.showLoading("正在加载..", "div"); //加载文字和类型,plus环境中类型为div时强制以div方式显示
},
complete: function () {
mui.hideLoading(function () {
});//隐藏后的回调函数
},
success: function (data) {
if (data) {
func(data);
} else {
mui.alert("数据加载失败");
}
},
error: function() {
mui.alert(‘服务器连接超时,请稍后再试‘);
}
});
}
//扩展mui.showLoading
(function ($, window) {
//显示加载框
$.showLoading = function (message, type) {
if ($.os.plus && type !== ‘div‘) {
$.plusReady(function () {
plus.nativeUI.showWaiting(message);
});
} else {
var html = ‘‘;
html += ‘<i class="mui-spinner mui-spinner-white"></i>‘;
html += ‘<p class="text">‘ + (message || "数据加载中") + ‘</p>‘;
//遮罩层
var mask = document.getElementsByClassName("mui-show-loading-mask");
if (mask.length == 0) {
mask = document.createElement(‘div‘);
mask.classList.add("mui-show-loading-mask");
document.body.appendChild(mask);
mask.addEventListener("touchmove", function (e) { e.stopPropagation(); e.preventDefault(); });
} else {
mask[0].classList.remove("mui-show-loading-mask-hidden");
}
//加载框
var toast = document.getElementsByClassName("mui-show-loading");
if (toast.length == 0) {
toast = document.createElement(‘div‘);
toast.classList.add("mui-show-loading");
toast.classList.add(‘loading-visible‘);
document.body.appendChild(toast);
toast.innerHTML = html;
toast.addEventListener("touchmove", function (e) { e.stopPropagation(); e.preventDefault(); });
} else {
toast[0].innerHTML = html;
toast[0].classList.add("loading-visible");
}
}
};
//隐藏加载框
$.hideLoading = function (callback) {
if ($.os.plus) {
$.plusReady(function () {
plus.nativeUI.closeWaiting();
});
}
var mask = document.getElementsByClassName("mui-show-loading-mask");
var toast = document.getElementsByClassName("mui-show-loading");
if (mask.length > 0) {
mask[0].classList.add("mui-show-loading-mask-hidden");
}
if (toast.length > 0) {
toast[0].classList.remove("loading-visible");
callback && callback();
}
}
})(mui, window);
window.addEventListener("resize", setSize, false);
window.addEventListener("orientationchange", setSize, false);
function setSize() {
var oHtml = document.getElementsByTagName("html")[0];
var iWidth = oHtml.getBoundingClientRect().width;
$("html").css("fontSize", iWidth / 15)
}
function getDaysInMonth(year, month) {
month = parseInt(month, 10);
var temp = new Date(year, month, 0);
return temp.getDate();
}
标签:str width 时间 ssl ack doc resize end 扩展
原文地址:https://www.cnblogs.com/zhouxiaobai/p/9235362.html