_keycode.vue 13 KB

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