Commit f67492df authored by beisir's avatar beisir

feat:share 分享

parent fb7c7878
......@@ -53,6 +53,7 @@ export default {
this.shareDialogConfirm();
}
const nativeBridge = this.nativeBridge;
console.log('派发事件!');
EventBus.$emit('shareClickItem', { ev, nativeBridge });
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', {
sku_no: '',
......
......@@ -151,7 +151,7 @@ export default {
deactivated() {
clearTimeout((this.$refs.swipeRota && this.$refs.swipeRota.timer) || null);
this.showLoops = false;
EventBus.$off();
// EventBus.$off();
},
activated() {
this.showLoops = true;
......
......@@ -89,7 +89,6 @@ import { isWxMp, isApp } from '@/service/validation.service';
import Bridge from '@qg/js-bridge';
import MpBridge from '@/service/mp';
import { registeredEvents } from '@/service/sa.service';
import { EventBus } from '@/service/utils.service';
import groupBuyApi from '@/api/groupBuy';
export default {
name: 'OrderSkuList',
......@@ -151,9 +150,6 @@ export default {
if (isApp) this.nativeBridge = new Bridge();
else if (isWxMp) this.nativeBridge = new MpBridge();
},
mounted() {
this.onShareEventChange();
},
methods: {
goGroupDetails(skuInfo) {
this.nativeBridge.openNewUrl({
......@@ -168,9 +164,10 @@ export default {
console.log(res);
},
async openShareEvent(skuInfo) {
this.$emit('option-click', { ...skuInfo, eventType: 'share' });
// this.getGroupShareInfo('1440970158226214912');
this.shareInfo = skuInfo;
this.$store.dispatch('goods_share_open');
// this.shareInfo = skuInfo;
// this.$store.dispatch('goods_share_open');
registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', {
sku_no: '',
......@@ -198,38 +195,6 @@ export default {
},
onOptionClick(orderInfo, eventType) {
this.$emit(EVENT_CLICK, { orderInfo, eventType });
},
async getShareData(shareInfo) {
return {
title: shareInfo.skuName,
link: `${window.location.origin}/activity/zeroBuy`, // 页面地址
imgUrl: shareInfo.skuImg // 图片地
};
},
onShareEventChange() {
EventBus.$on('shareClickItem', async function({ ev, nativeBridge }) {
if (ev === 'pic') {
// 分享海报跳转小程序海报分享页面
// nativeBridge.openNewUrl({
// newUrl: `/pages/goodshare/index?url=${encodeURIComponent(
// JSON.stringify(shareDic.posterUrl)
// )}`
// });
}
if (ev === 'weixin') {
// const res = await groupBuyApi.getGroupShareInfo(this.shareInfo.order);
const [res] = await groupBuyApi.getGroupShareInfo('1440884214932389888');
console.log(res);
const shareDic = await this.getShareData(res);
// 分享朋友派发微信postMessage事件
nativeBridge.run({
event: 'showShareView',
data: {
shareDic
}
});
}
});
}
}
};
......
......@@ -34,6 +34,8 @@ import groupBuyApi from '@/api/groupBuy';
import List from './components/List';
import { isApp } from '@/service/validation.service';
import localStorage from '@/service/localStorage.service';
import { EventBus } from '@/service/utils.service';
import qs from 'qs';
const commonParams = {
loading: false,
finished: false,
......@@ -78,9 +80,56 @@ export default {
mounted() {
this.getstatusQuery();
this.getList();
this.onShareEventChange();
// this.$track.registeredEvents('H5_2B_MyOrderPageExposure');
},
methods: {
async getShareData(shareInfo) {
const linkPath = qs.stringify({
h: 0,
skuNo: shareInfo.skuNo,
groupBuyGroupId: shareInfo.activityHundredGroupId,
goodsSpecialId: shareInfo.specialId,
activityId: shareInfo.activityInfoId,
templateId: shareInfo.templateId,
templateDetailId: shareInfo.templateId
});
return Promise.resolve({
title: shareInfo.skuName,
link: `pages/webview/webview?url=${window.location.origin}?url=${encodeURIComponent(
JSON.stringify(linkPath)
)}`, // 页面地址
imgUrl: shareInfo.skuImg // 图片地
});
},
onShareEventChange() {
const vm = this;
console.log('update');
EventBus.$on('shareClickItem', async function({ ev, nativeBridge }) {
console.log(ev);
if (ev === 'pic') {
// 分享海报跳转小程序海报分享页面
// nativeBridge.openNewUrl({
// newUrl: `/pages/goodshare/index?url=${encodeURIComponent(
// JSON.stringify(shareDic.posterUrl)
// )}`
// });
}
if (ev === 'weixin') {
console.log('监听事件');
// const res = await groupBuyApi.getGroupShareInfo(this.shareInfo.order);
const [res] = await groupBuyApi.getGroupShareInfo('1440884214932389888');
const shareDic = await vm.getShareData(res);
// 分享朋友派发微信postMessage事件
nativeBridge.run({
event: 'showShareView',
data: {
shareDic
}
});
}
});
},
getstatusQuery() {
const { status } = this.$route.params || {};
status && (this.currentTab = Number(status));
......@@ -93,34 +142,14 @@ export default {
handleLoad() {
this.getList();
},
openShareEvent() {
this.$store.dispatch('goods_share_open');
},
handleOptionClick(info) {
const { orderInfo } = info || {};
const { cashCouponCancelNote, showCashCouponCancelNote } = orderInfo || {};
this.currentOrder = orderInfo;
this.currentOrder = info;
switch (info.eventType) {
case 'cancel':
this.orderCancelPopup();
break;
case 'pay':
this.toPay();
break;
case 'notify':
this.orderNotify();
break;
case 'again':
this.toGoods();
break;
case 'logistics':
this.expressActionsCheck();
break;
case 'confirm':
this.orderConfirmPopup();
break;
case 'toRefund':
this.orderRefundPopup(cashCouponCancelNote, showCashCouponCancelNote);
break;
case 'refund':
this.toRefund();
case 'share':
this.openShareEvent();
break;
default:
this.currentOrder = {};
......
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