Files
ebiz-h5/src/views/ebiz/train/TrainLoading.vue
2021-05-20 21:07:41 +08:00

121 lines
3.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="loading-content flex justify-content-c align-items-c">
<div class="context-core text-center line-height">
正在跳转培训中心请稍候...
</div>
</div>
</template>
<script>
import { Image, Lazyload, Grid, GridItem, Toast } from 'vant'
import { trainHomeUrl } from '@/api/ebiz/train/train.js'
export default {
components: {
[Toast.name]: Toast,
[Image.name]: Image,
[Grid.name]: Grid,
[GridItem.name]: GridItem,
[Lazyload.name]: Lazyload
},
data() {
return {
trainHomeUrl: '',
time: 9,
requestRes: '',
clickFlag: false
}
},
mounted() {
Toast.loading({
message: '加载中...',
forbidClick: true,
duration: 0,
loadingType: 'spinner'
})
setTimeout(() => {
this.initThisPage()
}, 1000)
},
methods: {
// 初始化页面
async initThisPage() {
let that = this
// eslint-disable-next-line no-undef
const response = await EWebBridge.webCallAppInJs('getDeviceInfo', {
secretKey: 'trainSecretKey'
})
// const response = await new Promise((resolve, reject) => {
// setTimeout(() => {
// resolve(JSON.stringify({ uuid: '232432413212' }))
// }, 2000)
// })
let jsonResponse = JSON.parse(response)
if (jsonResponse.uuid && jsonResponse.uuid != '') {
const res = await trainHomeUrl({ deviceCode: jsonResponse.uuid })
if (res.result == 0) {
window.location.href = res.homeUrlDTO.fullPath
} else {
this.$toast(res.resultMessage)
}
} else {
this.$toast(jsonResponse.errorMessage)
}
},
// 定时器
timeOut() {
let timer = setInterval(() => {
this.time--
if (this.time <= 0) {
this.time = 0
clearInterval(timer)
this.time = '-'
if (!this.clickFlag) {
window.location.href = this.trainHomeUrl
}
}
}, 1000)
},
// 点击跳转
async nextStep() {
this.clickFlag = true
if (!(this.trainHomeUrl && this.trainHomeUrl != '')) {
// eslint-disable-next-line no-undef
const response = await EWebBridge.webCallAppInJs('getDeviceInfo', {
secretKey: 'trainSecretKey'
})
let jsonResponse = JSON.parse(response)
if (jsonResponse.uuid && jsonResponse.uuid != '') {
trainHomeUrl({ deviceCode: jsonResponse.uuid }).then(res => {
console.log(res)
if (res.result == 0) {
this.trainHomeUrl = res.homeUrlDTO.fullPath
window.location.href = this.trainHomeUrl
} else {
this.$toast(res.resultMessage)
}
})
} else {
this.$toast(jsonResponse.errorMessage)
}
} else {
window.location.href = this.trainHomeUrl
}
}
}
}
</script>
<style lang="scss" scoped>
.loading-content {
width: 100vw;
height: 100vh;
flex-direction: column;
}
.next-step {
text-decoration: underline;
color: #5ca5ea;
}
</style>