This commit is contained in:
parent
4207adf8a1
commit
c910876f27
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 已读消息:不再调用接口,直接返回
|
||||||
|
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({
|
uni.showToast({
|
||||||
title: '已确认',
|
title: '已确认',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
})
|
})
|
||||||
|
uni.$emit('refreshMessageNotificationList')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack()
|
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 = () => {
|
const handleBack = () => {
|
||||||
|
// 已读或已确认:直接返回
|
||||||
|
if (isConfirmed.value || isAlreadyRead.value) {
|
||||||
uni.navigateBack()
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 未读才启用倒计时,已读则立即可确认且不再调用接口
|
||||||
|
if (!isAlreadyRead.value) {
|
||||||
startCountdown()
|
startCountdown()
|
||||||
|
} else {
|
||||||
|
canConfirm.value = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue