//import { setInterval } from "timers";

//获取最大值
function getMax(){
var max = arguments[0];
for(var i=0;i<arguments.length;i++){
if(max<=arguments[i]){
max=arguments[i]
}
}
return max;
}
//
//获取最小值
function getMin(){
var min =arguments[0];
for(var i=0;i<arguments.length;i++){
if(min>=arguments[i]){
min=arguments[i]
}
}
return min;
} //随机数 n小于m
function random1Num(n,m){
return parseInt(n+Math.random()*(m-n+1));
} //打乱随机排序 function random1Number(arr){
arr.sort(function(){
return 0.5-Math.random();
}) return arr;
} //返回最大值 传入的参数是数组
function getMax(arr){
var max = arr[0];
for(var i=0;i<arr.length;i++){
if(max<arr[i]){
max=arr[i]
}
}
return max;
} //返回最小值 传入的参数是数组
function getMin(arr){
var min = arr[0];
for(var i=0;i<arr.length;i++){
if(min>arr[i]){
min=arr[i]
}
}
return min;
} //返回最大值的下标 传入的是数组
function getMaxIndex(arr){
var max = arr[0];
var index;
for(var i=0;i<arr.length;i++){
if(max<arr[i]){
max=arr[i]
index=i;
}
}
return index;
} //返回最小下标 传入的是数组
function getMinIndex(arr){
var min = arr[arr.length-1];
var index=arr.length-1;
for(var i=0;i<arr.length;i++){
if(min>arr[i]){
min=arr[i];
index=i;
}
}
return index;
} //冒泡排序 传入的是数组
function bubbling(arr){
var temp;
for(var i=0;i<arr.length-1;i++){
for(var j=0;j<arr.length-1-i;j++){
if(arr[j]>arr[j+1]){
temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp; }
}
}
return arr;
} //选择排序 传入的是数组
function selectSort(arr){
var temp;
for(var i=0;i<arr.length-1;i++){
for(var j=i+1;j<arr.length;j++){
if(arr[i]>arr[j]){0
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}
//数组判断是否有某个值
//传入的值是一个数组 n是一个字符
function has(arr,n){
for(var i in arr){
if(arr[i]===n){
return true;
}
}
return false;
} //数组去重
function norepeat(arr){
var newArr = [];
for(var i in arr){
if(!has(newArr,arr[i])){
newArr.push(arr[i])
}
}
return newArr;
} //数组插入 按照原来顺序排序
function sort1Arr(arr,n){
for(var i=0;i<arr.length;i++){
if(arr[arr.length-1]<n){
arr.push(n);
}else if(arr[i]>n){
arr.splice(i,0,n);
break;
}
}
return arr
}
//验证码 6位数的验证码
function authCode(){
var str = '';
while(str.length<6){
var num = random1Num(48,122) if((num>57&&num<65)||(num>90&&num<97)){
num = random1Num(48,122)
}else{
str+=''+String.fromCharCode(num)
} }
return str
} //随机颜色
function randomColor(){
var R = random1Num(0,255)
var G = random1Num(0,255)
var B = random1Num(0,255)
return "#"+string2Num(R,G,B)
}
//转换为16进制不足补0
function string2Num(r,g,b){
r = r.toString(16).length<2?"0"+r.toString(16):r.toString(16);
g = g.toString(16).length<2?"0"+g.toString(16):g.toString(16);
b = b.toString(16).length<2?"0"+b.toString(16):b.toString(16);
return r+g+b;
}
//当前时间
function getdate(sign){
var date = new Date();
var time = (date.getFullYear()+"") +sign+ ((String(date.getMonth()+1)).length<2?("0"+String(date.getMonth()+1)):(String(date.getMonth()+1))) +sign+ ((String(date.getDate())).length<2?("0"+String(date.getDate())):(String(date.getDate())))
return time;
} //将时间对象转换成字符串
function date2String(d,sign){
if(sign==undefined){
sign="/"
} return d.getFullYear()+sign+addzero((d.getMonth()+1))+sign+addzero(d.getDate())+" "+addzero(d.getHours())+":"+addzero(d.getMinutes())+":"+addzero(d.getSeconds());
}
//当数字不足两位的时候补0 应用于时间对象
function addzero(num){
var str = ""+num;
return str.length<2?"0"+str:str;
}
//获取id元素
function $(id){
var id = id.slice(1,id.length)
return document.getElementById(id)
}
//获取非行间样式
//ele:对象
//attr:属性
function getStyle(ele,attr){
if(ele.currentStyle){
return ele.currentStyle[attr];
}else{
return getComputedStyle(ele,false)[attr]
}
}
//隐藏
function hide(ele){
ele.style.display="none";
}
//显示
function show(ele){
ele.style.display="block";
}
//获取设置自定义属性
function attr(ele,type,val){
if(arguments.length<2){return}; if(arguments.length==2){
return ele.getAttribute(type);
} ele.setAttribute(type,val);
}
//获取到前一个兄弟节点(元素)
function prevChild(ele) {
return ele.previousElementSibling;
}
//获取当前元素距离页面的距离
function offset(ele){
var obj = {};
obj.l = ele.offsetLeft;
obj.t = ele.offsetTop; while(ele.offsetParent){
var ele = ele.offsetParent;
obj.l+=ele.offsetLeft;
obj.t+=ele.offsetTop;
}
return obj;
} //阻止浏览器默认行为
function prevent(e){
e.preventDefault?e.preventDefault():e.returnValue = false;
} //事件监听
//第一次参数:对象
//第二个参数:事件类型
//第三个参数:回调函数
//第四个参数:是否捕获
function attach(ele,type,fn,bool){
if(!bool){
bool=false;
}
if(ele.addEventListener){
ele.addEventListener(type,fn,bool)
}else{
ele.attachEvent("on"+type,fn)
}
} //阻止事件冒泡
function cancel(e){
e.stopPropagetion?e.stopPropagetion():e.cancelBubble = true;
} //判断是否是闰年
function leap(year){
return (year%4==0)&&(year%100!=0||year%400==0)
} //设置cookie
function setCookie(_name,_val,expires){
var d = new Date();
d.setDate(d.getDate()+expires);
document.cookie = _name+"="+_val+";expires="+d;
} //获取cookie
function getCookie(_name){
var cookie = document.cookie;
var arr = cookie.split("; ")
for(var i=0;i<arr.length;i++){
var newArr = arr[i].split("=");
if(newArr[0]==_name){
return newArr[1];
}
}
} //删除cookie
function removeCookie(_name,_val){
setCookie(_name,_val,-1)
}
//获取className 无兼容性问题
//父级元素
//class类名
function getClassName(parent,aClass){
//获取到父元素底下所有的子元素
var aEle = parent.getElementsByTagName('*');
var arr = [];
//匹配传进来的这个字符是不是一个边界符
var reg = new RegExp('\\b'+aClass+'\\b');
for(var i=0;i<aEle.length;i++){
if(reg.test(aEle[i].className)){
arr.push(aEle[i])
}
}
return arr;
} //运动框架
function move(obj,json,fn){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var bStop = true;
for(var attr in json){
var iCur = 0;
if(attr=='opacity'){
iCur = parseInt(parseFloat(getStyle(obj,attr))*100)
}else{
iCur = parseInt(getStyle(obj,attr))
} if(iCur!=json[attr]){
bStop=false;
} var speed = (json[attr]-iCur)/8;
speed = speed>0?Math.ceil(speed):Math.floor(speed); if(attr=='opacity'){
obj.style.opacity = (iCur+speed)/100;
obj.style.filter = 'alpha(opacity:'+(iCur+speed)+')'
}else{
obj.style[attr]=iCur+speed+'px';
}
} if(bStop){
clearInterval(obj.timer);
if(fn){
fn();
}
}
},30)
}
//获取url参数
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return null; //返回参数值
}
//初始化倒计时
function counttime(){
const timeCount = 60;
this.count = timeCount;
this.timer = setInterval(function(){
if(this.count > 0 && this.count <=timeCount){
this.count--
} else {
clearInterval(this.timer)
this.timer = null
}
},1000)
}
//适应移动端的viewport自适应
//<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
//<meta name="format-detection" content="telephone=no">
//uc强制竖屏
//<meta name="screen-orientation" content="portrait">
//qq强制竖屏
//<meta name="x5-orientation" content="portrait">
//uc强制全屏
//<meta name="full-screen" content="yes">
//qq强制全屏
//<meta name="x5-fullscreen" content="true">
//uc应用模式
//<meta name="browsermode" content="application">
//qq应用模式
//<meta name="x5-page-mode" content="app">
//金额千分位分割
function fenge(str){
return Number(str).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,") }
//获取前一周的日期
var date = new Date();
date.setDate(date.getDate()-7);
var oneweekdate = date.getFullYear() + "-" + addzero(date.getMonth()+1) + "-" + addzero(date.getDate()) //移动端添加固定的额高度
function scrollH(rem){
var el = document.getElementById("app");
var doc = document.documentElement;
el.style.height = (parseFloat(doc.clientHeight)) - (parseFloat(doc.style.fontSize)*parseFloat(rem)) + "px"
}
//永久本地存储
function save(key,value){
localStorage.setItem(key,JSON.stringify(value))
}
//获取永久本地存储
function fecth(key){
return JSON.parse(localStorage.getItem(value))
}
//ios自动聚焦
document.addEventListener('touchstart',function(e){
document.getElementById("ipt").focus();
})
//监听历史记录
pushHistory();
window.addEventListener("popstate",function(e){
window.location = "http://baibu.com"; },false);
function pushHistory(){
var state = {
title:'baidu',
url:""
};
window.history.pushState(state,"title","");
}
//jq插件
jQuery.fn.extend({
text:function(value){
return access(this,function(value){
return value ===undefined?
jQuery.text(this):
this.empty().each(function(){
if(this.nodeType === 1 || this.nodeType ===11 || this.nodeType===9){
this.textContent = value;
}
})
})
}
})
//金额千分位分割
function fenge(str){
str = Number(str).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,");
return str;
}
//金额输入正则表达式
function formNum(obj){
obj.value = obj.value.replace(/[^0-9.]+/,"");//清除number和’.‘以外的字符
obj.value = obj.value.replace(/^\./g,"");//第一个字符是数字
obj.value = obj.value.replace(/\.{2,}/g,"");//只保留第一个'.',清除多余的
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");//
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,"$1$2.$3")//只能输入两位小数
}
//判断是否是闰年
function pyear(year){
return (year%4 == 0) || (year%100!=0 && year%400==0)
}
//判断月份的天数
function mdays(year,mouth){
var days = 0;
if(mouth==1||mouth==3||mouth==5||mouth==7||mouth==8||mouth==10||mouth==12){
days=31;
}else if(mouth==6||mouth==4||mouth==9||mouth==11){
days=30;
}else if(mouth==2 && ((year%4 == 0) || (year%100!=0 && year%400==0))){
days=29;
}else if(mouth==2){
days=28;
}
return days;
}
//日期20180808=>2018-08-08
//vue filter.js
//export const formateDate = Vue.filter('formateDate',function(val){
// var year = val.substr(0,4)
// var month = val.substr(4,2)
// var day = val.substr(-2)
// return year + "-" + month + "-" +day
// }) //卡号四位加一空格
//export const formateaccoutNo = Vue.filter('formateaccoutNo',function(val){
// var accoutNo = '';
// for(var i=0;i<5;i++){
// accountNo = accoutNo + val.substr(i*4,4) + ''
// }
// return accoutNo
// }) //金额转成大写
function converChinese(money){
//汉字的数字
var cnNums = new Array('零','壹','貳','叁','肆','伍','陆','柒','捌','玖');
//基本单位
var cnIntRadice = new Array('','拾','佰','仟');
//对应整数部分扩展单位
var cnIntUnits = new Array('','万','亿','兆');
//对应小数部分单位
var cnDecUnits = new Array('角','分','毫','厘');
//整数金额时后面跟的单位
var cnInteger = "整";
//整型后的单位
var cnIntLast = '元';
//最大处理的数字
var maxNum = 9999999999999999.9999;
//金额整数部分
var integerNum;
//金额小数部分
var decimalNum;
//输出的中文金额字符串
var chineseStr = '';
//分离金额后用的数组,预定义
var parts;
if(money == ''){
return '';
}
money = parseFloat(money)
//超出最大处理数字
if(money >= maxNum){
return ''
}
if(money == 0){
chineseStr = cnNums[0] + cnIntLast + cnInteger;
return chineseStr;
}
//转换成字符串
money = money.toString();
if(money.indexOf('.') == -1){
integerNum = money;
decimalNum ='';
} else {
parts = money.split('.');
integerNum = parts[0];
decimalNum = parts[1].substr(0,4);
}
//获取整型部分转换
if(parseInt(integerNum,10) > 0){
var zeroCount = 0;
var IntLen = integerNum.length;
for(var i = 0;i < IntLen; i++){
var n = integerNum.substr(i,1);
var p = IntLen - i - 1;
var q = p/4;
var m = p%4;
if(n === '0'){
zeroCount++;
} else {
if(zeroCount > 0){
chineseStr += cnNums[0];
}
//归零
zeroCount = 0;
chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
}
if(m == 0 && zeroCount < 4){
chineseStr += cnIntUnits[q];
}
}
chineseStr += cnIntLast;
}
//小数部分
if(decimalNum != ''){
var decLen = decimalNum.length;
for(var i=0;i<decLen;i++){
var n = decimalNum.substr(i,1);
if(n !='0'){
chineseStr += cnNums[Number(n)] + cnDecUnits[i]
}
}
}
if(chineseStr == ''){
chineseStr += cnNums[0] + cnIntLast + cnInteger;
}else if(decimalNum == ''){
chineseStr += cnInteger;
}
return chineseStr;
} //初始化短信倒计时
function getCodel(){
const timeCount = 60;
var count = timeCount;
var self = this;
this.timer = setInterval(function(){
if(self.count > 0 && self.count <= timeCount){
self.count --;
} else {
self.show = true;
clearInterval(self.timer)
self.timer = null
}
},1000) }
//首字母大写过滤器
// filters: {
// capitalize: function (value) {
// if (!value) return ''
// value = value.toString()
// return value.charAt(0).toUpperCase() + value.slice(1)
// }
//ie9 placeholder模拟
function ifie9(){
//判断是否是ie9
if(navigator.userAgent.indexOf("MSIE 9.0")>0){
//input元素
$(".ipt").each(function(){
var self = $(this);
self.parent().append('<span class="placeholder" data-type = "placeholder"></span>')
if(self.val() != ''){
self.parent().find("span.placeholder").hide()
}else{
self.parent().find("span.placeholder").show()
}
}).on('foucs',function(){
$(this).parent().find("span.placeholder").hide()
}).on('blur',function(){
var self = $(this);
if(self.val != ''){
self.parent().find("span.placeholder").hide()
}else{
self.parent().find("span.placeholder").show()
}
});
$("span.placeholder").on('clock',function(){
$(this).hide()
})
}
}
//滚动条
$(document).ready(function() {
$(window).scroll(function() {
//$(document).scrollTop() 获取垂直滚动的距离
//$(document).scrollLeft() 这是获取水平滚动条的距离
if ($(document).scrollTop() <= 0) {
alert("滚动条已经到达顶部为0");
} if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
alert("滚动条已经到达底部为" + $(document).scrollTop());
}
});
}); //有就删除,没有就添加
$(".bo").toggleClass('box') //保留两位小数,非四舍五入 function cuntnum(num){
if(num.toString().indexOf(".") > -1){
var c = num.toString().indexOf(".")
var d = num.toString().substr(c+1,2)
var e = num.toString().substring(0,c+1)
return e+d
}else if(num.toString().indexOf(".") == -1){
return num
}
}
//import { setInterval } from "timers";
//获取最大值
function getMax(){
    var max = arguments[];
    for(var i=;i<arguments.length;i++){
        if(max<=arguments[i]){
            max=arguments[i]
        }
    }
    return max;
}
//
//获取最小值
function getMin(){
    var min =arguments[];
    for(var i=;i<arguments.length;i++){
        if(min>=arguments[i]){
            min=arguments[i]
        }
    }
    return min;
}
//随机数 n小于m
function random1Num(n,m){
    return parseInt(n+Math.random()*(m-n+));
}
//打乱随机排序
function random1Number(arr){
    arr.sort(function(){
        return 0.5-Math.random();
    })
    return arr;
}
//返回最大值 传入的参数是数组
function getMax(arr){
    var max = arr[];
    for(var i=;i<arr.length;i++){
        if(max<arr[i]){
            max=arr[i]
        }
    }
    return max;
}
//返回最小值 传入的参数是数组
function getMin(arr){
    var min = arr[];
    for(var i=;i<arr.length;i++){
        if(min>arr[i]){
            min=arr[i]
        }
    }
    return min;
}
//返回最大值的下标 传入的是数组
function getMaxIndex(arr){
    var max = arr[];
    var index;
    for(var i=;i<arr.length;i++){
        if(max<arr[i]){
            max=arr[i]
            index=i;
        }
    }
    return index;
}
//返回最小下标 传入的是数组
function getMinIndex(arr){
    var min = arr[arr.length-];
    var index=arr.length-;
    for(var i=;i<arr.length;i++){
        if(min>arr[i]){
            min=arr[i];
            index=i;
        }
    }
    return index;
}
//冒泡排序 传入的是数组
function bubbling(arr){
    var temp;
    for(var i=;i<arr.length-;i++){
        for(var j=;j<arr.length--i;j++){
            if(arr[j]>arr[j+]){
                temp = arr[j];
                arr[j]=arr[j+];
                arr[j+]=temp;
            }
        }
    }
    return arr;
}
//选择排序 传入的是数组
function selectSort(arr){
    var temp;
    for(var i=;i<arr.length-;i++){
        for(var j=i+;j<arr.length;j++){
            if(arr[i]>arr[j]){
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }
    return arr;
}
//数组判断是否有某个值
//传入的值是一个数组 n是一个字符
function has(arr,n){
    for(var i in arr){
        if(arr[i]===n){
            return true;
        }
    }
    return false;
}
//数组去重
function norepeat(arr){
    var newArr = [];
    for(var i in arr){
        if(!has(newArr,arr[i])){
            newArr.push(arr[i])
        }
    }
    return newArr;
}
//数组插入 按照原来顺序排序
function sort1Arr(arr,n){           
    for(var i=;i<arr.length;i++){
        if(arr[arr.length-]<n){
        arr.push(n);
        }else if(arr[i]>n){
        arr.splice(i,,n);
        break;
        }
        }
    return arr  
}
//验证码 6位数的验证码
function authCode(){
    var str = '';
    while(str.length<){
        var num = random1Num(,)
    
        if((num>&&num<)||(num>&&num<)){
            num = random1Num(,)
        }else{
            str+=''+String.fromCharCode(num)
        }
        
    }
    return str
}
//随机颜色
function randomColor(){
    var R = random1Num(,)
    var G = random1Num(,)
    var B = random1Num(,)
    return "#"+string2Num(R,G,B)
}
//转换为16进制不足补0
function string2Num(r,g,b){
    r = r.toString().length<?"0"+r.toString():r.toString();
    g = g.toString().length<?"0"+g.toString():g.toString();
    b = b.toString().length<?"0"+b.toString():b.toString();
    return r+g+b;
}
//当前时间
function getdate(sign){
    var date = new Date();
    var time = (date.getFullYear()+"") +sign+ ((String(date.getMonth()+)).length<?("0"+String(date.getMonth()+)):(String(date.getMonth()+))) +sign+ ((String(date.getDate())).length<?("0"+String(date.getDate())):(String(date.getDate())))
    return time;
}
//将时间对象转换成字符串
function date2String(d,sign){
    if(sign==undefined){
        sign="/"
    }
    return d.getFullYear()+sign+addzero((d.getMonth()+))+sign+addzero(d.getDate())+" "+addzero(d.getHours())+":"+addzero(d.getMinutes())+":"+addzero(d.getSeconds());
}
//当数字不足两位的时候补0 应用于时间对象
function addzero(num){
    var str = ""+num;
    return str.length<?"0"+str:str;
}
//获取id元素
function $(id){
    var id = id.slice(,id.length)
return document.getElementById(id)
}
//获取非行间样式
//ele:对象
//attr:属性
function getStyle(ele,attr){
    if(ele.currentStyle){
        return ele.currentStyle[attr];
    }else{
        return getComputedStyle(ele,false)[attr]
    }
}
//隐藏
function hide(ele){
    ele.style.display="none";
}
//显示
function show(ele){
    ele.style.display="block";
}
//获取设置自定义属性
function attr(ele,type,val){
    if(arguments.length<){return};
    if(arguments.length==){
        return ele.getAttribute(type);
    }
    ele.setAttribute(type,val);
}
//获取到前一个兄弟节点(元素)
function prevChild(ele) {
     return ele.previousElementSibling;
}
//获取当前元素距离页面的距离
function offset(ele){
    var obj = {};
    obj.l = ele.offsetLeft;
    obj.t = ele.offsetTop;
    while(ele.offsetParent){
        var ele = ele.offsetParent;
        obj.l+=ele.offsetLeft;
        obj.t+=ele.offsetTop;
    }
    return obj;
}
//阻止浏览器默认行为
function prevent(e){
    e.preventDefault?e.preventDefault():e.returnValue = false;
}
//事件监听
//第一次参数:对象
//第二个参数:事件类型
//第三个参数:回调函数
//第四个参数:是否捕获
function attach(ele,type,fn,bool){
    if(!bool){
        bool=false;
    }
    if(ele.addEventListener){
        ele.addEventListener(type,fn,bool)
    }else{
        ele.attachEvent("on"+type,fn)
    }
}
//阻止事件冒泡
function cancel(e){
    e.stopPropagetion?e.stopPropagetion():e.cancelBubble = true;
}
//判断是否是闰年
function leap(year){
    return (year%==)&&(year%!=||year%==)
}
//设置cookie
function setCookie(_name,_val,expires){
    var d = new Date();
    d.setDate(d.getDate()+expires);
    document.cookie = _name+"="+_val+";expires="+d;
}
//获取cookie
function getCookie(_name){
    var cookie = document.cookie;
    var arr = cookie.split("; ")
    for(var i=;i<arr.length;i++){
        var newArr = arr[i].split("=");
        if(newArr[]==_name){
            return newArr[];
        }
    }
}
//删除cookie
function removeCookie(_name,_val){
    setCookie(_name,_val,-)
}
//获取className 无兼容性问题
//父级元素
//class类名
function getClassName(parent,aClass){
    //获取到父元素底下所有的子元素
    var aEle = parent.getElementsByTagName('*');
    var arr = [];
    //匹配传进来的这个字符是不是一个边界符
    var reg = new RegExp('\\b'+aClass+'\\b');
    for(var i=;i<aEle.length;i++){
        if(reg.test(aEle[i].className)){
            arr.push(aEle[i])
        }
    }
    return arr;
}
//运动框架
function move(obj,json,fn){
    clearInterval(obj.timer);
    obj.timer = setInterval(function(){
        var bStop = true;
        for(var attr in json){
            var iCur = ;
            if(attr=='opacity'){
                iCur = parseInt(parseFloat(getStyle(obj,attr))*)
            }else{
                iCur = parseInt(getStyle(obj,attr))
            }
            if(iCur!=json[attr]){
                bStop=false;
            }
            var speed = (json[attr]-iCur)/;
            speed = speed>?Math.ceil(speed):Math.floor(speed);
            
            if(attr=='opacity'){
                obj.style.opacity = (iCur+speed)/;
                obj.style.filter = 'alpha(opacity:'+(iCur+speed)+')'
            }else{
                obj.style[attr]=iCur+speed+'px';
            }
        }
        if(bStop){
            clearInterval(obj.timer);
            if(fn){
                fn();
            }
        }
    },)
}
//获取url参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr().match(reg); //匹配目标参数
    if (r != null) return unescape(r[]); return null; //返回参数值
}
//初始化倒计时
function counttime(){
    const timeCount = ;
    this.count = timeCount;
    this.timer = setInterval(function(){
        if(this.count > && this.count <=timeCount){
            this.count--
        } else {
            clearInterval(this.timer)
            this.timer = null
        }
    },)
}
//适应移动端的viewport自适应
//<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
//<meta name="format-detection" content="telephone=no">
//uc强制竖屏
//<meta name="screen-orientation" content="portrait">
//qq强制竖屏
//<meta name="x5-orientation" content="portrait">
//uc强制全屏
//<meta name="full-screen" content="yes">
//qq强制全屏
//<meta name="x5-fullscreen" content="true">
//uc应用模式
//<meta name="browsermode" content="application">
//qq应用模式
//<meta name="x5-page-mode" content="app">
//金额千分位分割
function fenge(str){
    return Number(str).toFixed().replace(/(\d)(?=(\d{3})+\.)/g,"$1,")
    
}
//获取前一周的日期
var date = new Date();
date.setDate(date.getDate()-);
var oneweekdate = date.getFullYear() + "-" + addzero(date.getMonth()+) + "-" + addzero(date.getDate())
//移动端添加固定的额高度
function scrollH(rem){
    var el = document.getElementById("app");
    var doc = document.documentElement;
    el.style.height = (parseFloat(doc.clientHeight)) - (parseFloat(doc.style.fontSize)*parseFloat(rem)) + "px"
}
//永久本地存储
function save(key,value){
    localStorage.setItem(key,JSON.stringify(value))
}
//获取永久本地存储
function fecth(key){
    return JSON.parse(localStorage.getItem(value))
}
//ios自动聚焦
document.addEventListener('touchstart',function(e){
    document.getElementById("ipt").focus();
})
//监听历史记录
pushHistory();
window.addEventListener("popstate",function(e){
window.location = "http://baibu.com";
},false);
function pushHistory(){
var state = {
    title:'baidu',
    url:""
};
window.history.pushState(state,"title","");
}
//jq插件
jQuery.fn.extend({
    text:function(value){
        return access(this,function(value){
            return value ===undefined?
            jQuery.text(this):
            this.empty().each(function(){
                if(this.nodeType === || this.nodeType === || this.nodeType===){
                    this.textContent = value;
                }
            })
        })
    }
})
//金额千分位分割
function fenge(str){
    str = Number(str).toFixed().replace(/(\d)(?=(\d{3})+\.)/g,"$1,");
    return str;
}
//金额输入正则表达式
function formNum(obj){
    obj.value = obj.value.replace(/[^0-9.]+/,"");//清除number和’.‘以外的字符
    obj.value = obj.value.replace(/^\./g,"");//第一个字符是数字
    obj.value = obj.value.replace(/\.{2,}/g,"");//只保留第一个'.',清除多余的
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");//
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,"$1$2.$3")//只能输入两位小数
}
//判断是否是闰年
function pyear(year){
    return (year% == ) || (year%!= && year%==)
}
//判断月份的天数
function mdays(year,mouth){
    var days = ;
    if(mouth==||mouth==||mouth==||mouth==||mouth==||mouth==||mouth==){
        days=;
    }else if(mouth==||mouth==||mouth==||mouth==){
        days=;
    }else if(mouth== && ((year% == ) || (year%!= && year%==))){
        days=;
    }else if(mouth==){
        days=;
    }
    return days;
}
//日期20180808=>2018-08-08
//vue filter.js
//export const formateDate = Vue.filter('formateDate',function(val){
//  var year = val.substr(0,4)
//  var month = val.substr(4,2)
//  var day = val.substr(-2)
//  return year + "-" + month + "-" +day
// })
//卡号四位加一空格
//export const formateaccoutNo = Vue.filter('formateaccoutNo',function(val){
//  var accoutNo = '';
//  for(var i=0;i<5;i++){
//      accountNo = accoutNo + val.substr(i*4,4) + ''
//  }
//  return accoutNo
// })
//金额转成大写
function converChinese(money){
    //汉字的数字
    var cnNums = new Array('零','壹','貳','叁','肆','伍','陆','柒','捌','玖');
    //基本单位
    var cnIntRadice = new Array('','拾','佰','仟');
    //对应整数部分扩展单位
    var cnIntUnits = new Array('','万','亿','兆');
    //对应小数部分单位
    var cnDecUnits = new Array('角','分','毫','厘');
    //整数金额时后面跟的单位
    var cnInteger = "整";
    //整型后的单位
    var cnIntLast = '元';
    //最大处理的数字
    var maxNum = 9999999999999999.9999;
    //金额整数部分
    var integerNum;
    //金额小数部分
    var decimalNum;
    //输出的中文金额字符串
    var chineseStr = '';
    //分离金额后用的数组,预定义
    var parts;
    if(money == ''){
        return '';
    }
    money = parseFloat(money)
    //超出最大处理数字
    if(money >= maxNum){
        return ''
    }
    if(money == ){
        chineseStr = cnNums[] + cnIntLast + cnInteger;
        return chineseStr;
    }
    //转换成字符串
    money = money.toString();
    if(money.indexOf('.') == -){
        integerNum = money;
        decimalNum ='';
    } else {
        parts = money.split('.');
        integerNum = parts[];
        decimalNum = parts[].substr(,);
    }
    //获取整型部分转换
    if(parseInt(integerNum,) > ){
        var zeroCount = ;
        var IntLen = integerNum.length;
        for(var i = ;i < IntLen; i++){
            var n = integerNum.substr(i,);
            var p = IntLen - i - ;
            var q = p/;
            var m = p%;
            if(n === '0'){
                zeroCount++;
            } else {
                if(zeroCount > ){
                    chineseStr += cnNums[];
                }
                //归零
                zeroCount = ;
                chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
            }
            if(m == && zeroCount < ){
                chineseStr += cnIntUnits[q];
            }
        }
        chineseStr += cnIntLast;
    }
    //小数部分
    if(decimalNum != ''){
        var decLen = decimalNum.length;
        for(var i=;i<decLen;i++){
            var n = decimalNum.substr(i,);
            if(n !='0'){
                chineseStr += cnNums[Number(n)] + cnDecUnits[i]
            }
        }
    }
    if(chineseStr == ''){
        chineseStr += cnNums[] + cnIntLast + cnInteger;
    }else if(decimalNum == ''){
        chineseStr += cnInteger;
    }
    return chineseStr;
}
//初始化短信倒计时
function getCodel(){
    const timeCount = ;
    var count = timeCount;
    var self = this;
    this.timer = setInterval(function(){
        if(self.count > && self.count <= timeCount){
            self.count --;
        } else {
            self.show = true;
            clearInterval(self.timer)
            self.timer = null
        }
    },)
}
//首字母大写过滤器
// filters: {
// capitalize: function (value) {
// if (!value) return ''
// value = value.toString()
// return value.charAt(0).toUpperCase() + value.slice(1)
// }
//ie9 placeholder模拟
function ifie9(){
    //判断是否是ie9
    if(navigator.userAgent.indexOf("MSIE 9.0")>){
        //input元素
        $(".ipt").each(function(){
            var self = $(this);
            self.parent().append('<span class="placeholder" data-type = "placeholder"></span>')
            if(self.val() != ''){
                self.parent().find("span.placeholder").hide()
            }else{
                self.parent().find("span.placeholder").show()
            }
        }).on('foucs',function(){
            $(this).parent().find("span.placeholder").hide()
        }).on('blur',function(){
            var self = $(this);
            if(self.val != ''){
                self.parent().find("span.placeholder").hide()
            }else{
                self.parent().find("span.placeholder").show()
            }
        });
        $("span.placeholder").on('clock',function(){
            $(this).hide()
        })
    }
}
//滚动条
$(document).ready(function() {
    $(window).scroll(function() {
        //$(document).scrollTop() 获取垂直滚动的距离
        //$(document).scrollLeft() 这是获取水平滚动条的距离
        if ($(document).scrollTop() <= ) {
            alert("滚动条已经到达顶部为0");
        }
        if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
            alert("滚动条已经到达底部为" + $(document).scrollTop());
        }
    });
});
//有就删除,没有就添加
$(".bo").toggleClass('box')
//保留两位小数,非四舍五入改进版
function tofixedTwo(num){
    var bb = num+"";
    var dian = bb.indexOf('.');
    var result = "";
    if(dian == -1){
        result = num.toFixed(2);
    }else{
        var cc = bb.substr(dian+1,2);
        var dd = bb.substring(0,dian+1);
        if(cc.length < 2){
            result = dd + cc + "0";
        }else{
            result = dd + cc;
        }
    }
    return result
}
// encodeURI 加密和解密
var url = encodeURIComponent("https://www.baidu.com?a='王武杰'")
console.log(url,decodeURIComponent(url))
// 点击除了特定元素之外的元素
function other(obj,othobj){//要点击的元素和要去除的元素
    obj.click(function(event){
        var con = othobj
        if(!con.is(event.target) && con.has(event.target).length === 0){
            dosomething
        }
    })
}
if(!!document.all){
//ie浏览器处理,判断是否是ie
}
//跨域请求头设置
//后端设置请求头部Access-Control-Allow-Credentials: true和Access-Control-Allow-Origin: www.xxx.com
//前端post请求设置withCredentials=true
//淘宝镜像安装node
//npm install -g cnpm –registry=https://registry.npm.taobao.org
//浏览器回退返回按钮
var tempHash = window.location.hash;
if(window.history && window.history.pushState){
    window.addEventListener('popstate',function(){
        var hasLocation = location.hash;
        var hashSplit = hashLocation.split("#");
        var hashName = hashSplit[1];
        if(hashName != ''){
            var hash = window.location.hash;
            if(hash == tempHash){
                window.opener = null
                window.open("about:blank","_self","")
                window.close()
            }
        }
    });
    window.history.replaceState('forward',null,window.location.hash + '#forward');
    window.history.pushState('forward',null,tempHash);
    tempHash = window.location.hash;
}
window.history.forward(1);
//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
     history.pushState(null, null, document.URL);
});
//字符串动态创建dom
function parseDom(arg) {
       var objE = document.createElement("div");
       objE.innerHTML = arg;
       return objE.childNodes;
    };
    var obj=parseDom('<div id="div_1" class="div1">Hello World!</div>');
    //返回的obj是个数组
    console.log(obj[0])
    var box = document.getElementById("box")
    box.appendChild(obj[0])

最新文章

  1. 【Win10 应用开发】OCR识别
  2. 一个python的计算熵(entropy)的函数
  3. java selenium验证元素是否存在
  4. MQ安装配置
  5. 由简入繁实现Jquery树状结构
  6. 小甲鱼PE详解之区块表(节表)和区块(节)(PE详解04)
  7. geeksforgeeks@ Find sum of different corresponding bits for all pairs (Bit manipulation)
  8. SpringDataMongoDB介绍(一)-入门
  9. maven插件mybatis-generator生成代码配置
  10. MySQL外键约束OnDelete和OnUpdate的使用
  11. VS2015安装
  12. loadrunner常用计数器分析
  13. 【春华秋实】深入源码理解.NET Core中Startup的注册及运行
  14. C#学习-查询表达式
  15. python基础循环
  16. ubuntu 上 SSH scp 技巧
  17. bootstrap-海棠
  18. ajax 传递参数中文乱码解决办法
  19. hdu3518(后缀数组)
  20. ORA-04031: Unable To Allocate 32 Bytes Of Shared Memory

热门文章

  1. sysbench测试MySQL筛选tps
  2. OpenStack Weekly Rank 2015.07.27
  3. pacman usage
  4. hash冲突解决和javahash冲突解决
  5. 在Java中VO , PO , BO , QO, DAO ,POJO是什么意思
  6. [转]完美的背景图全屏css代码 – background-size:cover?
  7. 前端性能优化-Cookie
  8. mysql 使用 unix 方式显示日期和时间
  9. c# 截取picturebox部分图像
  10. [LeetCode]19. Remove Nth Node From End of List删除链表的倒数第N个节点