This commit is contained in:
BianLzhaoMin 2026-01-07 15:28:35 +08:00
parent 4207adf8a1
commit c910876f27
3 changed files with 86 additions and 12 deletions

View File

@ -72,7 +72,10 @@
import { ref, computed, onMounted, onUnmounted } from 'vue' import { ref, computed, onMounted, onUnmounted } from 'vue'
import NavBarModal from '@/components/NavBarModal/index.vue' import NavBarModal from '@/components/NavBarModal/index.vue'
import { getContentStyle, getSafeAreaInfo } from '@/utils/safeArea' import { getContentStyle, getSafeAreaInfo } from '@/utils/safeArea'
import { useMemberStore } from '@/stores'
import { confirmMessageAPI } from '@/services/realName/own/message-notification'
const memberStore = useMemberStore()
const contentStyle = computed(() => { const contentStyle = computed(() => {
return getContentStyle({ return getContentStyle({
includeNavBar: true, includeNavBar: true,
@ -85,6 +88,8 @@ const countdown = ref(5)
let countdownTimer = null let countdownTimer = null
const canConfirm = ref(false) const canConfirm = ref(false)
const messageDetail = ref({}) const messageDetail = ref({})
const isConfirmed = ref(false)
const isAlreadyRead = ref(false)
const photoList = computed(() => { const photoList = computed(() => {
if (!messageDetail.value.photoFilePath) { if (!messageDetail.value.photoFilePath) {
@ -103,6 +108,11 @@ const photoList = computed(() => {
}) })
const confirmButtonText = computed(() => { const confirmButtonText = computed(() => {
//
if (isAlreadyRead.value) {
return '点击确认'
}
//
if (countdown.value > 0) { if (countdown.value > 0) {
return `${countdown.value}` return `${countdown.value}`
} }
@ -204,23 +214,66 @@ const handleDownload = () => {
}) })
} }
const handleConfirm = () => { const handleConfirm = async () => {
if (!canConfirm.value) { if (!canConfirm.value) {
return return
} }
uni.showToast({ //
title: '已确认', if (isAlreadyRead.value) {
icon: 'success',
})
setTimeout(() => {
uni.navigateBack() uni.navigateBack()
}, 1500) 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()
}, 500)
} else {
uni.showToast({
title: res?.msg || '确认失败',
icon: 'none',
})
}
} catch (error) {
uni.hideLoading()
console.error('确认消息失败:', error)
uni.showToast({
title: '确认失败',
icon: 'none',
})
}
} }
const handleBack = () => { const handleBack = () => {
uni.navigateBack() //
if (isConfirmed.value || isAlreadyRead.value) {
uni.navigateBack()
return
}
uni.showModal({
title: '提示',
content: '请先确认消息',
showCancel: false,
})
} }
onMounted(() => { onMounted(() => {
@ -231,13 +284,21 @@ onMounted(() => {
const messageParam = options.message const messageParam = options.message
if (messageParam) { 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) { } catch (error) {
console.error('获取页面参数失败:', error) console.error('获取页面参数失败:', error)
} }
startCountdown() //
if (!isAlreadyRead.value) {
startCountdown()
} else {
canConfirm.value = true
}
}) })
onUnmounted(() => { onUnmounted(() => {

View File

@ -35,7 +35,7 @@
</template> </template>
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted, onUnmounted } from 'vue'
import NavBarModal from '@/components/NavBarModal/index.vue' import NavBarModal from '@/components/NavBarModal/index.vue'
import ReviewEmptyState from '@/components/ReviewEmptyState/index.vue' import ReviewEmptyState from '@/components/ReviewEmptyState/index.vue'
import { getContentStyle } from '@/utils/safeArea' import { getContentStyle } from '@/utils/safeArea'
@ -76,6 +76,11 @@ const handleBack = () => {
onMounted(() => { onMounted(() => {
loadMessageList() loadMessageList()
uni.$on('refreshMessageNotificationList', loadMessageList)
})
onUnmounted(() => {
uni.$off('refreshMessageNotificationList')
}) })
</script> </script>

View File

@ -9,3 +9,11 @@ export const getMessageNotificationListAPI = (data) => {
method: 'POST', method: 'POST',
}) })
} }
// 确认消息
export const confirmMessageAPI = (data) => {
return realNameHttp({
url: `/notify/addNotifyRecord?${initParams(data)}`,
method: 'POST',
})
}