Commit 8672747a authored by beisir's avatar beisir

feat:eventBus派发

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