default.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <el-container class="default-container">
  3. <!-- 头部 -->
  4. <div class="banner" v-loading="loadingAd" v-if="is_show && adList.length && adv_position">
  5. <el-carousel height="70px" arrow="hover" direction="vertical" indicator-position="none">
  6. <el-carousel-item v-for="item in adList" :key="item.adv_id" :style="{ backgroundColor: item.background }">
  7. <el-image :src="$img(item.adv_image)" fit="cover" @click="$util.pushToTab(item.adv_url.url)" />
  8. </el-carousel-item>
  9. </el-carousel>
  10. <i class="el-icon-circle-close" @click="closeAd"></i>
  11. </div>
  12. <el-header>
  13. <ns-header />
  14. </el-header>
  15. <el-main>
  16. <transition name="slide">
  17. <nuxt />
  18. </transition>
  19. <!-- 右侧栏 -->
  20. <ns-aside />
  21. </el-main>
  22. <!-- 底部 -->
  23. <el-footer>
  24. <ns-footer />
  25. </el-footer>
  26. </el-container>
  27. </template>
  28. <script>
  29. import NsHeader from "./components/NsHeader"
  30. import NsFooter from "./components/NsFooter"
  31. import NsAside from "./components/NsAside"
  32. import {
  33. adList
  34. } from "../api/website"
  35. export default {
  36. name: "Layout",
  37. components: {
  38. NsHeader,
  39. NsFooter,
  40. NsAside
  41. },
  42. created() {
  43. this.getAdList()
  44. },
  45. data: () => {
  46. return {
  47. loadingAd: true,
  48. adList: [],
  49. is_show: true,
  50. indexTopAdNum: 0,
  51. adv_position: {}
  52. }
  53. },
  54. mounted() {},
  55. computed: {},
  56. watch: {},
  57. methods: {
  58. getAdList() {
  59. if (this.$store.state.app.indexTopAdNum >= 3) {
  60. this.loadingAd = false
  61. this.is_show = false
  62. return
  63. }
  64. adList({
  65. keyword: "NS_PC_INDEX_TOP"
  66. })
  67. .then(res => {
  68. this.adList = res.data.adv_list;
  69. this.adv_position = res.data.adv_position;
  70. for (let i = 0; i < this.adList.length; i++) {
  71. if (this.adList[i].adv_url) this.adList[i].adv_url = JSON.parse(this.adList[i].adv_url)
  72. }
  73. this.loadingAd = false
  74. })
  75. .catch(err => {
  76. this.loadingAd = false
  77. })
  78. },
  79. closeAd() {
  80. this.is_show = false
  81. this.indexTopAdNum = this.$store.state.app.indexTopAdNum
  82. this.indexTopAdNum++
  83. this.$store.commit("app/SET_INDEXTOPADNUM", this.indexTopAdNum)
  84. }
  85. },
  86. head() {
  87. return {
  88. title: this.$store.state.site.siteInfo.site_name
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .default-container {
  95. min-height: 100vh;
  96. display: flex;
  97. }
  98. .banner {
  99. text-align: center;
  100. height: 70px;
  101. position: relative;
  102. i {
  103. font-size: 30px;
  104. position: absolute;
  105. z-index: 100;
  106. right: 280px;
  107. top: 10px;
  108. cursor: pointer;
  109. color: #d4d4d4;
  110. }
  111. }
  112. .el-header {
  113. padding: 0;
  114. height: 144px !important;
  115. }
  116. .el-footer {
  117. padding: 0;
  118. height: auto !important;
  119. padding-top: 0;
  120. }
  121. .el-main {
  122. margin: unset;
  123. }
  124. </style>