qa-prevention-gwj-first-app/common/tool.js

119 lines
3.3 KiB
JavaScript

//正式
export var basePath = "https://skqhdg.porthebei.com:9004/qa-prevention-gwj/";
export var baseImgPath = "https://skqhdg.porthebei.com:9004/file/";
// export var basePath = "http://192.168.0.31:8991/qa-prevention-gwj/";
// export var baseImgPath = "https://qgqy.qhdsafety.com/file/";
export const adminPath = "https://www.qdkjchina.com/qa-prevention-admin";
export const majorSocketPath = "ws://192.168.210.7:8889";
export const publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zCyUYSD0pNrbtaYdvGfHfWoRV+fo/2N9O2PLLz/jZvMkigkq4eAq4JO+Ek0wDHI9WxP6iTSLYCHhIOs9CQTPvyldJFm8riZtQZlBTD8Plkb3rjrgwTqbBi3w3+HKYdkSvGFXJIdSOPbpXnj5BzN8vlVaybs24R/vpUzG9178lwIDAQAB"
export var corpinfoId ='';//
export var loginUserId ='';
import Vue from 'vue'
export const door = Vue.observable(
{ openSouth: false, doorSouthHtml: '门禁南口:开',
openNorth: false, doorNorthHtml: '门禁北口:开' })
export const doorMethed = {
setOpenSouth (flag){
door.openSouth = flag
},
setDoorSouthHtml (val){
door.doorSouthHtml = val
},
setOpenNorth (flag) {
door.openNorth = flag
},
setDoorNorthHtml (val){
door.doorNorthHtml = val
}
}
export var loginUser ='';
export function loginSession (){
if('' == corpinfoId || undefined ==corpinfoId || ''==loginUserId || undefined ==loginUserId
|| ''==loginUser || undefined ==loginUser){
uni.navigateTo({
url: '/pages/login/home',
});
}
}
export function setloginUser (user){
loginUser = user;
}
export function setloginUserId(id){
loginUserId = id
}
export function setCorpinfoId(id){
corpinfoId = id
}
export var deptId = '';
export function setDeptId(id){
deptId = id
}
export var postId = '';
export function setPostId(id){
postId = id
}
export var username = '';
export function setUsername(name){
username = name
}
export var version = '';
export function setVersion(ver){
version = ver
}
export function setBasePath(url){
basePath = url
}
export function formatDate(date, fmt) {
if(null != JSON.stringify(date) && 'null' != JSON.stringify(date) && undefined != JSON.stringify(date) && 'undefined' != JSON.stringify(date) && JSON.stringify(date) != '' && JSON.stringify(date).length > 0){
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
let str = o[k] + ''
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
}
}
return fmt
} else {
return ''
}
}
function padLeftZero(str) {
return ('00' + str).substr(str.length)
}
// 处理多次点击
function noMultipleClicks(methods,e) {
let that = this;
if (that.noClick) {
that.noClick= false;
methods(e);
setTimeout(function () {
that.noClick= true;
}, 2000)
} else {
console.log("请稍后点击")
}
}
//导出
export default {
noMultipleClicks,//禁止多次点击
}