分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

全局js

发布时间:2023-09-06 01:35责任编辑:熊小新关键词:js

//单位
(function(){
var iScale = 1;
iScale = iScale / window.devicePixelRatio;
document.write(‘<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=‘ + 1 + ‘,minimum-scale=‘ + 1 + ‘,maximum-scale=‘ + 1 + ‘">‘)
var iWidth = document.documentElement.clientWidth;
var iFontSize = iWidth/7.5;
document.getElementsByTagName("html")[0].style.fontSize=iFontSize+"px";
})();

var url = ‘http://www.10086jxt.com:8080/customermanager/‘;
// var url = ‘http://120.77.206.254:7788/wxm/‘;


// 验证手机号
function isPhoneNo(phone) {
var pattern = /^1[34578]\d{9}$/;
return pattern.test(phone);
}
// 非中文正则
var myReg= /^[0-9a-zA_Z]+$/;

function Appendzero (obj) {
???if (obj < 10) return "0" + obj; else return obj;
}
var date = new Date();
date.getFullYear(); ?// 获取完整的年份(4位,1970)
date.getMonth(); ?// 获取月份(0-11,0代表1月,用的时候记得加上1)
date.getDate(); ?// 获取日(1-31)
// date.getTime(); ?// 获取时间(从1970.1.1开始的毫秒数)
date.getHours(); ?// 获取小时数(0-23)
date.getMinutes(); ?// 获取分钟数(0-59)
date.getSeconds(); ?// 获取秒数(0-59)

var codeNum = Math.floor(Math.random()*9000)+1000; ?//序列号
var day = date.getDate();
var month = date.getMonth()+1;
//alert(date.getHours())
var hour = date.getHours();
var branc = date.getMinutes();
var sec = date.getSeconds();
var reqNo = date.getFullYear().toString()+Appendzero(month).toString()+Appendzero(day).toString()+Appendzero(hour).toString()+Appendzero(branc).toString()+Appendzero(sec).toString()+codeNum; ??

// 日期选择
var month = date.getMonth()+1;
if(month<10){
var months = "0"+month;
}else{
?var months = month;
}
if(date.getDate()<10){
?day = "0"+date.getDate();
}else{
?day = date.getDate();
}
var datew = date.getFullYear()+"-"+months+"-"+day;
// console.log(datew); ???//当前时间

// 相减时间
function addDate(date,days){
???var d=new Date(date);
???d.setDate(d.getDate()+days);
???var month=d.getMonth()+1;
???var day = d.getDate();
???if(month<10){
???month = "0"+month;
???}
???if(day<10){
???day = "0"+day;
???}
???var val = d.getFullYear()+"-"+month+"-"+day;
???return val;
}

//html获取url地址 ??转码
var isurl = decodeURIComponent(window.location.search);
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = isurl.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}

// 获取文档高度
function getDocumentTop() {
???var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
???if (document.body) {
???????bodyScrollTop = document.body.scrollTop;
???}
???if (document.documentElement) {
???????documentScrollTop = document.documentElement.scrollTop;
???}
???scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop; ???return scrollTop;
}
//可视窗口高度
function getWindowHeight() {
???var windowHeight = 0; ???if (document.compatMode == "CSS1Compat") {
???????windowHeight = document.documentElement.clientHeight;
???} else {
???????windowHeight = document.body.clientHeight;
???}
???return windowHeight;
}
//滚动条滚动高度
function getScrollHeight() {
???var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
???if (document.body) {
???????bodyScrollHeight = document.body.scrollHeight;
???}
???if (document.documentElement) {
???????documentScrollHeight = document.documentElement.scrollHeight;
???}
???scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight; ???return scrollHeight;
}
// 页面剩余高度
var webHeight = 2*getWindowHeight()-getScrollHeight();
var pageHeight = "500";

// window.onscroll = function () {
// ????//监听事件内容
// ????if(getScrollHeight() == getWindowHeight() + getDocumentTop()){
// ????if(length<10){
// ????return page
// ????}else{
// ????page++;
// ????request();
// ????}
// ????}
// }

// <div class="maskWrapBox"><span class="mask"></div></span>
// $(".mask").text("登录失败").show().fadeOut(4000);
function hintMask(code){
???if (code=="2") { ?
???????$(".mask").text("集团编号错误").show().fadeOut(4000);
???}
???else if (code=="1"){
???????$(".mask").text("登录过期,请重新登录").show().fadeOut(2000,function(){
????????????window.location.href=‘login.html‘;
???????});
???}
???else if (code=="3"){
???????$(".mask").text("企业不存在").show().fadeOut(4000);
???}
???else if (code=="4"){
???????$(".mask").text("用户不存在,请重新登录").show().fadeOut(4000);
???}
???else if (code=="5"){
???????$(".mask").text("手机号码错误").show().fadeOut(4000);
???}
???else if (code=="6"){
???????$(".mask").text("密码错误").show().fadeOut(4000);
???}
???else if (code=="7"){
???????$(".mask").text("短信验证码错误").show().fadeOut(4000);
???}
???else if (code=="8"){
???????$(".mask").text("集团编号或密码错误").show().fadeOut(4000);
???}
???else if (code=="9"){
???????$(".mask").text("无有效手机号码").show().fadeOut(4000);
???}
???else if (code=="10"){
???????$(".mask").text("彩信内容错误").show().fadeOut(4000);
???}
???else if (code=="11"){
???????$(".mask").text("短信内容为空").show().fadeOut(4000);
???}
???else if (code=="12"){
???????$(".mask").text("短信内容包含非法字符").show().fadeOut(4000);
???}
???else if (code=="13"){
???????$(".mask").text("短信流量不足").show().fadeOut(4000);
???}
???else if (code=="14"){
???????$(".mask").text("彩信流量不足").show().fadeOut(4000);
???}
???else if (code=="15"){
???????$(".mask").text("通讯录组不存在").show().fadeOut(4000);
???}
???else if (code=="16"){
???????$(".mask").text("通讯录组名称已存在").show().fadeOut(4000);
???}
???else if (code=="17"){
???????$(".mask").text("联系人不存在").show().fadeOut(4000);
???}
???else if (code=="18"){
???????$(".mask").text("手机号码已存在").show().fadeOut(4000);
???}
???else if (code=="19"){
???????$(".mask").text("未查询到数据").show().fadeOut(4000);
???}
???else if (code=="99"){
???????$(".mask").text("系统异常").show().fadeOut(4000);
???}
}

全局js

原文地址:https://www.cnblogs.com/weiwentaweb/p/8250717.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved