fix:修复bug
This commit is contained in:
@@ -30,7 +30,7 @@ export const getCommonByBrand = (brandName) => {
|
||||
// 查询激活的且临近关闭时间最近的活动
|
||||
export const getActiveActivity = () => {
|
||||
return request({
|
||||
url: '/app/activity/nearest-active',
|
||||
url: '/device/activity/agent/list',
|
||||
method: 'get',
|
||||
hideLoading: true
|
||||
})
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// export const URL = "https://my.gxfs123.com/api" //正式服务器
|
||||
export const URL = "https://fansdev.gxfs123.com/api" //测试服务器
|
||||
export const URL = "https://my.gxfs123.com/api" //正式服务器
|
||||
// export const URL = "https://fansdev.gxfs123.com/api" //测试服务器
|
||||
// export const URL = "http://192.168.5.149:8080" //本地调试
|
||||
// export const URL = "http://127.0.0.1:8080" //本地调试
|
||||
|
||||
|
||||
+151
-25
@@ -151,20 +151,42 @@
|
||||
</view>
|
||||
</uv-popup>
|
||||
|
||||
<!-- 活动弹窗:居中弹出,主要展示海报 -->
|
||||
<uv-popup ref="activityPopup" mode="center" round="16" :overlay="true" :closeOnClickOverlay="false" :safeAreaInsetBottom="false">
|
||||
<view class="activity-popup" v-if="activityData">
|
||||
<!-- 活动海报图片 -->
|
||||
<!-- 活动弹窗:居中弹出,支持多个活动轮播 -->
|
||||
<uv-popup ref="activityPopup" mode="center" round="16" :overlay="true" :closeOnClickOverlay="false" :safeAreaInsetBottom="false" :customStyle="{ background: 'transparent' }">
|
||||
<view class="activity-popup" v-if="activityList && activityList.length > 0">
|
||||
<!-- 轮播图 -->
|
||||
<swiper
|
||||
class="activity-swiper"
|
||||
:indicator-dots="activityList.length > 1"
|
||||
:autoplay="false"
|
||||
:circular="false"
|
||||
@change="onActivitySwiperChange"
|
||||
:current="currentActivityIndex"
|
||||
>
|
||||
<swiper-item v-for="(activity, index) in activityList" :key="index">
|
||||
<view class="activity-poster-wrapper">
|
||||
<image
|
||||
:src="activityData.imageUrl || activityData.posterUrl"
|
||||
mode="widthFix"
|
||||
:src="activity.coverImageUrl || activity.imageUrl || activity.posterUrl"
|
||||
mode="aspectFit"
|
||||
class="activity-poster"
|
||||
></image>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
<!-- 自定义指示器 -->
|
||||
<view class="activity-indicators" v-if="activityList.length > 1">
|
||||
<view
|
||||
v-for="(item, index) in activityList"
|
||||
:key="index"
|
||||
class="indicator-dot"
|
||||
:class="{ active: index === currentActivityIndex }"
|
||||
></view>
|
||||
</view>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<view class="activity-close-btn" @click="closeActivityPopup">
|
||||
<uv-icon name="close-circle-fill" size="40" color="#ffffff"></uv-icon>
|
||||
<text class="close-text">{{ $t('common.close') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</uv-popup>
|
||||
@@ -234,7 +256,9 @@ const isRelocating = ref(false) // 防抖标志:是否正在重新定位
|
||||
const showGuidePopup = ref(false) // 使用指南弹窗显示状态
|
||||
const showNoticePopup = ref(false) // 通知详情弹窗显示状态
|
||||
const showActivityPopup = ref(false) // 活动弹窗显示状态
|
||||
const activityData = ref(null) // 活动数据
|
||||
const activityList = ref([]) // 活动列表
|
||||
const currentActivityIndex = ref(0) // 当前活动索引
|
||||
const hasShownActivityThisSession = ref(false) // 本次会话是否已显示过活动(内存变量)
|
||||
|
||||
// 导航栏高度相关
|
||||
const statusBarHeight = ref(0)
|
||||
@@ -292,23 +316,51 @@ const statusBarHeight = ref(0)
|
||||
// 查询最近的活动
|
||||
const checkActiveActivity = async () => {
|
||||
try {
|
||||
// 检查是否已经显示过活动弹窗(本次会话)
|
||||
const hasShownActivity = uni.getStorageSync('hasShownActivityInSession');
|
||||
if (hasShownActivity) {
|
||||
// 检查本次会话是否已经显示过活动弹窗(使用内存变量)
|
||||
if (hasShownActivityThisSession.value) {
|
||||
console.log('本次会话已显示过活动弹窗,跳过');
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await getActiveActivity();
|
||||
if (res.code === 200 && res.data) {
|
||||
activityData.value = res.data;
|
||||
console.log('活动接口返回:', res);
|
||||
|
||||
if (res.code === 200) {
|
||||
let activities = [];
|
||||
|
||||
// 处理活动数据:兼容多种返回格式
|
||||
if (res.rows && Array.isArray(res.rows)) {
|
||||
// 格式1: { code: 200, rows: [...] }
|
||||
activities = res.rows;
|
||||
} else if (res.data && res.data.rows && Array.isArray(res.data.rows)) {
|
||||
// 格式2: { code: 200, data: { rows: [...] } }
|
||||
activities = res.data.rows;
|
||||
} else if (Array.isArray(res.data)) {
|
||||
// 格式3: { code: 200, data: [...] }
|
||||
activities = res.data;
|
||||
} else if (res.data && typeof res.data === 'object') {
|
||||
// 格式4: { code: 200, data: {...} } 单个对象
|
||||
activities = [res.data];
|
||||
}
|
||||
|
||||
// 过滤有效的活动(必须有封面图)
|
||||
activityList.value = activities.filter(item => {
|
||||
return item && (item.coverImageUrl || item.imageUrl || item.posterUrl);
|
||||
});
|
||||
|
||||
console.log('过滤后的活动列表:', activityList.value);
|
||||
|
||||
// 如果有活动数据,则显示弹窗
|
||||
if (activityList.value.length > 0) {
|
||||
currentActivityIndex.value = 0; // 重置索引
|
||||
// 延迟一下显示,避免与其他弹窗冲突
|
||||
setTimeout(() => {
|
||||
openActivityPopup();
|
||||
// 标记本次会话已显示过活动弹窗
|
||||
uni.setStorageSync('hasShownActivityInSession', true);
|
||||
// 标记本次会话已显示过活动弹窗(内存变量,小程序重启后自动重置)
|
||||
hasShownActivityThisSession.value = true;
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('查询活动失败:', e);
|
||||
}
|
||||
@@ -379,6 +431,14 @@ const activityPopup = ref(null)
|
||||
const init = async () => {
|
||||
isLoading.value = true
|
||||
try {
|
||||
// 清理旧版本的缓存键(兼容性处理)
|
||||
try {
|
||||
uni.removeStorageSync('hasShownActivityInSession');
|
||||
uni.removeStorageSync('activityLastShownDate');
|
||||
} catch (e) {
|
||||
console.warn('清理旧缓存失败:', e);
|
||||
}
|
||||
|
||||
// 开发环境测试距离计算
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
testDistanceCalculation()
|
||||
@@ -903,8 +963,15 @@ const closeActivityPopup = () => {
|
||||
try {
|
||||
showActivityPopup.value = false
|
||||
activityPopup.value && typeof activityPopup.value.close === 'function' && activityPopup.value.close()
|
||||
// 重置索引
|
||||
currentActivityIndex.value = 0
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 活动轮播图切换
|
||||
const onActivitySwiperChange = (e) => {
|
||||
currentActivityIndex.value = e.detail.current
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@@ -1736,7 +1803,7 @@ const closeActivityPopup = () => {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
/* 活动弹窗样式 - 简洁海报模式 */
|
||||
/* 活动弹窗样式 - 支持轮播 */
|
||||
.activity-popup {
|
||||
position: relative;
|
||||
width: 600rpx;
|
||||
@@ -1744,38 +1811,97 @@ const closeActivityPopup = () => {
|
||||
background: transparent;
|
||||
border-radius: 16rpx;
|
||||
overflow: visible;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
/* 覆盖 uv-popup 的默认背景色 */
|
||||
:deep(.uv-popup__content) {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.activity-swiper {
|
||||
width: 100%;
|
||||
height: 800rpx;
|
||||
max-height: 70vh;
|
||||
border-radius: 16rpx;
|
||||
background: transparent;
|
||||
|
||||
:deep(swiper) {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:deep(swiper-item) {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.activity-poster-wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
|
||||
overflow: visible;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.activity-poster {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
height: 100%;
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* 自定义指示器 */
|
||||
.activity-indicators {
|
||||
position: absolute;
|
||||
bottom: 140rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.indicator-dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.indicator-dot.active {
|
||||
width: 32rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.activity-close-btn {
|
||||
position: absolute;
|
||||
bottom: -100rpx;
|
||||
bottom: 20rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
padding: 16rpx 48rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 999;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 40rpx;
|
||||
|
||||
.close-text {
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateX(-50%) scale(0.9);
|
||||
transform: translateX(-50%) scale(0.95);
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user