index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. margin: 4vw;
  48. .one {
  49. padding: 2vw;
  50. border-radius: 5px;
  51. box-shadow:
  52. 0 0 5px rgba(0, 0, 0, 0.1),
  53. /* 内阴影 */
  54. 4px 0 5px rgba(0, 0, 0, 0.1),
  55. /* 右上 */
  56. -4px 0 5px rgba(0, 0, 0, 0.1),
  57. /* 左上 */
  58. 0 4px 5px rgba(0, 0, 0, 0.1),
  59. /* 右下 */
  60. 0 -4px 5px rgba(0, 0, 0, 0.1);
  61. /* 左下 */
  62. .one_1 {
  63. margin: 0 0 2vw 0;
  64. border: 1px solid var(--f9Color);
  65. .text {
  66. color: var(--3c9Color);
  67. font-size: var(--font16Size);
  68. margin: 0 0 2vw 0;
  69. }
  70. .value {
  71. font-size: var(--font14Size);
  72. .rich img {
  73. max-width: 100%;
  74. /* 图片宽度不超过其容器宽度 */
  75. height: auto;
  76. /* 图片高度自动 */
  77. display: block;
  78. /* 图片作为块级元素显示 */
  79. margin: 0 auto;
  80. /* 图片居中 */
  81. }
  82. }
  83. }
  84. }
  85. }
  86. </style>