index.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. that.search();
  23. },
  24. methods: {
  25. async search() {
  26. const that = this;
  27. const res = await that.$api(`/banner/${that.id}`, "GET");
  28. if (res.errcode == "0") {
  29. let data = res.data;
  30. if (data.content) data.content = data.content.replace(/\<img/gi, '<img class="rich-img"');
  31. that.$set(that, `info`, data);
  32. } else {
  33. uni.showToast({
  34. title: res.errmsg,
  35. icon: "none",
  36. });
  37. }
  38. },
  39. },
  40. };
  41. </script>
  42. <style lang="scss">
  43. .main {
  44. display: flex;
  45. flex-direction: column;
  46. width: 100vw;
  47. height: 100vh;
  48. .one {
  49. padding: 2vw;
  50. .rich-img {
  51. width: 100% !important;
  52. display: block;
  53. }
  54. }
  55. }
  56. </style>