StoreBanner.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. \<template>
  2. <div class="container" id="title-fragment">
  3. <div class="container">
  4. <div class="shop-pcb">
  5. <ul class="pk-list">
  6. <li class="pk-item" @click="setKindIds(null, -1)" :class="{active: selectedIndex === -1}">全部<i class="icon-arrow-right iconfont"></i></li>
  7. <li @click="setKindIds(kind, index)" class="pk-item" :class="{active: selectedIndex === index}" v-for="(kind, index) in kinds" :key="kind.id">{{kind.nameCn}}<i class="icon-arrow-right iconfont"></i></li>
  8. </ul>
  9. </div>
  10. <div class="pcb-banner">
  11. <img :src="storeInfo.bannerUrl || '/images/store/default/shop_banner.png'">
  12. <div id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'store-banner',
  20. data () {
  21. return {
  22. selectedIndex: -1
  23. }
  24. },
  25. computed: {
  26. kinds () {
  27. return this.$store.state.pcb.kindsData.kinds.data
  28. },
  29. storeInfo () {
  30. return this.$store.state.shop.storeInfo.store.data
  31. }
  32. },
  33. methods: {
  34. setKindIds (kind, index) {
  35. let idsArr = []
  36. if (kind) {
  37. if (kind.children && kind.children.length) {
  38. kind.children.forEach(item => {
  39. idsArr.push(item.id)
  40. })
  41. } else {
  42. idsArr.push(kind.id)
  43. }
  44. }
  45. this.selectedIndex = index
  46. this.$emit('kindAction', idsArr.join(','))
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. #title-fragment {
  53. padding: 0;
  54. }
  55. #title-fragment .container {
  56. width: 1190px;
  57. padding-left: 0px;
  58. padding-right: 0px;
  59. }
  60. #title-fragment .shop-pcb{
  61. margin-right: 10px;
  62. width: 220px;
  63. border: 1px solid #e8e8e8;
  64. float: left;
  65. text-align: center;
  66. line-height: 210px;
  67. position: relative;
  68. background: #fff;
  69. .pk-list {
  70. height:300px;
  71. position: relative;
  72. left: -1px;
  73. width: 220px;
  74. .pk-item{
  75. height:43px;
  76. line-height:43px;
  77. border-bottom:1px solid #e7e7e7;
  78. cursor:pointer;
  79. text-align: left;
  80. color: #666;
  81. padding-left:20px;
  82. &:hover,
  83. &.active{
  84. background: #d3eafc;
  85. color: #2496f1;
  86. }
  87. &:last-child{
  88. border:none;
  89. }
  90. .iconfont {
  91. float: right;
  92. margin-right: 18px;
  93. }
  94. }
  95. }
  96. }
  97. #title-fragment .pcb-banner {
  98. float: left;
  99. position: relative;
  100. width: 955px;
  101. height: 320px;
  102. border: 1px solid #e8e8e8;
  103. border-left: none;
  104. overflow: hidden;
  105. border-radius: 5px;
  106. img{
  107. width: 955px;
  108. height: 300px;
  109. }
  110. #shop-title{
  111. position: absolute;
  112. top: 50px;
  113. left: 60px;
  114. font-size: 30px;
  115. color: rgb(255,255,255);
  116. }
  117. }
  118. .container{
  119. width: 1190px;
  120. padding: 0;
  121. }
  122. </style>