index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div class="website-home">
  3. <div class="banner">
  4. <el-carousel :interval="5000" arrow="always" height="100%">
  5. <el-carousel-item>
  6. <img class="banner-img"
  7. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/1eeba102483945589db9fa134581c19c"
  8. alt="" />
  9. </el-carousel-item>
  10. <el-carousel-item>
  11. <img class="banner-img"
  12. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/e5a861ad85284564ad3fca7783dfbdfd"
  13. alt="" />
  14. </el-carousel-item>
  15. <el-carousel-item>
  16. <img class="banner-img"
  17. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/fbcd3f73ece94cde94f768428d164a9f"
  18. alt="" />
  19. </el-carousel-item>
  20. <el-carousel-item>
  21. <img class="banner-img"
  22. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/29a9a76dd14942198a28851cfe920061"
  23. alt="" />
  24. </el-carousel-item>
  25. </el-carousel>
  26. </div>
  27. <!-- <div class="website-home-bg"></div> -->
  28. <div class="container">
  29. <!-- <div class="main-container">
  30. <div class="main-title">WORKARK-寻找合适的服务</div>
  31. <div class="main-sub-title">方便、快捷、精准</div>
  32. </div> -->
  33. <div class="product-box">
  34. <div class="product-iview" v-for="item in list" :key="item.id" :id="`list${item.id}`">
  35. <div class="title">{{item.name}}</div>
  36. <div class="product-list">
  37. <product-item v-for="(node,index) in item.children" :key="index" :item="node" :parent="item">
  38. </product-item>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. const productItem = () => import('@/components/website/productItem');
  47. import {
  48. getServeProductList
  49. } from '@/api/system'
  50. export default {
  51. name: 'index',
  52. data() {
  53. return {
  54. list: [],
  55. scrollPosition: 0 // 保存滚动条位置
  56. }
  57. },
  58. mounted() {
  59. this.init();
  60. },
  61. activated() {
  62. // 组件被激活时调用
  63. if (document.getElementsByClassName('website-layout')) {
  64. document.getElementsByClassName('website-layout')[0].scrollTo(0, this.scrollPosition);
  65. }
  66. },
  67. beforeRouteLeave(to, from, next) {
  68. if (document.getElementsByClassName('website-layout')) {
  69. this.scrollPosition = document.getElementsByClassName('website-layout')[0].scrollTop;
  70. }
  71. next();
  72. },
  73. deactivated() {
  74. // 组件被停用时调用
  75. },
  76. methods: {
  77. init() {
  78. getServeProductList(-1).then(res => {
  79. if (res.state) {
  80. this.list = res.data;
  81. let navList = JSON.parse(JSON.stringify(res.data));
  82. // navList.push({
  83. // name: '产品介绍',
  84. // id: -1
  85. // })
  86. this.$emit('navFunc', navList);
  87. }
  88. })
  89. },
  90. screenTo(item) {
  91. if (!document.getElementById('list' + item.id)) return;
  92. let top = document.getElementById('list' + item.id).offsetTop;
  93. if (document.getElementsByClassName('website-layout')) {
  94. document.getElementsByClassName('website-layout')[0].scrollTo({
  95. top: top - 40, // 纵坐标位置
  96. left: 0, // 横坐标位置
  97. behavior: 'smooth' // 平滑滚动效果
  98. });
  99. }
  100. }
  101. },
  102. components: {
  103. productItem
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. .website-home {
  109. position: relative;
  110. .container {
  111. width: 1200px;
  112. margin: 0 auto;
  113. }
  114. .website-home-bg {
  115. width: 100%;
  116. min-width: 1200px;
  117. height: 600px;
  118. background: url(https://file-node.oss-cn-shanghai.aliyuncs.com/youji/5ea8dc9317c643d0b0254d8d13a154f3);
  119. background-repeat: no-repeat;
  120. background-size: 100% 100%;
  121. position: absolute;
  122. top: 0;
  123. left: 0;
  124. }
  125. .el-carousel {
  126. height: 100%;
  127. }
  128. .banner {
  129. width: 100%;
  130. height: 600px;
  131. background: #eee;
  132. }
  133. .banner-img {
  134. object-fit: cover;
  135. width: 100%;
  136. height: 100%;
  137. }
  138. .main-container {
  139. height: 600px;
  140. color: #fff;
  141. padding-top: 80px;
  142. box-sizing: border-box;
  143. display: flex;
  144. flex-direction: column;
  145. justify-content: center;
  146. position: relative;
  147. z-index: 8;
  148. .main-title {
  149. font-weight: 500;
  150. font-size: 30px;
  151. line-height: 50px;
  152. margin-bottom: 12px;
  153. }
  154. .main-sub-title {
  155. font-weight: 300;
  156. font-size: 20px;
  157. line-height: 28px;
  158. opacity: .7;
  159. margin-bottom: 50px;
  160. }
  161. }
  162. .product-box {
  163. margin-top: 80px;
  164. padding-bottom: 200px;
  165. .title {
  166. font-size: 36px;
  167. line-height: 50px;
  168. font-weight: 600;
  169. margin-bottom: 30px;
  170. }
  171. }
  172. .product-list {
  173. display: flex;
  174. flex-wrap: wrap;
  175. }
  176. .product-iview {
  177. margin-bottom: 30px;
  178. }
  179. }
  180. </style>