export var basePath = "http://192.168.0.42:8099/";
// export var basePath = "https://gateway.qhdsafety.com/";
export const baseImgPath = "https://file.zcloudchina.com/YTHFile";
export const adminPath = "http://192.168.0.18:8085";
export const projectManagerUrl = 'https://pm.qhdsafety.com/zy-projectManage/';
export const publicKey =  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUoHAavCikaZxjlDM6Km8cX+ye78F4oF39AcEfnE1p2Yn9pJ9WFxYZ4Vkh6F8SKMi7k4nYsKceqB1RwG996SvHQ5C3pM3nbXCP4K15ad6QhN4a7lzlbLhiJcyIKszvvK8ncUDw8mVQ0j/2mwxv05yH6LN9OKU6Hzm1ninpWeE+awIDAQAB'


//export const basePath = "http://192.168.0.9:8081";
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 var premission = '';
export function setPremission(list) {
	premission = list
}

export var updateInfo = false;
export function setUpdateInfo(flag) {
	updateInfo = flag
}

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, //禁止多次点击
}