过滤高僧,法师文章内容背景色样式

This commit is contained in:
WindowBird 2025-09-18 16:21:16 +08:00
parent 5a340d574b
commit 909d6a8470
2 changed files with 529 additions and 495 deletions

View File

@ -5,19 +5,23 @@
<view class="container">
<view class="header">
<view class="content">
<image class="monk-image" :src="monkInfo.imgUrl" mode="aspectFill"></image>
<image
:src="monkInfo.imgUrl"
class="monk-image"
mode="aspectFill"
></image>
</view>
</view>
</view>
<view class="body" :style="{ backgroundColor: CommonEnum.BASE_COLOR }">
<view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="body">
<!-- 导航标签 -->
<view class="nav-tabs">
<view
v-for="(tab, index) in tabs"
:key="index"
class="nav-tab"
:class="{ active: activeTab === index }"
class="nav-tab"
@click="switchTab(index)"
>
{{ tab.title }}
@ -29,10 +33,10 @@
<view class="section-title">
{{ tabs[activeTab].title }}
</view>
<view class="monk-basic" v-if="activeTab === 0">
<view v-if="activeTab === 0" class="monk-basic">
<text class="monk-name">{{ monkInfo.name }}</text>
<view class="duties-wrapper">
<text class="monk-duties">{{ monkInfo.duties || '暂无记录' }}</text>
<text class="monk-duties">{{ monkInfo.duties || "暂无记录" }}</text>
</view>
</view>
<view class="section-content" v-html="tabs[activeTab].content"></view>
@ -42,11 +46,11 @@
</template>
<script>
import CommonEnum from '../../enum/common'
import MonkEnum from '../../enum/monk'
import { getMonkDetail } from '../../api/monk/monkDetail.js'
import CustomNavbar from '../../components/custom-navbar/custom-navbar.vue'
import BaseBackground from '../../components/base-background/base-background.vue'
import CommonEnum from "../../enum/common";
import MonkEnum from "../../enum/monk";
import { getMonkDetail } from "../../api/monk/monkDetail.js";
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
import BaseBackground from "../../components/base-background/base-background.vue";
export default {
components: {
@ -55,10 +59,10 @@
},
computed: {
MonkEnum() {
return MonkEnum
return MonkEnum;
},
CommonEnum() {
return CommonEnum
return CommonEnum;
},
},
data() {
@ -66,71 +70,83 @@
activeTab: 0, //
tabs: [],
monkInfo: {},
}
};
},
onLoad() {
let id = uni.getStorageSync('abbotId')
let id = uni.getStorageSync("abbotId");
//
if (id) {
this.fetchMonkDetail(id)
this.fetchMonkDetail(id);
}
},
methods: {
//
switchTab(index) {
this.activeTab = index
this.activeTab = index;
},
//
async fetchMonkDetail(monkId) {
console.log('开始获取高僧详情, monkId:', monkId)
console.log("开始获取高僧详情, monkId:", monkId);
try {
const res = await getMonkDetail(monkId)
console.log('高僧详情API响应:', res)
const res = await getMonkDetail(monkId);
console.log("高僧详情API响应:", res);
if (res.code === 200 && res.data) {
this.monkInfo = res.data
this.monkInfo = res.data;
//
this.updateTabsContent()
console.log('高僧详情加载完成:', this.monkInfo)
this.updateTabsContent();
console.log("高僧详情加载完成:", this.monkInfo);
} else {
console.error('API响应异常:', res)
console.error("API响应异常:", res);
uni.showToast({
title: res.msg || '获取详情失败',
icon: 'none',
})
title: res.msg || "获取详情失败",
icon: "none",
});
}
} catch (error) {
console.error('获取高僧详情失败:', error)
console.error("获取高僧详情失败:", error);
uni.showToast({
title: '网络错误',
icon: 'none',
})
title: "网络错误",
icon: "none",
});
}
},
//
updateTabsContent() {
this.tabs = [
{
title: '人物简介',
content: this.monkInfo.profile || '暂无简介',
title: "人物简介",
content:
this.monkInfo.profile.replace(/background-color:[^;"]*;?/g, "") ||
"暂无简介",
},
{
title: '人物经历',
content: this.monkInfo.experience || '暂无经历',
title: "人物经历",
content:
this.monkInfo.experience.replace(
/background-color:[^;"]*;?/g,
"",
) || "暂无经历",
},
{
title: '慈善事迹',
content: this.monkInfo.deeds || '暂无事迹',
title: "慈善事迹",
content:
this.monkInfo.deeds.replace(/background-color:[^;"]*;?/g, "") ||
"暂无事迹",
},
{
title: '寺庙贡献',
content: this.monkInfo.contribution || '暂无贡献',
title: "寺庙贡献",
content:
this.monkInfo.contribution.replace(
/background-color:[^;"]*;?/g,
"",
) || "暂无贡献",
},
]
];
},
},
}
};
</script>
<style lang="scss" scoped>
@ -166,6 +182,7 @@
align-items: center;
//background-color: v-bind('CommonEnum.BASE_COLOR'); /* 使 */
}
.content {
padding: 20rpx;
position: relative;
@ -270,7 +287,7 @@
}
.nav-tab.active::after {
content: '';
content: "";
position: absolute;
bottom: -2rpx;
left: 50%;

View File

@ -5,19 +5,23 @@
<view class="container">
<view class="header">
<view class="content">
<image class="monk-image" :src="monkInfo.imgUrl" mode="aspectFill"></image>
<image
:src="monkInfo.imgUrl"
class="monk-image"
mode="aspectFill"
></image>
</view>
</view>
</view>
<view class="body" :style="{ backgroundColor: CommonEnum.BASE_COLOR }">
<view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="body">
<!-- 导航标签 -->
<view class="nav-tabs">
<view
v-for="(tab, index) in tabs"
:key="index"
class="nav-tab"
:class="{ active: activeTab === index }"
class="nav-tab"
@click="switchTab(index)"
>
{{ tab.title }}
@ -29,10 +33,10 @@
<view class="section-title">
{{ tabs[activeTab].title }}
</view>
<view class="monk-basic" v-if="activeTab === 0">
<view v-if="activeTab === 0" class="monk-basic">
<text class="monk-name">{{ monkInfo.name }}</text>
<view class="duties-wrapper">
<text class="monk-duties">{{ monkInfo.duties || '暂无记录' }}</text>
<text class="monk-duties">{{ monkInfo.duties || "暂无记录" }}</text>
</view>
</view>
<view class="section-content" v-html="tabs[activeTab].content"></view>
@ -42,11 +46,11 @@
</template>
<script>
import CommonEnum from '../../enum/common'
import MonkEnum from '../../enum/monk'
import { getMonkDetail } from '../../api/monk/monkDetail.js'
import CustomNavbar from '../../components/custom-navbar/custom-navbar.vue'
import BaseBackground from '../../components/base-background/base-background.vue'
import CommonEnum from "../../enum/common";
import MonkEnum from "../../enum/monk";
import { getMonkDetail } from "../../api/monk/monkDetail.js";
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
import BaseBackground from "../../components/base-background/base-background.vue";
export default {
components: {
@ -55,10 +59,10 @@
},
computed: {
MonkEnum() {
return MonkEnum
return MonkEnum;
},
CommonEnum() {
return CommonEnum
return CommonEnum;
},
},
data() {
@ -66,70 +70,82 @@
activeTab: 0, //
tabs: [],
monkInfo: {},
}
};
},
onLoad(options) {
//
if (options.id) {
this.fetchMonkDetail(options.id)
this.fetchMonkDetail(options.id);
}
},
methods: {
//
switchTab(index) {
this.activeTab = index
this.activeTab = index;
},
//
async fetchMonkDetail(monkId) {
console.log('开始获取高僧详情, monkId:', monkId)
console.log("开始获取高僧详情, monkId:", monkId);
try {
const res = await getMonkDetail(monkId)
console.log('高僧详情API响应:', res)
const res = await getMonkDetail(monkId);
console.log("高僧详情API响应:", res);
if (res.code === 200 && res.data) {
this.monkInfo = res.data
this.monkInfo = res.data;
//
this.updateTabsContent()
console.log('高僧详情加载完成:', this.monkInfo)
this.updateTabsContent();
console.log("高僧详情加载完成:", this.monkInfo);
} else {
console.error('API响应异常:', res)
console.error("API响应异常:", res);
uni.showToast({
title: res.msg || '获取详情失败',
icon: 'none',
})
title: res.msg || "获取详情失败",
icon: "none",
});
}
} catch (error) {
console.error('获取高僧详情失败:', error)
console.error("获取高僧详情失败:", error);
uni.showToast({
title: '网络错误',
icon: 'none',
})
title: "网络错误",
icon: "none",
});
}
},
//
updateTabsContent() {
this.tabs = [
{
title: '人物简介',
content: this.monkInfo.profile || '暂无简介',
title: "人物简介",
content:
this.monkInfo.profile.replace(/background-color:[^;"]*;?/g, "") ||
"暂无简介",
},
{
title: '人物经历',
content: this.monkInfo.experience || '暂无经历',
title: "人物经历",
content:
this.monkInfo.experience.replace(
/background-color:[^;"]*;?/g,
"",
) || "暂无经历",
},
{
title: '慈善事迹',
content: this.monkInfo.deeds || '暂无事迹',
title: "慈善事迹",
content:
this.monkInfo.deeds.replace(/background-color:[^;"]*;?/g, "") ||
"暂无事迹",
},
{
title: '寺庙贡献',
content: this.monkInfo.contribution || '暂无贡献',
title: "寺庙贡献",
content:
this.monkInfo.contribution.replace(
/background-color:[^;"]*;?/g,
"",
) || "暂无贡献",
},
]
];
},
},
}
};
</script>
<style lang="scss" scoped>
@ -165,6 +181,7 @@
align-items: center;
//background-color: v-bind('CommonEnum.BASE_COLOR'); /* 使 */
}
.content {
padding: 20rpx;
position: relative;
@ -269,7 +286,7 @@
}
.nav-tab.active::after {
content: '';
content: "";
position: absolute;
bottom: -2rpx;
left: 50%;