_keycode.vue 11 KB

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