文件
Henglianshutong/uniapp/pages/public/richtext.vue

69 行
2.1 KiB
Vue

<template>
<s-layout class="set-wrap" :title="state.title" :bgStyle="{ color: '#FFF' }">
<view class="ss-p-30 richtext"><mp-html :content="state.content"></mp-html></view>
</s-layout>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import sheep from '@/sheep';
const state = reactive({
title: '',
content: '',
});
const defaultPendingContent = `<div style="padding: 60px 20px 40px; text-align: center; font-family: sans-serif;">
<div style="width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 50%; background: #FAF5EB; border: 1px solid #E5D3B3; display: flex; align-items: center; justify-content: center;">
<span style="font-size: 34px; line-height: 76px;">⏳</span>
</div>
<div style="font-size: 20px; font-weight: bold; color: #262626; margin-bottom: 12px; letter-spacing: 1px;">待开发,敬请期待</div>
<div style="font-size: 14px; color: #8C8C8C; line-height: 1.6; max-width: 280px; margin: 0 auto;">该业务板块正在加速筹备建设中<br/>更多专属权益即将上线</div>
</div>`;
async function getRichTextContent(id) {
if (!id) {
state.content = defaultPendingContent;
return;
}
try {
const { code, data } = await sheep.$api.data.richtext(id);
if (code === 1 && data?.content) {
state.content = data.content;
if (state.title === '') {
state.title = data.title;
uni.setNavigationBarTitle({
title: state.title,
});
}
} else {
state.content = defaultPendingContent;
}
} catch (e) {
state.content = defaultPendingContent;
}
}
onLoad((options) => {
if (options.title) {
state.title = options.title;
uni.setNavigationBarTitle({
title: state.title,
});
}
getRichTextContent(options.id);
});
</script>
<style lang="scss" scoped>
.set-title {
margin: 0 30rpx;
}
:deep() {
image {
display: block;
}
}
</style>