_keycode.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. console.log(item)
  198. if (item.batchCode) {
  199. this.$router.push('/mobile/product/' + item.batchCode)
  200. } else {
  201. this.$router.push('/mobile/brand/componentDetail/' + item.uuid)
  202. // this.collectResult = '暂无参数信息'
  203. // this.timeoutCount ++
  204. }
  205. } else {
  206. this.isClickCollect = false
  207. }
  208. },
  209. goLastPage: function () {
  210. window.history.back(-1)
  211. },
  212. getMoreSearch: function () {
  213. this.page++
  214. this.isSearchSearchingMore = true
  215. this.$store.dispatch('searchData/searchForListInMobile', {count: 15, filter: this.filter, keyword: this.$route.query.w, page: this.page, sorting: this.sorting})
  216. },
  217. reloadData: function () {
  218. this.$store.dispatch('searchData/searchForListInMobile', {count: 15, filter: this.filter, keyword: this.$route.query.w, page: 1, sorting: this.sorting})
  219. this.$store.dispatch('searchData/searchForBrands', {collectList: 'goods_brand', keyword: this.$route.query.w, paramJSON: this.paramJSON})
  220. },
  221. scroll: function () {
  222. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  223. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
  224. this.getMoreSearch()
  225. }
  226. }
  227. }
  228. }
  229. </script>
  230. <style scoped lang="scss">
  231. .search-list{
  232. width:100%;
  233. padding-bottom: 1rem;
  234. .none-state{
  235. text-align: center;
  236. margin-top:2rem;
  237. width:100%;
  238. img{
  239. margin:0 auto;
  240. width: 3.31rem;
  241. height: 2.13rem;
  242. }
  243. p {
  244. font-size: .32rem;
  245. color: #999;
  246. margin: 1.19rem 0 0 0;
  247. }
  248. a {
  249. display: block;
  250. font-size: .28rem;
  251. color: #fff;
  252. width: 1.88rem;
  253. height: .54rem;
  254. line-height: .54rem;
  255. background: #418bf6;
  256. margin: .7rem auto 0;
  257. border-radius: .05rem;
  258. }
  259. }
  260. .search-item{
  261. text-align: center;
  262. span{
  263. display:inline-block;
  264. width:1.41rem;
  265. line-height: .76rem;
  266. font-size:.32rem;
  267. color:#666;
  268. &:first-child {
  269. margin-right: 2rem;
  270. }
  271. }
  272. span.active{
  273. color:#3976f4;
  274. border-bottom:.04rem solid #3976f4;
  275. }
  276. }
  277. .brand-list-content{
  278. margin:0 auto;
  279. border-top:.04rem solid #dedfdf;
  280. border-bottom:.04rem solid #dedfdf;
  281. width:7.1rem;
  282. min-height:1.51rem;
  283. overflow: hidden;
  284. text-align: left;
  285. padding-top:.33rem;
  286. padding-bottom:.33rem;
  287. .brand-list-top{
  288. span:first-child{
  289. font-size:.32rem;
  290. float: left;
  291. margin: 0 0 .1rem .2rem;
  292. }
  293. span.row-switch{
  294. font-size:.28rem;
  295. color:#53a0f7;
  296. float: right;
  297. margin: 0 .2rem 0 0;
  298. i {
  299. font-size: .16rem;
  300. }
  301. }
  302. }
  303. .brand-list-item{
  304. overflow: hidden;
  305. margin: .1rem .2rem 0;
  306. text-align: center;
  307. clear: both;
  308. >div {
  309. display: inline-block;
  310. margin-right: .14rem;
  311. float: left;
  312. &:nth-child(4n) {
  313. margin-right: 0;
  314. }
  315. a {
  316. width: 1.57rem;
  317. height: .77rem;
  318. display: inline-block;
  319. margin: .1rem 0;
  320. border: .04rem solid #53a0f7;
  321. border-radius: .1rem;
  322. line-height: .77rem;
  323. img{
  324. max-width:1.07rem;
  325. max-height:.57rem;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .detail-brand-content{
  332. margin:0 auto;
  333. border-top:.04rem solid #dedfdf;
  334. border-bottom:.04rem solid #dedfdf;
  335. width:7.1rem;
  336. height:3.02rem;
  337. padding-top:.18rem;
  338. h4{
  339. font-size:.32rem;
  340. line-height: .6rem;
  341. margin:0 0 0 3.97rem;
  342. position: relative;
  343. img {
  344. position: absolute;
  345. left: -1.28rem;
  346. top: .24rem;
  347. width: 3.8rem;
  348. height: .11rem;
  349. }
  350. }
  351. .brand-list{
  352. margin:0 .15rem;
  353. .list-left{
  354. border:.02rem solid #418ef7;
  355. border-radius: .05rem;
  356. width:2.03rem;
  357. height:1.73rem;
  358. display: inline-block;
  359. img{
  360. display:block;
  361. width:100%;
  362. height:1.25rem;
  363. }
  364. span{
  365. display: block;
  366. font-size: .24rem;
  367. color:#fff;
  368. text-align: center;
  369. width:100%;
  370. background: #418ef7;
  371. line-height: .45rem;
  372. overflow: hidden;
  373. text-overflow: ellipsis;
  374. white-space: nowrap;
  375. }
  376. }
  377. p{
  378. width:4.3rem;
  379. font-size:.28rem;
  380. line-height: .4rem;
  381. padding:.12rem .46rem 0 .05rem;
  382. float: right;
  383. }
  384. }
  385. }
  386. .detail-brand{
  387. background: #f8fcff;
  388. width:100%;
  389. min-height:1.5rem;
  390. padding-bottom: .2rem;
  391. .brand-item{
  392. width:7rem;
  393. margin:0 auto;
  394. border-radius:.1rem;
  395. background: #fff;
  396. padding:.2rem;
  397. position:relative;
  398. -webkit-box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  399. -moz-box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  400. box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  401. &:active{
  402. background: #e1e1e1;
  403. }
  404. p{
  405. font-size:.28rem;
  406. line-height:.5rem;
  407. color:#333;
  408. margin:0;
  409. width: 5.8rem;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. white-space: nowrap;
  413. }
  414. i{
  415. display:block;
  416. position:absolute;
  417. top:.1rem;
  418. right:.22rem;
  419. font-size:.5rem;
  420. color:#ff7800;
  421. width: .6rem;
  422. height: .6rem;
  423. line-height: .6rem;
  424. text-align: center;
  425. }
  426. }
  427. div.active{
  428. background: #d4d;
  429. }
  430. }
  431. }
  432. </style>