_keycode.vue 13 KB

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