获取最新公告,当公告栏显示公告title
This commit is contained in:
parent
2a4d00a50a
commit
1d4aa8cb67
|
|
@ -47,3 +47,22 @@ export function getPrivacyPolicy() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新公告
|
||||||
|
* @param {Object} params - 查询参数
|
||||||
|
* @param {string} params.appId - 应用ID,默认为1
|
||||||
|
* @param {string} params.type - 类型,4表示公告
|
||||||
|
* @returns {Promise} 返回最新公告数据
|
||||||
|
*/
|
||||||
|
export function getNewAnnouncement(params = {}) {
|
||||||
|
return request({
|
||||||
|
url: '/app/article/getNew',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
appId: '1',
|
||||||
|
type: '4',
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
export const DEV_CONFIG = {
|
export const DEV_CONFIG = {
|
||||||
// 临时token,用于开发测试
|
// 临时token,用于开发测试
|
||||||
TEMP_TOKEN:
|
TEMP_TOKEN:
|
||||||
'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImY3OTUyZDY4LTI3NWItNDQ2ZS1iNjAwLWZkNGFiYmVkZjkyYSJ9.Nw8an_L7efznUuF3NdFrpCOOlK5xLGcgQ6xhAwat8kxiNkmDLsgJ3rprFD_o3yueApzomDj1vZSOMLcEsBa8Dg',
|
' eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImVmZmVjZjk4LWUzZWMtNDY4YS04Y2VlLTcyMjUyOTllOGI2OSJ9.4u5ypyRjZCiQr-E02MJ2UQ0dV-PGK-s402Ex7CtAIO_8YDaUoQ0MTmwfFqS2IZenlrB7H5RB80P__U9zXB68Pg',
|
||||||
|
|
||||||
// 是否使用临时token
|
// 是否使用临时token
|
||||||
USE_TEMP_TOKEN: true,
|
USE_TEMP_TOKEN: true,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import commonEnum from '../../enum/commonEnum'
|
||||||
import AnnouncementBar from '../../components/announcement-bar/announcement-bar.vue'
|
import AnnouncementBar from '../../components/announcement-bar/announcement-bar.vue'
|
||||||
import BannerSwiper from '../../components/banner-swiper/banner-swiper.vue'
|
import BannerSwiper from '../../components/banner-swiper/banner-swiper.vue'
|
||||||
import EquipmentList from '../../components/equipment-list/equipment-list.vue'
|
import EquipmentList from '../../components/equipment-list/equipment-list.vue'
|
||||||
|
import { getNewAnnouncement } from '../../api/article/article.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -58,6 +59,7 @@ export default {
|
||||||
// 页面数据
|
// 页面数据
|
||||||
companyName: '福鼎创特物联科技有限公司',
|
companyName: '福鼎创特物联科技有限公司',
|
||||||
announcementText: '暂无更多公告! 暂无更多公告! 暂无更多公告!',
|
announcementText: '暂无更多公告! 暂无更多公告! 暂无更多公告!',
|
||||||
|
currentAnnouncement: null, // 当前公告数据
|
||||||
equipmentTitle: '我的租赁设备',
|
equipmentTitle: '我的租赁设备',
|
||||||
navItems: ['首页', '申请租赁', '个人中心'],
|
navItems: ['首页', '申请租赁', '个人中心'],
|
||||||
activeNavIndex: 0,
|
activeNavIndex: 0,
|
||||||
|
|
@ -101,7 +103,29 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 生命周期钩子
|
||||||
|
onLoad() {
|
||||||
|
this.fetchAnnouncement()
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
// 获取最新公告
|
||||||
|
async fetchAnnouncement() {
|
||||||
|
try {
|
||||||
|
const response = await getNewAnnouncement()
|
||||||
|
if (response.code === 200 && response.data) {
|
||||||
|
this.currentAnnouncement = response.data
|
||||||
|
// 更新公告文本,去除HTML标签
|
||||||
|
const content = response.data.content || ''
|
||||||
|
const plainText = content.replace(/<[^>]*>/g, '')
|
||||||
|
this.announcementText = response.data.title || plainText || '暂无更多公告!'
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取公告失败:', error)
|
||||||
|
this.announcementText = '暂无更多公告!'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 头部点击事件
|
// 头部点击事件
|
||||||
onLocationClick() {
|
onLocationClick() {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
@ -112,10 +136,22 @@ export default {
|
||||||
|
|
||||||
// 公告栏点击事件
|
// 公告栏点击事件
|
||||||
onAnnouncementClick() {
|
onAnnouncementClick() {
|
||||||
|
if (this.currentAnnouncement) {
|
||||||
|
// 显示公告详情
|
||||||
|
uni.showModal({
|
||||||
|
title: this.currentAnnouncement.title || '公告详情',
|
||||||
|
content: this.currentAnnouncement.content ?
|
||||||
|
this.currentAnnouncement.content.replace(/<[^>]*>/g, '') :
|
||||||
|
'暂无公告内容',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '知道了'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '查看公告详情',
|
title: '暂无公告',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 轮播图变化事件
|
// 轮播图变化事件
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user