hookehuyr

fix(Activities): 修复错误状态处理并添加返回按钮

- 移除错误状态下的默认URL回退逻辑,改为显示错误提示
- 在错误状态中添加返回按钮,提供更好的用户体验
- 优化错误状态下的按钮布局样式
......@@ -16,11 +16,14 @@
<view class="loading-text">加载中...</view>
</view>
<!---but态 -->
<!-- 错误状态 -->
<view v-if="error" class="error-container">
<view class="error-icon">⚠️</view>
<view class="error-text">页面加载失败</view>
<nut-button type="primary" size="small" @click="handleRetry">重试</nut-button>
<view class="error-buttons">
<nut-button type="primary" size="small" @click="handleRetry">重试</nut-button>
<nut-button type="default" size="small" @click="handleGoBack">返回</nut-button>
</view>
</view>
<!-- 底部导航 -->
......@@ -84,12 +87,22 @@ const handleMessage = (e) => {
const handleRetry = () => {
loading.value = true
error.value = false
// 重新设置URL触发重新加载
const currentUrl = webUrl.value
webUrl.value = ''
setTimeout(() => {
webUrl.value = currentUrl
}, 100)
// 重新初始化页面数据
initPageData()
}
/**
* 返回上一页
*/
const handleGoBack = () => {
Taro.navigateBack({
delta: 1
}).catch(() => {
// 如果无法返回,则跳转到首页
Taro.switchTab({
url: '/pages/Dashboard/index'
})
})
}
/**
......@@ -115,8 +128,14 @@ const initPageData = async () => {
console.log('获取到的地图URL:', baseUrl.value)
} else {
console.error('获取地图URL失败:', mapUrlResponse.msg)
// 使用默认URL作为备用
baseUrl.value = 'https://oa.onwall.cn/f/map/#/checkin/?id=2400107'
// 显示错误提示,不使用默认URL
error.value = true
loading.value = false
Taro.showToast({
title: mapUrlResponse.msg || '获取地图信息失败',
icon: 'none'
})
return
}
// 获取用户信息
......@@ -136,8 +155,9 @@ const initPageData = async () => {
}
} catch (error) {
console.error('初始化页面数据失败:', error)
// 使用默认URL作为备用
baseUrl.value = 'https://oa.onwall.cn/f/map/#/checkin/?id=2400107'
// 显示错误状态,不使用默认URL
error.value = true
loading.value = false
Taro.showToast({
title: '获取地图信息失败',
......@@ -221,4 +241,10 @@ onMounted(async () => {
color: #666;
margin-bottom: 32rpx;
}
.error-buttons {
display: flex;
gap: 24rpx;
align-items: center;
}
</style>
......