_keycode.vue 12 KB

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