Home.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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="iconfont icon-sousuo"></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="iconfont icon-delete"></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="iconfont icon-remensousuo"></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:.33rem;
  158. height:.33rem;
  159. background: #fff;
  160. color:#000;
  161. border-radius: .05rem .05rem 0 0 ;
  162. }
  163. }
  164. li.active span{
  165. background: #3c7cf5;
  166. color:#fff;
  167. cursor:pointer;
  168. }
  169. }
  170. .home-input{
  171. input{
  172. width:6rem;
  173. padding: 0 1.2rem 0 .16rem;
  174. margin-right:-1rem;
  175. font-size:.24rem;
  176. line-height: .64rem;
  177. border:.02rem solid #3c7cf5;
  178. border-radius:.05rem;
  179. }
  180. span{
  181. display:inline-block;
  182. text-align: center;
  183. width:1rem;
  184. height:.65rem;
  185. line-height: .64rem;
  186. font-size:.23rem;
  187. border-left:none;
  188. border-radius: 0 .05rem .05rem 0;
  189. background: #3c7cf5;
  190. color:#fff;
  191. i{
  192. font-size: .33rem;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. .home-main{
  200. width:100%;
  201. display:flex;
  202. justify-content:space-between;
  203. flex-wrap:wrap;
  204. text-align: center;
  205. padding-top:1rem;
  206. background: #f7fbff;
  207. }
  208. .home-main a.home-main-content {
  209. width:33%;
  210. margin-bottom:.55rem;
  211. }
  212. .home-main .home-main-content div{
  213. border-radius: .2rem;
  214. width:1.14rem;
  215. height:1.14rem;
  216. margin:0 auto;
  217. position:relative;
  218. }
  219. .home-main .home-main-content div:first-child{
  220. background:rgb(255,48,100);
  221. }
  222. .home-main .home-main-content:nth-child(2) div{
  223. background:rgb(250,103,67);
  224. }
  225. .home-main .home-main-content:nth-child(3) div {
  226. background: rgb(252, 184, 54);
  227. }
  228. .home-main .home-main-content:nth-child(4) div{
  229. background:rgb(99,147,255);
  230. }
  231. .home-main .home-main-content:nth-child(5) div{
  232. background:rgb(67,201,173);
  233. }
  234. .home-main .home-main-content:last-child div{
  235. background:rgb(135,201,79);
  236. }
  237. .home-main .home-main-content div>img{
  238. width: .8rem;
  239. height:.8rem;
  240. position:absolute;
  241. left:50%;
  242. top:50%;
  243. margin-left:-36%;
  244. margin-top:-36%;
  245. }
  246. .home-main .home-main-content p{
  247. font-size:.28rem;
  248. color:rgb(51,51,51);
  249. line-height: .52rem;
  250. }
  251. .home-main .home-main-content h2{
  252. font-size:.3rem;
  253. color:#ff7800;
  254. line-height: .32rem;
  255. margin:0;
  256. margin-top:.1rem;
  257. }
  258. /* 搜索记录 */
  259. .home-search-list {
  260. position:absolute;
  261. top:4.5rem;
  262. width:100%;
  263. min-height: 4rem;
  264. background: #fff;
  265. }
  266. .home-search-list div{
  267. width:6.55rem;
  268. margin:0 auto;
  269. margin-top:.1rem;
  270. padding-bottom:.2rem;
  271. .search-list-top{
  272. h5{
  273. font-size:.3rem;
  274. position:relative;
  275. line-height: .4rem;
  276. color:rgb(102,102,102);
  277. i{
  278. position:absolute;
  279. right:.2rem;
  280. top:.1rem;
  281. color:#4f8afb;
  282. font-size: .35rem;
  283. }
  284. }
  285. .search-list-item{
  286. a{
  287. display:inline-block;
  288. font-size:.28rem;
  289. line-height: .45rem;
  290. color:rgb(102,102,102);
  291. background: #fff;
  292. padding:0 .1rem;
  293. width:2.18rem;
  294. overflow:hidden;
  295. text-overflow : ellipsis;
  296. &:nth-child(2){
  297. border-left:1px solid #a5a6a6;
  298. border-right:1px solid #a5a6a6;
  299. text-align: center;
  300. }
  301. &:nth-child(5){
  302. border-left:1px solid #a5a6a6;
  303. border-right:1px solid #a5a6a6;
  304. text-align: center;
  305. }
  306. }
  307. }
  308. }
  309. .search-list-bottom{
  310. margin-top:-.07rem;
  311. h5{
  312. color:rgb(255,120,0);
  313. font-size:.3rem;
  314. text-align: center;
  315. i{
  316. margin-right:.15rem;
  317. }
  318. }
  319. a{
  320. display:inline-block;
  321. font-size:.24rem;
  322. color:rgb(255,120,0);
  323. background: #fff;
  324. max-width:1.62rem;
  325. line-height: .35rem;
  326. padding:0 .1rem;
  327. border:1px solid rgb(255,120,0);
  328. overflow:hidden;
  329. text-overflow : ellipsis;
  330. margin-left:.12rem;
  331. }
  332. }
  333. }
  334. </style>