BrandDetail.vue 13 KB

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