index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <rich-text :nodes="info.content"></rich-text>
  6. </view>
  7. </view>
  8. </mobile-frame>
  9. </template>
  10. <script>
  11. export default {
  12. components: {},
  13. data() {
  14. return {
  15. id: "",
  16. info: {},
  17. };
  18. },
  19. onLoad: function(e) {
  20. const that = this;
  21. that.$set(that, `id`, e.id || "");
  22. },
  23. onShow: function() {
  24. const that = this;
  25. that.search();
  26. },
  27. methods: {
  28. async search() {
  29. const that = this;
  30. const res = await that.$api(`/banner/${that.id}`, "GET");
  31. if (res.errcode == "0") {
  32. let data = res.data;
  33. if (data.content) data.content = data.content.replace(/\<img/gi, '<img class="rich-img"');
  34. that.$set(that, `info`, data);
  35. } else {
  36. uni.showToast({
  37. title: res.errmsg,
  38. icon: "none",
  39. });
  40. }
  41. },
  42. },
  43. };
  44. </script>
  45. <style lang="scss">
  46. .main {
  47. display: flex;
  48. flex-direction: column;
  49. width: 100vw;
  50. height: 100vh;
  51. .one {
  52. padding: 2vw;
  53. .rich-img {
  54. width: 100% !important;
  55. display: block;
  56. }
  57. }
  58. }
  59. </style>