message.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view :class="[AppTheme]" class="message" v-if="info">
  3. <u-parse :content="info.contents"></u-parse>
  4. </view>
  5. </template>
  6. <script>
  7. import homeApi from '@/api/home/index.js';
  8. export default {
  9. data() {
  10. return {
  11. primary: this.$theme.primary,
  12. info: '',
  13. settingFile: getApp().globalData.siteinfo
  14. };
  15. },
  16. onLoad(options) {
  17. let that = this
  18. console.log('options', JSON.stringify(options))
  19. if (!options.type) {
  20. options.type = 1;
  21. }
  22. console.log('options', JSON.stringify(options))
  23. if (options.type == 1) {
  24. if (options.id !== null && options.id !== undefined) {
  25. let data = {
  26. id: options.id
  27. }
  28. homeApi.Notice(data).then((ret) => {
  29. if (ret.data.artical) {
  30. uni.setNavigationBarTitle({
  31. title: ret.data.artical.title
  32. })
  33. that.info = ret.data.artical
  34. that.info.contents = that.info.contents.replace(/\<img src="/gi,
  35. `<img style='width:100%;display:block' src="${that.settingFile.root_rich_img}`);
  36. }
  37. })
  38. }
  39. } else if (options.type == 2) {
  40. if (options.title !== null && options.title !== undefined) {
  41. let data = {
  42. title: options.title
  43. }
  44. homeApi.Artical(data).then((ret) => {
  45. if (ret.data.artical) {
  46. uni.setNavigationBarTitle({
  47. title: ret.data.artical.title
  48. })
  49. that.info = ret.data.artical
  50. that.info.contents = that.info.content.replace(/\<img src="/gi,
  51. `<img style='width:100%' src="${that.settingFile.root_rich_img}`);
  52. }
  53. })
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. page {
  61. background-color: #ffffff;
  62. }
  63. .message {
  64. padding: 30rpx 20rpx 70rpx 20rpx;
  65. background: #fff;
  66. .author {
  67. font-size: 30rpx;
  68. margin-bottom: 20rpx;
  69. text-align: center;
  70. }
  71. .content {
  72. font-size: 28rpx;
  73. line-height: 40rpx;
  74. margin-bottom: 40rpx;
  75. }
  76. .read {
  77. color: #cecece;
  78. font-size: 28rpx;
  79. }
  80. .ft-flex {
  81. display: flex;
  82. justify-content: flex-end;
  83. }
  84. }
  85. </style>