Monk组件动态创建

This commit is contained in:
minimaxagent1 2025-07-29 16:24:38 +08:00
parent 8d1bb07ac0
commit 7c7ebc6271
2 changed files with 190 additions and 130 deletions

View File

@ -0,0 +1,14 @@
import { request } from '@/utils/request.js'
/**
* 获取高僧列表
* @param {Object} params 查询参数
* @returns {Promise}
*/
export function getMonkList(params = {}) {
return request({
url: '/app/monk/listMonk',
method: 'GET',
params
})
}

View File

@ -11,11 +11,13 @@
<view class="search-btn">搜索</view> <view class="search-btn">搜索</view>
</view> </view>
<view class="monk-list"> <view class="monk-list">
<view class="monk-item" v-for="(item, idx) in monkList" :key="idx"> <view class="monk-item" v-for="(item, idx) in monkList" :key="item.id">
<image class="monk-avatar" :src="item.avatar" mode="aspectFill"></image> <image class="monk-avatar" :src="item.imgUrl" mode="aspectFill"></image>
<view class="monk-info"> <view class="monk-info">
<view class="monk-desc">{{ item.desc }}</view> <view class="desc-row">
<view class="monk-detail" @click="goDetail(item)">查看详情></view> <view class="monk-desc">{{ item.name }}{{ stripHtmlTags(item.profile) }}</view>
<view class="monk-detail" @click="goDetail(item)">查看详情&gt;</view>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -24,138 +26,182 @@
</template> </template>
<script> <script>
import { CommonEnum } from '@/enum/common.js'; import {
import { MonkEnum } from '@/enum/monk.js'; CommonEnum
} from '@/enum/common.js'
import {
MonkEnum
} from '@/enum/monk.js'
import {
getMonkList
} from '@/api/monk.js'
export default { export default {
data() { data() {
return { return {
bgc: { bgc: {
backgroundColor: "#F5F0E7", backgroundColor: "#F5F0E7"
},
CommonEnum,
MonkEnum,
monkList: [
{
avatar: 'https://api.ccttiot.com/image-1753770000001.png',
desc: '释某某法师现任平山寺方丈。法师于2000年在平山寺剃度出家2001年平山寺龙坛受具足戒师承临济宗第11代传人深耕禅修。',
}, },
{ CommonEnum,
avatar: 'https://api.ccttiot.com/image-1753770000001.png', MonkEnum,
desc: '释某某法师现任平山寺方丈。法师于2000年在平山寺剃度出家2001年平山寺龙坛受具足戒师承临济宗第11代传人深耕禅修。', monkList: []
}, }
{ },
avatar: 'https://api.ccttiot.com/image-1753770000001.png', onLoad() {
desc: '释某某法师现任平山寺方丈。法师于2000年在平山寺剃度出家2001年平山寺龙坛受具足戒师承临济宗第11代传人深耕禅修。', this.fetchMonkList()
},
methods: {
async fetchMonkList() {
try {
const res = await getMonkList()
if (res.code === 200 && Array.isArray(res.rows)) {
this.monkList = res.rows
} else {
uni.showToast({
title: res.msg || '获取失败',
icon: 'none'
})
}
} catch (e) {
uni.showToast({
title: '网络错误',
icon: 'none'
})
} }
] },
} // HTML
}, stripHtmlTags(html) {
methods: { if (!html) return ''; //
goDetail(item) { return html.replace(/<[^>]+>/g, ''); // HTML
uni.showToast({ },
title: '详情功能待开发', goDetail(item) {
icon: 'none' uni.showToast({
}) title: '详情功能待开发',
icon: 'none'
})
}
} }
} }
}
</script> </script>
<style lang="scss"> <style lang="scss">
.page { .page {
width: 750rpx; width: 750rpx;
min-height: 100vh; min-height: 100vh;
background: #F5F0E7; background: #F5F0E7;
border-radius: 0rpx 0rpx 0rpx 0rpx; border-radius: 0rpx 0rpx 0rpx 0rpx;
} }
.container {
display: flex; .container {
flex-direction: column; display: flex;
align-items: center; flex-direction: column;
min-height: 100vh; align-items: center;
background-color: transparent; min-height: 100vh;
margin: 20px 14px 40rpx 14px; background-color: transparent;
width: 694rpx; margin: 20px 14px 40rpx 14px;
border-radius: 16rpx; width: 694rpx;
position: relative; border-radius: 16rpx;
} position: relative;
.background-image { }
position: absolute;
top: 0; .background-image {
left: 0; position: absolute;
width: 100%; top: 0;
height: 100%; left: 0;
z-index: -1; width: 100%;
border-radius: 16rpx; height: 100%;
} z-index: -1;
.searchBox { border-radius: 16rpx;
display: flex; }
align-items: center;
width: 660rpx; .searchBox {
height: 70rpx; display: flex;
background: #FFFBF5; align-items: center;
border-radius: 10rpx; width: 660rpx;
border: 1rpx solid #C7A26D; height: 70rpx;
margin-top: 20rpx; background: #FFFBF5;
padding: 0 12rpx; border-radius: 10rpx;
} border: 1rpx solid #C7A26D;
.search-icon { margin-top: 20rpx;
width: 32rpx; padding: 0 12rpx;
height: 32rpx; }
margin: 0 16rpx 0 0;
} .search-icon {
.search-text { width: 32rpx;
flex: 1; height: 32rpx;
font-size: 28rpx; margin: 0 16rpx 0 0;
color: #bfa16b; }
}
.search-btn { .search-text {
background: #bfa16b; flex: 1;
color: #fff; font-size: 28rpx;
font-size: 26rpx; color: #bfa16b;
border-radius: 6rpx; }
padding: 0 24rpx;
height: 48rpx; .search-btn {
display: flex; background: #bfa16b;
align-items: center; color: #fff;
justify-content: center; font-size: 26rpx;
margin-left: 16rpx; border-radius: 6rpx;
} padding: 0 24rpx;
.monk-list { height: 48rpx;
width: 100%; display: flex;
margin-top: 24rpx; align-items: center;
} justify-content: center;
.monk-item { margin-left: 16rpx;
display: flex; }
flex-direction: row;
align-items: flex-start; .monk-list {
background: transparent; width: 100%;
margin-bottom: 24rpx; margin-top: 24rpx;
} }
.monk-avatar {
width: 100rpx; .monk-item {
height: 100rpx; display: flex;
background: #e5e5e5; flex-direction: row;
border-radius: 8rpx; align-items: flex-start;
margin-right: 18rpx; background: transparent;
} margin-bottom: 24rpx;
.monk-info { }
flex: 1;
display: flex; .monk-avatar {
flex-direction: column; width: 184rpx;
justify-content: space-between; height: 184rpx;
} background: #e5e5e5;
.monk-desc { border-radius: 8rpx;
font-size: 26rpx; margin-right: 18rpx;
color: #695347; }
line-height: 1.6;
margin-bottom: 8rpx; .monk-info {
word-break: break-all; flex: 1;
} display: flex;
.monk-detail { flex-direction: column;
color: #bfa16b; justify-content: flex-start;
font-size: 24rpx; }
align-self: flex-end;
} .desc-row {
display: flex;
align-items: flex-end;
flex-direction: column;
width: 100%;
}
.monk-desc {
line-height: 38rpx;
font-size: 28rpx;
color: #695347;
margin-top: 8rpx;
word-break: break-all;
// 4
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
overflow: hidden;
}
.monk-detail {
color: #bfa16b;
font-size: 24rpx;
white-space: nowrap;
}
</style> </style>