fix(activity): 优化详情字典加载及界面样式
parent
f1f91afa38
commit
0e6751c4ce
|
|
@ -655,6 +655,7 @@ const handleBannerTap = (item) => {
|
|||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
padding: 19rpx;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.activity-cover {
|
||||
width: 100%;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<view class="info-row location-row">
|
||||
<image class="row-icon" src="/static/img/dw.png" mode="aspectFit" />
|
||||
<text class="location-text">{{ activityInfo.location }}</text>
|
||||
<image class="row-icon navigation-icon" src="/static/img/dh.png" mode="aspectFit" @tap="openNavigation" />
|
||||
<!-- <image class="row-icon navigation-icon" src="/static/img/dh.png" mode="aspectFit" @tap="openNavigation" /> -->
|
||||
</view>
|
||||
|
||||
<!-- 服务类别 -->
|
||||
|
|
@ -134,6 +134,7 @@
|
|||
import { ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import ActivityApi from '@/sheep/api/community/activity';
|
||||
import DictApi from '@/sheep/api/system/dict';
|
||||
import sheep from '@/sheep';
|
||||
|
||||
// 当前Tab
|
||||
|
|
@ -157,13 +158,43 @@ const activityInfo = ref({
|
|||
introduction: '',
|
||||
});
|
||||
|
||||
// 字典映射(动态加载)
|
||||
const serviceCategoryMap = ref({});
|
||||
const serviceTargetMap = ref({});
|
||||
|
||||
// 页面加载
|
||||
onLoad((options) => {
|
||||
// 并行加载字典
|
||||
loadDictMaps();
|
||||
if (options.id) {
|
||||
loadActivityDetail(options.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 加载字典映射
|
||||
async function loadDictMaps() {
|
||||
const [categoryRes, targetRes] = await Promise.all([
|
||||
DictApi.getDictDataListByType('comm_activity_service_category'),
|
||||
DictApi.getDictDataListByType('comm_activity_service_target'),
|
||||
]);
|
||||
|
||||
if (categoryRes.code === 0 && categoryRes.data) {
|
||||
const map = {};
|
||||
categoryRes.data.forEach((item) => {
|
||||
map[item.value] = item.label;
|
||||
});
|
||||
serviceCategoryMap.value = map;
|
||||
}
|
||||
|
||||
if (targetRes.code === 0 && targetRes.data) {
|
||||
const map = {};
|
||||
targetRes.data.forEach((item) => {
|
||||
map[item.value] = item.label;
|
||||
});
|
||||
serviceTargetMap.value = map;
|
||||
}
|
||||
}
|
||||
|
||||
// 安全解析 JSON 字符串
|
||||
function safeJsonParse(str, defaultVal = []) {
|
||||
if (!str) return defaultVal;
|
||||
|
|
@ -174,26 +205,6 @@ function safeJsonParse(str, defaultVal = []) {
|
|||
}
|
||||
}
|
||||
|
||||
// 服务类别映射
|
||||
const serviceCategoryMap = {
|
||||
1: '社区服务',
|
||||
2: '敬老服务',
|
||||
3: '助残服务',
|
||||
4: '关爱儿童',
|
||||
5: '环保宣传',
|
||||
6: '文明礼仪',
|
||||
7: '文化教育',
|
||||
};
|
||||
|
||||
// 服务对象映射
|
||||
const serviceTargetMap = {
|
||||
1: '儿童',
|
||||
2: '孤寡老人',
|
||||
3: '残障人士',
|
||||
4: '优抚对象',
|
||||
5: '其他',
|
||||
};
|
||||
|
||||
// 加载活动详情
|
||||
async function loadActivityDetail(id) {
|
||||
const { code, data } = await ActivityApi.getDetail(id);
|
||||
|
|
@ -203,8 +214,8 @@ async function loadActivityDetail(id) {
|
|||
title: data.title || '',
|
||||
banners: safeJsonParse(data.bannerImages, [data.coverImage]).filter(Boolean),
|
||||
location: data.location || '',
|
||||
serviceTypes: (data.serviceCategories || []).map((id) => serviceCategoryMap[id] || id),
|
||||
targetAudience: (data.serviceTargets|| []).map((id) => serviceTargetMap[id] || id),
|
||||
serviceTypes: (data.serviceCategories || []).map((id) => serviceCategoryMap.value[id] || id),
|
||||
targetAudience: (data.serviceTargets || []).map((id) => serviceTargetMap.value[id] || id),
|
||||
registerDate: data.registrationStartTime && data.registrationEndTime
|
||||
? `${sheep.$helper.timeFormat(data.registrationStartTime, 'yyyy/mm/dd')} - ${sheep.$helper.timeFormat(data.registrationEndTime, 'yyyy/mm/dd')}`
|
||||
: '',
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
<!-- 右下角浮动按钮 -->
|
||||
<view class="float-btn" @tap="handleFloatBtn">
|
||||
<text class="sicon-edit"></text>
|
||||
<image class="float-icon" src="/static/sicon-edit.png" mode="aspectFit" />
|
||||
</view>
|
||||
</view>
|
||||
</s-layout>
|
||||
|
|
@ -330,12 +330,10 @@ function handleFloatBtn() {
|
|||
bottom: 80rpx;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background: linear-gradient(135deg, #FA7E49 0%, #E86935 100%);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 8rpx 24rpx rgba(250, 126, 73, 0.4);
|
||||
z-index: 99;
|
||||
|
||||
&:active {
|
||||
|
|
@ -343,9 +341,10 @@ function handleFloatBtn() {
|
|||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.sicon-edit {
|
||||
font-size: 44rpx;
|
||||
color: #FFFFFF;
|
||||
.float-icon {
|
||||
width: 130rpx;
|
||||
height: 130rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Loading…
Reference in New Issue