134 lines
3.6 KiB
JavaScript
134 lines
3.6 KiB
JavaScript
|
|
export function timestampFormat(){
|
|
var currentTime = new Date();
|
|
var year = currentTime.getFullYear();
|
|
var getMonth = (currentTime.getMonth()) + 1;
|
|
var getDate = currentTime.getDate();
|
|
var getHours = currentTime.getHours();
|
|
var getMinutes = currentTime.getMinutes();
|
|
var getSeconds = currentTime.getSeconds();
|
|
if(getMonth < 10) {
|
|
getMonth = "0" + getMonth;
|
|
}
|
|
if(getDate < 10) {
|
|
getDate = "0" + getDate;
|
|
}
|
|
if(getHours < 10) {
|
|
getHours = "0" + getHours;
|
|
}
|
|
if(getMinutes < 10) {
|
|
getMinutes = "0" + getMinutes;
|
|
}
|
|
if(getSeconds < 10) {
|
|
getSeconds = "0" + getSeconds;
|
|
}
|
|
return year + "-" + getMonth + "-" + getDate + " " + getHours + ":" + getMinutes + ":" + getSeconds+"";
|
|
}
|
|
|
|
|
|
export function getWeekDate() {
|
|
var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
|
|
var now = new Date();
|
|
var day = now.getDay();
|
|
var week = weeks[day];
|
|
return week;
|
|
|
|
}
|
|
|
|
|
|
//接受url的值,进行解析
|
|
export function getParams(key) {
|
|
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
|
|
var r = window.location.search.substr(1).match(reg);
|
|
if (r != null) {
|
|
return unescape(r[2]);
|
|
}
|
|
return null;
|
|
};
|
|
|
|
var tianqiApi=[
|
|
["61656699","1D9KRiO5"],
|
|
["35891892","pzQCn7Xr"],
|
|
["44931254","oDROlNB6"]
|
|
];
|
|
var tangqiIndex=0;
|
|
/*调用天气的api 获取数据(https://www.tianqiapi.com/index/doc?version=v6)*/
|
|
export function getCityAndWeather(){
|
|
var appid=tianqiApi[tangqiIndex][0];
|
|
var appSecret=tianqiApi[tangqiIndex][1];
|
|
var url="https://tianqiapi.com/api?version=v6&appid="+appid+"&appsecret="+appSecret;
|
|
$.ajax({
|
|
url: url,
|
|
type: "post",
|
|
datatype:"json",
|
|
success: function(data) {
|
|
if("errcode" in data){
|
|
tangqiIndex++;
|
|
getCityAndWeather();
|
|
}else{
|
|
$(".temperature").html(data["tem"]+"℃");
|
|
$(".weatherCondition").html(data["wea"]);
|
|
$(".windDirection").html(`${data["win"]}(${data["win_speed"]})`);
|
|
$(".temIndexNumber").html(data["air_level"]);
|
|
}
|
|
},
|
|
error:function(e){
|
|
console.log(e);
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
|
|
//全屏退出全屏
|
|
$(".fullScreen").on('click', function () {
|
|
var state = $(this).attr("state");
|
|
fullState(state,this)
|
|
})
|
|
|
|
|
|
//全屏退出全屏
|
|
$(".exitSystem").on('click', function () {
|
|
window.location.href="./login.html";
|
|
})
|
|
|
|
|
|
function fullState(state,that){
|
|
if (state == "close") {
|
|
fullScreen()
|
|
$(that).attr("state", "open")
|
|
$(that).html(`<img src="./pages/index/image/fullscreen.png">退出全屏`)
|
|
} else {
|
|
exitFullscreen()
|
|
$(that).attr("state", "close")
|
|
$(that).html(`<img src="./pages/index/image/fullscreen.png">全屏`)
|
|
}
|
|
}
|
|
|
|
//全屏
|
|
function fullScreen() {
|
|
var element = document.documentElement;
|
|
if (element.requestFullscreen) {
|
|
element.requestFullscreen();
|
|
} else if (element.msRequestFullscreen) {
|
|
element.msRequestFullscreen();
|
|
} else if (element.mozRequestFullScreen) {
|
|
element.mozRequestFullScreen();
|
|
} else if (element.webkitRequestFullscreen) {
|
|
element.webkitRequestFullscreen();
|
|
}
|
|
}
|
|
|
|
//退出全屏
|
|
function exitFullscreen() {
|
|
if (document.exitFullscreen) {
|
|
document.exitFullscreen();
|
|
} else if (document.msExitFullscreen) {
|
|
document.msExitFullscreen();
|
|
} else if (document.mozCancelFullScreen) {
|
|
document.mozCancelFullScreen();
|
|
} else if (document.webkitExitFullscreen) {
|
|
document.webkitExitFullscreen();
|
|
}
|
|
}
|
|
|