This commit is contained in:
parent
4207adf8a1
commit
c910876f27
|
|
@ -72,7 +72,10 @@
|
|||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import NavBarModal from '@/components/NavBarModal/index.vue'
|
||||
import { getContentStyle, getSafeAreaInfo } from '@/utils/safeArea'
|
||||
import { useMemberStore } from '@/stores'
|
||||
import { confirmMessageAPI } from '@/services/realName/own/message-notification'
|
||||
|
||||
const memberStore = useMemberStore()
|
||||
const contentStyle = computed(() => {
|
||||
return getContentStyle({
|
||||
includeNavBar: true,
|
||||
|
|
@ -85,6 +88,8 @@ const countdown = ref(5)
|
|||
let countdownTimer = null
|
||||
const canConfirm = ref(false)
|
||||
const messageDetail = ref({})
|
||||
const isConfirmed = ref(false)
|
||||
const isAlreadyRead = ref(false)
|
||||
|
||||
const photoList = computed(() => {
|
||||
if (!messageDetail.value.photoFilePath) {
|
||||
|
|
@ -103,6 +108,11 @@ const photoList = computed(() => {
|
|||
})
|
||||
|
||||
const confirmButtonText = computed(() => {
|
||||
// 已读:始终显示“点击确认”
|
||||
if (isAlreadyRead.value) {
|
||||
return '点击确认'
|
||||
}
|
||||
// 未读:进入时有倒计时
|
||||
if (countdown.value > 0) {
|
||||
return `${countdown.value}秒`
|
||||
}
|
||||
|
|
@ -204,23 +214,66 @@ const handleDownload = () => {
|
|||
})
|
||||
}
|
||||
|
||||
const handleConfirm = () => {
|
||||
const handleConfirm = async () => {
|
||||
if (!canConfirm.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 已读消息:不再调用接口,直接返回
|
||||
if (isAlreadyRead.value) {
|
||||
uni.navigateBack()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '确认中...',
|
||||
})
|
||||
|
||||
const res = await confirmMessageAPI({
|
||||
workerId: memberStore.realNameUserInfo.workerId,
|
||||
notifyId: messageDetail.value.notifyId,
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
if (res && res.res === 1) {
|
||||
isConfirmed.value = true
|
||||
uni.showToast({
|
||||
title: '已确认',
|
||||
icon: 'success',
|
||||
})
|
||||
|
||||
uni.$emit('refreshMessageNotificationList')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}, 500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res?.msg || '确认失败',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('确认消息失败:', error)
|
||||
uni.showToast({
|
||||
title: '确认失败',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleBack = () => {
|
||||
// 已读或已确认:直接返回
|
||||
if (isConfirmed.value || isAlreadyRead.value) {
|
||||
uni.navigateBack()
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先确认消息',
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
|
@ -231,13 +284,21 @@ onMounted(() => {
|
|||
const messageParam = options.message
|
||||
|
||||
if (messageParam) {
|
||||
messageDetail.value = JSON.parse(decodeURIComponent(messageParam))
|
||||
const detail = JSON.parse(decodeURIComponent(messageParam))
|
||||
messageDetail.value = detail
|
||||
// isRead === 'No' 表示未读,其它情况视为已读
|
||||
isAlreadyRead.value = detail.isRead && detail.isRead !== 'No'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取页面参数失败:', error)
|
||||
}
|
||||
|
||||
// 未读才启用倒计时,已读则立即可确认且不再调用接口
|
||||
if (!isAlreadyRead.value) {
|
||||
startCountdown()
|
||||
} else {
|
||||
canConfirm.value = true
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import NavBarModal from '@/components/NavBarModal/index.vue'
|
||||
import ReviewEmptyState from '@/components/ReviewEmptyState/index.vue'
|
||||
import { getContentStyle } from '@/utils/safeArea'
|
||||
|
|
@ -76,6 +76,11 @@ const handleBack = () => {
|
|||
|
||||
onMounted(() => {
|
||||
loadMessageList()
|
||||
uni.$on('refreshMessageNotificationList', loadMessageList)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('refreshMessageNotificationList')
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,3 +9,11 @@ export const getMessageNotificationListAPI = (data) => {
|
|||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
// 确认消息
|
||||
export const confirmMessageAPI = (data) => {
|
||||
return realNameHttp({
|
||||
url: `/notify/addNotifyRecord?${initParams(data)}`,
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue