_keycode.vue 13 KB

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