*****
```
window.onload = function() {
//版本 2018-09-19(有待完善)
//说明:全能api,包括:永久屏蔽、关键字、
var permanentShielding = false;//永久屏蔽功能开关
var keyWordSwitch = false;//关键字开关
var uuidSwitch = false;//唯一标识开关
var qqAddGroup = false;//启动QQ加群功能
var p = 'pc';
var isiOSMQ;
var isSafari;
var isSAMSUNG;
var isUC;
var type = 1;
var randomNum = null;
var qq_wait_time = null;
var seconds_on = null;
var arr = [];//新数据保存
var access_num = null;
var access_num_max = 5;//允许访问的最大次数
var failure = false;
var uuid = null;
var prohibitedTime = null;//禁止时间
var type_ = $('#type').attr('value');
if(window.location.pathname.split('/')[1] != '') {
var host = window.location.origin + '/' + window.location.pathname.split('/')[1] + '/';
} else {
var host = window.location.origin + '/';
}
function isPC() {
//使用用户代理信息判断
var info = navigator.userAgent.toLocaleLowerCase();
if(info.indexOf('mobile') != -1) {
return false;
} else {
return true;
}
}
function importJs(src) {
var hm = document.createElement("script");
hm.src = src;
var s = document.getElementsByTagName("body")[0];
s.parentNode.insertBefore(hm, s);
};
function loadjscssfile(filename,filetype){
if(filetype == "js"){
var fileref = document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src",filename);
}else if(filetype == "css"){
var fileref = document.createElement('link');
fileref.setAttribute("rel","stylesheet");
fileref.setAttribute("type","text/css");
fileref.setAttribute("href",filename);
}
if(typeof fileref != "undefined"){
document.getElementsByTagName("head")[0].appendChild(fileref);
}
}
function setLocation(){
access_num = parseInt(localStorage.getItem('access_num')?localStorage.getItem('access_num'):0);
if(overDay(prohibitedTime)){
failure = localStorage.getItem('failure')?localStorage.getItem('failure'):false;
if(failure == 'false'){
access_num = 0;
}
}else{
if(access_num>access_num_max){
failure = true;
localStorage.setItem('failure',failure);
var str = '<span class="release" style="width:20px;height:20px;position:fixed;top:0;left:0;"></span>';
document.body.innerHTML += str;
var release = document.getElementsByClassName('release')[0];
isPC();
function isPC(){
var info = navigator.userAgent.toLocaleLowerCase();
if(info.indexOf('mobile') != -1){
release.onclick = function(){
access_num = 0;
failure = false;
window.location.href = window.location.href;
}
}else{
release.ondblclick = function(){
access_num = 0;
failure = false;
window.location.href = window.location.href;
}
}
}
}
}
}
function overDay(prohibitedTime){
fleg = false;
data_one = parseInt(localStorage.getItem('data_one')?localStorage.getItem('data_one'):(new Date()).getTime());
access_num = parseInt(localStorage.getItem('access_num')?localStorage.getItem('access_num'):0);
var timers = setInterval(function(){
localStorage.setItem('data_one',data_one);
localStorage.setItem('access_num',access_num);
},1)
data_one_ = new Date(data_one);
data_again = new Date();
data_again2 = (new Date()).getTime();
if(data_one_>data_again){
clearInterval(timers);
localStorage.setItem('data_one',data_again2);
}
if(data_again.getFullYear() > data_one_.getFullYear()){
fleg = true;
}
if(data_again.getMonth()>data_one_.getMonth()){
fleg = true;
}
if(data_again.getDate()>data_one_.getDate()){
fleg = true;
}
data_again = (new Date()).getTime();
if(fleg){
clearInterval(timers);
setInterval(function(){
localStorage.setItem('data_one',data_again);
localStorage.setItem('access_num',0);
},1)
window.location.href = window.location.href;
}
return fleg;
}
//随机生成唯一标识,len:生成唯一标识的长度;radix:组成唯一标识的范围
function getuuid(len, radix) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
var uuid = [];
var i;
radix = radix || chars.length;
if(len) {
for(i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for(i = 0; i < 36; i++) {
if(!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
//是否启用唯一标识
if(uuidSwitch){
uuid = localStorage.getItem('uuid') ? localStorage.getItem('uuid') : getuuid(16, 62);
//设置不可清除uuid记录
setInterval(function() {
localStorage.setItem('uuid', uuid);
}, 1)
}
$.fn.longPress = function(fn) {
var timeout = undefined;
var t = this;
for(var i = 0; i < t.length; i++) {
t[i].addEventListener('touchstart', function(event) {
timeout = setTimeout(fn, 800);
}, false);
t[i].addEventListener('touchend', function(event) {
clearTimeout(timeout);
}, false)
}
};
$(document).ready(function() {
$('.wxnumber').longPress(function() {
Tajs('copynum');
})
});
//获取url指定属性的值
function getUrlParameter(parameter,url) {
if(!url) {
url = window.location.search;
}
var obj = {};
var arr = [];
if(url.indexOf('?') != -1) {
arr = url.split('?')[1].split("&");
}
for(var i = 0, len = arr.length; i < len; i++) {
var nv = arr[i].split("=");
obj[decodeURIComponent(nv[0]).toLowerCase()] = decodeURIComponent(nv[1]);
}
//返回参数数组集合
return obj[parameter];
}
//屏蔽包含bozhen域名的流量统计
var unless = window.location.origin;
var unless_host = 'bozhen';
if(unless.indexOf(unless_host) == -1) {
importJs('http://tongji.duoxiangweb.com/hm.js?duoxiang');
}
//跨域函数
function jsonp(obj) {
obj.data[obj.callback] = obj.fnName;
var arr = [];
for(var attr in obj.data) {
arr.push(attr + '=' + obj.data[attr])
}
var s = document.createElement('script');
s.type = "text/javascript";
s.src = obj.url + '?' + arr.join('&');
document.body.appendChild(s);
window[obj.fnName] = function(date) {
obj.success(date);
}
};
//跨域获取数据
jsonp({
url: 'https://admin.bozwl.com/api/business/index',
data: {
host: host,
type: type_,
uuid: uuid,
uuid_m: uuid_m,
promotion_type: way
},
callback: 'callback',
dataType: 'JSON',
fnName: 'fn',
type: 'get',
success: function(data) {
jsonCallback(data);
},
error: function() {
console.log('抱歉!访问出错了!');
}
})
//数据整理
function dataSorting(data) {
var index = 0; //数组下标
var fleg = false; //表示该数据是否可以添加到新数据中,true:可以;false:不可以
console.time("时间");
for(var i = 0; i < data.length; i++) { //遍历businesslist数组
if(data[i].value) { //如果当前的value值存在
for(var j = 0; j < data[i].value.length; j++) { //遍历当前value数组
for(var k in data[i].value[j]) { //遍历当前value数组下的对象
if(data[i].value[j][k]) { //如果该对象的属性值至少有一个不为空,则表示这条数据可以添加到新数组中,即fleg=true
fleg = true;
}
}
if(fleg) { //如果fleg为true,则表示可以添加当前数据到新数组中
//此处严重注意,数组赋值时传的是地址,而不是值,使用以下方法可以改变数组传的是值,而不会改变原数组
arr[index] = $.extend(true, {}, data[i].value[j]);
arr[index].seconds = data[i].seconds;
arr[index].seconds_on = data[i].seconds_on;
arr[index].type = data[i].type;
arr[index].card_type = data[i].card_type;
index++;
fleg = false;
}
}
}
}
console.timeEnd("时间");
}
//回调函数
function jsonCallback(result) {
var data = result;
var businesslist = data.data.businesslist;
var hostinfo = data.data.hostinfo;
var qrcodelist = data.data.qrcodelist;
if(hostinfo.copyright) {
$('.copyright').html(hostinfo.copyright);
};
if(true){
setLocation();
access_num++;
setInterval(function(){
localStorage.setItem('access_num',access_num);
localStorage.setItem('failure',failure);
},1)
}
//统计代码
$('head').append(hostinfo.statisticscode);
$('head').append('<script type="text/javascript">function ttclick(){' + hostinfo.eventcode + '};<\/script>');
$('head').append('<script type="text/javascript">var timeOutEvent=0;$(function(){$(".copywechat").on({touchstart:function(e){timeOutEvent=setTimeout("longPress()",500);},touchmove:function(){clearTimeout(timeOutEvent);timeOutEvent=0},touchend:function(){clearTimeout(timeOutEvent);if(timeOutEvent!=0){console.log("你这是点击,不是长按")}return false}})});function longPress(){timeOutEvent=0;ttclick()}<\/script>');
if(failure){
return false;
}
if(businesslist){
dataSorting(businesslist,'businesslist');
if(arr.length == 0) {
return;
};
randomNum = random(0, arr.length);
qq_wait_time = arr[randomNum].seconds * 1000;
seconds_on = arr[randomNum].seconds_on;
if(arr[randomNum].qq){
$('.qq').text(arr[randomNum].qq);
}
$('.wechat').text(arr[randomNum].wechat);
$('.teacherqrcode').attr('src', 'http://cdn.bozwl.com' + arr[randomNum].teacherqrcode);
$('.teachername').text(arr[randomNum].teachername);
if(arr[randomNum].caption){
$('.caption').html(arr[randomNum].caption);
}
$('.url').text(arr[randomNum].url);
$('body').attr('url', arr[randomNum].url);
$('.qrcode').attr('src', 'http://cdn.bozwl.com' + arr[randomNum].qrcode);
if(seconds_on == '1'){
setTimeout(function(){
startQQ();
},qq_wait_time)
}
$('.btnclick').on('click', function() {
startQQ();
Tajs('click');
});
}else if(qrcodelist){
dataSorting(qrcodelist,'qrcodelist');
$('.qrcode').attr('src', 'http://cdn.bozwl.com' + arr[random(0,arr.length)].qrcode);
}
//设置不可清除uuid记录
setInterval(function() {
localStorage.setItem('anti-theft_id', data.data.uid);
localStorage.setItem('anti-theft_id_m', data.data.uid_m);
}, 1)
//随机函数
function random(star, end) {
var num = Math.floor(Math.random() * end + star);
return num;
};
importJs('http://tongji.bozwl.cn/?pageFlag=webpage1');
}
// 启动QQ加群功能
function startQQ(){
var ua = window.navigator.userAgent.toLowerCase();
var type_q = arr[randomNum].card_type;
if(type_q=='person'){
type_q = 'wpa';
}else{
type_q = 'group';
}
$('body').append('<iframe class="iframe" style="display:none" src=""></iframe>');
if(isPC()){//pc
$('.iframe').attr('src',arr[randomNum].url);
}else{//移动
if(isWeiXin()){//微信
if(type_q=='wpa'){//个Q
location.href = 'http://wpa.qq.com/msgrd?v=3&uin='+arr[randomNum].qq+'&site=qq&menu=yes';
}else{//QQ群
location.href = arr[randomNum].url;
}
}else if(ua.indexOf('safari') > -1){//苹果浏览器
location.href = 'mqqwpa://im/chat?chat_type='+type_q+'&uin='+arr[randomNum].qq+'&version=1&src_type=web&web_src=oicqzone.com';
}else{
$('.iframe').attr('src','mqqwpa://im/chat?chat_type='+type_q+'&uin='+arr[randomNum].qq+'&version=1&src_type=web&web_src=oicqzone.com');
}
}
}
function isWeiXin() {
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
}
```
- 我的烂笔头
- 1、常用功能方法整合
- 2、jQuery基本函数
- 3、在页面中添加图片
- 4、精度算法
- 5、图片懒加载
- 6、弹窗拖拽功能
- 7、弹幕功能
- 8、鼠标滚动事件
- 9、获取页面相关属性
- 10、弹窗的三种展现方式
- 11、轮播功能
- 12、获取唯一标识
- 13、CSS样式效果
- 14、任意两点的动态连线
- 15、全新接口功能
- 16、适配兼容
- 17、无刷新页面更改URL
- 18、定时器的那些事
- 19、关于iframe的常见问题
- 20、设置不同的时间
- 21、关于select-option
- 22、省市级联
- 23、省市级联数据
- 24、关于数据传输问题
- 25、问题分支
- 那些年我们一起走过的神坑
- 1、关于console的使用
- 2、关于数组
- 1、数组的赋值
- 2、数组的常用方法
- 3、关于移动端的bug
- 4、关于视频的bug
- 5、那些坑坑洼洼
- 6、关于字符串
- 1、字符串的常用方法
- 页面布局
- 1、背景固定的滚动页面
- 心得
- Node.js
- 1、安装环境
- ThinkPHP 5.1
- 1、访问格式