物联网平台 +Web 组态
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

131 lines
2.9 KiB

/**
* 版权所有 @鸿名物联
* 未经授权,禁止侵权和商业,违法必究
* 联系QQ:2224313811
*
*/
// config------------
var baseurl= window.location.href.split("/page")[0] ;
var ucode= localStorage.getItem("ucode") ;
var mqttUserName = 'iot2yun' ;
var mqttPassword = '888888' ;
// config end -----------------------------------------------------------------
// ----------------- 方法区-----------------------------------------------------
function getQueryString(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
/**
* @time
* @Func 将长整形时间 转换制定格式
* @param time 长整形数值
* @returns {String}
* @Exp timeStamp2String("1464058102000","MM/dd hh:mm")
*/
function timeStamp2String(time,format){
if(time == "" || time == null)
return ;
if(format==undefined || format == "")
format = "yyyy/MM/dd hh:mm:ss";
var datetime = new Date();
datetime.setTime(time);
return datetime.Format(format);
};
/**
* @time
* @Func 时间格式化
* @FuncName Format
* (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
*/
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
/**
* 获取默认值
*/
function gdv(value,default_val){
if(value!=undefined && value+''!="" && value!='undefined'){
return value ;
}else{
if(default_val != undefined)
return default_val ;
return "";
}
};
/**
* 判断空函数
*/
var util = {
isEmpty: function(val){
if(val==null || val == ''){
return true ;
}
return false ;
},
isNotEmpty: function(val){
if(val != null && val != ''){
return true ;
}
return false ;
}
}
/**
* 请求
**/
function commonAjax(method,url, data,sucessCallBack, errorCallBack) {
var config = {
type : method ,
url : url,
contentType : "application/json",
dataType : "json",
async : true,
success : function(data){
if(data.status == 20000){
return;
}else{
sucessCallBack(data);
}
},
error : errorCallBack
};
if(typeof(ucode) != "undefined"){
config.headers={ 'USER-KEY' :ucode };
}
if(method.toUpperCase() != 'GET' && method.toUpperCase() != 'DELETE' ){
config.data = JSON.stringify(data);
}
$.ajax(config)
};
var isOk= isOK ;
function isOK(e){
if(e.status == 2 ){
return true ;
}else{
return false ;
}
}