youdas/pages/index/index.vue
2025-07-08 14:10:30 +08:00

97 lines
1.9 KiB
Vue

<template>
<view class="page">
<view class="welcome">
<image class="welcome__logo" :src="icon" mode="aspectFit">
</image>
<image :src="login_icon" class="welcome__animation"></image>
<view class="welcome__tips">{{ tips_text }}</view>
</view>
</view>
</template>
<script setup>
import {
defineComponent,
ref
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
getConfig,
getPlatformConfig
} from '@/common/server/config';
import {
navigateTo
} from '@/common/system/router';
let icon = ref("/static/app-plus/icon_108.png");
let login_icon = ref("/static/app-plus/index_login.gif");
let tips_text = ref("正在加载中。。。");
onLoad(async () => {
// 检查网络状态
const network = await uni.getNetworkType();
if (network.networkType === 'none') {
tips_text.value = '请检查网络连接';
// 监听网络状态变化
uni.onNetworkStatusChange(checkNetwork);
return;
}
const config = await getPlatformConfig();
console.log("config", config);
// navigateTo('/pages/news/news');
if (config.buildVersion == "105") {
navigateTo('/pages/news/news');
} else {
uni.reLaunch({
url: '/pages/other/user-agreement'
})
}
});
/**
* 检查网络状态
* @param {Object} res 网络状态
*/
function checkNetwork(res) {
console.log('网络状态变化:', res.isConnected, res.networkType);
if (res.isConnected) {
tips_text.value = '正在加载中。。。';
// #ifdef APP
plus.runtime.restart();
// #endif
} else {
tips_text.value = '请检查网络连接';
}
}
</script>
<style lang="scss">
.page {
width: 100vw;
height: 100vh;
background-color: #f8f8f8;
}
.welcome {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
&__logo {
width: 96px;
height: 96px;
margin-top: 20vh;
border-radius: 50%;
}
&__animation {
width: 200rpx;
height: 200rpx;
}
&__tips {
margin-top: 10px;
}
}
</style>