QA-UniApp-wlaq/common/tool.js

109 lines
2.8 KiB
JavaScript
Raw Normal View History

2024-11-19 14:17:54 +08:00
export var basePath = "http://192.168.0.69:7062/";
export const baseImgPath = "http://36.133.193.8:8086/wlaqfile";
// export var basePath = "http://192.168.0.31:7062/qa-prevention-wlaq/";
// export const baseImgPath = "http://36.133.193.8:8086/wlaqfile";
// export var basePath = "https://wlqy.zcloudchina.com/qa-prevention-wlaq/";
// export const baseImgPath = "https://wlqy.zcloudchina.com/file";
// export const adminPath = "http://192.168.0.21:8085";
export var corpinfoId = ''; //
export var loginUserId = '';
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 deptLevel = '';
export function setDeptLevel(level) {
deptLevel = level
}
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 var isRest = '';
export function setIsRest(rest) {
isRest = rest
}
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, //禁止多次点击
}