Commit 95c6c758 authored by Xuguangxing's avatar Xuguangxing

feat: 增加详情页分享

parent cc244d52
...@@ -124,7 +124,8 @@ export default { ...@@ -124,7 +124,8 @@ export default {
inProgress: false, // 活动是否已经开始 inProgress: false, // 活动是否已经开始
countDownText: '', countDownText: '',
stockPercentage: 0, stockPercentage: 0,
sharePicData: {}, sharePicData: {}, // 生成海报图所需要的链接
shareInfo: {}, // 调用分享需要的参数
picUrl: '', // 海报url picUrl: '', // 海报url
// 以下是原有的data // 以下是原有的data
detailParam: { detailParam: {
...@@ -184,17 +185,23 @@ export default { ...@@ -184,17 +185,23 @@ export default {
}); });
this.$store.dispatch('goods_share_close'); this.$store.dispatch('goods_share_close');
} }
if (ev === 'weixin') {
nativeBridge.run({
event: 'showShareView',
data: this.shareInfo
});
}
}, },
outputPicUrl(res) { outputPicUrl(res) {
this.picUrl = res || ''; this.picUrl = res || '';
const shareInfo = { this.shareInfo = {
title: this.detailInfo.goodsName, title: this.detailInfo.goodsName,
desc: '', desc: '',
link: `${window.location.href}&groupBuyGroupId=${this.groupId}` || '', // 页面地址 link: `${window.location.href}&groupBuyGroupId=${this.groupId}` || '', // 页面地址
imgUrl: this.detailInfo.thumbImageUrl, // 图片地 imgUrl: this.detailInfo.thumbImageUrl, // 图片地
posterUrl: res || '' posterUrl: res || ''
}; };
this.$store.dispatch('goods_share_open', shareInfo); this.$store.dispatch('goods_share_open', this.shareInfo);
}, },
setShareData() { setShareData() {
const avatorList = []; const avatorList = [];
...@@ -215,7 +222,7 @@ export default { ...@@ -215,7 +222,7 @@ export default {
skuImg: this.detailInfo.thumbImageUrl, // y, skuImg: this.detailInfo.thumbImageUrl, // y,
activityPrice: this.detailInfo.activityPrice, // y activityPrice: this.detailInfo.activityPrice, // y
skuNo: this.detailParam.skuNo, skuNo: this.detailParam.skuNo,
peoplePhotoList: ['https://img.lkbang.net/avator/default.png'] peoplePhotoList: avatorList
}; };
this.$refs.sharePic.createAndUploadPic(); this.$refs.sharePic.createAndUploadPic();
}, },
......
...@@ -76,6 +76,8 @@ import groupBuyApi from '@/api/groupBuy'; ...@@ -76,6 +76,8 @@ import groupBuyApi from '@/api/groupBuy';
import { isApp, isWxMp } from '@/service/validation.service'; import { isApp, isWxMp } from '@/service/validation.service';
import { EventBus } from '@/service/utils.service'; import { EventBus } from '@/service/utils.service';
import sharePic from '@/components/sharePic'; import sharePic from '@/components/sharePic';
import qs from 'qs';
import config from '@/config';
export default { export default {
components: { components: {
// Goods, // Goods,
...@@ -98,6 +100,19 @@ export default { ...@@ -98,6 +100,19 @@ export default {
picUrl: '' picUrl: ''
}; };
}, },
computed: {
goodsShareInfo() {
return this.$store.state.pay.goodsShareInfo;
}
},
watch: {
goodsShareInfo: {
immediate: false,
handler(val) {
this.onShareEventChange(val);
}
}
},
created() { created() {
const { orderNo, reason, amount, freeAmount, payType } = this.$route.query; const { orderNo, reason, amount, freeAmount, payType } = this.$route.query;
const { success } = this.$route.meta; const { success } = this.$route.meta;
...@@ -111,26 +126,45 @@ export default { ...@@ -111,26 +126,45 @@ export default {
this.payStatusName = success ? '支付成功' : '支付失败'; this.payStatusName = success ? '支付成功' : '支付失败';
this.getCouponList(); this.getCouponList();
}, },
mounted() { beforeDestroy() {
const _this = this; EventBus.$off('shareClickItem');
EventBus.$on('shareClickItem', async function({ ev, nativeBridge }) { },
methods: {
async onShareEventChange({ ev, nativeBridge }) {
if (ev === 'pic') { if (ev === 'pic') {
// 处理图片url // 处理图片url
nativeBridge.openNewUrl({ nativeBridge.openNewUrl({
newUrl: `/pages/goodshare/index?url=${encodeURIComponent(JSON.stringify(_this.picUrl))}` newUrl: `/pages/goodshare/index?url=${encodeURIComponent(JSON.stringify(this.picUrl))}`
}); });
_this.$store.dispatch('goods_share_close'); this.$store.dispatch('goods_share_close');
} }
}); if (ev === 'weixin') {
}, nativeBridge.run({
beforeDestroy() { event: 'showShareView',
EventBus.$off('shareClickItem'); data: this.shareInfo
}, });
methods: { }
},
outputPicUrl(res) { outputPicUrl(res) {
this.picUrl = res; this.picUrl = res;
this.$store.dispatch('goods_share_open'); const linkPath = qs.stringify({
console.log(this.picUrl); h: 0,
skuNo: this.sharePicData.skuNo,
groupBuyGroupId: this.sharePicData.groupBuyGroupId,
goodsSpecialId: this.sharePicData.goodsSpecialId,
activityId: this.sharePicData.activityId,
templateId: this.sharePicData.templateId,
templateDetailId: this.sharePicData.templateDetailId
});
let detailUrl = `${config.localHost}/groupBuy/skuInfo?${linkPath}`;
this.shareInfo = {
title: this.sharePicData.skuName,
desc: '',
link: detailUrl || '', // 页面地址
imgUrl: this.sharePicData.skuImg, // 图片地
posterUrl: res || ''
};
this.$store.dispatch('goods_share_open', this.shareInfo);
}, },
async setShareData() { async setShareData() {
const [res, error] = await groupBuyApi.getGroupShareInfo(this.orderNo); const [res, error] = await groupBuyApi.getGroupShareInfo(this.orderNo);
...@@ -140,16 +174,6 @@ export default { ...@@ -140,16 +174,6 @@ export default {
this.sharePicData = res; this.sharePicData = res;
this.$refs.sharePic.createAndUploadPic(); this.$refs.sharePic.createAndUploadPic();
}, },
// goPay() {
// this.$track?.registeredEvents('h5_RechargeResultPageClick', {
// commodity_id: this.skuID,
// order_number: this.orderNo,
// pay_method: this.payMethodName,
// pay_status: this.payStatusName,
// buttons_name: '重新支付'
// });
// this.$router.replace({ name: 'pay', query: { orderNo: this.orderNo } });
// },
goPage(type) { goPage(type) {
if (type == 1) { if (type == 1) {
this.$router.replace({ path: '/orderList/0' }); this.$router.replace({ path: '/orderList/0' });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment