index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="layout">
  3. <div class="ui-con">
  4. <img @click="$router.push({path:'/'})" class="logo" :src="`${$cdn}images/k.png`" alt="">
  5. <div class="search-con">
  6. <input v-model="keywordVal" @keydown.enter="gotoResult('')" :placeholder="defaultKey" type="text">
  7. <img @click="gotoResult('')" :src="`${$cdn}images/s-search.png`" alt="">
  8. </div>
  9. <ul class="txt-con" v-if="!isMobile">
  10. <li @click="gotoResult(item)" v-for="(item,i) in keyword" :key="i">
  11. {{item}}
  12. </li>
  13. </ul>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import browser from "@/utils/browser.js";
  19. let keyword = [
  20. '西楼外立面',
  21. '东楼',
  22. '铁栏杆',
  23. '贵宾室'
  24. ]
  25. export default {
  26. data() {
  27. return {
  28. keyword,
  29. keywordVal:'',
  30. defaultKey:'东楼',
  31. isMobile: browser.mobile
  32. };
  33. },
  34. methods:{
  35. gotoResult(item=''){
  36. this.$router.push({name:'Result',query:{
  37. keyword:item||this.keywordVal||this.defaultKey
  38. }})
  39. }
  40. }
  41. };
  42. </script>
  43. <style lang="less" scoped>
  44. @import '../../assets/css/globalVars.less';
  45. input::placeholder {
  46. color: @theme !important;
  47. }
  48. .layout{
  49. width: 100%;
  50. height: 100%;
  51. position: fixed;
  52. top: 0;
  53. left: 0;
  54. .ui-con{
  55. position: absolute;
  56. top: 32%;
  57. left: calc(50% - 200px / 2);
  58. transform: translate(-50%,-50%);
  59. text-align: center;
  60. >div:not(:last-of-type){
  61. text-align: center;
  62. margin-top: 40px;
  63. }
  64. .logo{
  65. width: 340px;
  66. }
  67. .search-con{
  68. border: 2px solid @theme;
  69. border-radius: 28px;
  70. width: 560px;
  71. margin: 20px auto;
  72. position: relative;
  73. padding-left: 0px;
  74. background: rgba(0, 0, 0, .05);
  75. input{
  76. border: none;
  77. background: none;
  78. line-height: @inputH;
  79. height: @inputH;
  80. width: 94%;
  81. vertical-align: middle;
  82. color: @theme;
  83. }
  84. img{
  85. position: absolute;
  86. top: 50%;
  87. transform: translateY(-50%);
  88. right: 6px;
  89. }
  90. }
  91. .txt-con{
  92. display: flex;
  93. justify-content: space-between;
  94. margin-bottom: 20px;
  95. li{
  96. padding: 4px 6px;
  97. cursor: pointer;
  98. &:hover{
  99. background: @theme;
  100. color: #C9A27B;
  101. position: relative;
  102. &::after{
  103. position: absolute;
  104. bottom: -40px;
  105. left: 50%;
  106. transform: translateX(-50%);
  107. content: '';
  108. background: url('@{cdn}search-icon.png') no-repeat;
  109. width: 30px;
  110. height: 30px;
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. @media screen and (max-width: 500px) {
  118. .layout {
  119. .ui-con {
  120. position: fixed;
  121. top: 25vh;
  122. left: 50vw;
  123. transform: translateX(-50%);
  124. .logo, .search-con{
  125. width: 50vw;
  126. }
  127. .search-con {
  128. input {
  129. font-size: 16px;
  130. }
  131. }
  132. }
  133. }
  134. }
  135. </style>