index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 class="one">
  32. <view class="one_1">公众号</view>
  33. <view class="one_2">
  34. <image class="image" :show-menu-by-longpress="true" :src="getUrl(info.Code)"></image>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. components: {},
  42. data() {
  43. return {
  44. config: {},
  45. info: {},
  46. }
  47. },
  48. onLoad: async function(e) {
  49. const that = this;
  50. that.searchConfig();
  51. },
  52. methods: {
  53. searchConfig() {
  54. const that = this;
  55. try {
  56. const res = uni.getStorageSync('config');
  57. if (res) {
  58. that.$set(that, `config`, res);
  59. that.$set(that, `info`, res?.footInfo);
  60. }
  61. } catch (e) {}
  62. },
  63. // 图片处理
  64. getUrl(e) {
  65. const that = this;
  66. if (e && e.length > 0) return that.$config.serverFile + e[0].url
  67. else return '/static/match.png'
  68. },
  69. // 处理富文本
  70. formatRichText(html) {
  71. if (html) {
  72. html = html.replace(/<table[^>]*>/gi, match => {
  73. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  74. return match.replace(/style="[^"]+"/gi,
  75. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  76. .replace(/<table/gi,
  77. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  78. });
  79. html = html.replace(/<th[^>]*>/gi, match => {
  80. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  81. return match.replace(/style="[^"]+"/gi,
  82. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  83. )
  84. .replace(/<table/gi,
  85. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  86. );
  87. });
  88. html = html.replace(/<td[^>]*>/gi, match => {
  89. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  90. return match.replace(/style="[^"]+"/gi,
  91. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  92. .replace(/<table/gi,
  93. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  94. });
  95. // 富文本内容格式化
  96. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  97. // 查找所有的 img 元素
  98. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  99. '')
  100. // 删除找到的所有 img 元素中的 style 属性
  101. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  102. }
  103. },
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .main {
  109. background-color: var(--f9Color);
  110. .one {
  111. padding: 2vw;
  112. margin: 2vw 0 0 0;
  113. background-color: var(--mainColor);
  114. .one_1 {
  115. text-indent: 10px;
  116. border-left: 3px solid var(--f3CColor);
  117. font-weight: bold;
  118. font-size: var(--font16Size);
  119. }
  120. .one_2 {
  121. padding: 2vw;
  122. font-size: var(--font14Size);
  123. color: var(--f69Color);
  124. display: flex;
  125. align-items: center;
  126. .t-icon {
  127. width: var(--font14Size);
  128. height: var(--font14Size);
  129. }
  130. text {
  131. margin: 0 0 0 1vw;
  132. }
  133. .image {
  134. width: 150px;
  135. height: 150px;
  136. }
  137. }
  138. }
  139. }
  140. </style>