brief.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="brief_body" :style="'background-image:url('+ back +')'">
  3. <view v-for="(item, i) in p" :key="i">
  4. <view class="paragraph" v-if="item.context" v-text="item.context"></view>
  5. <image v-if="item.url"
  6. :style=" item.style ? 'width:'+ item.style.w +'px;height:' + item.style.h + 'px' : '' " :src="item.url"
  7. @load="e=>imageload(e,i)" mode="scaleToFill"></image>
  8. </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. import {
  13. defineProps,
  14. ref
  15. } from "vue";
  16. import config from "../../config/index.js";
  17. import {
  18. onShareAppMessage,
  19. onShareTimeline
  20. } from '@dcloudio/uni-app'
  21. onShareAppMessage(() => {})
  22. onShareTimeline(() => {})
  23. const props = defineProps({
  24. page: String
  25. })
  26. const p = ref([]);
  27. const back = ref("");
  28. const info = uni.getSystemInfoSync();
  29. uni.request({
  30. url: config.base + props.page + ".json?" + Date.now(),
  31. success: r => {
  32. if (r.statusCode !== 200) return
  33. p.value = r.data.list || [];
  34. back.value = r.data.background || "";
  35. }
  36. })
  37. function imageload(v, i) {
  38. const w = info.windowWidth;
  39. const h = v.detail.height / v.detail.width * w;
  40. p.value[i].style = {
  41. w,
  42. h
  43. };
  44. }
  45. </script>
  46. <style lang="scss">
  47. .brief_body {
  48. font-size: 0;
  49. background-position: 0%;
  50. background-size: 100% 100%;
  51. background-repeat: no-repeat;
  52. height: 100vh;
  53. overflow-y: auto;
  54. .paragraph {
  55. font-size: 16px;
  56. padding: .5em;
  57. text-indent: 2em;
  58. line-height: 1.5em;
  59. }
  60. }
  61. </style>