BrandDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="brand-detail" @click="checkShowFilter()">
  3. <div class="brand-logo">
  4. <img :src="brandDetail.logoUrl || '/images/component/default.png'" :alt="brandDetail.nameEn"/>
  5. </div>
  6. <div class="brand-switch-item">
  7. <span :class="activeType=='detail'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='detail'">品牌</span>
  8. <span :class="activeType=='product'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='product'">产品</span>
  9. </div>
  10. <div class="brand-param-list" v-if="activeType=='detail'">
  11. <div class="brand-param-item" v-if="brandDetail.series">
  12. <span class="remind-tag">| </span>
  13. <span>主营产品</span>
  14. <div class="main-sell">{{brandDetail.series}}</div>
  15. </div>
  16. <div class="brand-param-item" v-if="applications.length>0">
  17. <span class="remind-tag">| </span>
  18. <span>应用领域</span>
  19. <div class="main-sell">
  20. <span v-for="(item, index) in applications"><span>{{item}}</span><span v-show="index+1 < applications.length">|</span></span>
  21. </div>
  22. </div>
  23. <div class="brand-param-item" v-if="brandDetail.brief">
  24. <span class="remind-tag">| </span>
  25. <span>品牌介绍</span>
  26. <div class="main-sell">{{brandDetail.brief}}</div>
  27. </div>
  28. <div class="brand-param-item" v-if="brandDetail.url">
  29. <span class="remind-tag">| </span>
  30. <span>官网地址</span>
  31. <a class="brand-url" v-text="brandDetail.url"></a>
  32. </div>
  33. </div>
  34. <div class="brand-product-list" v-if="activeType=='product'">
  35. <div class="search-box">
  36. <div class="kind-selecter">
  37. <div @mouseenter="isInList = true" @mouseleave="isInList = false">
  38. <span @click="showKindList = !showKindList" v-text="selectedKind"></span>
  39. <ul v-show="showKindList">
  40. <li @click="selectKind({nameCn: '全部分类', id: ''})">全部分类</li>
  41. <li v-for="kind in kindList" v-text="kind.nameCn" @click="selectKind(kind)"></li>
  42. </ul>
  43. </div>
  44. </div>
  45. <div class="kind-search">
  46. <input type="text" v-model="keyword" placeholder="请输入型号">
  47. <i @click="goodsSearch()" class="icon-sousuo iconfont"></i>
  48. </div>
  49. </div>
  50. <ul class="product-list">
  51. <li v-for="product in productList.content">
  52. <nuxt-link class="text-left" :to="'/mobile/brand/componentDetail/' + product.uuid">{{product.code}}</nuxt-link>
  53. <a class="text-right" @click="toShowPdf(product.attach)">规格书 <i class="icon-chakan iconfont"></i></a>
  54. </li>
  55. </ul>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. export default {
  61. name: 'MobileBrandsDetail',
  62. data () {
  63. return {
  64. applications: [],
  65. activeType: 'detail',
  66. keyword: '',
  67. showKindList: false,
  68. parentid: 0,
  69. ids: null,
  70. pageParams: {
  71. page: 1,
  72. count: 10,
  73. filter: {}
  74. },
  75. selectedKind: '全部分类',
  76. isInList: false
  77. }
  78. },
  79. computed: {
  80. brandDetail () {
  81. let list = this.$store.state.brandDetail.detail.data
  82. if (list.application && list.application !== '') {
  83. this.applications = list.application.split(',')
  84. }
  85. return list
  86. },
  87. productList () {
  88. return this.$store.state.brandComponent.component.data || []
  89. },
  90. kindList () {
  91. let brands = this.$store.state.brandCategories.categories.data
  92. if (!brands || brands.length === 0) {
  93. return []
  94. }
  95. // 初始化去除重复数据
  96. for (let i = 0; i < brands.length; i++) {
  97. for (let j = 0; j < brands[i].length; j++) {
  98. brands[i][j].children = []
  99. }
  100. }
  101. // 处理第1层
  102. if ((brands[0] && brands[0].length > 0) && (brands[1] && brands[1].length > 0)) {
  103. for (let i = 0; i < brands[1].length; i++) {
  104. for (let j = 0; j < brands[0].length; j++) {
  105. if (brands[0][j].id === brands[1][i].parentid) {
  106. if (!brands[0][j].children) {
  107. brands[0][j].children = []
  108. }
  109. brands[0][j].children.push(brands[1][i])
  110. break
  111. }
  112. }
  113. }
  114. }
  115. // 处理第2层
  116. if ((brands[1] && brands[1].length > 0) && (brands[2] && brands[2].length > 0)) {
  117. for (let i = 0; i < brands[2].length; i++) {
  118. for (let j = 0; j < brands[1].length; j++) {
  119. if (brands[1][j].id === brands[2][i].parentid) {
  120. if (!brands[1][j].children) {
  121. brands[1][j].children = []
  122. }
  123. brands[1][j].children.push(brands[2][i])
  124. break
  125. }
  126. }
  127. }
  128. }
  129. // 处理第3层
  130. if ((brands[2] && brands[2].length > 0) && (brands[3] && brands[3].length > 0)) {
  131. for (let i = 0; i < brands[3].length; i++) {
  132. for (let j = 0; j < brands[2].length; j++) {
  133. if (brands[2][j].id === brands[3][i].parentid) {
  134. if (!brands[2][j].children) {
  135. brands[2][j].children = []
  136. }
  137. brands[2][j].children.push(brands[3][i])
  138. break
  139. }
  140. }
  141. }
  142. }
  143. let kindList = []
  144. if (brands[0]) {
  145. for (let i = 0; i < brands[0].length; i++) {
  146. this.getKinds(brands[0][i], kindList)
  147. }
  148. }
  149. return kindList
  150. }
  151. },
  152. methods: {
  153. getKinds: function (list, kindList) {
  154. if (list.children && list.children.length > 0) {
  155. for (let i = 0; i < list.children.length; i++) {
  156. this.getKinds(list.children[i], kindList)
  157. }
  158. } else {
  159. kindList.push(list)
  160. }
  161. },
  162. selectKind: function (data) {
  163. this.showKindList = false
  164. this.selectedKind = data.nameCn
  165. if (this.parentid === data.id) {
  166. this.parentid = 0
  167. this.ids = null
  168. } else {
  169. if (data.level === 1) {
  170. this.parentid = data.id
  171. }
  172. }
  173. this.pageParams.page = 1
  174. this.pageParams.filter.brandid = this.brandDetail.id
  175. if (data.id !== '') {
  176. this.pageParams.filter.kindid = data.id
  177. } else {
  178. delete this.pageParams.filter.kindid
  179. }
  180. this.pageCommodity(this.pageParams, this.ids)
  181. },
  182. goodsSearch () {
  183. this.pageParams.page = 1
  184. this.pageParams.filter.brandid = this.brandDetail.id
  185. this.pageParams.filter.code = this.keyword
  186. this.pageCommodity(this.pageParams)
  187. },
  188. async pageCommodity (params) {
  189. try {
  190. let { data } = await this.$http.get('/api/product/component/list', { params })
  191. this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', data)
  192. } catch (err) {
  193. this.$store.commit('brandComponent/GET_COMPONENT_FAILURE', err)
  194. }
  195. },
  196. checkShowFilter: function () {
  197. if (!this.isInList) {
  198. this.showKindList = false
  199. }
  200. },
  201. toShowPdf: function (url) {
  202. if (url !== '1') {
  203. window.location.href = url
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .brand-detail {
  211. margin: 0 auto;
  212. margin-top: .88rem;
  213. margin-bottom: 1.2rem;
  214. text-align: center;
  215. .brand-logo {
  216. height: 2.21rem;
  217. width: 3.73rem;
  218. display: inline-block;
  219. border: .01rem solid #e75610;
  220. margin: .38rem auto;
  221. line-height: 2.13rem;
  222. img {
  223. max-height: 2.13rem;
  224. }
  225. }
  226. .brand-switch-item {
  227. text-align: center;
  228. .mobile-switch-btn {
  229. background: #e75610;
  230. color: #fff;
  231. display: inline-block;
  232. height: .68rem;
  233. font-size: .28rem;
  234. padding: .19rem .53rem;
  235. position: relative;
  236. &:first-child {
  237. background: #fff;
  238. color: #e75610;
  239. border: .01rem solid #e75610;
  240. border-left: none;
  241. padding-left: .30rem;
  242. }
  243. &:first-child.active {
  244. background: #e75610;
  245. color: #fff;
  246. border: .01rem solid #e75610;
  247. padding-left: .30rem;
  248. }
  249. &:last-child {
  250. background: #fff;
  251. color: #e75610;
  252. border: .01rem solid #e75610;
  253. border-right: none;
  254. padding-right: .35rem;
  255. }
  256. &:last-child.active {
  257. background: #e75610;
  258. color: #fff;
  259. border: .01rem solid #e75610;
  260. border-right: none;
  261. padding-right: .35rem;
  262. }
  263. &:first-child:before {
  264. content: '';
  265. background: #fff;
  266. border: .01rem solid #e75610;
  267. width: .64rem;
  268. height: .68rem;
  269. border-radius: 100%;
  270. position: absolute;
  271. left: -.33rem;
  272. top: -.01rem;
  273. z-index: -5;
  274. }
  275. &:first-child.active:before {
  276. background: #e75610;
  277. border: .01rem solid #e75610;
  278. }
  279. &:last-child:before {
  280. content: '';
  281. background: #fff;
  282. width: .64rem;
  283. height: .68rem;
  284. border-radius: 100%;
  285. position: absolute;
  286. border: .01rem solid #e75610;
  287. left: 1.04rem;
  288. z-index: -5;
  289. top: -.01rem;
  290. }
  291. &:last-child.active:before {
  292. background: #e75610;
  293. border: .01rem solid #e75610;
  294. }
  295. }
  296. }
  297. .brand-param-list {
  298. text-align: left;
  299. padding: 0 .44rem;
  300. margin-top: .28rem;
  301. .brand-param-item {
  302. font-size: .28rem;
  303. margin-bottom: .48rem;
  304. .remind-tag {
  305. color: rgb(4,198,96);
  306. font-size: .24rem;
  307. position: relative;
  308. bottom: .03rem;
  309. }
  310. .main-sell {
  311. color: #666;
  312. margin-top: .19rem;
  313. line-height: .4rem;
  314. max-height: 1.2rem;
  315. overflow: hidden;
  316. text-overflow: ellipsis;
  317. display: -webkit-box;
  318. -webkit-box-orient: vertical;
  319. -webkit-line-clamp: 3;
  320. }
  321. .brand-url {
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. white-space: nowrap;
  325. color: #01a44e;
  326. margin-left: .28rem;
  327. }
  328. }
  329. }
  330. .brand-product-list {
  331. margin-top: .5rem;
  332. font-size: .28rem;
  333. ul.product-list {
  334. text-align: center;
  335. li {
  336. margin-left: .42rem;
  337. width: 6.66rem;
  338. height: .66rem;
  339. line-height: .66rem;
  340. border: {
  341. top: 1px solid rgb(230,228,228);
  342. bottom: 1px solid rgb(230,228,228);
  343. }
  344. &:nth-child(even) {
  345. background: #f9f9f9;
  346. }
  347. &:active, &:hover {
  348. background: #eee;
  349. }
  350. .text-left {
  351. float: left;
  352. color: #333;
  353. }
  354. .text-right {
  355. float: right;
  356. color: #333;
  357. i {
  358. font-size: .55rem;
  359. float: right;
  360. margin-right: .27rem;
  361. margin-left: .54rem;
  362. color: #6fcafe;
  363. }
  364. }
  365. }
  366. }
  367. .search-box {
  368. margin-bottom: .28rem;
  369. .kind-selecter {
  370. display: inline-block;
  371. position: relative;
  372. float: left;
  373. margin-left: .72rem;
  374. div {
  375. display: inline-block;
  376. span {
  377. width: 1.64rem;
  378. height: .6rem;
  379. line-height: .6rem;
  380. border: .01rem solid rgb(195,195,195);
  381. border-radius: .05rem;
  382. font-size: .28rem;
  383. display: inline-block;
  384. background: url('/images/mobile/@2x/productDetail/kind-narrow-down@2x.png')no-repeat;
  385. padding-right: .15rem;
  386. background-position: 1.35rem .25rem;
  387. background-size: .14rem .1rem;
  388. overflow: hidden;
  389. }
  390. }
  391. }
  392. .kind-search {
  393. display: inline-block;
  394. margin-right: .19rem;
  395. input[type = "text"] {
  396. width: 3.61rem;
  397. height: .6rem;
  398. padding-left: .21rem;
  399. font-size: .24rem;
  400. margin-top: .01rem;
  401. }
  402. i {
  403. background: rgb(65,142,247);
  404. float: right;
  405. position: relative;
  406. left: -.01rem;
  407. width: .61rem;
  408. height: .6rem;
  409. line-height: .6rem;
  410. font-size: .32rem;
  411. color: #fff;
  412. display: inline-block;
  413. }
  414. }
  415. ul {
  416. position: absolute;
  417. top: 0.65rem;
  418. max-height: 3.15rem;
  419. overflow-y: auto;
  420. &::-webkit-scrollbar
  421. {
  422. display: none;
  423. }
  424. li {
  425. width: 1.64rem;
  426. height: .63rem;
  427. line-height: .63rem;
  428. padding: 0 .08rem;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. white-space: nowrap;
  432. background: rgba(0, 0, 0, 0.6);
  433. color: #fff;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. </style>