Home.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. <a 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. </a>
  33. <a 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. </a>
  40. <a 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. </a>
  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: '/mobile/brand/componentDetail/1100400300009990'},
  105. {name: 'Vishay', url: '/mobile/brand/30327265e42a871be050007f01003d96'},
  106. {name: 'Panasonic', url: '/mobile/brand/30327265e47d871be050007f01003d96'}
  107. ]
  108. }
  109. }
  110. },
  111. methods: {
  112. onFocus () {
  113. this.associate = true
  114. },
  115. onSearch () {
  116. if (this.keyword) {
  117. this.$router.push({path: '/mobile/search?w=' + encodeURIComponent(this.keyword)})
  118. }
  119. }
  120. },
  121. created () {
  122. this.$store.dispatch('resetSearchKeywords')
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .home{
  128. margin-top: .88rem;
  129. font-size:.28rem;
  130. margin-bottom:1rem;
  131. .home-header{
  132. width:100%;
  133. padding-top:1.3rem;
  134. background:#ecede2;
  135. padding-bottom:1rem;
  136. .home-top{
  137. text-align: center;
  138. margin-bottom:.4rem;
  139. p{
  140. font-size:.32rem;
  141. color:rgb(23,21,26);
  142. }
  143. }
  144. .home-search{
  145. width:6rem;
  146. line-height: .3rem;
  147. margin:0 auto;
  148. ul{
  149. display:inline-flex;
  150. li{
  151. flex:1;
  152. text-align:center;
  153. >span{
  154. display:inline-block;
  155. width:.72rem;
  156. line-height:.33rem;
  157. height:.33rem;
  158. background: #fff;
  159. color:#000;
  160. border-radius: .05rem .05rem 0 0 ;
  161. }
  162. }
  163. li.active span{
  164. background: #3c7cf5;
  165. color:#fff;
  166. cursor:pointer;
  167. }
  168. }
  169. .home-input{
  170. input{
  171. width:6rem;
  172. padding: 0 1.2rem 0 .16rem;
  173. margin-right:-1rem;
  174. font-size:.24rem;
  175. line-height: .64rem;
  176. border:.02rem solid #3c7cf5;
  177. border-radius:.05rem;
  178. }
  179. span{
  180. display:inline-block;
  181. text-align: center;
  182. width:1rem;
  183. height:.65rem;
  184. line-height: .64rem;
  185. font-size:.23rem;
  186. border-left:none;
  187. border-radius: 0 .05rem .05rem 0;
  188. background: #3c7cf5;
  189. color:#fff;
  190. i{
  191. font-size: .33rem;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. .home-main{
  199. width:100%;
  200. display:flex;
  201. justify-content:space-between;
  202. flex-wrap:wrap;
  203. text-align: center;
  204. padding-top:1rem;
  205. background: #f7fbff;
  206. }
  207. .home-main a.home-main-content {
  208. width:33%;
  209. margin-bottom:.55rem;
  210. }
  211. .home-main .home-main-content div{
  212. border-radius: .2rem;
  213. width:1.14rem;
  214. height:1.14rem;
  215. margin:0 auto;
  216. position:relative;
  217. }
  218. .home-main .home-main-content div:first-child{
  219. background:rgb(255,48,100);
  220. }
  221. .home-main .home-main-content:nth-child(2) div{
  222. background:rgb(250,103,67);
  223. }
  224. .home-main .home-main-content:nth-child(3) div {
  225. background: rgb(252, 184, 54);
  226. }
  227. .home-main .home-main-content:nth-child(4) div{
  228. background:rgb(99,147,255);
  229. }
  230. .home-main .home-main-content:nth-child(5) div{
  231. background:rgb(67,201,173);
  232. }
  233. .home-main .home-main-content:last-child div{
  234. background:rgb(135,201,79);
  235. }
  236. .home-main .home-main-content div>img{
  237. width: .8rem;
  238. height:.8rem;
  239. position:absolute;
  240. left:50%;
  241. top:50%;
  242. margin-left:-36%;
  243. margin-top:-36%;
  244. }
  245. .home-main .home-main-content p{
  246. font-size:.28rem;
  247. color:rgb(51,51,51);
  248. line-height: .52rem;
  249. }
  250. .home-main .home-main-content h2{
  251. font-size:.3rem;
  252. color:#ff7800;
  253. line-height: .32rem;
  254. margin:0;
  255. margin-top:.1rem;
  256. }
  257. /* 搜索记录 */
  258. .home-search-list {
  259. position:absolute;
  260. top:4.5rem;
  261. width:100%;
  262. min-height: 4rem;
  263. background: #fff;
  264. }
  265. .home-search-list div{
  266. width:6.55rem;
  267. margin:0 auto;
  268. margin-top:.1rem;
  269. padding-bottom:.2rem;
  270. .search-list-top{
  271. h5{
  272. font-size:.3rem;
  273. position:relative;
  274. line-height: .4rem;
  275. color:rgb(102,102,102);
  276. i{
  277. position:absolute;
  278. right:.2rem;
  279. top:.1rem;
  280. color:#4f8afb;
  281. font-size: .35rem;
  282. }
  283. }
  284. .search-list-item{
  285. a{
  286. display:inline-block;
  287. font-size:.28rem;
  288. line-height: .45rem;
  289. color:rgb(102,102,102);
  290. background: #fff;
  291. padding:0 .1rem;
  292. width:2.18rem;
  293. overflow:hidden;
  294. text-overflow : ellipsis;
  295. &:nth-child(2){
  296. border-left:1px solid #a5a6a6;
  297. border-right:1px solid #a5a6a6;
  298. text-align: center;
  299. }
  300. &:nth-child(5){
  301. border-left:1px solid #a5a6a6;
  302. border-right:1px solid #a5a6a6;
  303. text-align: center;
  304. }
  305. }
  306. }
  307. }
  308. .search-list-bottom{
  309. margin-top:-.07rem;
  310. h5{
  311. color:rgb(255,120,0);
  312. font-size:.3rem;
  313. text-align: center;
  314. i{
  315. margin-right:.15rem;
  316. }
  317. }
  318. a{
  319. display:inline-block;
  320. font-size:.24rem;
  321. color:rgb(255,120,0);
  322. background: #fff;
  323. max-width:1.62rem;
  324. line-height: .35rem;
  325. padding:0 .1rem;
  326. border:1px solid rgb(255,120,0);
  327. overflow:hidden;
  328. text-overflow : ellipsis;
  329. margin-left:.12rem;
  330. }
  331. }
  332. }
  333. </style>