_keycode.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="search-list">
  3. <div class="search-item" v-if="productList.expose > 0 || productList.brands">
  4. <span :class="activeType=='store'?'active':''" @click="clickType('store')">所有器件</span>
  5. <span :class="activeType=='support'?'active':''" @click="clickType('support')">仅看有货</span>
  6. </div>
  7. <div class="brand-list-content" v-if="(!productList.brands && brandList && brandList.length > 0) && productList.expose > 0">
  8. <div class="brand-list-top">
  9. <span>品牌墙</span>
  10. <span class="row-switch" @click="onclick()" v-if="brandList.length > 8">{{!isShow?'收起':'展开'}}<i :class="{'iconfont icon-arrow-down':isShow,'icon-icon-shang iconfont':!isShow}"></i></span>
  11. </div>
  12. <div class="brand-list-item" >
  13. <div v-for="item in isShow?brandList.slice(0, 8):brandList">
  14. <nuxt-link :to="'/mobile/brand/'+item.br_uuid">
  15. <img :src="item.logoUrl ||'/images/component/default.png'"/>
  16. </nuxt-link>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="detail-brand-content" v-if="productList.brands" @click="goBrand(list.uuid)">
  21. <h4>主营产品 <img src="/images/mobile/@2x/search/search-brand.png" alt=""></h4>
  22. <div class="brand-list">
  23. <div class="list-left">
  24. <img :src="list.logoUrl || '/images/component/default.png'" :alt="list.nameEn"/>
  25. <span>{{list.nameCn}}</span>
  26. </div>
  27. <p>{{list.series | productDescFilter}}</p>
  28. </div>
  29. </div>
  30. <div class="detail-brand" v-for="(item, index) in searchLists" :style="index == 0 ? 'padding-top: .2rem;' : ''" v-if="searchLists.length > 0">
  31. <div class="brand-item" @click="goComponent(item.uuid)">
  32. <p>型号:<span>{{item.code}}</span></p>
  33. <p>品牌:<span>{{item.brandEn || item.brand.nameCn}}</span></p>
  34. <p>产品描述:<span>{{item.description || '-'}}</span></p>
  35. <i class="iconfont icon-shoucang" :style="(item.isFocus)?'color:#ff7800':'color:#bbb'" @click="collect(item, $event)"></i>
  36. </div>
  37. </div>
  38. <div class="none-state" v-if="!productList.components || productList.components.length === 0">
  39. <img :src="brandList && brandList.length > 0 ? '/images/mobile/@2x/car@2x.png':'/images/mobile/@2x/search-empty.png'">
  40. <p v-text="brandList && brandList.length > 0 ? '抱歉,暂无器件信息' : '抱歉,暂无搜索结果'"></p>
  41. <a @click="goLastPage">返回上一页</a>
  42. </div>
  43. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  44. <loading v-show="isSearchSearchingMore"></loading>
  45. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  46. </div>
  47. </template>
  48. <script>
  49. import {RemindBox, Loading, LoginBox} from '~components/mobile/common'
  50. export default {
  51. layout: 'mobile',
  52. data () {
  53. return {
  54. activeType: 'store',
  55. count: '',
  56. filter: {},
  57. page: 1,
  58. sorting: {},
  59. isShow: true,
  60. isMove: '',
  61. isFocus: false,
  62. isClickCollect: false,
  63. collectResult: '收藏成功',
  64. timeoutCount: 0,
  65. searchLists: [],
  66. isSearchSearchingMore: false,
  67. showLoginBox: false,
  68. isChange: false
  69. }
  70. },
  71. components: {
  72. RemindBox,
  73. Loading,
  74. LoginBox
  75. },
  76. mounted: function () {
  77. let _this = this
  78. _this.$nextTick(function () {
  79. window.addEventListener('scroll', function () {
  80. _this.scroll()
  81. }, false)
  82. })
  83. },
  84. fetch ({store, route}) {
  85. return Promise.all([
  86. store.dispatch('searchData/searchForListInMobile', {count: 15, filter: {}, keyword: route.query.w, page: 1, sorting: {}}),
  87. store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: route.query.w, paramJSON: {}})
  88. ])
  89. },
  90. filters: {
  91. productDescFilter: function (str) {
  92. return str.length > 50 ? str.substring(0, 50) + '...' : str
  93. }
  94. },
  95. computed: {
  96. productList () {
  97. let list = this.$store.state.searchData.searchList.lists.data
  98. if (this.isChange) {
  99. this.searchLists = []
  100. this.page = 1
  101. this.isChange = false
  102. } else {
  103. this.searchLists = this.searchLists.concat(list.components)
  104. this.isSearchSearchingMore = false
  105. }
  106. return list
  107. },
  108. allPage () {
  109. return Math.floor(this.productList.total / this.productList.size) + Math.floor(this.productList.total % this.productList.size > 0 ? 1 : 0)
  110. },
  111. brandList () {
  112. return this.$store.state.searchData.searchBrands.brands.data
  113. },
  114. brandDetail () {
  115. return this.$store.state.searchData.searchList.lists.data.brands
  116. },
  117. list () {
  118. let list = this.$store.state.searchData.searchDetail.detail.data
  119. if (list.application && list.application !== '') {
  120. this.applications = list.application.split(',')
  121. }
  122. return list
  123. },
  124. user () {
  125. return this.$store.state.option.user
  126. }
  127. },
  128. methods: {
  129. onclick () {
  130. this.isShow = !this.isShow
  131. },
  132. clickType (type) {
  133. // this.searchLists = []
  134. this.isChange = true
  135. if (type === 'store') {
  136. this.activeType = 'store'
  137. this.$store.dispatch('searchData/searchForListInMobile', {count: 15, filter: {}, keyword: this.$route.query.w, page: 1, sorting: {}})
  138. } else if (type === 'support') {
  139. this.activeType = 'support'
  140. this.$store.dispatch('searchData/searchForListInMobile', {count: 15, filter: {'goods_status': 601}, keyword: this.$route.query.w, page: 1, sorting: {'RESERVE': 'DESC'}})
  141. }
  142. },
  143. goBrand: function (uuid) {
  144. this.$router.push('/mobile/brand/' + uuid)
  145. },
  146. collect: function (item, $event) {
  147. this.isClickCollect = true
  148. if (this.user.logged) {
  149. if (!item.isFocus) {
  150. this.$http.post('/trade/collection/save', {componentid: item.cmpId, kind: 2})
  151. .then(response => {
  152. item.isFocus = true
  153. this.collectResult = '收藏成功'
  154. this.timeoutCount++
  155. })
  156. } else {
  157. this.$http.post('/trade/collection/delete/cmpId', [item.cmpId]).then(response => {
  158. item.isFocus = false
  159. this.collectResult = '取消成功'
  160. this.timeoutCount++
  161. })
  162. }
  163. } else {
  164. this.showLoginBox = true
  165. }
  166. },
  167. goComponent: function (uuid) {
  168. if (!this.isClickCollect) {
  169. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  170. } else {
  171. this.isClickCollect = false
  172. }
  173. },
  174. goLastPage: function () {
  175. window.history.back(-1)
  176. },
  177. getMoreSearch: function () {
  178. this.page++
  179. this.isSearchSearchingMore = true
  180. this.$store.dispatch('searchData/searchForListInMobile', {count: 15, filter: {}, keyword: this.$route.query.w, page: this.page, sorting: {'RESERVE': 'DESC'}})
  181. },
  182. scroll: function () {
  183. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  184. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  185. this.getMoreSearch()
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style scoped lang="scss">
  192. .search-list{
  193. width:100%;
  194. padding-bottom: 1rem;
  195. .none-state{
  196. text-align: center;
  197. margin-top:2rem;
  198. width:100%;
  199. img{
  200. margin:0 auto;
  201. width: 3.31rem;
  202. height: 2.13rem;
  203. }
  204. p {
  205. font-size: .32rem;
  206. color: #999;
  207. margin: 1.19rem 0 0 0;
  208. }
  209. a {
  210. display: block;
  211. font-size: .28rem;
  212. color: #fff;
  213. width: 1.88rem;
  214. height: .54rem;
  215. line-height: .54rem;
  216. background: #418bf6;
  217. margin: .7rem auto 0;
  218. border-radius: .05rem;
  219. }
  220. }
  221. .search-item{
  222. text-align: center;
  223. span{
  224. display:inline-block;
  225. width:1.41rem;
  226. line-height: .76rem;
  227. font-size:.32rem;
  228. color:#666;
  229. &:first-child {
  230. margin-right: 2rem;
  231. }
  232. }
  233. span.active{
  234. color:#3976f4;
  235. border-bottom:.04rem solid #3976f4;
  236. }
  237. }
  238. .brand-list-content{
  239. margin:0 auto;
  240. border-top:.04rem solid #dedfdf;
  241. border-bottom:.04rem solid #dedfdf;
  242. width:7.1rem;
  243. min-height:1.51rem;
  244. overflow: hidden;
  245. text-align: left;
  246. padding-top:.33rem;
  247. padding-bottom:.33rem;
  248. .brand-list-top{
  249. span:first-child{
  250. font-size:.32rem;
  251. float: left;
  252. margin: 0 0 .1rem .2rem;
  253. }
  254. span.row-switch{
  255. font-size:.28rem;
  256. color:#53a0f7;
  257. float: right;
  258. margin: 0 .2rem 0 0;
  259. i {
  260. font-size: .16rem;
  261. }
  262. }
  263. }
  264. .brand-list-item{
  265. overflow: hidden;
  266. margin: .1rem .2rem 0;
  267. text-align: center;
  268. clear: both;
  269. >div {
  270. display: inline-block;
  271. margin-right: .14rem;
  272. float: left;
  273. &:nth-child(4n) {
  274. margin-right: 0;
  275. }
  276. a {
  277. width: 1.57rem;
  278. height: .77rem;
  279. display: inline-block;
  280. margin: .1rem 0;
  281. border: .04rem solid #53a0f7;
  282. border-radius: .1rem;
  283. line-height: .77rem;
  284. img{
  285. max-width:1.07rem;
  286. max-height:.57rem;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. .detail-brand-content{
  293. margin:0 auto;
  294. border-top:.04rem solid #dedfdf;
  295. border-bottom:.04rem solid #dedfdf;
  296. width:7.1rem;
  297. height:3.02rem;
  298. padding-top:.18rem;
  299. h4{
  300. font-size:.32rem;
  301. line-height: .6rem;
  302. margin:0 0 0 3.97rem;
  303. position: relative;
  304. img {
  305. position: absolute;
  306. left: -1.28rem;
  307. top: .24rem;
  308. width: 3.8rem;
  309. height: .11rem;
  310. }
  311. }
  312. .brand-list{
  313. margin:0 .15rem;
  314. .list-left{
  315. border:.02rem solid #418ef7;
  316. border-radius: .05rem;
  317. width:2.03rem;
  318. height:1.73rem;
  319. display: inline-block;
  320. img{
  321. display:block;
  322. width:100%;
  323. height:1.25rem;
  324. }
  325. span{
  326. display: block;
  327. font-size: .24rem;
  328. color:#fff;
  329. text-align: center;
  330. width:100%;
  331. background: #418ef7;
  332. line-height: .45rem;
  333. overflow: hidden;
  334. text-overflow: ellipsis;
  335. white-space: nowrap;
  336. }
  337. }
  338. p{
  339. width:4.3rem;
  340. font-size:.28rem;
  341. line-height: .4rem;
  342. padding:.12rem .46rem 0 .05rem;
  343. float: right;
  344. }
  345. }
  346. }
  347. .detail-brand{
  348. background: #f8fcff;
  349. width:100%;
  350. min-height:1.5rem;
  351. padding-bottom: .2rem;
  352. .brand-item{
  353. width:7rem;
  354. margin:0 auto;
  355. border-radius:.1rem;
  356. background: #fff;
  357. padding:.2rem;
  358. position:relative;
  359. -webkit-box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  360. -moz-box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  361. box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  362. &:active{
  363. background: #e1e1e1;
  364. }
  365. p{
  366. font-size:.28rem;
  367. line-height:.4rem;
  368. color:#333;
  369. margin:0;
  370. span{}
  371. }
  372. i{
  373. display:block;
  374. position:absolute;
  375. top:.1rem;
  376. right:.22rem;
  377. font-size:.5rem;
  378. color:#ff7800;
  379. width: .6rem;
  380. height: .6rem;
  381. line-height: .6rem;
  382. text-align: center;
  383. }
  384. }
  385. div.active{
  386. background: #d4d;
  387. }
  388. }
  389. }
  390. </style>