Home.vue 8.0 KB

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