_keycode.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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>主营产品</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.brand.nameCn}}</span></p>
  34. <p>产品描述:<span>{{item.kind.nameCn}}</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.expose">
  39. <img src="/images/mobile/@2x/sousuokongzhuangtai@2x.png">
  40. <a @click="goLastPage">返回上一页</a>
  41. </div>
  42. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  43. <div class="loading" v-show="isSearchingMore">
  44. <img src="/images/all/loading.gif" alt="">
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import RemindBox from '~components/mobile/common/RemindBox.vue'
  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. }
  68. },
  69. components: {
  70. RemindBox
  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: 4.08rem;
  184. height: 4.13rem;
  185. }
  186. a {
  187. display: block;
  188. font-size: .28rem;
  189. color: #fff;
  190. width: 1.88rem;
  191. height: .54rem;
  192. line-height: .54rem;
  193. background: #418bf6;
  194. margin: .7rem auto 0;
  195. border-radius: .05rem;
  196. }
  197. }
  198. .search-item{
  199. justify-content: space-around;
  200. text-align: center;
  201. display:flex;
  202. span{
  203. display:inline-block;
  204. width:1.41rem;
  205. line-height: .76rem;
  206. font-size:.32rem;
  207. color:#666;
  208. }
  209. span.active{
  210. color:#3976f4;
  211. border-bottom:.02rem solid #3976f4;
  212. }
  213. }
  214. .brand-list-content{
  215. margin:0 auto;
  216. border-top:.02rem solid #dedfdf;
  217. border-bottom:.02rem solid #dedfdf;
  218. width:7.1rem;
  219. min-height:1.51rem;
  220. overflow: hidden;
  221. text-align: left;
  222. padding-top:.33rem;
  223. padding-bottom:.33rem;
  224. .brand-list-top{
  225. span:first-child{
  226. font-size:.32rem;
  227. margin-right:4.98rem;
  228. margin-left: .2rem;
  229. }
  230. span.row-switch{
  231. font-size:.28rem;
  232. color:#53a0f7;
  233. }
  234. }
  235. .brand-list-item{
  236. flex-wrap: wrap;
  237. display:inline-flex;
  238. overflow: hidden;
  239. margin:0 .2rem;
  240. text-align: center;
  241. >div {
  242. display: inline-block;
  243. margin-right: .14rem;
  244. &:nth-child(4n) {
  245. margin-right: 0;
  246. }
  247. a {
  248. width: 1.57rem;
  249. height: .77rem;
  250. display: inline-block;
  251. margin-top: .2rem;
  252. border: .02rem solid #53a0f7;
  253. border-radius: .1rem;
  254. line-height: .77rem;
  255. img{
  256. max-width:1.07rem;
  257. max-height:.57rem;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. .detail-brand-content{
  264. margin:0 auto;
  265. border-top:.02rem solid #dedfdf;
  266. border-bottom:.02rem solid #dedfdf;
  267. width:7.1rem;
  268. height:3.02rem;
  269. padding-top:.18rem;
  270. h4{
  271. font-size:.32rem;
  272. line-height: .6rem;
  273. margin:0;
  274. margin-left:3.97rem;
  275. }
  276. .brand-list{
  277. display:flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. margin:0 .15rem;
  281. .list-left{
  282. border:.02rem solid #418ef7;
  283. border-radius: .05rem;
  284. width:2.03rem;
  285. height:1.73rem;
  286. img{
  287. display:block;
  288. width:100%;
  289. height:1.25rem;
  290. }
  291. span{
  292. display: block;
  293. font-size: .24rem;
  294. color:#fff;
  295. text-align: center;
  296. width:100%;
  297. background: #418ef7;
  298. line-height: .45rem;
  299. }
  300. }
  301. p{
  302. width:4.3rem;
  303. font-size:.28rem;
  304. line-height: .4rem;
  305. padding:.12rem .46rem 0 .05rem;
  306. }
  307. }
  308. }
  309. .detail-brand{
  310. background: #f8fcff;
  311. width:100%;
  312. min-height:1.5rem;
  313. padding-top:.2rem;
  314. .brand-item{
  315. width:7rem;
  316. margin:0 auto;
  317. border-radius:.1rem;
  318. background: #fff;
  319. padding:.2rem;
  320. position:relative;
  321. box-shadow: 0 0 0 .02rem #ddd;
  322. &:active{
  323. background: #e1e1e1;
  324. }
  325. p{
  326. font-size:.28rem;
  327. line-height:.4rem;
  328. color:#333;
  329. margin:0;
  330. span{}
  331. }
  332. i{
  333. display:block;
  334. position:absolute;
  335. top:.1rem;
  336. right:.34rem;
  337. font-size:.4rem;
  338. color:#ff7800;
  339. }
  340. }
  341. div.active{
  342. background: #d4d;
  343. }
  344. }
  345. .loading {
  346. text-align: center;
  347. >img {
  348. width: .64rem;
  349. height: .64rem;
  350. margin: .2rem 0;
  351. }
  352. }
  353. }
  354. </style>