_keycode.vue 12 KB

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