需要开发 IM

This commit is contained in:
cbb
2025-12-30 17:52:19 +08:00
parent 8fe2079446
commit d0cf491201
23 changed files with 515 additions and 61 deletions

25
utils/dateUtils.js Normal file
View File

@@ -0,0 +1,25 @@
/** 日期格式化 YYYY-MM-DD */
export const formatDate = date => {
const d = new Date(date)
const year = d.getFullYear()
const month = String(d.getMonth() + 1).padStart(2, '0') // 月份从0开始
const day = String(d.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
/** 日期格式化:月.日 */
export const formatMonthDay = date => {
// 统一处理为 Date 对象
const d = new Date(date)
// 检查是否是有效日期
if (isNaN(d.getTime())) {
console.error('Invalid date:', date)
return '--.--'
}
const month = String(d.getMonth() + 1).padStart(2, '0') // getMonth() 是 0-11
const day = String(d.getDate()).padStart(2, '0')
return `${month}.${day}`
}

View File

@@ -17,7 +17,7 @@ export const removeToken = () => {
/** 保存用户信息 */
export const setUserInfoData = v => {
return uni.setStorageSync(STORAGE_KEYS.USER, JSON.stringify(v))
return uni.setStorageSync(STORAGE_KEYS.USER, JSON.stringify(v))
}
/** 获取用户信息 */
@@ -29,3 +29,21 @@ export const getUserInfoData = () => {
export const removeUserInfoData = () => {
return uni.removeStorageSync(STORAGE_KEYS.USER)
}
/** 保存腾讯 IM */
export const setSig = v => {
return uni.setStorageSync(
STORAGE_KEYS.TENCENT_USER_SIG,
JSON.stringify(v)
)
}
/** 获取腾讯 IM */
export const getSig = () => {
return uni.getStorageSync(STORAGE_KEYS.TENCENT_USER_SIG) || ''
}
/** 删除腾讯 IM */
export const removeSig = () => {
return uni.removeStorageSync(STORAGE_KEYS.TENCENT_USER_SIG)
}