BrandDetail.vue 13 KB

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