WContent.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="w-content" :style="`background-image:${getBgUrl(bgid)}`">
  3. <slot/>
  4. </div>
  5. </template>
  6. <style lang="scss" scoped>
  7. .w-content {
  8. position: absolute;
  9. top: 72px;
  10. left: 0;
  11. right: 0;
  12. bottom: 0;
  13. overflow: auto;
  14. background-repeat: no-repeat;
  15. background-position: center;
  16. background-color: #EEEEEE;
  17. background-size: cover;
  18. .w-container {
  19. min-height: 500px;
  20. }
  21. }
  22. </style>
  23. <script>
  24. export default {
  25. name: 'WContent',
  26. data() {
  27. return {
  28. bgid: -1,
  29. }
  30. },
  31. mounted() {
  32. this.bgid = $A.runNum(this.usrInfo.bgid);
  33. },
  34. watch: {
  35. usrInfo: {
  36. handler(info) {
  37. this.bgid = $A.runNum(info.bgid);
  38. },
  39. deep: true
  40. }
  41. },
  42. methods: {
  43. getBgUrl(id, thumb) {
  44. if (id < 0) {
  45. return 'none';
  46. }
  47. id = Math.max(1, parseInt(id));
  48. return 'url(' + window.location.origin + '/images/bg/' + (thumb ? 'thumb/' : '') + id + '.jpg' + ')';
  49. },
  50. }
  51. }
  52. </script>