Home.vue 8.9 KB

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