Feat(专题页):1、第一张图片点击领取优惠券;2、增加转发标题和图片

This commit is contained in:
lifizer
2025-07-24 11:22:57 +08:00
parent 3b3d39f460
commit 199912c4da
7 changed files with 127 additions and 8 deletions
@@ -4,6 +4,7 @@
:src="topImage"
class="top-img"
mode="widthFix"
@click="topImageClick"
/>
<view class="page-wrap">
<view class="page-2">
@@ -4,6 +4,7 @@
:src="topImage"
class="top-img"
mode="widthFix"
@click="topImageClick"
/>
<view class="page-wrap">
<view class="page-2">
@@ -4,6 +4,7 @@
:src="topImage"
class="top-img"
mode="widthFix"
@click="topImageClick"
/>
<!-- 第二页 -->
<view class="page-wrap">
@@ -4,6 +4,7 @@
:src="topImage"
class="top-img"
mode="widthFix"
@click="topImageClick"
/>
<!-- 第二页 -->
<view class="page-wrap">
+19
View File
@@ -1,3 +1,4 @@
import { getCouponReceive } from '@/api/user'
export const themeTemplateMixins = {
props: {
topImage: {
@@ -12,6 +13,24 @@ export const themeTemplateMixins = {
}
},
methods: {
topImageClick() {
if (this.templateProperties.page1CouponEnable === 1 && this.templateProperties.page1CouponId) {
getCouponReceive(this.templateProperties.page1CouponId).then(res => {
if (res.status === 200) {
uni.showToast({
title: '领取成功',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err.data.msg + '',
icon: 'none',
duration: 3000
})
})
}
},
itemClick(item) {
if (!item.available) return
this.$emit('view', item)
+53 -4
View File
@@ -15,6 +15,7 @@
:src="topImage"
class="top-img"
mode="widthFix"
@click="topImageClick"
/>
<view
v-for="(content, cIndex) in contents"
@@ -79,6 +80,7 @@
* options.theme:best-尖货,''-节日
*/
import { getFestivalV2, getContentBest } from '@/api/product'
import { getCouponReceive } from '@/api/user'
import { pageListenMixins } from '@/mixins/pageListenMixins'
import ThemePageTemplate1 from '../components/ThemePageTemplate1.vue'
import ThemePageTemplate2 from '../components/ThemePageTemplate2.vue'
@@ -96,6 +98,8 @@ export default {
data() {
return {
isLoad: false,
theme: '',
pageData: {},
topImage: '',
contents: [],
pageKeyId: '',
@@ -107,6 +111,7 @@ export default {
onLoad(options) {
const theme = options.theme || ''
const id = options.id
this.theme = theme
// 尖货
if (theme === 'best') {
this.pageKeyId = `appContentBest_id_${id}`
@@ -116,6 +121,34 @@ export default {
this.getFestivalReq()
}
},
onShareAppMessage() {
if (this.pageData.forwardTitle && this.pageData.forwardImage) {
return {
title: this.pageData.forwardTitle,
path: `/pkg_product/views/festival?id=${this.pageData.id}&from=index&theme=${this.theme}`,
imageUrl: this.pageData.forwardImage
}
} else {
return {
title: this.share.title,
path: this.share.path,
imageUrl: this.share.imageUrl,
desc: this.share.desc,
content: this.share.content,
success(res){
uni.showToast({
title:'分享成功'
})
},
fail(res){
uni.showToast({
title:'分享失败',
icon:'none'
})
}
}
}
},
methods: {
getFestivalReq() {
/*旧接口
@@ -137,6 +170,7 @@ export default {
})
},
renderTemplateData(data) {
this.pageData = data
const contents = []
if (data.templateProperties) {
const templateKey = data.templateKey
@@ -156,15 +190,30 @@ export default {
products: temp.page3Links
})
}
// 模板1
if (['template_1', 'template_2', 'template_3', 'template_4'].includes(templateKey)) {
this.templateProperties = temp
}
}
this.templateProperties = data.templateProperties || {}
this.templateKey = data.templateKey
this.contents = contents
this.isLoad = true
},
topImageClick() {
if (this.templateProperties.page1CouponEnable === 1 && this.templateProperties.page1CouponId) {
getCouponReceive(this.templateProperties.page1CouponId).then(res => {
if (res.status === 200) {
uni.showToast({
title: '领取成功',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err.data.msg + '',
icon: 'none',
duration: 3000
})
})
}
},
goGoodsOrShop(item) {
const id = item.linkId
const type = item.type || 1
+51 -4
View File
@@ -15,6 +15,7 @@
:src="topImage"
mode="widthFix"
class="top-img"
@click="topImageClick"
/>
<view
v-for="(content, cIndex) in contents"
@@ -76,6 +77,7 @@
<script>
// 民宿专题
import { getHomestayV2 } from '@/api/product'
import { getCouponReceive } from '@/api/user'
import { pageListenMixins } from '@/mixins/pageListenMixins'
import ThemePageTemplate1 from '../components/ThemePageTemplate1.vue'
import ThemePageTemplate2 from '../components/ThemePageTemplate2.vue'
@@ -93,6 +95,7 @@ export default {
data() {
return {
isLoad: false,
pageData: {},
topImage: '',
contents: [],
pageKeyId: '',
@@ -106,6 +109,34 @@ export default {
this.pageKeyId = `appContentHomestay_id_${id}`
this.getHomestayReq(id)
},
onShareAppMessage() {
if (this.pageData.forwardTitle && this.pageData.forwardImage) {
return {
title: this.pageData.forwardTitle,
path: `/pkg_product/views/homestay?id=${this.pageData.id}`,
imageUrl: this.pageData.forwardImage
}
} else {
return {
title: this.share.title,
path: this.share.path,
imageUrl: this.share.imageUrl,
desc: this.share.desc,
content: this.share.content,
success(res){
uni.showToast({
title:'分享成功'
})
},
fail(res){
uni.showToast({
title:'分享失败',
icon:'none'
})
}
}
}
},
methods: {
getHomestayReq(id) {
/*旧接口
@@ -120,6 +151,7 @@ export default {
})
},
renderTemplateData(data) {
this.pageData = data
const contents = []
if (data.templateProperties) {
const templateKey = data.templateKey
@@ -144,15 +176,30 @@ export default {
list: temp.page4Links
})
}
// 模板1
if (['template_1', 'template_2', 'template_3', 'template_4'].includes(templateKey)) {
this.templateProperties = temp
}
}
this.templateProperties = data.templateProperties || {}
this.templateKey = data.templateKey
this.contents = contents
this.isLoad = true
},
topImageClick() {
if (this.templateProperties.page1CouponEnable === 1 && this.templateProperties.page1CouponId) {
getCouponReceive(this.templateProperties.page1CouponId).then(res => {
if (res.status === 200) {
uni.showToast({
title: '领取成功',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err.data.msg + '',
icon: 'none',
duration: 3000
})
})
}
},
goGoodsOrShop(item) {
const id = item.linkId
const type = item.type || 1