Commit f67492df authored by beisir's avatar beisir

feat:share 分享

parent fb7c7878
...@@ -53,6 +53,7 @@ export default { ...@@ -53,6 +53,7 @@ export default {
this.shareDialogConfirm(); this.shareDialogConfirm();
} }
const nativeBridge = this.nativeBridge; const nativeBridge = this.nativeBridge;
console.log('派发事件!');
EventBus.$emit('shareClickItem', { ev, nativeBridge }); EventBus.$emit('shareClickItem', { ev, nativeBridge });
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', { registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', {
sku_no: '', sku_no: '',
......
...@@ -151,7 +151,7 @@ export default { ...@@ -151,7 +151,7 @@ export default {
deactivated() { deactivated() {
clearTimeout((this.$refs.swipeRota && this.$refs.swipeRota.timer) || null); clearTimeout((this.$refs.swipeRota && this.$refs.swipeRota.timer) || null);
this.showLoops = false; this.showLoops = false;
EventBus.$off(); // EventBus.$off();
}, },
activated() { activated() {
this.showLoops = true; this.showLoops = true;
......
...@@ -89,7 +89,6 @@ import { isWxMp, isApp } from '@/service/validation.service'; ...@@ -89,7 +89,6 @@ import { isWxMp, isApp } from '@/service/validation.service';
import Bridge from '@qg/js-bridge'; import Bridge from '@qg/js-bridge';
import MpBridge from '@/service/mp'; import MpBridge from '@/service/mp';
import { registeredEvents } from '@/service/sa.service'; import { registeredEvents } from '@/service/sa.service';
import { EventBus } from '@/service/utils.service';
import groupBuyApi from '@/api/groupBuy'; import groupBuyApi from '@/api/groupBuy';
export default { export default {
name: 'OrderSkuList', name: 'OrderSkuList',
...@@ -151,9 +150,6 @@ export default { ...@@ -151,9 +150,6 @@ export default {
if (isApp) this.nativeBridge = new Bridge(); if (isApp) this.nativeBridge = new Bridge();
else if (isWxMp) this.nativeBridge = new MpBridge(); else if (isWxMp) this.nativeBridge = new MpBridge();
}, },
mounted() {
this.onShareEventChange();
},
methods: { methods: {
goGroupDetails(skuInfo) { goGroupDetails(skuInfo) {
this.nativeBridge.openNewUrl({ this.nativeBridge.openNewUrl({
...@@ -168,9 +164,10 @@ export default { ...@@ -168,9 +164,10 @@ export default {
console.log(res); console.log(res);
}, },
async openShareEvent(skuInfo) { async openShareEvent(skuInfo) {
this.$emit('option-click', { ...skuInfo, eventType: 'share' });
// this.getGroupShareInfo('1440970158226214912'); // this.getGroupShareInfo('1440970158226214912');
this.shareInfo = skuInfo; // this.shareInfo = skuInfo;
this.$store.dispatch('goods_share_open'); // this.$store.dispatch('goods_share_open');
registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', { registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', {
sku_no: '', sku_no: '',
...@@ -198,38 +195,6 @@ export default { ...@@ -198,38 +195,6 @@ export default {
}, },
onOptionClick(orderInfo, eventType) { onOptionClick(orderInfo, eventType) {
this.$emit(EVENT_CLICK, { 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'; ...@@ -34,6 +34,8 @@ import groupBuyApi from '@/api/groupBuy';
import List from './components/List'; import List from './components/List';
import { isApp } from '@/service/validation.service'; import { isApp } from '@/service/validation.service';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import { EventBus } from '@/service/utils.service';
import qs from 'qs';
const commonParams = { const commonParams = {
loading: false, loading: false,
finished: false, finished: false,
...@@ -78,9 +80,56 @@ export default { ...@@ -78,9 +80,56 @@ export default {
mounted() { mounted() {
this.getstatusQuery(); this.getstatusQuery();
this.getList(); this.getList();
this.onShareEventChange();
// this.$track.registeredEvents('H5_2B_MyOrderPageExposure'); // this.$track.registeredEvents('H5_2B_MyOrderPageExposure');
}, },
methods: { 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() { getstatusQuery() {
const { status } = this.$route.params || {}; const { status } = this.$route.params || {};
status && (this.currentTab = Number(status)); status && (this.currentTab = Number(status));
...@@ -93,34 +142,14 @@ export default { ...@@ -93,34 +142,14 @@ export default {
handleLoad() { handleLoad() {
this.getList(); this.getList();
}, },
openShareEvent() {
this.$store.dispatch('goods_share_open');
},
handleOptionClick(info) { handleOptionClick(info) {
const { orderInfo } = info || {}; this.currentOrder = info;
const { cashCouponCancelNote, showCashCouponCancelNote } = orderInfo || {};
this.currentOrder = orderInfo;
switch (info.eventType) { switch (info.eventType) {
case 'cancel': case 'share':
this.orderCancelPopup(); this.openShareEvent();
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();
break; break;
default: default:
this.currentOrder = {}; 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