youdas/pages/index/index.vue
2025-06-20 16:06:03 +08:00

80 lines
1.7 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 } from '@/common/server/config';
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 getConfig();
// console.log('config', config);
// const config1 = await getConfig();
// console.log('config1', config1);
});
/**
* 检查网络状态
* @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>