first commit
This commit is contained in:
37
金壶/appV1/utils/index.js
Normal file
37
金壶/appV1/utils/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
function formatNumber (n) {
|
||||
const str = n.toString()
|
||||
return str[1] ? str : `0${str}`
|
||||
}
|
||||
|
||||
export function formatTime (date) {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
const t1 = [year, month, day].map(formatNumber).join('/')
|
||||
const t2 = [hour, minute, second].map(formatNumber).join(':')
|
||||
|
||||
return `${t1} ${t2}`
|
||||
}
|
||||
|
||||
function getLocalStorage(key) {
|
||||
try {
|
||||
const value = uni.getStorageSync(key);
|
||||
if (value) {
|
||||
return value
|
||||
}
|
||||
return false
|
||||
} catch (e) {
|
||||
console.error("数据读取出错:", JSON.stringify(e))
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
formatNumber,
|
||||
formatTime,
|
||||
getLocalStorage
|
||||
}
|
||||
Reference in New Issue
Block a user