notice.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="home">
  3. <view class="title">
  4. {{info.noticeTitle}}
  5. </view>
  6. <text class="time">创建时间:{{info.createTime}}</text>
  7. <rich-text :nodes="info.noticeContent" style="text-indent: 2em;" class="content"></rich-text>
  8. </view>
  9. </template>
  10. <script>
  11. import { studyDetail } from '@/api/visitor.js'
  12. import baseUrl from '@/utils/baseurl.js'
  13. export default {
  14. data() {
  15. return {
  16. info:{},
  17. id:null
  18. };
  19. },
  20. onLoad:function(option){
  21. this.id = option.id
  22. console.log(this.id)
  23. this.init()
  24. },
  25. methods:{
  26. init(){
  27. const arr = baseUrl.split("/")
  28. let url = ''
  29. for(let i = 0; i < arr.length - 1; i++) {
  30. if (i != arr.length - 2) {
  31. url += arr[i] + "/"
  32. continue
  33. }
  34. url += arr[i]
  35. }
  36. studyDetail(this.id).then(res=>{
  37. res.noticeContent = res.noticeContent.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (match, p1) => {
  38. console.log(match)
  39. return `<img style="width: 90%;text-align: center;" src='${p1.indexOf('http') > -1 ? p1 : url + p1}' />`
  40. })
  41. this.info = res
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss">
  48. .home{
  49. padding:0 30rpx 30rpx;
  50. .title{
  51. color: #252525;
  52. font-size: $uni-title-font-size;
  53. line-height: 300%;
  54. text-align: center;
  55. }
  56. .time{
  57. color: rgba(80, 80, 80, 1);
  58. font-size: 28rpx;
  59. line-height: 200%;
  60. text-align: left;
  61. }
  62. .content{
  63. color: #252525;
  64. font-size: $uni-font-size;
  65. line-height: $uni-line-height;
  66. text-align: left;
  67. text-indent: 2em;
  68. }
  69. }
  70. </style>