index.vue
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<u-navbar autoBack title="消息通知" :safeAreaInsetTop="true" placeholder>
<!-- <template #right>
<view style="font-size: 26rpx; font-weight: 700">一键已读</view>
</template> -->
</u-navbar>
<view class="message">
<view v-for="(_, index) in list" :key="index" @click="jumpUrlHandler(_)">
<view class="flexJ">
<view class="flexA">
<view class="poBox">
<image :src="_.imgUrl" mode="aspectFill" />
<view class="message-badge flexC" v-if="![0, '0'].includes(_.BadgeNum)">{{ _.BadgeNum < 99 ? _.BadgeNum : '99+' }}</view>
</view>
<view style="margin-left: 20rpx">
<view class="message-title">{{ _.title }}</view>
<text class="message-text">{{ _.text }}</text>
</view>
</view>
<!-- <view>
<view class="message-time">{{ _.time }}</view>
</view> -->
</view>
<view class="flexD">
<u-line margin="30rpx 0" v-if="index !== list.length - 1" length="80%"></u-line>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getMsg_count } from '../../api'
import { MessageCountType, PageMessageListType } from '../../types'
const { proxy } = getCurrentInstance() as { proxy: ComponentPublicInstance }
const list = ref<PageMessageListType[]>([
{ title: '系统通知', text: '', numKey: 'sysCount', textkey: 'sysFirstContent', BadgeNum: 0, time: '暂无', type: '1', imgUrl: '/static/images/response.png' },
{ title: '用户反馈', text: '', numKey: 'userCount', textkey: 'userFirstContent', BadgeNum: 0, time: '暂无', type: '2', imgUrl: '/static/images/message.png' },
{ title: '续方通知', text: '', numKey: 'xufangCount', textkey: 'xufangContent', BadgeNum: 0, time: '暂无', type: '3', imgUrl: '/static/images/xftz.png', url: '/pages2/order/renew' }
])
const getDataHandler = async () => {
const { result }: { result: MessageCountType } = await getMsg_count()
list.value = list.value.map(_ => ({ ..._, BadgeNum: result[_.numKey] || 0, text: result[_.textkey] || '暂无消息' }))
}
const jumpUrlHandler = (_: PageMessageListType) => (['1', '2'].includes(_.type) ? proxy.$h.jumpUrl(`/pages2/message/list?title=${_.title}&type=${_.type}`) : proxy.$h.jumpUrl(_.url))
onShow(() => getDataHandler())
</script>
<style lang="scss" scoped>
.message {
box-sizing: border-box;
padding: 40rpx 24rpx;
image {
width: 108rpx;
height: 108rpx;
border-radius: 50%;
margin-right: 20rpx;
}
&-title {
color: #323233;
font-size: 36rpx;
font-weight: 700;
margin-bottom: 8rpx;
}
&-text {
width: 65vw;
color: #666666;
font-size: 26rpx;
@include oneLine(2);
}
&-time {
color: #999999;
font-size: 26rpx;
margin-bottom: 12rpx;
}
.poBox {
position: relative;
}
&-badge {
box-sizing: border-box;
padding: 1rpx 8rpx;
background: #f44d36;
border-radius: 50%;
color: #ffffff;
font-size: 20rpx;
position: absolute;
top: 0;
right: 14rpx;
}
}
</style>