WContent.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. userInfo: {}
  30. }
  31. },
  32. mounted() {
  33. this.userInfo = $A.getUserInfo((res) => {
  34. this.userInfo = res;
  35. this.bgid = this.userInfo.bgid;
  36. }, false);
  37. this.bgid = this.userInfo.bgid;
  38. },
  39. methods: {
  40. getBgUrl(id, thumb) {
  41. if (id < 0) {
  42. return 'none';
  43. }
  44. id = Math.max(1, parseInt(id));
  45. return 'url(' + window.location.origin + '/images/bg/' + (thumb ? 'thumb/' : '') + id + '.jpg' + ')';
  46. },
  47. }
  48. }
  49. </script>