_keycode.vue 12 KB

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