|
|
@@ -1,72 +1,83 @@
|
|
|
<template>
|
|
|
<div class="boot" :style="`background-image: url(${'./app/splashscreen/1080x1920.png'});`">
|
|
|
- <Swipe class="boot__guide" :loop="false" v-if="state.showGuide">
|
|
|
- <SwipeItem>
|
|
|
- <img :src="'./app/splashscreen/1080x1920.png'" />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <img src="../../assets/images/guide-1.png" />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <img src="../../assets/images/guide-2.png" @click="skip(init())" />
|
|
|
- </SwipeItem>
|
|
|
- </Swipe>
|
|
|
+ <article v-if="state.showSplash">
|
|
|
+ <section v-html="formatHtmlString(state.documentContent)" />
|
|
|
+ <footer>
|
|
|
+ <Button type="danger" block @click="navigateToHome">{{ state.buttonText }}</Button>
|
|
|
+ </footer>
|
|
|
+ </article>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { reactive, onUnmounted } from 'vue'
|
|
|
+import { reactive } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
-import { Swipe, SwipeItem } from 'vant'
|
|
|
+import { Button } from 'vant'
|
|
|
+import { formatHtmlString } from '@/filters'
|
|
|
import { showLoading, dialog } from '@/utils/vant'
|
|
|
import { useLogin } from '@/business/login'
|
|
|
import { useCommonStore } from '@/stores/modules/common'
|
|
|
import service from '@/services'
|
|
|
import plus from '@/utils/h5plus'
|
|
|
|
|
|
-const { logining, initBaseData } = useLogin()
|
|
|
+const { initBaseData } = useLogin()
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
-const countdown = 1 // 倒计时秒数
|
|
|
-
|
|
|
-const commonStore=useCommonStore()
|
|
|
|
|
|
const state = reactive({
|
|
|
- showGuide: false,
|
|
|
- //showGuide: (!plus.hasPlus() || localStorage.getItem('muchinfo_app_showguide') === 'false') ? false : true, // 是否显示引导页
|
|
|
- second: countdown, // 剩余秒数
|
|
|
- currentRate: 100, // 当前进度
|
|
|
- rate: 100, // 目标进度
|
|
|
+ showSplash: false,
|
|
|
+ documentContent: '',
|
|
|
+ buttonText: ''
|
|
|
})
|
|
|
|
|
|
-const init = () => initBaseData(true) // 初始化数据
|
|
|
-const onLoad = state.showGuide ? Promise.resolve() : init()
|
|
|
+// 任务 #7076
|
|
|
+const shouldShowSplash = () => {
|
|
|
+ const commonStore = useCommonStore()
|
|
|
+ const { isenabled, displayfrequency, intervaldays = 0, documentcontent = '', buttontext = '进入首页' } = commonStore.getDocumentById(6) ?? {}
|
|
|
+
|
|
|
+ state.documentContent = documentcontent
|
|
|
+ state.buttonText = buttontext
|
|
|
+
|
|
|
+ if (isenabled) {
|
|
|
+ if (displayfrequency === 1) {
|
|
|
+ const shown = localStorage.getItem('splash_shown') === 'true'
|
|
|
|
|
|
-// 倒计时
|
|
|
-const timer = window.setInterval(() => {
|
|
|
- state.second--
|
|
|
- state.rate = (100 / countdown) * state.second
|
|
|
- if (state.second <= 0) {
|
|
|
- clearInterval(timer)
|
|
|
- // 判断是否首次打开应用
|
|
|
- if (!state.showGuide) {
|
|
|
- skip(onLoad)
|
|
|
+ if (!shown) {
|
|
|
+ localStorage.setItem('splash_shown', 'true')
|
|
|
+ state.showSplash = true
|
|
|
+ }
|
|
|
+ } else if (displayfrequency === 2) {
|
|
|
+ state.showSplash = true
|
|
|
+ } else if (displayfrequency === 3) {
|
|
|
+ const storageTimestamp = Number(localStorage.getItem('splash_timestamp'))
|
|
|
+ const currentTimestamp = Date.now()
|
|
|
+ const intervalMillisecond = intervaldays * 86400000 // 将天数转换为毫秒
|
|
|
+
|
|
|
+ if ((currentTimestamp - storageTimestamp) > intervalMillisecond) {
|
|
|
+ state.showSplash = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-}, 1000)
|
|
|
+}
|
|
|
|
|
|
-// 跳过广告
|
|
|
-const skip = (promise: Promise<void>) => {
|
|
|
- clearInterval(timer)
|
|
|
- const toast = logining.value ? showLoading() : undefined
|
|
|
+// 进入首页
|
|
|
+const navigateToHome = () => {
|
|
|
+ const redirect = route.query.redirect
|
|
|
+ if (redirect) {
|
|
|
+ router.replace(redirect.toString())
|
|
|
+ } else {
|
|
|
+ router.replace({ name: 'home-index' })
|
|
|
+ }
|
|
|
+ plus.exitFullSreen()
|
|
|
+}
|
|
|
|
|
|
- promise.then(() => {
|
|
|
- localStorage.setItem('muchinfo_app_showguide', 'false')
|
|
|
- const redirect = route.query.redirect
|
|
|
- if (redirect) {
|
|
|
- router.replace(redirect.toString())
|
|
|
- } else {
|
|
|
- router.replace({ name: 'home-index' })
|
|
|
+// 初始化
|
|
|
+const init = () => {
|
|
|
+ const toast = showLoading()
|
|
|
+ initBaseData(true).then(() => {
|
|
|
+ shouldShowSplash()
|
|
|
+ if (!state.showSplash) {
|
|
|
+ navigateToHome()
|
|
|
}
|
|
|
}).catch((err) => {
|
|
|
if (service.isReady) {
|
|
|
@@ -87,14 +98,14 @@ const tryInit = (message: string) => {
|
|
|
cancelButtonText: '退出',
|
|
|
confirmButtonText: '重试'
|
|
|
}).then(() => {
|
|
|
- skip(init())
|
|
|
+ init()
|
|
|
}).catch(() => {
|
|
|
plus.quit()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+init()
|
|
|
plus.setFullSreen()
|
|
|
-onUnmounted(() => plus.exitFullSreen())
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|