绩效考核手机版
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.
 
 
 
 

123 lines
3.1 KiB

//公共图表用色
const colorCommon = ['#5470C6','#91CC75','#FAC858','#EE6666','#73C0DE','#3BA272','#FF0000','#009900','#FFCC00','#660099','#CCFF33','#66CCFF','#000CCC','#FF99FF','#CC9999','#CC9933','#33FFFF','#CC6633','#9933CC','#FF3366']
//跳转链接
// const localhostUrl = "http://kpi.beiding.net";
const localhostUrl = "http://hxgk.user.phone";
const serverUrl ="";
const JumpUrl = function(UrlStr) {
console.log(UrlStr)
uni.navigateTo({
url: UrlStr,
success:function(data){
console.log("redirectTo--->",data)
},
fail: errval=>{
uni.redirectTo({
url: UrlStr,
success:function(data){
console.log("navigateTo--->",data)
},
fail: errsunval => {
uni.reLaunch({
url: UrlStr,
fail: err_sun_val => {
console.log(123)
console.log("reLaunch---->",err_sun_val)
}
});
}
});
}
});
}
//清除缓存
const delCache = function(UrlStr) {
uni.clearStorage();
_this.JumpUrl(UrlStr)
}
//判断授权是否还有效
const verifyPowerIsTrue = function(userKeyCont,UrlStr){
console.log(userKeyCont,UrlStr,"判断授权是否还有效")
let _this =this
_this.loading = true
uni.request({
url:localhostUrl+'/kpiapi/base/verify_empower_istrue',
header: {
// 'Content-Type': 'application/x-www-form-urlencoded'
'Content-Type': 'application/json' //自定义请求头信息
},
method:'POST',//请求方式,必须为大写
data:{
userKey:userKeyCont.userKey
},
success: (res) => {
// console.log('接口返回--login--3--',res.data);
let callBackData = res.data
if(callBackData.code != 0){
delCache(UrlStr)
}else{
setSystemCacheData(userKeyCont.userKey,userKeyCont.token,userKeyCont.userName,userKeyCont.myPwd,userKeyCont.userinfo,userKeyCont.usercont)
}
},
fail:function(e){
console.log('接口返回--login--2--',e);
}
})
}
//设置本地数据缓存
const setSystemCacheData = function (userKeyVal,tokenVal,userNameVal,myPwdVal,userInfo,userCont) {
console.log('接口返回--缓存设置-1---',userKeyVal,tokenVal);
let _this=this
let tokenTimeVal=new Date().getTime()
let returnData = false
uni.setStorage({
key: 'myCache',
data: {
tokenTime:tokenTimeVal,
userKey:userKeyVal,
token:tokenVal,
userName:userNameVal,
myPwd:myPwdVal,
userInfo:userInfo,
userCont:userCont
},
success: function () {
returnData = true
},
fail() {
returnData = false
}
});
return returnData
}
//获取缓存数据
const getSystemCacheDate = function(cacheKey){
let cacheDate = uni.getStorageSync(cacheKey)
// console.log(cacheDate);
return cacheDate
}
//随机生成16禁止颜色
const randomHexColor= function() {
//随机生成十六进制颜色
var hex = Math.floor(Math.random() * 16777216).toString(16);
//生成ffffff以内16进制数
while (hex.length < 6) {
//while循环判断hex位数,少于6位前面加0凑够6位
hex = '0' + hex;
}
return '#' + hex; //返回‘#'开头16进制颜色
}
//注册定义的方法
export const commonMethod= {
JumpUrl,
delCache,
verifyPowerIsTrue,
setSystemCacheData,
getSystemCacheDate,
localhostUrl,
serverUrl,
colorCommon,
randomHexColor
}