_keycode.vue 10 KB

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