css:
@charset "UTF-8";
* {
margin: 0;
padding: 0;
color: #333333;
list-style: none;
vertical-align: middle;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
img {
display: inline-block;
}
input {
outline: none;
border: none;
border: 1px solid #ccc;
}
a {
color: #333;
cursor: pointer;
outline: none;
text-decoration: none;
display: inline-block;
blr: expression(this.onFocus=this.blur());
}
.clearfix:before, .clearfix:after {
display: block;
content: " ";
clear: both;
}
.yincang {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.yincangs {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.newline {
word-break: break-all;
word-wrap: break-word;
white-space: pre-wrap;
}
.ban_newline {
white-space: nowrap;
}
.input::-webkit-input-placeholder {
text-align: center;
}
.scroll_bar::-webkit-scrollbar {
width: 0 !important;
}
.flexs {
display: flex;
align-items: center;
justify-content: center;
}
#loading {
width: 100%;
height: 100%;
z-index: 1;
position: absolute;
top: 0px;
left: 0px;
background: rgba(238, 238, 238, 0.9);
}
#loading > img {
width: 32px;
height: 32px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
js:
var urs="";
function ajaxs(url,type,data,suFn,erFn,params){
var token= JSON.parse(localStorage.getItem('tokens'));
$.ajax(Object.assign({
url:urs+url,
headers:{"Authorization":token},
type:type,
dataType : "json",
data:data,
success: function(data){
suFn(data);
},error: function(error){
erFn(error);
}
},params||{}));
}
function getRequest(){
var url=window.location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1){
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
}
function loading(){
return html = '<div id="loading"><img src="../img/loadings.gif" /></div>';
}
function imgks(){
document.addEventListener("error", function (e) {
var elem = e.target;
if (elem.tagName.toLowerCase() == 'img') {
elem.src ="";
}
}, true);
}
function convertImgToBase64(url, callback, outputFormat) {
var canvas = document.createElement('CANVAS'),
ctx = canvas.getContext('2d'),
img = new Image;
img.crossOrigin = 'Anonymous';
img.onload = function() {
canvas.height = img.height;
canvas.width = img.width;
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL(outputFormat || 'image/png');
callback.call(this, dataURL);
canvas = null;
};
img.src = url;
}
function limitImport(str,num){
$(document).on('input propertychange',str,function(){
var self = $(this);
var content = self.val();
if (content.length > num){
self.val(content.substring(0,num));
}
$(".mun").text(self.val().length+'/'+num);
});
}
var _loadIndex =1,
_loadState = 0;
function loadmore(element,url,type,dataObj,successFn,errorFn) {
$(element).on("scroll",function(){
var _elementHeight = $(element).outerHeight(),
_elementChildHeight = $(element).children().outerHeight(),
_elementScroll = $(element).scrollTop();
if(_elementChildHeight - _elementScroll - 10 > _elementHeight){
}else {
if(_loadState == 0){
_loadState = 1;
_loadIndex += 1;
$(element).append('<p class="nowLoad">正在加载...</p>');
ajaxLoad(_loadIndex);
}
}
});
function ajaxLoad(page) {
dataObj.page = page;
$.ajax({
url:urs+url,
xhrFields:{
withCredentials:true
},
type:type,
dataType:'json',
data:dataObj,
success:function (data) {
successFn(data);
if(data.length > 0){
_loadState = 0;
function hg(){
$(".nowLoad").remove();
}
setTimeout(hg,1200);
}else {
_loadState = 2;
$('.nowLoad').remove();
$(element).after('<p class="endLoad">没有数据了...</p>');
function fg(){
$(".endLoad").remove();
}
setTimeout(fg,1200);
}
},
error:function (err) {
errorFn(err);
}
})
}
};
function getMyDate(str,state){
var oDate = new Date(str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth()+1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oFf=oDate.getMilliseconds()
if(state==1){
oTime = oYear +'.'+ getzf(oMonth) +'.'+ getzf(oDay);
}else{
oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);
}
return oTime;
};
function getzf(num){
return num< 10 ? '0' + num:num;
}
function heavy(heavy){
return Array.from(new Set(heavy));
}