index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <section class="page-container container-index">
  3. <my-header ref="myHeader"/>
  4. <div class="page-wrap">
  5. <div class="nav-container">
  6. <div class="nav-wrap">
  7. <a
  8. :href="`/${wwwURL}/${locale}`"
  9. target="_blank"
  10. class="logo">
  11. <img
  12. :src="`//static.hoolihome.com/common/default/logo-${locale}.png`"
  13. alt="Logo">
  14. </a>
  15. <ul class="tabs">
  16. <li
  17. v-for="(item,index) in tabs"
  18. :key="index"
  19. :class="{'item':true,'active':tabActiveIndex===index}">
  20. <a
  21. :href="item.url"
  22. class="link">{{ item.name }}</a>
  23. </li>
  24. </ul>
  25. </div>
  26. </div>
  27. <nuxt-child/>
  28. </div>
  29. <my-footer :friendship-link-arr="friendshipLinkArr"/>
  30. </section>
  31. </template>
  32. <script>
  33. import MyHeader from '~/components/common/MyHeader'
  34. import MyFooter from '~/components/common/MyFooter'
  35. import { php_api_link_list } from '~/common/apis.js'
  36. import { wwwURL } from '~/common/config.js'
  37. export default {
  38. async asyncData({ app, store }) {
  39. let friendshipLinkArr = await app.$axios
  40. .$post(php_api_link_list)
  41. .then(res => {
  42. if (res) {
  43. let { code, data } = res
  44. code = parseInt(code)
  45. if (code === 0 && data && Array.isArray(data.list)) {
  46. return data.list
  47. }
  48. }
  49. return []
  50. })
  51. .catch(e => {
  52. return []
  53. })
  54. return { friendshipLinkArr }
  55. },
  56. head() {
  57. let title = ''
  58. let keywords = ''
  59. let description = ''
  60. let { locale } = this.$store.state
  61. if (locale === 'cn') {
  62. title = '海外租房_美国|英国|澳洲|加拿大留学生租房_留学生公寓-hooli社区'
  63. keywords =
  64. '海外租房,美国租房,英国租房,澳大利亚租房,加拿大租房,留学生公寓,留学生租房'
  65. description =
  66. 'hooli社区是解决海外租房,留学生租房问题的网站,提供美国租房、英国租房、澳大利亚租房、加拿大租房等全球热门国家500+城市租房和海外高校生活、留学生租房问题解答。'
  67. } else if (locale === 'en') {
  68. title =
  69. 'Overseas Rentals_International Student Rentals_International Student Residences - hooli Community'
  70. keywords =
  71. 'International student apartments, study and rent, study abroad, house rental, overseas rental prices, overseas rentals, overseas rentals, overseas purchases, overseas purchases, overseas living services'
  72. description =
  73. "Hooli, the preferred platform for studying abroad to rent a house, the listing is located in 500+ cities in the world's most popular study countries, providing 200,000+ rooms, covering all major overseas universities, real-time updating of the latest information on renting a house, international student housing, overseas real estate, etc. Effective, welcome to free consultation."
  74. }
  75. return {
  76. title,
  77. meta: [
  78. {
  79. hid: 'keywords',
  80. name: 'keywords',
  81. content: keywords
  82. },
  83. {
  84. hid: 'description',
  85. name: 'description',
  86. content: description
  87. }
  88. ]
  89. }
  90. },
  91. components: {
  92. MyHeader,
  93. MyFooter
  94. },
  95. data() {
  96. return {
  97. wwwURL,
  98. locale: this.$store.state.locale,
  99. friendshipLinkArr: [],
  100. tabs: [],
  101. tabActiveIndex: 0
  102. }
  103. },
  104. scrollToTop: true,
  105. validate({ route, redirect }) {
  106. const { fullPath } = route
  107. if (fullPath === '/cn') {
  108. return redirect(301, '/')
  109. } else if (fullPath.startsWith('/cn')) {
  110. return redirect(301, fullPath.replace('/cn/', '/'))
  111. } else {
  112. return true
  113. }
  114. },
  115. created() {
  116. let { locales, locale } = this.$store.state
  117. let { fullPath } = this.$route
  118. let flag = false //路由是否带语言,默认不带
  119. locales.some(val => {
  120. if (fullPath.indexOf(`/${val}`) === 0) {
  121. flag = true
  122. return true
  123. }
  124. })
  125. this.tabs = [
  126. {
  127. name: this.$t('tabHome'),
  128. url: flag ? `/${locale}` : '/'
  129. },
  130. {
  131. name: this.$t('tabVideos'),
  132. url: flag ? `/${locale}/videos` : '/videos'
  133. }
  134. ]
  135. },
  136. methods: {
  137. handleShowView() {
  138. this.$refs.myHeader.handleShowView('LoginByPassword')
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="less" scoped>
  144. .page-container {
  145. .page-wrap {
  146. width: 100%;
  147. margin: 0 auto;
  148. .nav-container {
  149. background-color: #fff;
  150. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  151. .nav-wrap {
  152. display: flex;
  153. align-items: center;
  154. width: 1200px;
  155. height: 75px;
  156. margin: 0 auto;
  157. padding: 0 5px;
  158. .logo {
  159. width: 109px;
  160. font-size: 0;
  161. img {
  162. width: 100%;
  163. }
  164. }
  165. .tabs {
  166. display: flex;
  167. align-items: center;
  168. margin: 0 60px;
  169. .item {
  170. position: relative;
  171. height: 20px;
  172. line-height: 20px;
  173. &:not(:last-child) {
  174. margin-right: 40px;
  175. }
  176. .link {
  177. font-size: 14px;
  178. font-family: PingFangSC-Medium;
  179. font-weight: 500;
  180. color: rgba(0, 0, 0, 1);
  181. &:hover {
  182. color: #ff523d;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </style>