Commit eb58585b authored by Xuguangxing's avatar Xuguangxing

feat: 增加活动结束提示弹窗

parent af52d3ab
...@@ -6,7 +6,10 @@ export default class ActivityController extends Controller { ...@@ -6,7 +6,10 @@ export default class ActivityController extends Controller {
const apollo = ctx.app.config.apollo || {}; const apollo = ctx.app.config.apollo || {};
let body = ''; let body = '';
// 获取服务器端当前时间,用于与页面有效期做对比 // 获取服务器端当前时间,用于与页面有效期做对比
const serverTimeStamp = new Date().getTime(); const currentTime = new Date().getTime();
const offsetTime = new Date(currentTime).getTimezoneOffset();
const serverTimeStamp = currentTime - offsetTime;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
body = await ctx.renderToHtml('activity.js', { url: ctx.url, apollo, serverTimeStamp }); body = await ctx.renderToHtml('activity.js', { url: ctx.url, apollo, serverTimeStamp });
} else { } else {
......
...@@ -158,7 +158,6 @@ export default { ...@@ -158,7 +158,6 @@ export default {
}, },
initShareInfo() { initShareInfo() {
if (EASY_ENV_IS_NODE) return; if (EASY_ENV_IS_NODE) return;
console.log(this.pageInfo, 'this.pageInfo')
let shareCoverImage = ''; let shareCoverImage = '';
try { try {
shareCoverImage = this.pageInfo.page.props.shareCoverImage; shareCoverImage = this.pageInfo.page.props.shareCoverImage;
......
<template>
<cr-popup v-model="show" round>
<div class="content">
<img src="https://img.lkbang.net/activityInvalid.18ea3ddc.png" alt="">
<p class="title">活动已结束</p>
<p class="subtitle">请关注更多精彩活动</p>
<cr-button type="primary" shape="circle" @click="toOtherActivity">去看看其他活动</cr-button>
</div>
<!-- <cr-icon type="close" size="34px" color="#FFF" @click="close" /> -->
</cr-popup>
</template>
<script>
export default {
name: 'InvalidNotice',
props: {
value: Boolean,
},
data() {
return {
show: false,
}
},
methods: {
toOtherActivity() {
this.$emit('toOtherActivity')
}
},
watch: {
value(val) {
this.show = val;
}
},
}
</script>
<style lang="less" scoped>
@deep: ~'>>>';
.content{
width: 311px;
height: 360px;
background: #fff;
border-radius: 16px;
display: flex;
flex-direction: column;
align-items: center;
padding: 32px 0;
img{
display: block;
width: 162px;
}
.title{
font-size: 17px;
margin-top: 20px;
color:#333;
}
.subtitle{
margin: 12px auto 26px;
font-size: 12px;
color:#999;
}
button{
width: 236px;
}
}
.cr-popup {
background-color: transparent;
border-radius: 0;
}
.cr-icon {
display: block;
margin: 20px auto 0;
}
</style>
\ No newline at end of file
...@@ -2,6 +2,7 @@ import { Vue, Component, Watch, Provide, Mixins } from 'vue-property-decorator'; ...@@ -2,6 +2,7 @@ import { Vue, Component, Watch, Provide, Mixins } from 'vue-property-decorator';
import { Getter, State, Mutation } from 'vuex-class'; import { Getter, State, Mutation } from 'vuex-class';
import FreedomContainer from '../../component/FreedomContainer/index.vue'; import FreedomContainer from '../../component/FreedomContainer/index.vue';
import BackTop from '../../component/BackTop/index.vue'; import BackTop from '../../component/BackTop/index.vue';
import InvalidNotice from '../../component/invalidNotice/index.vue';
import EmptyState from '../../component/EmptyState/index.vue'; import EmptyState from '../../component/EmptyState/index.vue';
import PageBottomTip from '../../component/PageBottomTip/index.vue'; import PageBottomTip from '../../component/PageBottomTip/index.vue';
import GridLayout from '../../component/VueGridLayout/GridLayout.vue'; import GridLayout from '../../component/VueGridLayout/GridLayout.vue';
...@@ -20,7 +21,7 @@ import Bridge from '@qg/js-bridge'; ...@@ -20,7 +21,7 @@ import Bridge from '@qg/js-bridge';
import MpBridge from '@qg/citrus-ui/src/helper/service/mp'; import MpBridge from '@qg/citrus-ui/src/helper/service/mp';
import navigatorApi from '@/api/navigator.api'; import navigatorApi from '@/api/navigator.api';
import editorApi from '@/api/editor.api'; import editorApi from '@/api/editor.api';
@Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, EmptyState }, name: 'Activity'}) @Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, InvalidNotice, EmptyState }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyleMixin, SaMixin, DisableTouchMixin) { export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyleMixin, SaMixin, DisableTouchMixin) {
@Getter('pageData') pageData; @Getter('pageData') pageData;
...@@ -37,7 +38,7 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle ...@@ -37,7 +38,7 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
@Provide() editor = this; @Provide() editor = this;
isEditor: boolean = false; isEditor: boolean = false;
pageExpire: boolean = false; pageInvalid: boolean = false;
bottomInfo: object = { bottomInfo: object = {
x: 0, x: 0,
y: 0, y: 0,
...@@ -152,13 +153,48 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle ...@@ -152,13 +153,48 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
this.comparePageTime(); // 验证活动是否在设定的有效期范围内 this.comparePageTime(); // 验证活动是否在设定的有效期范围内
} }
comparePageTime() { comparePageTime() {
console.log(this.serverTimestamp);
// this.pageExpire
console.log(this.pageInfo);
const { validStartTime, validEndTime, redirectUrl } = this.pageInfo; const { validStartTime, validEndTime, redirectUrl } = this.pageInfo;
if (validStartTime && validEndTime) { if (validStartTime && validEndTime) {
// todo 当设置了页面的有效时间起止,用当前服务器返回的时间作对比,判断页面是否在有效期内 // todo 当设置了页面的有效时间起止,用当前服务器返回的时间作对比,判断页面是否在有效期内
// if (this.serverTimeStamp < this.) const startTime = new Date(validStartTime).getTime();
const endTime = new Date(validEndTime).getTime();
if (this.serverTimestamp < startTime || this.serverTimestamp > endTime) {
this.pageInvalid = true;
}
}
}
toOtherActivity() {
const { redirectUrl } = this.pageInfo;
let nativeBridge;
let mpBridge;
if (isApp) {
nativeBridge = new Bridge();
nativeBridge.openNewUrl({
data: {
// 需要打开的新链接
newUrl: redirectUrl ? redirectUrl : home.app,
},
});
} else if (isWxMp) {
mpBridge = new MpBridge();
const jumpConfig: any = {
// 需要打开的新链接
newUrl: redirectUrl ? redirectUrl : home.wxmp,
};
if (!redirectUrl) { jumpConfig.type = 'switchTab'; }
mpBridge.openNewUrl(jumpConfig);
} else {
if (!redirectUrl) { return; }
let url = redirectUrl;
const token = localStorage.get('vccToken') || '';
const { vccChannel, fromHost } = this.$route.query;
if (!isApp && !isWxMp) {
if (vccChannel) { url = this.addOrEditUrlParams(url, 'vccChannel', vccChannel); }
if (fromHost) { url = this.addOrEditUrlParams(url, 'fromHost', fromHost); }
}
if (token) { url = this.addOrEditUrlParams(url, 'vccToken', token); }
window.location.href = url;
return;
} }
} }
async getNavigatorConfig(navId, index) { async getNavigatorConfig(navId, index) {
...@@ -441,7 +477,3 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle ...@@ -441,7 +477,3 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
// if (fromHost) { url = this.addOrEditUrlParams(url, 'fromHost', fromHost); } // if (fromHost) { url = this.addOrEditUrlParams(url, 'fromHost', fromHost); }
// window.location.href = url; // window.location.href = url;
// } // }
}
}
}
<template> <template>
<div class="pageContent"> <div class="pageContent">
<!-- {{pageInfo}} -->
<div class="activity" :class="{hasBottomNav: navigatorConfig}" :style="transformStyle(pageData.commonStyle)"> <div class="activity" :class="{hasBottomNav: navigatorConfig}" :style="transformStyle(pageData.commonStyle)">
<template v-if="!noPageData && tenantIdCorrect"> <template v-if="!noPageData && tenantIdCorrect">
<div class="layout"> <div class="layout">
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
</div> </div>
</div> </div>
<back-top v-if="showBackTop" :show-back-top="showBackTop" ref="backTop" /> <back-top v-if="showBackTop" :show-back-top="showBackTop" ref="backTop" />
<invalid-notice v-model="pageInvalid" @toOtherActivity="toOtherActivity"/>
</template> </template>
<empty-state v-else /> <empty-state v-else />
</div> </div>
......
...@@ -14,6 +14,7 @@ import Loading from '@qg/cherry-ui/src/loading'; ...@@ -14,6 +14,7 @@ import Loading from '@qg/cherry-ui/src/loading';
import Text from '@qg/cherry-ui/src/text'; import Text from '@qg/cherry-ui/src/text';
import Tag from '@qg/cherry-ui/src/tag'; import Tag from '@qg/cherry-ui/src/tag';
import Popover from '@qg/cherry-ui/src/popover'; import Popover from '@qg/cherry-ui/src/popover';
import Popup from '@qg/cherry-ui/src/popup';
import Icon from '@qg/cherry-ui/src/icon'; import Icon from '@qg/cherry-ui/src/icon';
import Empty from '@qg/cherry-ui/src/empty'; import Empty from '@qg/cherry-ui/src/empty';
import NoticeBar from '@qg/cherry-ui/src/notice-bar'; import NoticeBar from '@qg/cherry-ui/src/notice-bar';
...@@ -34,7 +35,7 @@ Vue.use(Tag); ...@@ -34,7 +35,7 @@ Vue.use(Tag);
Vue.use(Popover); Vue.use(Popover);
Vue.use(Icon); Vue.use(Icon);
Vue.use(Empty); Vue.use(Empty);
Vue.use(Popup);
Vue.use(citrusUi); Vue.use(citrusUi);
Vue.prototype.$notify = Notify; Vue.prototype.$notify = Notify;
......
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