_keycode.vue 12 KB

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