富文本接口请求

This commit is contained in:
陈善美 2025-08-28 20:24:46 +08:00
parent 45c0f1e05b
commit cf792b854a
5 changed files with 82 additions and 51 deletions

10
src/api/other.ts Normal file
View File

@ -0,0 +1,10 @@
import { request } from '@/utils/request'
// 富文本案例介绍
export const editorApi = (data : { key : string }) => {
return request({
method: 'POST',
url: 'api/index/editor',
data,
})
}

View File

@ -101,7 +101,7 @@
"pages": [{ "pages": [{
"path": "pages/blank/rich-text", "path": "pages/blank/rich-text",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": ""
// #ifdef WEB // #ifdef WEB
"navigationStyle": "custom" "navigationStyle": "custom"
// #endif // #endif

View File

@ -1,24 +1,47 @@
<script setup lang="ts">
const props = defineProps<{
title?: string
content: string
}>()
const content = decodeURIComponent(props.content)
//
if (props.title) {
uni.setNavigationBarTitle({ title: props.title })
}
</script>
<template> <template>
<view class="rich-text"> <view class="rich-text">
<mp-html :content="content" /> <mp-html :content="richText" />
</view> </view>
</template> </template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { editorApi } from '@/api/other.ts'
const props = defineProps<{
title ?: string
content : string
}>()
const content = decodeURIComponent(props.content)
const richText = ref()
const title = ref()
const params = {
key: 'expoApply'
}
onLoad(() => {
editor()
})
//
// if (props.title) {
// // uni.setNavigationBarTitle({ title: props.title })
// }
//
const editor = () => {
editorApi(params).then(res => {
if (res.code == 1) {
richText.value = res.data.editor
uni.setNavigationBarTitle({ title: res.data.title })
}
})
}
</script>
<style scoped lang="scss"> <style scoped lang="scss">
.rich-text { .rich-text {
padding: 20rpx 10rpx; padding: 30rpx;
} text-indent: 60rpx;
}
</style> </style>

View File

@ -33,9 +33,7 @@ const onLogout = () => {
// //
const toRichTextPage = (type: string) => { const toRichTextPage = (type: string) => {
const agreements = settngStore.data.agreement const agreements = settngStore.data.agreement
const content = encodeURIComponent(agreements[type as keyof typeof agreements]) const content = encodeURIComponent(agreements[type as keyof typeof agreements])
uni.navigateTo({ uni.navigateTo({
url: `${pageUrl['rich-text']}?content=${content}`, url: `${pageUrl['rich-text']}?content=${content}`,
}) })

View File

@ -53,43 +53,43 @@ export const isIOSWithHomeIndicator = () => {
*/ */
export enum pageUrl { export enum pageUrl {
// pages // pages
'index' = '/pages/index/index', 'index' = '/pages/home/index',
'my' = '/pages/my/my', 'my' = '/pages/my/userCenter',
'cart' = '/pages/cart/cart', 'assistant' = 'pages/assistant/index',
'category' = '/pages/category/category', 'todo' = 'pages/todo/index',
// pagesGoods // pagesGoods
'goods-list' = '/pagesGoods/pages/list/list', 'goods-list' = '/pagesShop/pages/list/list',
'goods-detail' = '/pagesGoods/pages/goods/goods', 'goods-detail' = '/pagesShop/pages/goods/goods',
'goods-evaluate' = '/pagesGoods/pages/evaluate/evaluate', 'goods-evaluate' = '/pagesShop/pages/evaluate/evaluate',
'goods-search' = '/pagesGoods/pages/search/search', 'goods-search' = '/pagesShop/pages/search/search',
// pagesOrder // pagesOrder
'order-create' = '/pagesOrder/pages/create/create', 'order-create' = '/pagesShop/pages/create/create',
'order-detail' = '/pagesOrder/pages/detail/detail', 'order-detail' = '/pagesShop/pages/detail/detail',
'order-pay' = '/pagesOrder/pages/payment/pay', 'order-pay' = '/pagesShop/pages/payment/pay',
'order-payment' = '/pagesOrder/pages/payment/payment', 'order-payment' = '/pagesShop/pages/payment/payment',
'order-list' = '/pagesOrder/pages/list/list', 'order-list' = '/pagesShop/pages/list/list',
'order-receive' = '/pagesOrder/pages/receive/receive', 'order-receive' = '/pagesShop/pages/receive/receive',
'order-evaluate' = '/pagesOrder/pages/evaluate/evaluate', 'order-evaluate' = '/pagesShop/pages/evaluate/evaluate',
'order-refund' = '/pagesOrder/pages/refund/refund', 'order-refund' = '/pagesShop/pages/refund/refund',
'order-refund-list' = '/pagesOrder/pages/refund/list', 'order-refund-list' = '/pagesShop/pages/refund/list',
'order-refund-detail' = '/pagesOrder/pages/refund/detail', 'order-refund-detail' = '/pagesShop/pages/refund/detail',
'order-delivery' = '/pagesOrder/pages/delivery/delivery', 'order-delivery' = '/pagesShop/pages/delivery/delivery',
'order-center' = '/pagesOrder/pages/center/center', 'order-center' = '/pagesShop/pages/center/center',
'recharge-order-list' = '/pagesOrder/pages/recharge/list', 'recharge-order-list' = '/pagesShop/pages/recharge/list',
// pagesMember // pagesMember
'login' = '/pagesMember/pages/login/login', 'login' = '/pagesShop/pages/login/login',
'setting' = '/pagesMember/pages/settings/settings', 'setting' = '/pagesShop/pages/settings/settings',
'profile' = '/pagesMember/pages/profile/profile', 'profile' = '/pagesShop/pages/profile/profile',
'address' = '/pagesMember/pages/address/address', 'address' = '/pagesShop/pages/address/address',
'address-form' = '/pagesMember/pages/address/address-form', 'address-form' = '/pagesShop/pages/address/address-form',
'balance' = '/pagesMember/pages/balance/balance', 'balance' = '/pagesShop/pages/balance/balance',
'balance-recharge' = '/pagesMember/pages/balance/recharge', 'balance-recharge' = '/pagesShop/pages/balance/recharge',
'coupon' = '/pagesMember/pages/coupon/coupon', 'coupon' = '/pagesShop/pages/coupon/coupon',
'coupon-center' = '/pagesMember/pages/coupon/center', 'coupon-center' = '/pagesShop/pages/coupon/center',
'favorite' = '/pagesMember/pages/favorite/favorite', 'favorite' = '/pagesShop/pages/favorite/favorite',
// pagesOther // pagesOther
'rich-text' = '/pagesOther/pages/blank/rich-text', 'rich-text' = '/pagesOther/pages/blank/rich-text',