_keycode.vue 11 KB

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