diff --git a/pkg_product/mixins/themeMixins.js b/pkg_product/mixins/themeMixins.js new file mode 100644 index 0000000..c0f915b --- /dev/null +++ b/pkg_product/mixins/themeMixins.js @@ -0,0 +1,87 @@ +import { getCouponReceive } from '@/api/user' +export const themeMixins = { + data() { + return { + isLoad: false, + pageData: {}, + topImage: '', + contents: [], + pageKeyId: '', + templateKey: '', + // 模板数据 + templateProperties: {} + } + }, + 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: { + 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.msg + '', + icon: 'none', + duration: 3000 + }) + }) + } + }, + goGoodsOrShop(item) { + const id = item.linkId + const type = item.type || 1 + if (type === 1) { + uni.navigateTo({ + url: `/pages/shop/GoodsCon/index?id=${id}&from=festival` + }) + } + if (type === 2) { + uni.navigateTo({ + url: `/pagesInn/inn/innHome?id=${id}&from=festival` + }) + } + if (type === 3) { + uni.navigateTo({ + url: `/pages/town/index?id=${id}&from=festival` + }) + } + if (type === 4) { + uni.navigateTo({ + url: `/pkg_product/views/famousQianxianShop?id=${id}&from=festival` + }) + } + } + } +} \ No newline at end of file diff --git a/pkg_product/mixins/themeTemplateMixins.js b/pkg_product/mixins/themeTemplateMixins.js index b96c586..9921943 100644 --- a/pkg_product/mixins/themeTemplateMixins.js +++ b/pkg_product/mixins/themeTemplateMixins.js @@ -24,7 +24,7 @@ export const themeTemplateMixins = { } }).catch((err) => { uni.showToast({ - title: err.data.msg + '', + title: err.msg + '', icon: 'none', duration: 3000 }) diff --git a/pkg_product/views/festival.vue b/pkg_product/views/festival.vue index 3a85ea5..735708f 100644 --- a/pkg_product/views/festival.vue +++ b/pkg_product/views/festival.vue @@ -80,8 +80,8 @@ * options.theme:best-尖货,''-节日 */ import { getFestivalV2, getContentBest } from '@/api/product' -import { getCouponReceive } from '@/api/user' import { pageListenMixins } from '@/mixins/pageListenMixins' +import { themeMixins } from '../mixins/themeMixins' import ThemePageTemplate1 from '../components/ThemePageTemplate1.vue' import ThemePageTemplate2 from '../components/ThemePageTemplate2.vue' import ThemePageTemplate3 from '../components/ThemePageTemplate3.vue' @@ -94,20 +94,7 @@ export default { ThemePageTemplate3, ThemePageTemplate4 }, - mixins: [pageListenMixins], - data() { - return { - isLoad: false, - theme: '', - pageData: {}, - topImage: '', - contents: [], - pageKeyId: '', - templateKey: '', - // 模板数据 - templateProperties: {} - } - }, + mixins: [pageListenMixins, themeMixins], onLoad(options) { const theme = options.theme || '' const id = options.id @@ -121,34 +108,6 @@ 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() { /*旧接口 @@ -195,48 +154,6 @@ export default { 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 - if (type === 1) { - uni.navigateTo({ - url: `/pages/shop/GoodsCon/index?id=${id}&from=festival` - }) - } - if (type === 2) { - uni.navigateTo({ - url: `/pagesInn/inn/innHome?id=${id}&from=festival` - }) - } - if (type === 3) { - uni.navigateTo({ - url: `/pages/town/index?id=${id}&from=festival` - }) - } - if (type === 4) { - uni.navigateTo({ - url: `/pkg_product/views/famousQianxianShop?id=${id}&from=festival` - }) - } } } } diff --git a/pkg_product/views/homestay.vue b/pkg_product/views/homestay.vue index e871214..9279634 100644 --- a/pkg_product/views/homestay.vue +++ b/pkg_product/views/homestay.vue @@ -77,8 +77,8 @@