Commit 8672747a authored by beisir's avatar beisir

feat:eventBus派发

parent e4d6b301
<template> <template>
<cr-count-down :time="time"> <cr-count-down :time="time" :auto-start="true" @finish="finishEndChange">
<template #default="timeData"> <template #default="timeData">
<template v-if="timeData.d != 0"> <template v-if="timeData.d != 0">
<span :class="blockNoBg ? 'block-no-bg' : 'block'">{{ fillZero(timeData.d) }}</span> <span :class="blockNoBg ? 'block-no-bg' : 'block'">{{ fillZero(timeData.d) }}</span>
...@@ -34,6 +34,9 @@ export default { ...@@ -34,6 +34,9 @@ export default {
} }
}, },
methods: { methods: {
finishEndChange() {
this.$emit('finish-time');
},
fillZero(t) { fillZero(t) {
t = t.toString(); t = t.toString();
if (t.length == 1) { if (t.length == 1) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
import MpBridge from '@/service/mp'; import MpBridge from '@/service/mp';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { registeredEvents } from '@/service/sa.service'; import { registeredEvents } from '@/service/sa.service';
import { EventBus } from '@/service/utils.service';
export default { export default {
name: 'GroupShare', name: 'GroupShare',
components: {}, components: {},
...@@ -49,20 +50,24 @@ export default { ...@@ -49,20 +50,24 @@ export default {
methods: { methods: {
shareCloseChange() {}, shareCloseChange() {},
bundleShareClickItem(ev) { bundleShareClickItem(ev) {
if (ev === 'pic') { if (ev === 'wexin') {
this.nativeBridge.openNewUrl({
newUrl: `/pages/goodshare/index?ev=${ev}`
});
}
if (ev === 'weixin') {
this.nativeBridge.run({
event: 'showShareView',
data: {
shareDic: this.shareInfo
}
});
this.shareDialogConfirm(); this.shareDialogConfirm();
} }
EventBus.$emit('shareClickItem', ev);
// if (ev === 'pic') {
// 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: '', // 按钮名称
...@@ -73,13 +78,10 @@ export default { ...@@ -73,13 +78,10 @@ export default {
}, },
shareDialogConfirm() { shareDialogConfirm() {
this.$dialog({ this.$dialog({
message: '在微信小程序中参与此活动哦~', message: '点击小程序右上角更多进行分享~',
showCancelButton: false, showCancelButton: false,
confirmButtonText: '我知道了哦~', confirmButtonText: '我知道了哦~',
onConfirm: () => { onConfirm: () => {}
// todo 跳转到小程序
this.$toast('确定');
}
}); });
} }
// shareAppChange() {} // shareAppChange() {}
......
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
<cr-button <cr-button
size="small" size="small"
shape="circle" shape="circle"
type="danger" type="primary"
:disabled="btnByStatus.d" :class="{
@click.stop="onButtonClick" btnabled: btnByStatus.d
}"
>{{ btnByStatus.t }}</cr-button >{{ btnByStatus.t }}</cr-button
> >
</dd> </dd>
...@@ -87,8 +88,8 @@ export default { ...@@ -87,8 +88,8 @@ export default {
handleProgressByStatus(item) { handleProgressByStatus(item) {
if (!item) return 0; if (!item) return 0;
let percentage = 0; let percentage = 0;
const { showSaleCount, goodsCount } = item; const { goodsCount, activitySkuTotalCount } = item;
percentage = (goodsCount / (goodsCount + showSaleCount)) * 100; percentage = (goodsCount / activitySkuTotalCount) * 100;
percentage = percentage < 0 ? 0 : percentage; percentage = percentage < 0 ? 0 : percentage;
percentage = this.btnByStatus.d ? 0 : percentage; percentage = this.btnByStatus.d ? 0 : percentage;
return Math.round(percentage * 100) / 100; return Math.round(percentage * 100) / 100;
...@@ -102,16 +103,7 @@ export default { ...@@ -102,16 +103,7 @@ export default {
activityInfoId activityInfoId
} = this.goodsItem; } = this.goodsItem;
const { s } = this.btnByStatus; const { s } = this.btnByStatus;
if (s === 3) {
this.$notify({ type: 'warning', message: '该商品已抢完' });
return;
}
if (s === 2) { if (s === 2) {
// skuNo=2305164578817
// goodsSpecialId=59
// activityId=47
// templateId=58
// templateDetailId=83
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageOpenGroupImmediatelyBtnClick', { registeredEvents('H5_GroupZeroYuanPurchaseActivityPageOpenGroupImmediatelyBtnClick', {
skuNo skuNo
}); });
...@@ -129,24 +121,16 @@ export default { ...@@ -129,24 +121,16 @@ export default {
// 正常跳转 // 正常跳转
return false; return false;
} }
let messageTemp = '非常感谢亲对羊小咩的关注,活动还没有开始哦~';
if (s === 3) {
messageTemp = '您选的商品太火爆了,已经卖完了呢,您可以选择其他的团品重新开团哦~';
} else if (s === 1) {
messageTemp = '非常抱歉,亲本次活动已经结束了哦~';
}
this.$dialog({ this.$dialog({
message: '该活动已结束~', message: messageTemp,
confirmButtonText: s === 3 ? '重新选择' : '订阅消息', showCancelButton: false
onConfirm: () => {
// todo 跳转到小程序
// let getScheme = async function() {
// const [res] = await groupBuy.getScheme({
// miniUrl: 'pages/user/login'
// });
// const url = res;
// window.location.href = url; // todo 需要验证
// };
// getScheme();
// getScheme = null;
}
}); });
// this.$emit(EVENT_BUTTON_CLICK, this.goodsItem);
} }
} }
}; };
...@@ -241,6 +225,10 @@ export default { ...@@ -241,6 +225,10 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.btnabled {
cursor: not-allowed;
opacity: 0.7;
}
&.disabled { &.disabled {
opacity: 0.3; opacity: 0.3;
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
padding-left: 12px; padding-left: 12px;
padding-right: 12px; padding-right: 12px;
padding-bottom: 12px; padding-bottom: 12px;
&.padtop {
padding-top: 12px;
}
.group-list { .group-list {
background-color: @white; background-color: @white;
border-radius: 10px; border-radius: 10px;
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
<!-- 配置头部动态信息 end --> <!-- 配置头部动态信息 end -->
<!-- 下方列表展示信息 start --> <!-- 下方列表展示信息 start -->
<div class="group-bottom"> <div class="group-bottom" :class="{ padtop: isShowSwiper }">
<div class="group-portrait"> <div v-if="!isShowSwiper" class="group-portrait">
<div class="group-portrait-head"> <div class="group-portrait-head">
<div class="group-portrait-swipe" @click="switchAnimation"> <div class="group-portrait-swipe">
<swipeCustomerInfo v-model="showSwipe" :avatar="customers.src" :name="customers.name" /> <swipeCustomerInfo v-model="showSwipe" :avatar="customers.src" :name="customers.name" />
</div> </div>
<div class="group-portrait-ul"> <div class="group-portrait-ul">
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<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">{{ topicCfg.stateTxt }}</span>
<count-down :end-time="gpCountDown" /> <count-down :end-time="gpCountDown" @finish-time="finishTimeChange" />
</div> </div>
</div> </div>
<cr-list <cr-list
...@@ -83,7 +83,7 @@ import { isNull } from '@/service/validation.service'; ...@@ -83,7 +83,7 @@ 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 } 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; let topicIndex;
export default { export default {
...@@ -94,20 +94,10 @@ export default { ...@@ -94,20 +94,10 @@ export default {
data() { data() {
return { return {
showShare: false, showShare: false,
avatorData: [],
animate: {
animateAuto: false,
transition: true,
blue: true,
green: false,
animation: false
},
showSwipe: false, showSwipe: false,
showLoops: false, showLoops: false,
customers: {}, customers: {},
// goodsSpecialId 是
showLoading: true, showLoading: true,
pageNo: 1, // 是 pageNo: 1, // 是
...@@ -126,7 +116,10 @@ export default { ...@@ -126,7 +116,10 @@ export default {
isShowShare() { isShowShare() {
return this.$store.state.pay.isPrimordialBrowser; return this.$store.state.pay.isPrimordialBrowser;
}, },
isShowSwiper() {
const { hasStart, hasStop } = this.topicCfg;
return !hasStart && !hasStop;
},
// 更具goodsSpecialId 获取查询活动模板列表-对应数据项 // 更具goodsSpecialId 获取查询活动模板列表-对应数据项
topicCfg() { topicCfg() {
const { topicList } = this; const { topicList } = this;
...@@ -135,13 +128,11 @@ export default { ...@@ -135,13 +128,11 @@ export default {
}, },
gpCountDown() { gpCountDown() {
const { endTime } = this.topicCfg; const { endTime, hasStart, hasStop } = this.topicCfg;
// if (hasStart) { if (!hasStart && !hasStop) {
// return +new Date(endTime || 0); // 活动未开始
// } else { return 0;
}
// };
// if (){}
return +new Date(endTime || 0); return +new Date(endTime || 0);
} }
...@@ -154,6 +145,9 @@ export default { ...@@ -154,6 +145,9 @@ 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;
...@@ -178,7 +172,7 @@ export default { ...@@ -178,7 +172,7 @@ export default {
activated() { activated() {
this.showLoops = true; this.showLoops = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.swipeRota.onSlidePrevChange(); this.$refs.swipeRota && this.$refs.swipeRota.onSlidePrevChange();
}); });
// this.topicIndex = topicIndex; // this.topicIndex = topicIndex;
// this.setTitleColor(this.topicCfg.bgcolor); // this.setTitleColor(this.topicCfg.bgcolor);
...@@ -192,9 +186,18 @@ export default { ...@@ -192,9 +186,18 @@ export default {
this.customers = avator; this.customers = avator;
this.showSwipe = true; this.showSwipe = true;
}, },
finishTimeChange() {
let info = this.topicList;
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 ? '活动已结束' : '距结束';
this.topicList = info;
},
async goToMyorder() { async goToMyorder() {
console.log(this.$track);
const isLogin = this.checkLogin(); const isLogin = this.checkLogin();
if (!isLogin) { if (!isLogin) {
this.$router.push('/orderList/0'); this.$router.push('/orderList/0');
...@@ -220,16 +223,6 @@ export default { ...@@ -220,16 +223,6 @@ export default {
posterUrl: sharePosterTemplateUrl posterUrl: sharePosterTemplateUrl
}); });
}, },
showSwipeSync(avatorData) {
let timer = setTimeout(() => {
this.avatorData = avatorData;
this.showSwipe = true;
clearTimeout(timer);
}, 1000);
},
switchAnimation() {
this.animate.animateAuto = !this.animate.animateAuto;
},
setTitleColor(bgcolor = '#fff') { setTitleColor(bgcolor = '#fff') {
setAppTitleColor(bgcolor); setAppTitleColor(bgcolor);
}, },
...@@ -294,10 +287,16 @@ async function getActivityList(urlQuery, next) { ...@@ -294,10 +287,16 @@ async function getActivityList(urlQuery, next) {
const [result] = await groupBuyApi.getTemplateList(activityId); const [result] = await groupBuyApi.getTemplateList(activityId);
if (result?.templateInfo) { if (result?.templateInfo) {
let t = result.templateInfo; let t = result.templateInfo;
// t.startTime = '2021-09-25 00:00:00'; // 即将开始
// t.endTime = '2021-09-15 00:00:00'; // t.startTime = '2021-09-24 00:00:00';
// t.startTime = '2021-09-15 00:00:00'; // t.endTime = '2021-09-25 00:00:00';
// t.endTime = '2021-09-18 00:00:00'; // 正在活动中
t.startTime = '2021-09-23 00:00:00';
t.endTime = '2021-09-25 00:00:00';
// 活动已结束
// t.startTime = '2021-09-23 10:45:00';
// t.endTime = '2021-09-23 11:16:30';
const { endTime, startTime } = t; const { endTime, startTime } = t;
t.remainTime = handleRemainTime('', endTime)[0]; t.remainTime = handleRemainTime('', endTime)[0];
t.hasStop = t.remainTime < 1; t.hasStop = t.remainTime < 1;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<cr-image class="Ol__head-avator" width="85%" :src="item.profilePhoto" /> <cr-image class="Ol__head-avator" width="85%" :src="item.profilePhoto" />
<cr-image class="Ol__head-group" src="@/assets/images/group.png" /> <cr-image class="Ol__head-group" src="@/assets/images/group.png" />
</span> </span>
<span class="Ol__head-name">{{ item.nickname }}**</span> <span class="Ol__head-name">{{ item.nickname }}</span>
</div> </div>
<div class="Ol__head-right"> <div class="Ol__head-right">
<template v-if="item.openGroupStatus === 1"> <template v-if="item.openGroupStatus === 1">
......
...@@ -52,10 +52,10 @@ export default { ...@@ -52,10 +52,10 @@ export default {
showCancelPopup: false, showCancelPopup: false,
showExpressPopup: false, showExpressPopup: false,
currentTab: 0, currentTab: 0,
// 0-全部 1 -拼团中 2-拼团成功 // -1-全部 1-拼团中,未支付 2-拼团成功
navList: [ navList: [
{ {
status: 0, status: -1,
title: '全部', title: '全部',
...JSON.parse(JSON.stringify(commonParams)) ...JSON.parse(JSON.stringify(commonParams))
}, },
...@@ -84,6 +84,7 @@ export default { ...@@ -84,6 +84,7 @@ export default {
getstatusQuery() { getstatusQuery() {
const { status } = this.$route.params || {}; const { status } = this.$route.params || {};
status && (this.currentTab = Number(status)); status && (this.currentTab = Number(status));
console.log(this.currentTab);
}, },
handleTabChange(name) { handleTabChange(name) {
this.currentTab = name; this.currentTab = name;
......
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