BrandDetail.vue 14 KB

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