BrandDetail.vue 13 KB

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