const BASE_IMG_URL = 'https://file-dev.xyyxt.net/' import store from '@/store/index.js' export default { isLogin() { if(uni.getStorageSync('union_id')){ return true; }else{ return false } }, splitImgHost(url) { if(!url){ return '' } if(url.indexOf("http") != -1||url.indexOf("https") != -1){ return url; } return BASE_IMG_URL+url }, exit() { uni.removeStorageSync('union_id') uni.removeStorageSync('token') store.state.userInfo = null uni.reLaunch({ url: '/pages/index/index' }); }, /* 时间戳转换成日期 * @param timestamp * @returns {*} */ timestampToTime(timestamp,isDay=true) { var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; var D = date.getDate() + ' '; var h = date.getHours() + ':'; var m = date.getMinutes() + ':'; var s = date.getSeconds(); if(isDay){ return Y+M+D; } return Y+M+D+h+m+s; } }