Commit 34a39ff0 by Lin

feat(ActivityDetail): 添加活动详情页面及相关功能

- 新增活动详情页面,支持展示商品信息和预学习功能。
- 更新 HomeFrame 组件以支持商品详情页的跳转。
- 在 PreStudyPopup 组件中整合预学习数据,优化学习状态判断。
- 修改 ActivityTime 组件以支持商品点击事件,增强用户交互体验。
1 parent d4572b27
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</scroll-view> </scroll-view>
<!-- 活动商品展示 --> <!-- 活动商品展示 -->
<view class="goods-box"> <view class="goods-box">
<view class="goods-img-wrap"> <view class="goods-img-wrap" @click="handleGoodsDetailClick">
<image <image
class="goods-img" class="goods-img"
:src="mainImageUrl" :src="mainImageUrl"
...@@ -236,6 +236,21 @@ export default { ...@@ -236,6 +236,21 @@ export default {
this.goodsIndex = index this.goodsIndex = index
this.$emit('goodsClick', item, index) this.$emit('goodsClick', item, index)
}, },
handleGoodsDetailClick() {
const goods = this.selectedGoods
if (!goods?.id && !goods?.productId) return
const payload = {
...goods,
activityTypeLabel: this.activityTypeList[this.activityTypeIndex]?.label || '',
carSeriesName: this.isAllCarModelSelected ? '全部车型' : (this.selectedCarTab?.carSeriesName || '')
}
uni.navigateTo({
url: `/pages/common/actuvityDetail?row=${encodeURIComponent(JSON.stringify(payload))}`,
fail: (err) => {
console.error('商品详情页跳转失败:', err)
}
})
},
handleEntranceClick(item) { handleEntranceClick(item) {
this.$emit('entranceClick', item) this.$emit('entranceClick', item)
} }
...@@ -330,6 +345,7 @@ export default { ...@@ -330,6 +345,7 @@ export default {
width: 100%; width: 100%;
height: 288px; height: 288px;
overflow: hidden; overflow: hidden;
cursor: pointer;
} }
.goods-img { .goods-img {
......
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
<!-- 预学习弹框 --> <!-- 预学习弹框 -->
<StudyPopup :show.sync="showPreStudyPopup" title="提示" :width="848" :height="968" <StudyPopup :show.sync="showPreStudyPopup" title="提示" :width="848" :height="968"
:topImage="require('@/assets/images/common/warning-notice.webp')" :topImageWidth="848" :topImageHeight="248"> :topImage="require('@/assets/images/common/warning-notice.webp')" :topImageWidth="848" :topImageHeight="248">
<PreStudyPopup :confirmText="preStudyPopInfo.confirmText" @cancel="handlePreStudyCancel" <PreStudyPopup :prelearnData="prelearnData" :confirmText="preStudyPopInfo.confirmText" @cancel="handlePreStudyCancel"
@confirm="handlePreStudyConfirm" @start-study="handlePreStudyStart" /> @confirm="handlePreStudyConfirm" @start-study="handlePreStudyStart" />
</StudyPopup> </StudyPopup>
...@@ -382,7 +382,8 @@ export default { ...@@ -382,7 +382,8 @@ export default {
top: '-1000px', top: '-1000px',
left: '-1000px' left: '-1000px'
}), }),
activityProductList: [] activityProductList: [],
prelearnData: {}
} }
}, },
beforeDestroy() { beforeDestroy() {
...@@ -738,10 +739,6 @@ export default { ...@@ -738,10 +739,6 @@ export default {
this.getActivityProductList() this.getActivityProductList()
} }
}, },
async getCustomerProfileGroupInfo() {
const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({})
console.log('查询客户建档分页查询-月按天分组:', res)
},
/** /**
* 查询当前进行中的营销活动商品列表 * 查询当前进行中的营销活动商品列表
*/ */
...@@ -840,6 +837,14 @@ export default { ...@@ -840,6 +837,14 @@ export default {
this.activityProductList = res this.activityProductList = res
// console.log('查询当前进行中的营销活动商品列表:', res) // console.log('查询当前进行中的营销活动商品列表:', res)
}, },
/**
* 查询客户建档分页查询-月按天分组
*/
async getCustomerProfileGroupInfo() {
// const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({})
// console.log('查询客户建档分页查询-月按天分组:', res)
},
/** /**
* 查询预学习首页弹框信息 * 查询预学习首页弹框信息
*/ */
...@@ -858,12 +863,13 @@ export default { ...@@ -858,12 +863,13 @@ export default {
} }
], ],
"remainingSkipCount": 3, "remainingSkipCount": 3,
"shouldPopup": false, "shouldPopup": true,
"muteReason": null, "muteReason": null,
"remainingActivityCount": null "remainingActivityCount": null
} }
console.log('查询预学习首页弹框信息:', res) console.log('查询预学习首页弹框信息:', res)
if (res) { if (res) {
this.prelearnData = res
this.showPreStudyPopup = res.shouldPopup this.showPreStudyPopup = res.shouldPopup
} }
}, },
......
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
<view <view
class="course-item" class="course-item"
v-for="(item, index) in displayCourseList" v-for="(item, index) in displayCourseList"
:key="item.id || index" :key="item.activityProductId || index"
> >
<view class="course-item-title"> <view class="course-item-title">
<view class="course-item-title-text">{{ item.title }}</view> <view class="course-item-title-text">{{ item.packageName }}</view>
<view class="course-item-desc">{{ item.description }}</view> <text class="course-item-desc">{{ formatIncludes(item.includes) }}</text>
</view> </view>
<view <view
class="course-item-btn" class="course-item-btn"
v-if="item.state === 0" v-if="item.learnStatus === 'NOT_STUDY'"
@click.stop="handleStartStudy(item, index)" @click.stop="handleStartStudy(item, index)"
>开启学习</view> >开启学习</view>
<view class="course-item-btn course-item-btn--learned" v-else> <view class="course-item-btn course-item-btn--learned" v-else>
...@@ -33,21 +33,6 @@ ...@@ -33,21 +33,6 @@
</template> </template>
<script> <script>
const DEFAULT_COURSE_LIST = [
{
id: 1,
title: 'AITO 春醒悦享车衣套餐',
description: '包含:原厂定制隐形车衣 + 专属天窗....',
state: 1
},
{
id: 2,
title: 'AITO 春醒悦享车衣套餐',
description: '包含:原厂定制隐形车衣 + 专属天窗....',
state: 0
}
]
export default { export default {
name: 'PreStudyPopup', name: 'PreStudyPopup',
props: { props: {
...@@ -55,22 +40,30 @@ export default { ...@@ -55,22 +40,30 @@ export default {
type: String, type: String,
default: '跳过' default: '跳过'
}, },
courseList: { prelearnData: {
type: Array, type: Object,
default: () => [] default: () => ({})
} }
}, },
computed: { computed: {
displayCourseList() { displayCourseList() {
return this.courseList.length ? this.courseList : DEFAULT_COURSE_LIST return this.prelearnData?.packages || []
} }
}, },
methods: { methods: {
formatIncludes(includes) {
if (!includes?.length) return ''
return `包含:${includes.join(' + ')}`
},
handleStartStudy(item, index) { handleStartStudy(item, index) {
if (item.state !== 0) return if (item.learnStatus !== 'NOT_STUDY') return
this.$emit('start-study', item, index) this.$emit('start-study', item, index)
const prelearnDataStr = encodeURIComponent(JSON.stringify(this.prelearnData))
uni.navigateTo({ uni.navigateTo({
url: '/pages/common/prelearnBridge' url: `/pages/common/prelearnBridge?prelearnData=${prelearnDataStr}&entrySource=home_popup`,
fail: (err) => {
console.error('预学习桥接页跳转失败:', err)
}
}) })
}, },
handleCancel() { handleCancel() {
...@@ -140,7 +133,9 @@ export default { ...@@ -140,7 +133,9 @@ export default {
} }
.course-item-desc { .course-item-desc {
display: block;
width: 100%; width: 100%;
min-width: 0;
color: #999999; color: #999999;
font-size: toRpx(28); font-size: toRpx(28);
font-weight: 400; font-weight: 400;
......
...@@ -122,6 +122,12 @@ ...@@ -122,6 +122,12 @@
} }
}, },
{ {
"path": "pages/common/actuvityDetail",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/common/studyCenter/myTask", "path": "pages/common/studyCenter/myTask",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
......
<template>
<view class="activity-detail-page">
<view class="nav-bar">
<view class="back" @click="back">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">商品详情</view>
</view>
<scroll-view class="detail-scroll" scroll-y>
<view class="detail-content">
<view class="goods-img-wrap">
<image
class="goods-img"
:src="displayMainImage"
mode="aspectFill"
/>
<view
v-if="goodsInfo.isMainPush == 1"
class="prelearn-btn"
@click.stop="handlePrelearnClick"
>
预学习
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
const GOODS_COVER = require('@/assets/images/common/goods-activity-cover.png')
export default {
name: 'ActuvityDetail',
data() {
return {
goodsInfo: {}
}
},
computed: {
displayMainImage() {
return this.goodsInfo.mainImageUrl || this.goodsInfo.thumbImageUrl || GOODS_COVER
}
},
onLoad(options) {
console.log('[actuvityDetail] 页面入参 options:', options)
if (!options.row) {
console.warn('[actuvityDetail] 缺少 row 参数,无法加载商品信息')
return
}
try {
this.goodsInfo = JSON.parse(decodeURIComponent(options.row))
console.log('[actuvityDetail] 商品完整数据 goodsInfo:', this.goodsInfo)
console.log('[actuvityDetail] 商品名称:', this.goodsInfo.name)
console.log('[actuvityDetail] 活动时间:', this.goodsInfo.startTime, '至', this.goodsInfo.endTime)
console.log('[actuvityDetail] 是否主推:', this.goodsInfo.isMainPush)
console.log('[actuvityDetail] 活动类型:', this.goodsInfo.activityTypeLabel)
console.log('[actuvityDetail] 车型:', this.goodsInfo.carSeriesName)
console.log('[actuvityDetail] 商品描述:', this.goodsInfo.description)
console.log('[actuvityDetail] 售价:', this.goodsInfo.price)
console.log('[actuvityDetail] 原价:', this.goodsInfo.originalPrice)
console.log('[actuvityDetail] 主图:', this.goodsInfo.mainImageUrl)
console.log('[actuvityDetail] 缩略图:', this.goodsInfo.thumbImageUrl)
console.log('[actuvityDetail] 详情图:', this.goodsInfo.detailImageUrl)
console.log('[actuvityDetail] 商品ID:', this.goodsInfo.id || this.goodsInfo.productId)
} catch (error) {
console.error('[actuvityDetail] 解析商品详情参数失败:', error)
uni.showToast({
title: '商品信息加载失败',
icon: 'none'
})
}
},
methods: {
back() {
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 100
})
},
handlePrelearnClick() {
if (!this.goodsInfo?.id && !this.goodsInfo?.productId) {
uni.showToast({
title: '商品信息不完整',
icon: 'none'
})
return
}
const row = encodeURIComponent(JSON.stringify(this.goodsInfo))
uni.navigateTo({
url: `/pages/common/prelearnBridge?row=${row}&entrySource=package_detail`
})
}
}
}
</script>
<style scoped lang="scss">
.activity-detail-page {
position: relative;
width: 100vw;
height: 100vh;
background-image: url('@/assets/images/common/page-bg.webp');
background-size: 100%;
box-sizing: border-box;
padding-top: toRpx(160);
}
.nav-bar {
position: fixed;
width: 100%;
height: toRpx(96);
left: 0;
top: toRpx(48);
z-index: 999;
pointer-events: none;
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
pointer-events: auto;
}
.title {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
}
}
.detail-scroll {
height: calc(100vh - #{toRpx(160)});
}
.detail-content {
margin: 0 toRpx(64) toRpx(80);
padding-bottom: toRpx(40);
}
.goods-img-wrap {
position: relative;
width: 100%;
height: 288px;
overflow: hidden;
border-radius: 8px;
}
.goods-img {
width: 100%;
height: 288px;
display: block;
border-radius: 8px;
}
.prelearn-btn {
position: absolute;
top: 0;
right: 0;
z-index: 1;
padding: toRpx(10) toRpx(16);
border-radius: 0 8px 0 8px;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
font-size: 14px;
line-height: 14px;
font-weight: 500;
color: #ffffff;
white-space: nowrap;
&:active {
opacity: 0.85;
}
}
</style>
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,7 @@ export default {
backPopInfo: { backPopInfo: {
confirmText: '确认', confirmText: '确认',
}, },
goodsInfo: {},
prelearnContext: { prelearnContext: {
activityId: '31', activityId: '31',
activityProductId: '16', activityProductId: '16',
...@@ -136,7 +137,43 @@ export default { ...@@ -136,7 +137,43 @@ export default {
onLoad(options) { onLoad(options) {
const defaultUrl = 'http://192.168.1.68:4173/prelearning.html' const defaultUrl = 'http://192.168.1.68:4173/prelearning.html'
this.webviewUrl = options.url ? decodeURIComponent(options.url) : defaultUrl this.webviewUrl = options.url ? decodeURIComponent(options.url) : defaultUrl
console.log('[prelearn bridge demo] open url:', this.webviewUrl) console.log('[prelearnBridge] 页面入参 options:', options)
if (options.prelearnData) {
try {
const prelearnData = JSON.parse(decodeURIComponent(options.prelearnData))
console.log('[prelearnBridge] 预学习弹窗数据 prelearnData:', prelearnData)
} catch (error) {
console.error('[prelearnBridge] 解析 prelearnData 失败:', error)
}
}
if (options.entrySource) {
this.prelearnContext.entrySource = options.entrySource
}
if (options.row) {
try {
this.goodsInfo = JSON.parse(decodeURIComponent(options.row))
console.log('[prelearnBridge] 商品完整数据 goodsInfo:', this.goodsInfo)
const productId = this.goodsInfo.id || this.goodsInfo.productId || this.goodsInfo.activityProductId
if (productId) {
this.prelearnContext.activityProductId = String(productId)
}
if (this.goodsInfo.activityId) {
this.prelearnContext.activityId = String(this.goodsInfo.activityId)
}
if (!options.entrySource) {
this.prelearnContext.entrySource = 'package_detail'
}
console.log('[prelearnBridge] 更新后的 prelearnContext:', this.prelearnContext)
} catch (error) {
console.error('[prelearnBridge] 解析商品参数失败:', error)
}
}
console.log('[prelearnBridge] open url:', this.webviewUrl)
}, },
onReady() { onReady() {
this.captureChildWebview() this.captureChildWebview()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!