75 行
1.5 KiB
Vue
75 行
1.5 KiB
Vue
<template>
|
|
<view class="home-notice" v-if="noticeTexts.length">
|
|
<u-notice-bar
|
|
mode="vertical"
|
|
:list="noticeTexts"
|
|
:volume-icon="true"
|
|
:more-icon="true"
|
|
color="#047857"
|
|
bg-color="#ECFDF5"
|
|
:border-radius="16"
|
|
:font-size="24"
|
|
:duration="3500"
|
|
@click="onNoticeClick"
|
|
@getMore="onNoticeMore"
|
|
></u-notice-bar>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { BASE_URL } from '@/env';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
noticeItems: []
|
|
};
|
|
},
|
|
computed: {
|
|
noticeTexts() {
|
|
return this.noticeItems.map(item => item.title || item.desc || '').filter(Boolean);
|
|
}
|
|
},
|
|
created() {
|
|
this.loadNotices();
|
|
},
|
|
methods: {
|
|
loadNotices() {
|
|
uni.request({
|
|
url: `${BASE_URL}/api/notice/index`,
|
|
method: 'GET',
|
|
data: { page: 1, type: 1 },
|
|
success: res => {
|
|
const body = res.data || {};
|
|
if (body.code === 1 && body.data && body.data.list && body.data.list.length) {
|
|
this.noticeItems = body.data.list.slice(0, 8);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
onNoticeClick(index) {
|
|
this.openNotice(this.noticeItems[index]);
|
|
},
|
|
onNoticeMore() {
|
|
this.openNotice(this.noticeItems[0]);
|
|
},
|
|
openNotice(item) {
|
|
if (!item || !item.id) return;
|
|
this.$Router.push({
|
|
path: '/pages/public/notice-detail',
|
|
query: { id: item.id }
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.home-notice {
|
|
margin: 12rpx $brand-page-gutter 0;
|
|
border-radius: 16rpx;
|
|
overflow: hidden;
|
|
border: 1rpx solid rgba(167, 243, 208, 0.55);
|
|
}
|
|
</style>
|