Commit 7bdf6a64 authored by beisir's avatar beisir

feat:update shareGroup

parent bfa869a1
...@@ -52,5 +52,8 @@ export default { ...@@ -52,5 +52,8 @@ export default {
return http.get(`${talosHost}/api/kdsp/group-order/list`, { return http.get(`${talosHost}/api/kdsp/group-order/list`, {
params params
}); });
},
getGroupShareInfo(orderNo) {
return http.get(`${talosHost}/api/kdsp/groupShareInfo?orderNo=${orderNo}`);
} }
}; };
...@@ -34,7 +34,6 @@ export default { ...@@ -34,7 +34,6 @@ export default {
}), }),
showShare: { showShare: {
get() { get() {
console.log(this.$store.state.pay);
return this.$store.state.pay.showShare; return this.$store.state.pay.showShare;
}, },
set() { set() {
...@@ -50,24 +49,11 @@ export default { ...@@ -50,24 +49,11 @@ export default {
methods: { methods: {
shareCloseChange() {}, shareCloseChange() {},
bundleShareClickItem(ev) { bundleShareClickItem(ev) {
if (ev === 'wexin') { if (ev === 'weixin') {
this.shareDialogConfirm(); this.shareDialogConfirm();
} }
EventBus.$emit('shareClickItem', ev); const nativeBridge = this.nativeBridge;
// if (ev === 'pic') { EventBus.$emit('shareClickItem', { ev, nativeBridge });
// const { posterUrl } = this.shareInfo;
// this.nativeBridge.openNewUrl({
// newUrl: `/pages/goodshare/index?url=${encodeURIComponent(JSON.stringify(posterUrl))}`
// });
// }
// if (ev === 'weixin') {
// this.nativeBridge.run({
// event: 'showShareView',
// data: {
// shareDic: this.shareInfo
// }
// });
// }
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', { registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', {
sku_no: '', sku_no: '',
buttons_name: '', // 按钮名称 buttons_name: '', // 按钮名称
......
<template> <template>
<!-- 配置活动背景色 --> <!-- 配置活动背景色 -->
<div class="group" :style="{ backgroundColor: topicCfg.bgcolor }"> <div class="group" :style="{ backgroundColor: goodsTemp.bgcolor }">
<div v-if="!isShowShare" class="group-puzzle" @click="goToMyorder">我的拼团</div> <div v-if="!isShowShare" class="group-puzzle" @click="goToMyorder">我的拼团</div>
<!-- 配置头部动态信息 start --> <!-- 配置头部动态信息 start -->
<div class="group-top"> <div class="group-top">
<!-- 动态活动背景图 --> <!-- 动态活动背景图 -->
<cr-image width="100%" height="100%" class="group-top-image" :src="topicCfg.img" /> <cr-image width="100%" height="100%" class="group-top-image" :src="goodsTemp.img" />
</div> </div>
<!-- 配置头部动态信息 end --> <!-- 配置头部动态信息 end -->
...@@ -20,21 +20,21 @@ ...@@ -20,21 +20,21 @@
<groupSwiper <groupSwiper
v-if="showLoops" v-if="showLoops"
ref="swipeRota" ref="swipeRota"
:avator-data="topicCfg.groupBuyUserInfoList" :avator-data="goodsTemp.groupBuyUserInfoList"
@animation-event-start="animationEventStart" @animation-event-start="animationEventStart"
@animation-event-end="animationEventEnd" @animation-event-end="animationEventEnd"
/> />
</div> </div>
</div> </div>
<div class="group-portrait-num" @click="showSwipe = !showSwipe"> <div class="group-portrait-num" @click="showSwipe = !showSwipe">
已有 {{ topicCfg.groupBuyUserCount }}人 参与拼单 已有 {{ goodsTemp.groupBuyUserCount }}人 参与拼单
</div> </div>
</div> </div>
<div class="group-list"> <div class="group-list">
<div class="list-title"> <div class="list-title">
<b class="list-title-text">今日拼团</b> <b class="list-title-text">今日拼团</b>
<div class="list-count"> <div class="list-count">
<span class="list-count-label">{{ topicCfg.stateTxt }}</span> <span class="list-count-label">{{ goodsTemp.stateTxt }}</span>
<count-down :end-time="gpCountDown" @finish-time="finishTimeChange" /> <count-down :end-time="gpCountDown" @finish-time="finishTimeChange" />
</div> </div>
</div> </div>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
:key="index" :key="index"
:index="index" :index="index"
:goods-item="item" :goods-item="item"
:topic-cfg="topicCfg" :topic-cfg="goodsTemp"
@on-button-click="handleBtnClick" @on-button-click="handleBtnClick"
/> />
</cr-list> </cr-list>
...@@ -79,13 +79,12 @@ import countDown from '@/components/countDown'; ...@@ -79,13 +79,12 @@ import countDown from '@/components/countDown';
import swipeCustomerInfo from '@/components/swipeCustomerInfo'; import swipeCustomerInfo from '@/components/swipeCustomerInfo';
import goodsCard from './components/goodsCard'; import goodsCard from './components/goodsCard';
import groupSwiper from '@/components/groupSwiper'; import groupSwiper from '@/components/groupSwiper';
import { isNull } from '@/service/validation.service';
import { handleRemainTime, handleDateFormat } from './components/utils'; import { handleRemainTime, handleDateFormat } from './components/utils';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import goodsCheckMixin from '@/mixins/goodsCheck.mixin'; import goodsCheckMixin from '@/mixins/goodsCheck.mixin';
import { setAppTitleColor, EventBus } from '@/service/utils.service'; import { setAppTitleColor, EventBus } from '@/service/utils.service';
import { registeredEvents } from '@/service/sa.service'; import { registeredEvents } from '@/service/sa.service';
let topicIndex; console.log(EventBus);
export default { export default {
// eslint-disable-next-line vue/name-property-casing // eslint-disable-next-line vue/name-property-casing
name: 'groupBuyList', name: 'groupBuyList',
...@@ -104,8 +103,7 @@ export default { ...@@ -104,8 +103,7 @@ export default {
pageSize: 10, // 否 pageSize: 10, // 否
activityId: '', //是 activityId: '', //是
topicIndex: 0, goodsTemp: {},
topicList: {},
goodsList: [], goodsList: [],
loading: false, loading: false,
...@@ -117,23 +115,15 @@ export default { ...@@ -117,23 +115,15 @@ export default {
return this.$store.state.pay.isPrimordialBrowser; return this.$store.state.pay.isPrimordialBrowser;
}, },
isShowSwiper() { isShowSwiper() {
const { hasStart, hasStop } = this.topicCfg; const { hasStart, hasStop } = this.goodsTemp;
return !hasStart && !hasStop; return (!hasStart && !hasStop) || (hasStart && hasStop);
}, },
// 更具goodsSpecialId 获取查询活动模板列表-对应数据项
topicCfg() {
const { topicList } = this;
const info = topicList || {};
return info;
},
gpCountDown() { gpCountDown() {
const { endTime, hasStart, hasStop } = this.topicCfg; const { startTime, endTime, hasStart, hasStop } = this.goodsTemp;
if (!hasStart && !hasStop) { if (!hasStart && !hasStop) {
// 活动未开始 // 活动未开始
return 0; return +new Date(startTime || 0);
} }
return +new Date(endTime || 0); return +new Date(endTime || 0);
} }
}, },
...@@ -145,9 +135,6 @@ export default { ...@@ -145,9 +135,6 @@ export default {
}, },
mounted() { mounted() {
this.showLoading = true; this.showLoading = true;
EventBus.$on('shareClickItem', ev => {
console.log(ev);
});
}, },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
const { activityId } = to.query; const { activityId } = to.query;
...@@ -158,25 +145,22 @@ export default { ...@@ -158,25 +145,22 @@ export default {
}); });
return; return;
} else { } else {
if (isNull(topicIndex)) {
getActivityList(to.query, next); getActivityList(to.query, next);
} else {
next();
}
} }
}, },
deactivated() { deactivated() {
clearTimeout(this.$refs.swipeRota.timer); clearTimeout((this.$refs.swipeRota && this.$refs.swipeRota.timer) || null);
this.showLoops = false; this.showLoops = false;
EventBus.$off();
}, },
activated() { activated() {
this.showLoops = true; this.showLoops = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.swipeRota && this.$refs.swipeRota.onSlidePrevChange(); this.$refs.swipeRota && this.$refs.swipeRota.onSlidePrevChange();
}); });
// this.topicIndex = topicIndex; this.onShareEventChange();
// this.setTitleColor(this.topicCfg.bgcolor); // this.setTitleColor(this.goodsTemp.bgcolor);
// store.commit('changeTitle', this.topicCfg.title || '活动页'); // store.commit('changeTitle', this.goodsTemp.title || '活动页');
}, },
methods: { methods: {
animationEventStart() { animationEventStart() {
...@@ -186,16 +170,9 @@ export default { ...@@ -186,16 +170,9 @@ export default {
this.customers = avator; this.customers = avator;
this.showSwipe = true; this.showSwipe = true;
}, },
finishTimeChange() { async finishTimeChange() {
let info = this.topicList; const info = this.goodsTemp;
const { endTime, startTime } = info; this.goodsTemp = await computedTemplate(info);
info.remainTime = handleRemainTime('', endTime)[0];
info.hasStop = info.remainTime < 1;
info.willTime = handleRemainTime('', startTime)[0];
info.hasStart = handleRemainTime(startTime, '')[0] > 0;
info = { ...info, ...handleDateFormat(startTime, endTime) };
info.stateTxt = !info.hasStart ? '即将开始' : info.hasStop ? '活动已结束' : '距结束';
this.topicList = info;
}, },
async goToMyorder() { async goToMyorder() {
const isLogin = this.checkLogin(); const isLogin = this.checkLogin();
...@@ -205,15 +182,36 @@ export default { ...@@ -205,15 +182,36 @@ export default {
}, },
async openShareEvent() { async openShareEvent() {
const activity_id = this.activityId; const activity_id = this.activityId;
let options = await this.getShareData(); this.$store.dispatch('goods_share_open');
this.$store.dispatch('goods_share_open', options);
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupBtnClick', { registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupBtnClick', {
activity_id activity_id
}); });
}, },
onShareEventChange() {
EventBus.$on('shareClickItem', async function({ ev, nativeBridge }) {
let shareDic = await this.getShareData();
if (ev === 'pic') {
// 分享海报跳转小程序海报分享页面
nativeBridge.openNewUrl({
newUrl: `/pages/goodshare/index?url=${encodeURIComponent(
JSON.stringify(shareDic.posterUrl)
)}`
});
}
if (ev === 'weixin') {
// 分享朋友派发微信postMessage事件
nativeBridge.run({
event: 'showShareView',
data: {
shareDic
}
});
}
});
},
async getShareData() { async getShareData() {
// const link = `${window.location.origin}/groupBuy/list`; const { title, sharePosterTemplateUrl, img } = this.goodsTemp;
const { title, sharePosterTemplateUrl, img } = this.topicCfg;
const link = window.location.href; const link = window.location.href;
return Promise.resolve({ return Promise.resolve({
title, title,
...@@ -228,7 +226,7 @@ export default { ...@@ -228,7 +226,7 @@ export default {
}, },
handleBtnClick(item) { handleBtnClick(item) {
const { activityId } = this; const { activityId } = this;
const { goodsSpecialId, templateId, templateDetailIds } = this.topicCfg; const { goodsSpecialId, templateId, templateDetailIds } = this.goodsTemp;
const { skuNo } = item; const { skuNo } = item;
if (item.goodsCount !== 0) { if (item.goodsCount !== 0) {
this.$router.push({ this.$router.push({
...@@ -240,14 +238,14 @@ export default { ...@@ -240,14 +238,14 @@ export default {
} }
}, },
onLoad() { onLoad() {
if (this.topicCfg) { if (this.goodsTemp) {
this.getGoodsList(); this.getGoodsList();
} }
}, },
async getGoodsList() { async getGoodsList() {
const { pageSize, pageNo, activityId } = this; const { pageSize, pageNo, activityId } = this;
const { goodsSpecialIds, templateDetailIds } = this.topicCfg; const { goodsSpecialIds, templateDetailIds } = this.goodsTemp;
this.loading = true; this.loading = true;
this.finished = false; this.finished = false;
try { try {
...@@ -275,6 +273,17 @@ export default { ...@@ -275,6 +273,17 @@ export default {
} }
} }
}; };
async function computedTemplate(info) {
const { endTime, startTime } = info;
info.remainTime = handleRemainTime('', endTime)[0];
info.hasStop = info.remainTime < 1;
info.willTime = handleRemainTime('', startTime)[0];
info.hasStart = handleRemainTime(startTime, '')[0] > 0;
info = { ...info, ...handleDateFormat(startTime, endTime) };
info.stateTxt = !info.hasStart ? '即将开始' : info.hasStop ? '活动已结束' : '距结束';
return info;
}
async function getActivityList(urlQuery, next) { async function getActivityList(urlQuery, next) {
const { activityId } = urlQuery; const { activityId } = urlQuery;
// eslint-disable-next-line prettier/prettier // eslint-disable-next-line prettier/prettier
...@@ -288,34 +297,21 @@ async function getActivityList(urlQuery, next) { ...@@ -288,34 +297,21 @@ async function getActivityList(urlQuery, next) {
if (result?.templateInfo) { if (result?.templateInfo) {
let t = result.templateInfo; let t = result.templateInfo;
// 即将开始 // 即将开始
// t.startTime = '2021-09-24 00:00:00'; t.startTime = '2021-09-23 20:00:00';
// t.endTime = '2021-09-25 00:00:00'; t.endTime = '2021-09-23 20:02:00';
// 正在活动中 // 正在活动中
t.startTime = '2021-09-23 00:00:00'; // t.startTime = '2021-09-23 00:00:00';
t.endTime = '2021-09-25 00:00:00'; // t.endTime = '2021-09-25 00:00:00';
// 活动已结束 // // 活动已结束
// t.startTime = '2021-09-23 10:45:00'; // t.startTime = '2021-09-23 10:45:00';
// t.endTime = '2021-09-23 11:16:30'; // t.endTime = '2021-09-23 19:17:20';
t = await computedTemplate(t);
const { endTime, startTime } = t;
t.remainTime = handleRemainTime('', endTime)[0];
t.hasStop = t.remainTime < 1;
t.willTime = handleRemainTime('', startTime)[0];
t.hasStart = handleRemainTime(startTime, '')[0] > 0;
t = { ...t, ...handleDateFormat(startTime, endTime) };
t.stateTxt = !t.hasStart ? '即将开始' : t.hasStop ? '活动已结束' : '距结束';
t.groupBuyUserInfoList = t.groupBuyUserInfoList.reverse(); t.groupBuyUserInfoList = t.groupBuyUserInfoList.reverse();
const { title } = t; store.commit('CHANGE_TITLE', t.title || '活动页');
store.commit('CHANGE_TITLE', title || '活动页');
nextFns(vm => { nextFns(vm => {
vm.activityId = activityId; vm.activityId = activityId;
vm.topicList = t; vm.goodsTemp = t;
// vm.topicIndex = activityIndex;
localStorage.set('activityId', activityId); localStorage.set('activityId', activityId);
// const { hasStop } = vm.topicCfg;
// if (hasStop || !list.length) {
// vm.showOverTip = true;
// }
vm.getGoodsList(); vm.getGoodsList();
vm.reload = false; vm.reload = false;
}); });
......
...@@ -89,7 +89,8 @@ import { isWxMp, isApp } from '@/service/validation.service'; ...@@ -89,7 +89,8 @@ 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';
export default { export default {
name: 'OrderSkuList', name: 'OrderSkuList',
components: { components: {
...@@ -106,6 +107,8 @@ export default { ...@@ -106,6 +107,8 @@ export default {
}, },
data() { data() {
return { return {
shareInfo: null,
nativeBridge: null, nativeBridge: null,
gpCountDown: new Date('2021-09-12 00:00:00').getTime(), gpCountDown: new Date('2021-09-12 00:00:00').getTime(),
...@@ -148,6 +151,9 @@ export default { ...@@ -148,6 +151,9 @@ 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({
...@@ -157,33 +163,29 @@ export default { ...@@ -157,33 +163,29 @@ export default {
goGroupPayPages(skuInfo) { goGroupPayPages(skuInfo) {
this.$router.push(`/pay?orderNo=${skuInfo.orderNo}`); this.$router.push(`/pay?orderNo=${skuInfo.orderNo}`);
}, },
async getGroupShareInfo(order) {
const res = await groupBuyApi.getGroupShareInfo(order);
console.log(res);
},
async openShareEvent(skuInfo) { async openShareEvent(skuInfo) {
let options = await this.getShareData(skuInfo); // this.getGroupShareInfo('1440970158226214912');
this.$store.dispatch('goods_share_open', options); this.shareInfo = skuInfo;
this.$store.dispatch('goods_share_open');
registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', { registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', {
sku_no: '', sku_no: '',
leader_user_id: '' leader_user_id: ''
}); });
}, },
async getShareData(skuInfo) {
return Promise.resolve({
title: skuInfo.skuName,
desc: '我正在免费拿商品,请你帮帮我',
link: `${window.location.origin}/activity/zeroBuy`, // 页面地址
imgUrl: skuInfo.imageUrl // 图片地
});
// await
},
toDetail(goodsItem) { toDetail(goodsItem) {
const { skuNo, skuList, activityInfoId, activityHundredGroupId } = goodsItem; const { skuList, activityInfoId, activityHundredGroupId } = goodsItem;
this.$router.push({ this.$router.push({
path: '/groupBuy/skuInfoSmallPic', path: '/groupBuy/skuInfoSmallPic',
query: { query: {
h: 0, h: 0,
skuNo, skuNo: skuList[0].skuNo,
activityHundredGroupId, groupBuyGroupId: activityHundredGroupId,
goodsSpecialId: skuList[0].goodsSpecialId, goodsSpecialId: skuList[0].goodsSpecialId,
activityId: activityInfoId, activityId: activityInfoId,
templateId: skuList[0].activityTemplateInfoId, templateId: skuList[0].activityTemplateInfoId,
...@@ -197,8 +199,37 @@ export default { ...@@ -197,8 +199,37 @@ export default {
onOptionClick(orderInfo, eventType) { onOptionClick(orderInfo, eventType) {
this.$emit(EVENT_CLICK, { orderInfo, eventType }); this.$emit(EVENT_CLICK, { orderInfo, eventType });
}, },
toHome() { async getShareData(shareInfo) {
this.$router.replace({ path: '/home' }); 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
}
});
}
});
} }
} }
}; };
......
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