index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="container main">
  3. <view class="one">
  4. <view class="one_1">联系电话</view>
  5. <view class="one_2">
  6. <text class="t-icon t-icon-bohao"></text>
  7. <text :user-select="true"> {{info.Phone||'暂无'}}</text>
  8. </view>
  9. </view>
  10. <view class="one">
  11. <view class="one_1">电子邮箱</view>
  12. <view class="one_2">
  13. <text class="t-icon t-icon-youxiang"></text>
  14. <text :user-select="true"> {{info.Email||'暂无'}}</text>
  15. </view>
  16. </view>
  17. <view class="one">
  18. <view class="one_1">公司</view>
  19. <view class="one_2">
  20. <text class="t-icon t-icon-gongsi"></text>
  21. <text :user-select="true"> {{info.Company||'暂无'}}</text>
  22. </view>
  23. </view>
  24. <view class="one">
  25. <view class="one_1">地址</view>
  26. <view class="one_2">
  27. <text class="t-icon t-icon-zuobiao"></text>
  28. <text :user-select="true"> {{info.Address||'暂无'}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. components: {},
  36. data() {
  37. return {
  38. config: {},
  39. info: {},
  40. }
  41. },
  42. onLoad: async function(e) {
  43. const that = this;
  44. that.searchConfig();
  45. },
  46. methods: {
  47. searchConfig() {
  48. const that = this;
  49. try {
  50. const res = uni.getStorageSync('config');
  51. if (res) {
  52. that.$set(that, `config`, res);
  53. that.$set(that, `info`, res?.footInfo);
  54. }
  55. } catch (e) {}
  56. },
  57. // 处理富文本
  58. formatRichText(html) {
  59. if (html) {
  60. html = html.replace(/<table[^>]*>/gi, match => {
  61. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  62. return match.replace(/style="[^"]+"/gi,
  63. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  64. .replace(/<table/gi,
  65. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  66. });
  67. html = html.replace(/<th[^>]*>/gi, match => {
  68. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  69. return match.replace(/style="[^"]+"/gi,
  70. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  71. )
  72. .replace(/<table/gi,
  73. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  74. );
  75. });
  76. html = html.replace(/<td[^>]*>/gi, match => {
  77. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  78. return match.replace(/style="[^"]+"/gi,
  79. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  80. .replace(/<table/gi,
  81. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  82. });
  83. // 富文本内容格式化
  84. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  85. // 查找所有的 img 元素
  86. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  87. '')
  88. // 删除找到的所有 img 元素中的 style 属性
  89. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  90. }
  91. },
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .main {
  97. background-color: var(--f9Color);
  98. .one {
  99. padding: 2vw;
  100. margin: 2vw 0 0 0;
  101. background-color: var(--mainColor);
  102. .one_1 {
  103. text-indent: 10px;
  104. border-left: 3px solid var(--f3CColor);
  105. font-weight: bold;
  106. font-size: var(--font16Size);
  107. }
  108. .one_2 {
  109. padding: 2vw;
  110. font-size: var(--font14Size);
  111. color: var(--f69Color);
  112. display: flex;
  113. align-items: center;
  114. .t-icon {
  115. width: var(--font14Size);
  116. height: var(--font14Size);
  117. }
  118. text {
  119. margin: 0 0 0 1vw;
  120. }
  121. }
  122. }
  123. }
  124. </style>