index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="one_1">
  5. <view class="text">关于我们</view>
  6. <view class="value">
  7. <rich-text class="rich" :nodes="formatRichText(config.brief)"></rich-text>
  8. </view>
  9. </view>
  10. <view class="one_1">
  11. <view class="text">联系我们</view>
  12. <view class="value">联系电话:{{config.phone||'暂无'}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. import { ref } from 'vue';
  19. //该依赖已内置不需要单独安装
  20. import { onShow } from "@dcloudio/uni-app";
  21. // 基本信息
  22. const config = ref({ logo: [], file: [] });
  23. onShow(async () => {
  24. await searchConfig();
  25. })
  26. // config信息
  27. const searchConfig = async () => {
  28. config.value = uni.getStorageSync('config');
  29. };
  30. // 处理富文本
  31. const formatRichText = (html) => {
  32. if (html) {
  33. // 富文本内容格式化
  34. return html && html.replace(/<img[^>]*>/gi, function (match, capture) {
  35. // 查找所有的 img 元素
  36. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  37. '')
  38. // 删除找到的所有 img 元素中的 style 属性
  39. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  40. }
  41. };
  42. </script>
  43. <style lang="scss" scoped>
  44. .content {
  45. display: flex;
  46. flex-direction: column;
  47. min-height: 100vh;
  48. margin: 4vw;
  49. .one {
  50. padding: 2vw;
  51. border-radius: 5px;
  52. box-shadow:
  53. 0 0 5px rgba(0, 0, 0, 0.1),
  54. /* 内阴影 */
  55. 4px 0 5px rgba(0, 0, 0, 0.1),
  56. /* 右上 */
  57. -4px 0 5px rgba(0, 0, 0, 0.1),
  58. /* 左上 */
  59. 0 4px 5px rgba(0, 0, 0, 0.1),
  60. /* 右下 */
  61. 0 -4px 5px rgba(0, 0, 0, 0.1);
  62. /* 左下 */
  63. .one_1 {
  64. margin: 0 0 2vw 0;
  65. border: 1px solid var(--f9Color);
  66. .text {
  67. color: var(--3c9Color);
  68. font-size: var(--font16Size);
  69. margin: 0 0 2vw 0;
  70. }
  71. .value {
  72. font-size: var(--font14Size);
  73. .rich img {
  74. max-width: 100%;
  75. /* 图片宽度不超过其容器宽度 */
  76. height: auto;
  77. /* 图片高度自动 */
  78. display: block;
  79. /* 图片作为块级元素显示 */
  80. margin: 0 auto;
  81. /* 图片居中 */
  82. }
  83. }
  84. }
  85. }
  86. }
  87. </style>