BrandDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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 && 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-bottom: 1.2rem;
  213. text-align: center;
  214. .brand-logo {
  215. height: 2.21rem;
  216. width: 3.73rem;
  217. display: inline-block;
  218. border: .01rem solid #e75610;
  219. margin: .38rem auto;
  220. line-height: 2.13rem;
  221. img {
  222. max-height: 2.13rem;
  223. }
  224. }
  225. .brand-switch-item {
  226. text-align: center;
  227. .mobile-switch-btn {
  228. background: #e75610;
  229. color: #fff;
  230. display: inline-block;
  231. height: .68rem;
  232. font-size: .28rem;
  233. padding: .19rem .53rem;
  234. position: relative;
  235. &:first-child {
  236. background: #fff;
  237. color: #e75610;
  238. border: .01rem solid #e75610;
  239. border-left: none;
  240. padding-left: .30rem;
  241. }
  242. &:first-child.active {
  243. background: #e75610;
  244. color: #fff;
  245. border: .01rem solid #e75610;
  246. padding-left: .30rem;
  247. }
  248. &:last-child {
  249. background: #fff;
  250. color: #e75610;
  251. border: .01rem solid #e75610;
  252. border-right: none;
  253. padding-right: .35rem;
  254. }
  255. &:last-child.active {
  256. background: #e75610;
  257. color: #fff;
  258. border: .01rem solid #e75610;
  259. border-right: none;
  260. padding-right: .35rem;
  261. }
  262. &:first-child:before {
  263. content: '';
  264. background: #fff;
  265. border: .01rem solid #e75610;
  266. width: .64rem;
  267. height: .68rem;
  268. border-radius: 100%;
  269. position: absolute;
  270. left: -.33rem;
  271. top: -.01rem;
  272. z-index: -5;
  273. }
  274. &:first-child.active:before {
  275. background: #e75610;
  276. border: .01rem solid #e75610;
  277. }
  278. &:last-child:before {
  279. content: '';
  280. background: #fff;
  281. width: .64rem;
  282. height: .68rem;
  283. border-radius: 100%;
  284. position: absolute;
  285. border: .01rem solid #e75610;
  286. left: 1.04rem;
  287. z-index: -5;
  288. top: -.01rem;
  289. }
  290. &:last-child.active:before {
  291. background: #e75610;
  292. border: .01rem solid #e75610;
  293. }
  294. }
  295. }
  296. .brand-param-list {
  297. text-align: left;
  298. padding: 0 .44rem;
  299. margin-top: .28rem;
  300. .brand-param-item {
  301. font-size: .28rem;
  302. margin-bottom: .48rem;
  303. .remind-tag {
  304. color: rgb(4,198,96);
  305. font-size: .24rem;
  306. position: relative;
  307. bottom: .03rem;
  308. }
  309. .main-sell {
  310. color: #666;
  311. margin-top: .19rem;
  312. line-height: .4rem;
  313. max-height: 1.2rem;
  314. overflow: hidden;
  315. text-overflow: ellipsis;
  316. display: -webkit-box;
  317. -webkit-box-orient: vertical;
  318. -webkit-line-clamp: 3;
  319. }
  320. .brand-url {
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. white-space: nowrap;
  324. color: #01a44e;
  325. margin-left: .28rem;
  326. }
  327. }
  328. }
  329. .brand-product-list {
  330. margin-top: .5rem;
  331. font-size: .28rem;
  332. ul.product-list {
  333. text-align: center;
  334. li {
  335. margin-left: .42rem;
  336. width: 6.66rem;
  337. height: .66rem;
  338. line-height: .66rem;
  339. border: {
  340. top: 1px solid rgb(230,228,228);
  341. bottom: 1px solid rgb(230,228,228);
  342. }
  343. &:nth-child(even) {
  344. background: #f9f9f9;
  345. }
  346. &:active, &:hover {
  347. background: #eee;
  348. }
  349. .text-left {
  350. float: left;
  351. color: #333;
  352. }
  353. .text-right {
  354. float: right;
  355. color: #333;
  356. i {
  357. font-size: .55rem;
  358. float: right;
  359. margin-right: .27rem;
  360. margin-left: .54rem;
  361. color: #6fcafe;
  362. }
  363. }
  364. }
  365. }
  366. .search-box {
  367. margin-bottom: .28rem;
  368. .kind-selecter {
  369. display: inline-block;
  370. position: relative;
  371. float: left;
  372. margin-left: .72rem;
  373. div {
  374. display: inline-block;
  375. span {
  376. width: 1.64rem;
  377. height: .6rem;
  378. line-height: .6rem;
  379. border: .01rem solid rgb(195,195,195);
  380. border-radius: .05rem;
  381. font-size: .28rem;
  382. display: inline-block;
  383. background: url('/images/mobile/@2x/productDetail/kind-narrow-down@2x.png')no-repeat;
  384. padding-right: .15rem;
  385. background-position: 1.35rem .25rem;
  386. background-size: .14rem .1rem;
  387. overflow: hidden;
  388. }
  389. }
  390. }
  391. .kind-search {
  392. display: inline-block;
  393. margin-right: .19rem;
  394. input[type = "text"] {
  395. width: 3.61rem;
  396. height: .6rem;
  397. padding-left: .21rem;
  398. font-size: .24rem;
  399. margin-top: .01rem;
  400. }
  401. i {
  402. background: rgb(65,142,247);
  403. float: right;
  404. position: relative;
  405. left: -.01rem;
  406. width: .61rem;
  407. height: .6rem;
  408. line-height: .6rem;
  409. font-size: .32rem;
  410. color: #fff;
  411. display: inline-block;
  412. }
  413. }
  414. ul {
  415. position: absolute;
  416. top: 0.65rem;
  417. max-height: 3.15rem;
  418. overflow-y: auto;
  419. &::-webkit-scrollbar
  420. {
  421. display: none;
  422. }
  423. li {
  424. width: 1.64rem;
  425. height: .63rem;
  426. line-height: .63rem;
  427. padding: 0 .08rem;
  428. overflow: hidden;
  429. text-overflow: ellipsis;
  430. white-space: nowrap;
  431. background: rgba(0, 0, 0, 0.6);
  432. color: #fff;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. </style>