_keycode.vue 12 KB

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