notedetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="page">
  3. <view class="title">
  4. {{detail.title}}
  5. </view>
  6. <view class="time2">
  7. {{timestamp(detail.addtime)}}
  8. </view>
  9. <view class="content">
  10. <!-- <rich-text class="text" :nodes="toText(detail.content)"></rich-text> -->
  11. <u-parse :content="toText(detail.content)" @navigate="navigate" />
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import uParse from '../../components/gaoyia-parse/parse.vue'
  17. export default {
  18. components: {
  19. uParse
  20. },
  21. data() {
  22. return {
  23. note:uni.getStorageSync('note'),
  24. detail:''
  25. }
  26. },
  27. methods: {
  28. navigate(e){
  29. let params = {url: e};
  30. return this.$jump('web.index',params)
  31. },
  32. toText(msg){
  33. var text= msg.replace(/<\/?[^>]*>/g, '');
  34. text=text.replace(/\n\n/g, '<br>');
  35. // text=text.replace(/\n/g, '<br>');
  36. //text=text.replace(/ /g, '&nbsp;');
  37. var reg= /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  38. // console.log(str);
  39. var s = text.match(reg);
  40. if(s!=null){
  41. for(var i=0;i<s.length;i++){
  42. text=text.replace(s[i],'<a style="color:#2319dc;" href="'+s[i]+'">'+s[i]+'</a>');
  43. }
  44. }
  45. return text;
  46. },
  47. timestamp(time){
  48. // return action.timestampFormat(new Date(time.replace(/(-|年|月)/g, '/').replace('日', '')).getTime()/1000)
  49. return this.$action.timestampFormat(time)
  50. },
  51. },
  52. onLoad(opts) {
  53. this.detail=this.note[opts.index]
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. .title{
  59. text-align: center;
  60. height: 35px;
  61. line-height: 35px;
  62. color: #000;;
  63. font-size: 16px;;
  64. font-weight: 600;
  65. margin-top: 0px;;
  66. }
  67. .title2{
  68. text-align: center;
  69. height: 30px;
  70. line-height: 30px;
  71. color: #000;;
  72. font-size: 16px;;
  73. font-weight: 600;
  74. }
  75. .time2{
  76. text-align: center;
  77. height: 20px;
  78. line-height: 20px;
  79. color: #666;
  80. font-size: 12px;
  81. border-bottom: 1px #eee solid;
  82. }
  83. .content{
  84. padding: 5px 10px;
  85. line-height: 30px;;
  86. overflow-y: scroll;
  87. font-size: 14px;
  88. }
  89. .content .text{
  90. line-height: 25px;
  91. }
  92. </style>