fix(activity): 优化详情字典加载及界面样式
parent
f1f91afa38
commit
0e6751c4ce
|
|
@ -655,6 +655,7 @@ const handleBannerTap = (item) => {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||||
padding: 19rpx;
|
padding: 19rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
.activity-cover {
|
.activity-cover {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
<view class="info-row location-row">
|
<view class="info-row location-row">
|
||||||
<image class="row-icon" src="/static/img/dw.png" mode="aspectFit" />
|
<image class="row-icon" src="/static/img/dw.png" mode="aspectFit" />
|
||||||
<text class="location-text">{{ activityInfo.location }}</text>
|
<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>
|
</view>
|
||||||
|
|
||||||
<!-- 服务类别 -->
|
<!-- 服务类别 -->
|
||||||
|
|
@ -134,6 +134,7 @@
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import ActivityApi from '@/sheep/api/community/activity';
|
import ActivityApi from '@/sheep/api/community/activity';
|
||||||
|
import DictApi from '@/sheep/api/system/dict';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
|
|
||||||
// 当前Tab
|
// 当前Tab
|
||||||
|
|
@ -157,13 +158,43 @@ const activityInfo = ref({
|
||||||
introduction: '',
|
introduction: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 字典映射(动态加载)
|
||||||
|
const serviceCategoryMap = ref({});
|
||||||
|
const serviceTargetMap = ref({});
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
|
// 并行加载字典
|
||||||
|
loadDictMaps();
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
loadActivityDetail(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 字符串
|
// 安全解析 JSON 字符串
|
||||||
function safeJsonParse(str, defaultVal = []) {
|
function safeJsonParse(str, defaultVal = []) {
|
||||||
if (!str) return 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) {
|
async function loadActivityDetail(id) {
|
||||||
const { code, data } = await ActivityApi.getDetail(id);
|
const { code, data } = await ActivityApi.getDetail(id);
|
||||||
|
|
@ -203,8 +214,8 @@ async function loadActivityDetail(id) {
|
||||||
title: data.title || '',
|
title: data.title || '',
|
||||||
banners: safeJsonParse(data.bannerImages, [data.coverImage]).filter(Boolean),
|
banners: safeJsonParse(data.bannerImages, [data.coverImage]).filter(Boolean),
|
||||||
location: data.location || '',
|
location: data.location || '',
|
||||||
serviceTypes: (data.serviceCategories || []).map((id) => serviceCategoryMap[id] || id),
|
serviceTypes: (data.serviceCategories || []).map((id) => serviceCategoryMap.value[id] || id),
|
||||||
targetAudience: (data.serviceTargets|| []).map((id) => serviceTargetMap[id] || id),
|
targetAudience: (data.serviceTargets || []).map((id) => serviceTargetMap.value[id] || id),
|
||||||
registerDate: data.registrationStartTime && data.registrationEndTime
|
registerDate: data.registrationStartTime && data.registrationEndTime
|
||||||
? `${sheep.$helper.timeFormat(data.registrationStartTime, 'yyyy/mm/dd')} - ${sheep.$helper.timeFormat(data.registrationEndTime, 'yyyy/mm/dd')}`
|
? `${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">
|
<view class="float-btn" @tap="handleFloatBtn">
|
||||||
<text class="sicon-edit"></text>
|
<image class="float-icon" src="/static/sicon-edit.png" mode="aspectFit" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</s-layout>
|
</s-layout>
|
||||||
|
|
@ -330,12 +330,10 @@ function handleFloatBtn() {
|
||||||
bottom: 80rpx;
|
bottom: 80rpx;
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
background: linear-gradient(135deg, #FA7E49 0%, #E86935 100%);
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
box-shadow: 0 8rpx 24rpx rgba(250, 126, 73, 0.4);
|
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
|
|
@ -343,9 +341,10 @@ function handleFloatBtn() {
|
||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sicon-edit {
|
.float-icon {
|
||||||
font-size: 44rpx;
|
width: 130rpx;
|
||||||
color: #FFFFFF;
|
height: 130rpx;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Loading…
Reference in New Issue