_keycode.vue 13 KB

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