个人中心页跳转实现

This commit is contained in:
WindowBird 2025-08-15 15:26:13 +08:00
parent 26ecf5f4c8
commit 897fc160a0
2 changed files with 730 additions and 664 deletions

View File

@ -8,12 +8,15 @@
</view> </view>
<!-- 背景图 --> <!-- 背景图 -->
<image class="bj" :src="templeData.imgUrl" mode="aspectFill"></image> <image :src="templeData.imgUrl" class="bj" mode="aspectFill"></image>
<!-- 公告 --> <!-- 公告 -->
<view class="announcement"> <view class="announcement">
<image class="ggimg" :src="pageConfig.announcement.icon" mode="" /> <image :src="pageConfig.announcement.icon" class="ggimg" mode="" />
<view class="marquee-wrap"> <view class="marquee-wrap">
<view class="marquee" :style="{ transform: `translateX(${marqueeX}rpx)` }"> <view
:style="{ transform: `translateX(${marqueeX}rpx)` }"
class="marquee"
>
{{ templeData.bulletinContent }} {{ templeData.bulletinContent }}
</view> </view>
</view> </view>
@ -23,16 +26,16 @@
<view class="audio-controls"> <view class="audio-controls">
<image <image
v-if="pageConfig.topIcons.leftIcon.hidden" v-if="pageConfig.topIcons.leftIcon.hidden"
:class="{ playing: isAudioPlaying }"
:src="pageConfig.topIcons.leftIcon.img" :src="pageConfig.topIcons.leftIcon.img"
mode="" mode=""
@click="playAudio" @click="playAudio"
:class="{ playing: isAudioPlaying }"
></image> ></image>
<image <image
:class="{ stopped: !isAudioPlaying }"
:src="pageConfig.topIcons.rightIcon.img" :src="pageConfig.topIcons.rightIcon.img"
mode="" mode=""
@click="stopAudio" @click="stopAudio"
:class="{ stopped: !isAudioPlaying }"
></image> ></image>
</view> </view>
<view class="tubiao-item"> <view class="tubiao-item">
@ -46,20 +49,22 @@
<text>{{ bottomSection.openingTime.title }}</text> <text>{{ bottomSection.openingTime.title }}</text>
<image :src="bottomSection.openingTime.decorationImg" mode=""></image> <image :src="bottomSection.openingTime.decorationImg" mode=""></image>
</view> </view>
<view class="time"> {{ templeData.startTime }} - {{ templeData.endTime }} </view> <view class="time">
{{ templeData.startTime }} - {{ templeData.endTime }}
</view>
<view class="hua"> <view class="hua">
<image <image
src="https://api.ccttiot.com/smartmeter/img/static/uyz1LDPTjPqeOzBMjLZ7"
mode="" mode=""
src="https://api.ccttiot.com/smartmeter/img/static/uyz1LDPTjPqeOzBMjLZ7"
></image> ></image>
</view> </view>
<view class="list-scroll"> <view class="list-scroll">
<view class="list"> <view class="list">
<!-- 导航项目列表 --> <!-- 导航项目列表 -->
<view <view
class="li"
v-for="(item, index) in navigationItems" v-for="(item, index) in navigationItems"
:key="index" :key="index"
class="li"
@click="navigateToPage(item, index)" @click="navigateToPage(item, index)"
> >
<image :src="item.img" mode=""></image> <image :src="item.img" mode=""></image>
@ -72,21 +77,34 @@
</view> </view>
<!-- 空状态提示 --> <!-- 空状态提示 -->
<view v-if="!loading && navigationItems.length === 0" class="empty-state"> <view
v-if="!loading && navigationItems.length === 0"
class="empty-state"
>
<text>暂无功能项目</text> <text>暂无功能项目</text>
</view> </view>
</view> </view>
</view> </view>
<view <view
v-if="
bottomSection.prayerSection &&
bottomSection.prayerSection.backgroundImg
"
class="bottom" class="bottom"
v-if="bottomSection.prayerSection && bottomSection.prayerSection.backgroundImg"
> >
<image :src="bottomSection.prayerSection.backgroundImg" mode=""></image> <image
:src="bottomSection.prayerSection.backgroundImg"
mode=""
@click="goToPersonalCenter"
></image>
<view class="rixing"> <view class="rixing">
{{ bottomSection.prayerSection.title }} {{ bottomSection.prayerSection.title }}
</view> </view>
<view class="qifu" @click="goToPray"> <view class="qifu" @click="goToPray">
<image :src="bottomSection.prayerSection.prayerButton.icon" mode=""></image> <image
:src="bottomSection.prayerSection.prayerButton.icon"
mode=""
></image>
<view class="zaixian"> <view class="zaixian">
<view class="da"> <view class="da">
{{ bottomSection.prayerSection.prayerButton.title }} {{ bottomSection.prayerSection.prayerButton.title }}
@ -102,143 +120,145 @@
</template> </template>
<script> <script>
import { navigateToPage } from '../../utils/router.js' import { navigateToPage } from "../../utils/router.js";
import { getHomeConfig, getTempleIndex } from '../../api/index/index.js' import { getHomeConfig, getTempleIndex } from "../../api/index/index.js";
import { getArticleById } from '../../api/article/article.js' import { getArticleById } from "../../api/article/article.js";
export default { export default {
data() { data() {
return { return {
marqueeX: '', // marquee-wrap marqueeX: "", // marquee-wrap
timer: null, timer: null,
loading: true, // trueAPI loading: true, // trueAPI
// API // API
pageConfig: { pageConfig: {
background: { img: '' }, background: { img: "" },
announcement: { icon: '', text: '' }, announcement: { icon: "", text: "" },
topIcons: { topIcons: {
leftIcon: { hidden: false, img: '' }, leftIcon: { hidden: false, img: "" },
rightIcon: { img: '' }, rightIcon: { img: "" },
bottomIcon: { img: '' }, bottomIcon: { img: "" },
}, },
}, },
navigationItems: [], navigationItems: [],
bottomSection: { bottomSection: {
openingTime: { openingTime: {
title: '', title: "",
time: '', time: "",
decorationImg: '', decorationImg: "",
}, },
}, },
templeData: { templeData: {
imgUrl: '', imgUrl: "",
bulletinContent: '', bulletinContent: "",
startTime: '', startTime: "",
endTime: '', endTime: "",
audioUrl: '', audioUrl: "",
}, },
isAudioPlaying: false, isAudioPlaying: false,
audioContext: null, audioContext: null,
} };
}, },
onLoad() { onLoad() {
// //
this.loadHomeConfig() this.loadHomeConfig();
// //
this.loadTempleData() this.loadTempleData();
}, },
// //
onPullDownRefresh() { onPullDownRefresh() {
console.log('用户触发下拉刷新') console.log("用户触发下拉刷新");
Promise.all([this.loadHomeConfig(), this.loadTempleData()]).finally(() => { Promise.all([this.loadHomeConfig(), this.loadTempleData()]).finally(() => {
uni.stopPullDownRefresh() uni.stopPullDownRefresh();
}) });
}, },
onShow() { onShow() {
// //
this.startMarquee() this.startMarquee();
}, },
onUnload() { onUnload() {
this.stopMarquee() this.stopMarquee();
// //
this.stopAudio() this.stopAudio();
}, },
methods: { methods: {
/** /**
* 获取首页配置 * 获取首页配置
*/ */
async loadHomeConfig() { async loadHomeConfig() {
console.log('开始获取首页配置...') console.log("开始获取首页配置...");
this.loading = true this.loading = true;
// //
const maxRetries = 3 const maxRetries = 3;
let retryCount = 0 let retryCount = 0;
while (retryCount < maxRetries) { while (retryCount < maxRetries) {
try { try {
console.log(`${retryCount + 1} 次尝试获取配置...`) console.log(`${retryCount + 1} 次尝试获取配置...`);
const response = await getHomeConfig() const response = await getHomeConfig();
console.log('API响应:', response) console.log("API响应:", response);
// //
if (response?.code === 200 && response?.data?.[0]?.body) { if (response?.code === 200 && response?.data?.[0]?.body) {
const parsedConfig = JSON.parse(response.data[0].body) const parsedConfig = JSON.parse(response.data[0].body);
// //
this.updatePageConfig(parsedConfig) this.updatePageConfig(parsedConfig);
// //
this.stopMarquee() this.stopMarquee();
this.startMarquee() this.startMarquee();
console.log('配置加载成功') console.log("配置加载成功");
break break;
} else { } else {
throw new Error('API响应数据无效') throw new Error("API响应数据无效");
} }
} catch (error) { } catch (error) {
retryCount++ retryCount++;
console.error(`${retryCount} 次尝试失败:`, error.message) console.error(`${retryCount} 次尝试失败:`, error.message);
if (retryCount >= maxRetries) { if (retryCount >= maxRetries) {
console.error('所有重试都失败了') console.error("所有重试都失败了");
this.useDefaultConfig() this.useDefaultConfig();
break break;
} else { } else {
await new Promise(resolve => setTimeout(resolve, retryCount * 1000)) await new Promise((resolve) =>
setTimeout(resolve, retryCount * 1000),
);
} }
} }
} }
this.loading = false this.loading = false;
console.log('配置加载完成') console.log("配置加载完成");
}, },
/** /**
* 处理配置加载失败 * 处理配置加载失败
*/ */
useDefaultConfig() { useDefaultConfig() {
console.log('API获取失败无法加载配置') console.log("API获取失败无法加载配置");
// //
// //
// //
uni.showModal({ uni.showModal({
title: '加载失败', title: "加载失败",
content: '无法获取页面配置,请检查网络连接后重试', content: "无法获取页面配置,请检查网络连接后重试",
showCancel: true, showCancel: true,
cancelText: '取消', cancelText: "取消",
confirmText: '重试', confirmText: "重试",
success: res => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.loadHomeConfig() this.loadHomeConfig();
} }
}, },
}) });
}, },
/** /**
@ -246,10 +266,10 @@
*/ */
updatePageConfig(parsedConfig) { updatePageConfig(parsedConfig) {
// 使undefined // 使undefined
this.pageConfig = parsedConfig.pageConfig || this.pageConfig this.pageConfig = parsedConfig.pageConfig || this.pageConfig;
this.navigationItems = parsedConfig.navigationItems || [] this.navigationItems = parsedConfig.navigationItems || [];
this.bottomSection = parsedConfig.bottomSection || this.bottomSection this.bottomSection = parsedConfig.bottomSection || this.bottomSection;
console.log('配置更新完成') console.log("配置更新完成");
}, },
/** /**
@ -257,136 +277,138 @@
*/ */
async loadTempleData() { async loadTempleData() {
try { try {
console.log('开始获取寺庙数据...') console.log("开始获取寺庙数据...");
const response = await getTempleIndex() const response = await getTempleIndex();
console.log('寺庙数据API响应:', response) console.log("寺庙数据API响应:", response);
if (response?.code === 200 && response?.data) { if (response?.code === 200 && response?.data) {
this.templeData = { this.templeData = {
imgUrl: response.data.imgUrl || '', imgUrl: response.data.imgUrl || "",
bulletinContent: response.data.bulletinContent || '', bulletinContent: response.data.bulletinContent || "",
startTime: response.data.startTime || '', startTime: response.data.startTime || "",
endTime: response.data.endTime || '', endTime: response.data.endTime || "",
audioUrl: response.data.audioUrl || '', audioUrl: response.data.audioUrl || "",
} };
uni.setStorageSync('abbotId', response.data.abbotId) uni.setStorageSync("abbotId", response.data.abbotId);
// //
this.stopMarquee() this.stopMarquee();
this.startMarquee() this.startMarquee();
console.log('寺庙数据加载成功') console.log("寺庙数据加载成功");
} else { } else {
throw new Error('寺庙数据API响应无效') throw new Error("寺庙数据API响应无效");
} }
} catch (error) { } catch (error) {
console.error('获取寺庙数据失败:', error) console.error("获取寺庙数据失败:", error);
uni.showToast({ uni.showToast({
title: '获取寺庙数据失败', title: "获取寺庙数据失败",
icon: 'none', icon: "none",
}) });
} }
}, },
startMarquee() { startMarquee() {
// //
const announcementText = const announcementText =
this.templeData?.bulletinContent || this.pageConfig?.announcement?.text this.templeData?.bulletinContent || this.pageConfig?.announcement?.text;
if (!announcementText) { if (!announcementText) {
return return;
} }
// //
this.stopMarquee() this.stopMarquee();
// 24rpx // 24rpx
const textWidth = announcementText.length * 24 const textWidth = announcementText.length * 24;
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.marqueeX-- this.marqueeX--;
if (this.marqueeX < -textWidth) { if (this.marqueeX < -textWidth) {
this.marqueeX = 600 this.marqueeX = 600;
} }
}, 16) }, 16);
}, },
stopMarquee() { stopMarquee() {
if (this.timer) { if (this.timer) {
clearInterval(this.timer) clearInterval(this.timer);
this.timer = null this.timer = null;
} }
}, },
// page aid // page aid
async navigateToPage(item, index) { async navigateToPage(item, index) {
try { try {
console.log('导航项信息:', item) console.log("导航项信息:", item);
console.log('导航项索引:', index) console.log("导航项索引:", index);
// 使page // 使page
if (item.page) { if (item.page) {
console.log('使用page字段进行路由跳转:', item.page) console.log("使用page字段进行路由跳转:", item.page);
// //
const { navigateToPage: routerNavigate } = await import('../../utils/router.js') const { navigateToPage: routerNavigate } = await import(
routerNavigate(item.page) "../../utils/router.js"
return );
routerNavigate(item.page);
return;
} }
// page使aid // page使aid
if (item.aid) { if (item.aid) {
console.log('使用aid字段获取文章详情:', item.aid) console.log("使用aid字段获取文章详情:", item.aid);
// //
uni.showLoading({ uni.showLoading({
title: '加载中...', title: "加载中...",
mask: true, mask: true,
}) });
// API // API
const response = await getArticleById(item.aid) const response = await getArticleById(item.aid);
// //
uni.hideLoading() uni.hideLoading();
if (response.code === 200 && response.data) { if (response.code === 200 && response.data) {
console.log('获取文章详情成功:', response.data) console.log("获取文章详情成功:", response.data);
// 使 // 使
uni.setStorageSync('currentArticle', response.data) uni.setStorageSync("currentArticle", response.data);
// //
uni.navigateTo({ uni.navigateTo({
url: '/pages/article/article-detail', url: "/pages/article/article-detail",
fail: err => { fail: (err) => {
console.error('跳转到文章详情页面失败:', err) console.error("跳转到文章详情页面失败:", err);
uni.showToast({ uni.showToast({
title: '页面跳转失败', title: "页面跳转失败",
icon: 'none', icon: "none",
}) });
}, },
}) });
} else { } else {
console.error('获取文章详情失败:', response) console.error("获取文章详情失败:", response);
uni.showToast({ uni.showToast({
title: '获取内容失败', title: "获取内容失败",
icon: 'none', icon: "none",
}) });
} }
} else { } else {
console.error('导航项既没有page字段也没有aid字段:', item) console.error("导航项既没有page字段也没有aid字段:", item);
uni.showToast({ uni.showToast({
title: '配置错误', title: "配置错误",
icon: 'none', icon: "none",
}) });
} }
} catch (error) { } catch (error) {
// //
uni.hideLoading() uni.hideLoading();
console.error('导航跳转出错:', error) console.error("导航跳转出错:", error);
uni.showToast({ uni.showToast({
title: '网络错误', title: "网络错误",
icon: 'none', icon: "none",
}) });
} }
}, },
@ -395,15 +417,28 @@
*/ */
goToPray() { goToPray() {
try { try {
console.log('跳转到祈福页面') console.log("跳转到祈福页面");
// 使navigateToPagepray // 使navigateToPagepray
navigateToPage('pray') navigateToPage("pray");
} catch (error) { } catch (error) {
console.error('跳转到祈福页面失败:', error) console.error("跳转到祈福页面失败:", error);
uni.showToast({ uni.showToast({
title: '页面跳转失败', title: "页面跳转失败",
icon: 'none', icon: "none",
}) });
}
},
goToPersonalCenter() {
try {
console.log("跳转到个人中心页面");
navigateToPage("pc");
} catch (error) {
console.error("跳转到祈福页面失败:", error);
uni.showToast({
title: "页面跳转失败",
icon: "none",
});
} }
}, },
@ -413,56 +448,56 @@
playAudio() { playAudio() {
if (!this.templeData.audioUrl) { if (!this.templeData.audioUrl) {
uni.showToast({ uni.showToast({
title: '暂无音频资源', title: "暂无音频资源",
icon: 'none', icon: "none",
}) });
return return;
} }
try { try {
// //
if (this.audioContext) { if (this.audioContext) {
this.stopAudio() this.stopAudio();
} }
// //
this.audioContext = uni.createInnerAudioContext() this.audioContext = uni.createInnerAudioContext();
this.audioContext.src = this.templeData.audioUrl this.audioContext.src = this.templeData.audioUrl;
this.audioContext.loop = true // this.audioContext.loop = true; //
// //
this.audioContext.onPlay(() => { this.audioContext.onPlay(() => {
console.log('音频开始播放') console.log("音频开始播放");
this.isAudioPlaying = true this.isAudioPlaying = true;
uni.showToast({ uni.showToast({
title: '音频已开启', title: "音频已开启",
icon: 'none', icon: "none",
}) });
}) });
this.audioContext.onError(err => { this.audioContext.onError((err) => {
console.error('音频播放错误:', err) console.error("音频播放错误:", err);
this.isAudioPlaying = false this.isAudioPlaying = false;
uni.showToast({ uni.showToast({
title: '音频播放失败', title: "音频播放失败",
icon: 'none', icon: "none",
}) });
}) });
this.audioContext.onEnded(() => { this.audioContext.onEnded(() => {
console.log('音频播放结束') console.log("音频播放结束");
this.isAudioPlaying = false this.isAudioPlaying = false;
}) });
// //
this.audioContext.play() this.audioContext.play();
} catch (error) { } catch (error) {
console.error('音频播放失败:', error) console.error("音频播放失败:", error);
this.isAudioPlaying = false this.isAudioPlaying = false;
uni.showToast({ uni.showToast({
title: '音频播放失败', title: "音频播放失败",
icon: 'none', icon: "none",
}) });
} }
}, },
@ -471,25 +506,26 @@
*/ */
stopAudio() { stopAudio() {
if (this.audioContext) { if (this.audioContext) {
this.audioContext.stop() this.audioContext.stop();
this.audioContext.destroy() this.audioContext.destroy();
this.audioContext = null this.audioContext = null;
} }
this.isAudioPlaying = false this.isAudioPlaying = false;
uni.showToast({ uni.showToast({
title: '音频已关闭', title: "音频已关闭",
icon: 'none', icon: "none",
}) });
}, },
}, },
} };
</script> </script>
<style lang="scss"> <style lang="scss">
page { page {
background-color: #fff; background-color: #fff;
} }
.bot {
.bot {
position: fixed; position: fixed;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
@ -498,15 +534,18 @@
max-width: 750rpx; max-width: 750rpx;
/* 确保不会限制子元素的滚动 */ /* 确保不会限制子元素的滚动 */
overflow: visible; overflow: visible;
.bottom { .bottom {
margin-top: 64rpx; margin-top: 64rpx;
display: flex; display: flex;
padding: 0 118rpx; padding: 0 118rpx;
box-sizing: border-box; box-sizing: border-box;
image { image {
width: 64rpx; width: 64rpx;
height: 64rpx; height: 64rpx;
} }
.rixing { .rixing {
width: 206rpx; width: 206rpx;
height: 64rpx; height: 64rpx;
@ -521,6 +560,7 @@
margin-left: 26rpx; margin-left: 26rpx;
margin-right: 26rpx; margin-right: 26rpx;
} }
.qifu { .qifu {
width: 194rpx; width: 194rpx;
height: 64rpx; height: 64rpx;
@ -529,17 +569,21 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
image { image {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
} }
.zaixian { .zaixian {
margin-left: 12rpx; margin-left: 12rpx;
.da { .da {
font-size: 24rpx; font-size: 24rpx;
color: #522510; color: #522510;
font-weight: 600; font-weight: 600;
} }
.xiao { .xiao {
font-size: 12rpx; font-size: 12rpx;
color: #522510; color: #522510;
@ -547,6 +591,7 @@
} }
} }
} }
.list-scroll { .list-scroll {
width: 100%; width: 100%;
margin-top: 20rpx; margin-top: 20rpx;
@ -560,10 +605,12 @@
/* 隐藏滚动条 */ /* 隐藏滚动条 */
scrollbar-width: none; scrollbar-width: none;
-ms-overflow-style: none; -ms-overflow-style: none;
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;
} }
} }
.list { .list {
display: flex; display: flex;
width: 1600rpx; /* 更大的宽度确保滚动 */ width: 1600rpx; /* 更大的宽度确保滚动 */
@ -571,20 +618,24 @@
box-sizing: border-box; box-sizing: border-box;
/* 确保内容不被压缩 */ /* 确保内容不被压缩 */
flex-shrink: 0; flex-shrink: 0;
.li { .li {
width: 150rpx; width: 150rpx;
flex: 0 0 150rpx; flex: 0 0 150rpx;
text-align: center; text-align: center;
margin-right: 20rpx; margin-right: 20rpx;
image { image {
width: 56rpx; width: 56rpx;
height: 56rpx; height: 56rpx;
} }
.da { .da {
font-size: 24rpx; font-size: 24rpx;
color: #522510; color: #522510;
margin-top: 8rpx; margin-top: 8rpx;
} }
.xiao { .xiao {
font-size: 12rpx; font-size: 12rpx;
color: #522510; color: #522510;
@ -599,15 +650,18 @@
font-size: 28rpx; font-size: 28rpx;
} }
} }
.hua { .hua {
width: 100%; width: 100%;
text-align: center; text-align: center;
margin-top: 30rpx; margin-top: 30rpx;
image { image {
width: 656rpx; width: 656rpx;
height: 108rpx; height: 108rpx;
} }
} }
.time { .time {
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
@ -616,11 +670,13 @@
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
.name { .name {
display: flex; display: flex;
align-items: center; align-items: center;
width: 100%; width: 100%;
justify-content: center; justify-content: center;
text { text {
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
@ -628,13 +684,15 @@
margin-left: 24rpx; margin-left: 24rpx;
margin-right: 24rpx; margin-right: 24rpx;
} }
image { image {
width: 12rpx; width: 12rpx;
height: 12rpx; height: 12rpx;
} }
} }
} }
.tubiao {
.tubiao {
width: 100%; width: 100%;
display: flex; display: flex;
padding: 0 40rpx; padding: 0 40rpx;
@ -667,9 +725,9 @@
opacity: 0.6; opacity: 0.6;
} }
} }
} }
@keyframes pulse { @keyframes pulse {
0% { 0% {
transform: scale(1); transform: scale(1);
} }
@ -679,8 +737,9 @@
100% { 100% {
transform: scale(1); transform: scale(1);
} }
} }
.announcement {
.announcement {
width: 100%; width: 100%;
margin-top: 184rpx; margin-top: 184rpx;
padding: 0 48rpx; padding: 0 48rpx;
@ -688,11 +747,13 @@
display: flex; display: flex;
align-items: center; align-items: center;
white-space: nowrap; white-space: nowrap;
.ggimg { .ggimg {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
margin-right: 14rpx; margin-right: 14rpx;
} }
.marquee-wrap { .marquee-wrap {
width: 600rpx; width: 600rpx;
overflow: hidden; overflow: hidden;
@ -701,6 +762,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
} }
.marquee { .marquee {
white-space: nowrap; white-space: nowrap;
position: absolute; position: absolute;
@ -709,18 +771,19 @@
font-size: 24rpx; font-size: 24rpx;
color: #522510; color: #522510;
} }
} }
.bj {
.bj {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
z-index: -1; z-index: -1;
} }
/* 加载状态指示器样式 */ /* 加载状态指示器样式 */
.loading-overlay { .loading-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -731,17 +794,17 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
z-index: 9999; z-index: 9999;
} }
.loading-content { .loading-content {
background-color: rgba(255, 255, 255, 0.9); background-color: rgba(255, 255, 255, 0.9);
padding: 40rpx 60rpx; padding: 40rpx 60rpx;
border-radius: 20rpx; border-radius: 20rpx;
text-align: center; text-align: center;
} }
.loading-content text { .loading-content text {
font-size: 28rpx; font-size: 28rpx;
color: #333; color: #333;
} }
</style> </style>

View File

@ -6,27 +6,29 @@
// 页面路由配置 // 页面路由配置
export const PAGE_ROUTES = { export const PAGE_ROUTES = {
// 主要功能页面 // 主要功能页面
MONK: '/pages/monk/monk', MONK: "/pages/monk/monk",
MONK_DETAIL: '/pages/monk/monkDetail', MONK_DETAIL: "/pages/monk/monkDetail",
WALK_INTO: '/pages/walkInto/walkInto', WALK_INTO: "/pages/walkInto/walkInto",
INSTITUTIONAL_STRUCTURE: '/pages/institutionalStructure/institutionalStructure', INSTITUTIONAL_STRUCTURE:
ACTIVITY: '/pages/activity/activity', "/pages/institutionalStructure/institutionalStructure",
PRAY: '/pages/pray/pray', ACTIVITY: "/pages/activity/activity",
PRAY: "/pages/pray/pray",
PC: "/pages/personalCenter/personalCenter",
// 待开发页面 // 待开发页面
NEWS: '/pages/news/news', NEWS: "/pages/news/news",
ABBOT: '/pages/abbot/abbot', ABBOT: "/pages/abbot/abbot",
ANCIENT: '/pages/ancient/ancient', ANCIENT: "/pages/ancient/ancient",
FUTURE: '/pages/future/future', FUTURE: "/pages/future/future",
// 其他页面 // 其他页面
LOGIN: '/pages/login/login', LOGIN: "/pages/login/login",
INDEX: '/pages/nearbystores/index', INDEX: "/pages/nearbystores/index",
MY: '/pages/my/my', MY: "/pages/my/my",
MY_ORDER: '/pages/myorder/index', MY_ORDER: "/pages/myorder/index",
MY_ORDER_RETURNED: '/pages/myorder/returned/index', MY_ORDER_RETURNED: "/pages/myorder/returned/index",
} };
// 页面类型映射 // 页面类型映射
export const PAGE_TYPE_MAP = { export const PAGE_TYPE_MAP = {
@ -41,7 +43,8 @@ export const PAGE_TYPE_MAP = {
future: PAGE_ROUTES.FUTURE, future: PAGE_ROUTES.FUTURE,
index: PAGE_ROUTES.INDEX, index: PAGE_ROUTES.INDEX,
pray: PAGE_ROUTES.PRAY, pray: PAGE_ROUTES.PRAY,
} pc: PAGE_ROUTES.PC,
};
/** /**
* 页面跳转方法 * 页面跳转方法
@ -51,37 +54,37 @@ export const PAGE_TYPE_MAP = {
export function navigateToPage(pageType, options = {}) { export function navigateToPage(pageType, options = {}) {
// 清除loading状态 // 清除loading状态
try { try {
uni.hideLoading() uni.hideLoading();
} catch (error) { } catch (error) {
console.warn('清除loading失败:', error) console.warn("清除loading失败:", error);
} }
const targetPage = PAGE_TYPE_MAP[pageType] const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) { if (!targetPage) {
// 使用uni.showToast替代console减少文件系统访问 // 使用uni.showToast替代console减少文件系统访问
uni.showToast({ uni.showToast({
title: '页面配置错误', title: "页面配置错误",
icon: 'none', icon: "none",
}) });
return return;
} }
const defaultOptions = { const defaultOptions = {
url: targetPage, url: targetPage,
fail: err => { fail: (err) => {
// 避免在真机调试时输出过多日志 // 避免在真机调试时输出过多日志
uni.showToast({ uni.showToast({
title: '页面开发中', title: "页面开发中",
icon: 'none', icon: "none",
}) });
}, },
} };
uni.navigateTo({ uni.navigateTo({
...defaultOptions, ...defaultOptions,
...options, ...options,
}) });
} }
/** /**
@ -91,35 +94,35 @@ export function navigateToPage(pageType, options = {}) {
export function switchToTab(pageType) { export function switchToTab(pageType) {
// 清除loading状态 // 清除loading状态
try { try {
uni.hideLoading() uni.hideLoading();
} catch (error) { } catch (error) {
console.warn('清除loading失败:', error) console.warn("清除loading失败:", error);
} }
const tabRoutes = { const tabRoutes = {
index: PAGE_ROUTES.INDEX, index: PAGE_ROUTES.INDEX,
my: PAGE_ROUTES.MY, my: PAGE_ROUTES.MY,
} };
const targetPage = tabRoutes[pageType] const targetPage = tabRoutes[pageType];
if (!targetPage) { if (!targetPage) {
uni.showToast({ uni.showToast({
title: '页面配置错误', title: "页面配置错误",
icon: 'none', icon: "none",
}) });
return return;
} }
uni.switchTab({ uni.switchTab({
url: targetPage, url: targetPage,
fail: err => { fail: (err) => {
uni.showToast({ uni.showToast({
title: '跳转失败', title: "跳转失败",
icon: 'none', icon: "none",
}) });
}, },
}) });
} }
/** /**
@ -131,9 +134,9 @@ export function navigateBack(delta = 1) {
delta, delta,
fail: () => { fail: () => {
// 如果没有上一页,跳转到首页 // 如果没有上一页,跳转到首页
switchToTab('index') switchToTab("index");
}, },
}) });
} }
/** /**
@ -143,24 +146,24 @@ export function navigateBack(delta = 1) {
export function redirectToPage(pageType) { export function redirectToPage(pageType) {
// 清除loading状态 // 清除loading状态
try { try {
uni.hideLoading() uni.hideLoading();
} catch (error) { } catch (error) {
console.warn('清除loading失败:', error) console.warn("清除loading失败:", error);
} }
const targetPage = PAGE_TYPE_MAP[pageType] const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) { if (!targetPage) {
console.error('未知的页面类型:', pageType) console.error("未知的页面类型:", pageType);
return return;
} }
uni.redirectTo({ uni.redirectTo({
url: targetPage, url: targetPage,
fail: err => { fail: (err) => {
console.error('页面重定向失败:', err) console.error("页面重定向失败:", err);
}, },
}) });
} }
/** /**
@ -170,22 +173,22 @@ export function redirectToPage(pageType) {
export function reLaunchToPage(pageType) { export function reLaunchToPage(pageType) {
// 清除loading状态 // 清除loading状态
try { try {
uni.hideLoading() uni.hideLoading();
} catch (error) { } catch (error) {
console.warn('清除loading失败:', error) console.warn("清除loading失败:", error);
} }
const targetPage = PAGE_TYPE_MAP[pageType] const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) { if (!targetPage) {
console.error('未知的页面类型:', pageType) console.error("未知的页面类型:", pageType);
return return;
} }
uni.reLaunch({ uni.reLaunch({
url: targetPage, url: targetPage,
fail: err => { fail: (err) => {
console.error('页面重启失败:', err) console.error("页面重启失败:", err);
}, },
}) });
} }