换皮test1.2

This commit is contained in:
minimaxagent1 2025-08-06 12:04:17 +08:00
parent 7678831bab
commit e30181e92a

View File

@ -41,6 +41,7 @@
</view>
<view class="list-scroll">
<view class="list">
<!-- 导航项目列表 -->
<view
class="li"
v-for="(item, index) in navigationItems"
@ -55,6 +56,11 @@
{{ item.subtitle }}
</view>
</view>
<!-- 空状态提示 -->
<view v-if="!loading && navigationItems.length === 0" class="empty-state">
<text>暂无功能项目</text>
</view>
</view>
</view>
<view class="bottom">
@ -80,7 +86,6 @@
</template>
<script>
import navigationData from "../../enum/navigationData.json";
import { navigateToPage } from "../../utils/router.js";
import { getHomeConfig } from "../../api/index/index.js";
import { getArticleById } from "../../api/article/article.js";
@ -90,21 +95,43 @@ import { getArticleById } from "../../api/article/article.js";
return {
marqueeX: '', // marquee-wrap
timer: null,
loading: false,
// API使
pageConfig: navigationData.pageConfig,
navigationItems: navigationData.navigationItems,
bottomSection: navigationData.bottomSection
loading: true, // trueAPI
// API
pageConfig: {
background: { img: '' },
announcement: { icon: '', text: '' },
topIcons: {
leftIcon: { hidden: false, img: '' },
rightIcon: { img: '' },
bottomIcon: { img: '' }
}
},
navigationItems: [],
bottomSection: {
openingTime: {
title: '',
time: '',
decorationImg: ''
}
}
}
},
onLoad() {
//
this.loadHomeConfig();
},
//
onPullDownRefresh() {
console.log('用户触发下拉刷新');
this.loadHomeConfig().finally(() => {
uni.stopPullDownRefresh();
});
},
onShow() {
//
if (this.pageConfig && this.pageConfig.announcement) {
this.startMarquee();
if (this.pageConfig && this.pageConfig.announcement && this.pageConfig.announcement.text) {
this.startMarquee();
}
},
onUnload() {
@ -131,13 +158,14 @@ import { getArticleById } from "../../api/article/article.js";
try {
console.log(`${retryCount + 1} 次尝试获取配置...`);
//
const isNetworkAvailable = await this.checkNetworkStatus();
if (!isNetworkAvailable) {
console.error('网络不可用,使用默认配置');
this.useDefaultConfig();
return;
}
//
const isNetworkAvailable = await this.checkNetworkStatus();
if (!isNetworkAvailable) {
console.error('网络不可用,使用默认配置');
this.useDefaultConfig();
this.loading = false;
return;
}
console.log('网络状态正常开始请求API...');
const response = await getHomeConfig();
@ -146,29 +174,25 @@ import { getArticleById } from "../../api/article/article.js";
//
if (!response) {
console.error('API响应为空');
this.useDefaultConfig();
return;
throw new Error('API响应为空');
}
//
if (response.code !== 200) {
console.error('API响应码错误:', response.code, response.msg);
this.useDefaultConfig();
return;
throw new Error(`API响应码错误: ${response.code}`);
}
//
if (!response.data) {
console.error('API响应数据为空');
this.useDefaultConfig();
return;
throw new Error('API响应数据为空');
}
//
if (!Array.isArray(response.data) || response.data.length === 0) {
console.error('API响应数据格式错误或为空数组');
this.useDefaultConfig();
return;
throw new Error('API响应数据格式错误');
}
//
@ -178,8 +202,7 @@ import { getArticleById } from "../../api/article/article.js";
// body
if (!configData.body) {
console.error('配置数据缺少body字段');
this.useDefaultConfig();
return;
throw new Error('配置数据缺少body字段');
}
// JSON
@ -190,8 +213,7 @@ import { getArticleById } from "../../api/article/article.js";
//
if (!this.validateConfig(parsedConfig)) {
console.error('配置数据验证失败');
this.useDefaultConfig();
return;
throw new Error('配置数据验证失败');
}
//
@ -206,7 +228,7 @@ import { getArticleById } from "../../api/article/article.js";
} catch (parseError) {
console.error('解析配置JSON失败:', parseError);
console.log('原始body数据:', configData.body);
this.useDefaultConfig();
throw new Error('解析配置JSON失败: ' + parseError.message);
}
//
@ -237,29 +259,26 @@ import { getArticleById } from "../../api/article/article.js";
},
/**
* 使用默认配置
* 处理配置加载失败
*/
useDefaultConfig() {
console.log('使用默认配置数据');
//
if (!this.pageConfig || !this.pageConfig.announcement) {
console.error('默认配置数据不完整');
uni.showToast({
title: '配置数据异常',
icon: 'none',
duration: 2000
});
return;
}
//
this.stopMarquee();
this.startMarquee();
console.log('API获取失败无法加载配置');
//
//
//
uni.showToast({
title: '使用本地配置',
icon: 'none',
duration: 1500
uni.showModal({
title: '加载失败',
content: '无法获取页面配置,请检查网络连接后重试',
showCancel: true,
cancelText: '取消',
confirmText: '重试',
success: (res) => {
if (res.confirm) {
this.loadHomeConfig();
}
}
});
},
@ -549,6 +568,14 @@ import { getArticleById } from "../../api/article/article.js";
color: #522510;
}
}
.empty-state {
width: 100%;
text-align: center;
padding: 40rpx;
color: #999;
font-size: 28rpx;
}
}
.hua{
width: 100%;