修改主页

This commit is contained in:
2025-09-12 14:40:18 +08:00
parent 44059dd320
commit 023dfb3be1
4 changed files with 112 additions and 79 deletions

View File

@@ -52,14 +52,14 @@
<text class="hot-more">全部热门活动 ></text>
</view>
<view class="hot-list">
<view class="hot-card" v-for="(item, idx) in hotList" :key="idx">
<image :src="item.img" class="hot-img" mode="aspectFill" />
<view class="hot-card" v-for="(item, idx) in hotList" :key="idx" @click="goActivityDetail(item)">
<image :src="item.activityImgUrl" class="hot-img" mode="aspectFill" />
<view class="hot-info">
<text class="hot-tag">#热门活动</text>
<text class="hot-tag">{{item.title}}</text>
<text class="hot-desc">{{ item.title }}</text>
<view class="hot-meta">
<text class="hot-date">{{ item.date }}</text>
<text class="hot-status">进行中</text>
<text class="hot-status">{{ getStatusText(item.status) }}</text>
</view>
</view>
</view>
@@ -84,89 +84,86 @@
],
current: 0,
gridList: [
// {
// icon: '/static/aaaa_gd.png',
// text: '工单',
// url:'/pages/sys/workbench/order/order'
// },
// {
// icon: '/static/aaaa_yjcl.png',
// text: '预警处理',
// url:'/pages/sys/workbench/earlyWarning/earlyWarning'
//
// },
// {
// icon: '/static/aaaa_jk.png',
// text: '监控',
// url:'/pages/sys/workbench/monitor/monitors'
// },
{
icon: '/static/aaaa_bsbx.png',
text: '报事报修',
url:'/pages/sys/user/myRepair/myRepair'
},
// {
// icon: '/static/aaa_bsbx.png',
// text: '报事报修',
// url:'/pages/sys/user/myRepair/myRepair'
// },
// {
// icon: '/static/aaa_tcjf.png',
// text: '停车缴费',
// url:'/pages/sys/user/myPayment/myPayment'
// },
// {
// icon: '/static/aaa_shfw.png',
// text: '生活服务'
// },
// {
// icon: '/static/aaa_fwzx.png',
// text: '服务中心',
// url:'/pages/sys/user/serviceCenter/serviceCenter'
// },
// {
// icon: '/static/aaa_hyyy.png',
// text: '会议预约',
// url:'/pages/sys/workbench/meet/meet'
// },
// {
// icon: '/static/aaa_gdgl.png',
// text: '工单管理',
// url:'/pages/sys/workbench/order/order'
// },
// {
// icon: '/static/aaa_fkgl.png',
// text: '访客管理',
// url:'/pages/sys/user/myVisitor/myVisitor'
// },
// {
// icon: '/static/aaa_jqqd.png',
// text: '敬请期待'
// }
],
newsList: [
'数智南川|最新资讯1',
'数智南川|最新资讯2',
'数智南川|最新资讯3'
],
hotList: [{
img: '/static/aaa_hd1.png',
title: '世界骑行日 低碳出行 让城市更美好',
date: '2025-07-03'
},
{
img: '/static/aaa_hd2.png',
title: '仲夏之夜低碳出行·绿色生活让城市更美好',
date: '2025-07-03'
}
]
hotList: []
}
},
onLoad() {
this.getActivityList()
},
methods: {
onBannerChange(e) {
this.current = e.detail.current;
},
getStatusText(status) {
const statusMap = {
'1': '待进行',
'2': '进行中',
'3': '已完成'
};
return statusMap[status] || '未知状态';
},
async getActivityList() {
let res = await this.$u.api.activity.getActivity();
if (res.code == '200') {
this.hotList = res.rows;
// 处理图片链接
await this.getImageUrl();
}
},
async getImageUrl() {
// 收集所有需要获取链接的图片ID
const imgIds = [];
const imgIdToIndexMap = []; // 保存图片ID对应的hotList索引
for (let i = 0; i < this.hotList.length; i++) {
const item = this.hotList[i];
if (item.activityImgUrl) {
imgIds.push(item.activityImgUrl);
imgIdToIndexMap.push({
id: item.activityImgUrl,
index: i
});
}
}
// 如果有图片ID需要处理则调用API一次获取所有图片链接
if (imgIds.length > 0) {
try {
const imgRes = await this.$u.api.getImageUrl({}, imgIds.join(','));
if (imgRes.code == 200 && imgRes.data) {
// 将返回的图片URL映射回对应的hotList项
imgRes.data.forEach(imgItem => {
const mapping = imgIdToIndexMap.find(m => m.id === imgItem.ossId);
if (mapping) {
this.$set(this.hotList[mapping.index], 'activityImgUrl', imgItem.url);
}
});
}
} catch (error) {
console.error('获取图片链接失败:', error);
}
}
},
goActivityDetail(item){
let params = {}
params.title = item.title
params.content = item.activityContent
params.time = item.startTime
params.img = item.activityImgUrl
const itemStr = encodeURIComponent(JSON.stringify(params));
uni.navigateTo({ url: '/pages/sys/user/serviceCenter/questionDetail?item=' + itemStr });
},
// 扫码功能
goToScan() {
uni.scanCode({