Home.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div class="home">
  3. <div class="home-header">
  4. <div class="home-top">
  5. <p>
  6. <span>搜品牌</span> |
  7. <span>搜现货</span> |
  8. <span>搜好店</span> |
  9. <span>搜规格书</span>
  10. </p>
  11. </div>
  12. <div class="home-search">
  13. <ul>
  14. <li :class="activeType=='model'?'active':''" @click="activeType='model'"><span>型号</span></li>
  15. <li :class="activeType=='brand'?'active':''" @click="activeType='brand'"><span>品牌</span></li>
  16. <li :class="activeType=='shops'?'active':''" @click="activeType='shops'"><span>商家</span></li>
  17. </ul>
  18. <div class="home-input">
  19. <input type="text" placeholder="请输入您要查找的型号或品牌" v-model="keyword"
  20. @focus.stop.prevent="onFocus()"/>
  21. <span @click="onSearch()"><i class="fa fa-camera-retro"></i></span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="home-main">
  26. <nuxt-link to="/mobile/brand" class="home-main-content">
  27. <div>
  28. <img src="/imgs/home/brand@2x.png" alt="1">
  29. </div>
  30. <h2>4036万</h2>
  31. <p>品牌</p>
  32. </nuxt-link>
  33. <nuxt-link to="/mobile/brand" class="home-main-content">
  34. <div>
  35. <img src="/imgs/home/modelbrand@2x.png" alt="1">
  36. </div>
  37. <h2>3250万</h2>
  38. <p>型号</p>
  39. </nuxt-link>
  40. <nuxt-link to="/brand" class="home-main-content">
  41. <div>
  42. <img src="/imgs/home/bookbrand@2x.png" alt="1">
  43. </div>
  44. <h2>926万</h2>
  45. <p>规格书</p>
  46. </nuxt-link>
  47. <nuxt-link to="/mobile/shop" class="home-main-content">
  48. <div>
  49. <img src="/imgs/home/shopbrand@2x.png" alt="1">
  50. </div>
  51. <p>店铺列表</p>
  52. </nuxt-link>
  53. <nuxt-link to="/mobile/user" class="home-main-content">
  54. <div>
  55. <img src="/imgs/home/storebrand@2x.png" alt="1">
  56. </div>
  57. <p>我的收藏</p>
  58. </nuxt-link>
  59. <nuxt-link to="/brand" class="home-main-content">
  60. <div>
  61. <img src="/imgs/home/phonebrand@2x.png" alt="1">
  62. </div>
  63. <p>联系我们</p>
  64. </nuxt-link>
  65. </div>
  66. <div class="home-search-list" v-if="associate && keyword">
  67. <div>
  68. <div class="search-list-top">
  69. <h5>历史搜索:<i class="fa fa-camera-retro"></i></h5>
  70. <div class="search-list-item">
  71. <a href="#">smk212121288</a>
  72. <a href="#">CPU</a>
  73. <a href="#">CPU</a>
  74. <a href="#">CPU</a>
  75. <a href="#">CPU</a>
  76. <a href="#">CPU</a>
  77. </div>
  78. </div>
  79. <div class="search-list-bottom">
  80. <h5><i class="fa fa-camera-retro"></i>热搜器件</h5>
  81. <span v-for="item in hotwords">
  82. <nuxt-link to="item.url" >{{item.name}}</nuxt-link>
  83. </span>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. export default {
  91. name: 'home',
  92. data () {
  93. return {
  94. keyword: '',
  95. activeType: 'model',
  96. associate: ''
  97. }
  98. },
  99. props: {
  100. hotwords: {
  101. type: Array,
  102. default () {
  103. return [
  104. {name: 'SCT2080KEC', url: '/product/component/1100400300009990'},
  105. {name: '电池组', url: '/product/kind/346'},
  106. {name: 'Vishay', url: '/product/brand/30327265e42a871be050007f01003d96'},
  107. {name: 'Panasonic', url: '/product/brand/30327265e47d871be050007f01003d96'}
  108. ]
  109. }
  110. }
  111. },
  112. methods: {
  113. onFocus () {
  114. this.associate = true
  115. },
  116. onSearch () {
  117. if (this.keyword) {
  118. this.$router.push({path: '/mobile/search?w=' + encodeURIComponent(this.keyword)})
  119. }
  120. }
  121. },
  122. created () {
  123. this.$store.dispatch('resetSearchKeywords')
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .home{
  129. font-size:.28rem;
  130. margin-bottom:1rem;
  131. margin-top:.88rem;
  132. .home-header{
  133. width:100%;
  134. padding-top:1.3rem;
  135. background:#ecede2;
  136. padding-bottom:1rem;
  137. .home-top{
  138. text-align: center;
  139. margin-bottom:.4rem;
  140. p{
  141. font-size:.32rem;
  142. color:rgb(23,21,26);
  143. }
  144. }
  145. .home-search{
  146. width:6rem;
  147. line-height: .3rem;
  148. margin:0 auto;
  149. ul{
  150. display:inline-flex;
  151. li{
  152. flex:1;
  153. text-align:center;
  154. span{
  155. display:inline-block;
  156. width:.72rem;
  157. line-height:.32rem;
  158. height:.32rem;
  159. background: #fff;
  160. color:#000;
  161. border-radius: .05rem .05rem 0 0 ;
  162. }
  163. }
  164. li.active{
  165. span{
  166. background: #3c7cf5;
  167. color:#fff;
  168. cursor:pointer;
  169. }
  170. }
  171. }
  172. input{
  173. width:6rem;
  174. padding: 0 1.2rem 0 .16rem;
  175. margin-right:-1rem;
  176. font-size:.24rem;
  177. line-height: .61rem;
  178. border:.02rem solid #3c7cf5;
  179. border-radius:.05rem;
  180. }
  181. span{
  182. display:inline-block;
  183. text-align: center;
  184. width:1rem;
  185. height:.63rem;
  186. line-height: .63rem;
  187. font-size:.23rem;
  188. border-left:none;
  189. border-radius: 0 .05rem .05rem 0;
  190. background: #3c7cf5;
  191. color:#fff;
  192. }
  193. }
  194. }
  195. }
  196. .home-main{
  197. width:100%;
  198. display:flex;
  199. justify-content:space-between;
  200. flex-wrap:wrap;
  201. text-align: center;
  202. padding-top:1rem;
  203. background: #f7fbff;
  204. }
  205. .home-main a.home-main-content {
  206. width:33%;
  207. margin-bottom:.55rem;
  208. }
  209. .home-main .home-main-content div{
  210. border-radius: .2rem;
  211. width:1.14rem;
  212. height:1.14rem;
  213. margin:0 auto;
  214. position:relative;
  215. }
  216. .home-main .home-main-content div:first-child{
  217. background:rgb(255,48,100);
  218. }
  219. .home-main .home-main-content:nth-child(2) div{
  220. background:rgb(250,103,67);
  221. }
  222. .home-main .home-main-content:nth-child(3) div {
  223. background: rgb(252, 184, 54);
  224. }
  225. .home-main .home-main-content:nth-child(4) div{
  226. background:rgb(99,147,255);
  227. }
  228. .home-main .home-main-content:nth-child(5) div{
  229. background:rgb(67,201,173);
  230. }
  231. .home-main .home-main-content:last-child div{
  232. background:rgb(135,201,79);
  233. }
  234. .home-main .home-main-content div>img{
  235. width: .8rem;
  236. height:.8rem;
  237. position:absolute;
  238. left:50%;
  239. top:50%;
  240. margin-left:-36%;
  241. margin-top:-36%;
  242. }
  243. .home-main .home-main-content p{
  244. font-size:.28rem;
  245. color:rgb(51,51,51);
  246. line-height: .52rem;
  247. }
  248. .home-main .home-main-content h2{
  249. font-size:.3rem;
  250. color:#ff7800;
  251. line-height: .32rem;
  252. margin:0;
  253. margin-top:.1rem;
  254. }
  255. /* 搜索记录 */
  256. .home-search-list {
  257. position:absolute;
  258. top:4.5rem;
  259. width:100%;
  260. min-height: 4rem;
  261. background: #fff;
  262. }
  263. .home-search-list div{
  264. width:6.55rem;
  265. margin:0 auto;
  266. margin-top:.1rem;
  267. padding-bottom:.2rem;
  268. .search-list-top{
  269. h5{
  270. font-size:.3rem;
  271. position:relative;
  272. line-height: .4rem;
  273. color:rgb(102,102,102);
  274. i{
  275. position:absolute;
  276. right:0;
  277. }
  278. }
  279. .search-list-item{
  280. a{
  281. display:inline-block;
  282. font-size:.28rem;
  283. line-height: .45rem;
  284. color:rgb(102,102,102);
  285. background: #fff;
  286. padding:0 .1rem;
  287. width:2.18rem;
  288. overflow:hidden;
  289. text-overflow : ellipsis;
  290. &:nth-child(2){
  291. border-left:1px solid #a5a6a6;
  292. border-right:1px solid #a5a6a6;
  293. text-align: center;
  294. }
  295. &:nth-child(5){
  296. border-left:1px solid #a5a6a6;
  297. border-right:1px solid #a5a6a6;
  298. text-align: center;
  299. }
  300. }
  301. }
  302. }
  303. .search-list-bottom{
  304. margin-top:-.07rem;
  305. h5{
  306. color:rgb(255,120,0);
  307. font-size:.3rem;
  308. text-align: center;
  309. i{
  310. margin-right:.15rem;
  311. }
  312. }
  313. a{
  314. display:inline-block;
  315. font-size:.24rem;
  316. color:rgb(255,120,0);
  317. background: #fff;
  318. max-width:1.62rem;
  319. line-height: .35rem;
  320. padding:0 .1rem;
  321. border:1px solid rgb(255,120,0);
  322. overflow:hidden;
  323. text-overflow : ellipsis;
  324. margin-left:.12rem;
  325. }
  326. }
  327. }
  328. </style>