Merge branch 'master' of https://gitea.zianxin.com/zax/biz-mobile-react-cloud
This commit is contained in:
commit
806eafa5a6
4 files changed
+130
No files matched your search
@@ -569,6 +569,12 @@
|
||||
"navigationBarTitleText": "公告详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "sysbanner/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "轮播公告详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "visitor/invitation",
|
||||
"style": {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<view class="banner-detail">
|
||||
<view class="detail-header">
|
||||
<view class="title">{{ detail.title || "加载中..." }}</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-tip">加载中...</view>
|
||||
<view v-else-if="error" class="error-tip">{{ error }}</view>
|
||||
<view v-else class="detail-content">
|
||||
<rich-text :nodes="richTextNodes || ''" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import sysBannerApi from "@/sheep/api/sysBanner"
|
||||
import { filePath } from "@/sheep/utils/file"
|
||||
|
||||
const detail = ref<{ title?: string; richTextContent?: string }>({})
|
||||
const loading = ref(false)
|
||||
const error = ref("")
|
||||
|
||||
const toAbsoluteUrl = (url?: string | null) => {
|
||||
if (!url) return ""
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
return filePath(url)
|
||||
}
|
||||
|
||||
const richTextNodes = computed(() => {
|
||||
const html = detail.value.richTextContent
|
||||
if (!html) return ""
|
||||
return html.replace(/<img\s+[^>]*src=["']([^"']+)["']/gi, (match, src) => {
|
||||
const fullSrc = toAbsoluteUrl(src)
|
||||
if (!fullSrc) return match
|
||||
return match.replace(src, fullSrc)
|
||||
})
|
||||
})
|
||||
|
||||
onLoad(async (options: any) => {
|
||||
const id = options.id
|
||||
if (!id) {
|
||||
error.value = "缺少轮播图 ID"
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
error.value = ""
|
||||
try {
|
||||
const response: any = await sysBannerApi.getDetail(id)
|
||||
if (response.code === 0 && response.data) {
|
||||
detail.value = {
|
||||
title: response.data.title,
|
||||
richTextContent: response.data.richTextContent,
|
||||
}
|
||||
} else {
|
||||
error.value = response.msg || "轮播图不存在"
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = "获取详情失败"
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.banner-detail {
|
||||
padding: 32rpx;
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-tip,
|
||||
.error-tip {
|
||||
text-align: center;
|
||||
padding: 80rpx 32rpx;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.error-tip {
|
||||
color: #f44336;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx;
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
line-height: 1.8;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -40,6 +40,8 @@ export { default as hardApi } from "./hard"
|
||||
|
||||
export { default as noticeApi } from "./notice"
|
||||
|
||||
export { default as sysBannerApi } from "./sysBanner"
|
||||
|
||||
export { default as invitationApi } from "./invitation"
|
||||
|
||||
export { default as totalApi } from "./total"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import request from "@/sheep/utils/request"
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 根据轮播图 id 查询标题和富文本详情
|
||||
*/
|
||||
getDetail: (id: string) =>
|
||||
request({
|
||||
url: `/integrated/sysBanner/detail/${id}`,
|
||||
method: "GET",
|
||||
}),
|
||||
}
|
||||
Reference in new issue
Block a user