StoreBanner.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div class="container" id="title-fragment" @mouseleave="hideChildrenLayout()">
  3. <div class="container">
  4. <div class="shop-pcb">
  5. <ul class="pk-list">
  6. <li class="pk-item"
  7. @click="setKindIds(null, null, -1)"
  8. :class="{active: selectedIndex === -1}"
  9. @mouseenter="hideChildrenLayout()">全部
  10. <li @click="setKindIds(kind, kind, index)" class="pk-item"
  11. :class="{active: selectedIndex === index}"
  12. v-for="(kind, index) in kinds"
  13. :key="kind.id"
  14. @mouseenter="showChildrenLayout(kind, index)">{{kind.nameCn}}<i class="icon-arrow-right iconfont"></i></li>
  15. </ul>
  16. <!-- 子类目 -->
  17. <transition name="fade" mode="out-in">
  18. <div class="kind-children" v-if="show">
  19. <div class="kind-children-layout" v-for="(kind, index) in kinds" :key="index" v-if="index === selectedIndex">
  20. <empty-box v-if="!kind.fetching && kind.children && !kind.children.length"></empty-box>
  21. <loading-box v-else-if="kind.fetching" color="rgba(80, 120, 203, 0.9)"></loading-box>
  22. <div class="kind-children-item-wrap" v-else>
  23. <dl class="kind-children-item dl-horizontal">
  24. <dt></dt>
  25. <dd>
  26. <ul class="list-unstyled list-inline">
  27. <li v-for="(c, index) in kind.children">
  28. <span @click.stop.prevent="setKindIds(kind, c, index)">{{ c.nameCn }}</span>
  29. </li>
  30. </ul>
  31. </dd>
  32. </dl>
  33. </div>
  34. </div>
  35. </div>
  36. </transition>
  37. </div>
  38. <div class="pcb-banner">
  39. <img :src="storeInfo.bannerUrl || '/images/store/default/shop_banner.png'">
  40. <div id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. name: 'store-banner',
  48. data () {
  49. return {
  50. selectedIndex: -1,
  51. show: false
  52. }
  53. },
  54. computed: {
  55. kinds () {
  56. return this.$store.state.pcb.kindsData.kinds.data
  57. },
  58. storeInfo () {
  59. return this.$store.state.shop.storeInfo.store.data
  60. }
  61. },
  62. methods: {
  63. setKindIds (kinds, kind, index) {
  64. let idsArr = []
  65. let item = {}
  66. item.kind = kind
  67. item.kinds = kinds
  68. if (kind) {
  69. if (kind.children && kind.children.length) {
  70. this.show = true
  71. kind.children.forEach(item => {
  72. idsArr.push(item.id)
  73. })
  74. } else {
  75. this.show = false
  76. idsArr.push(kind.id)
  77. }
  78. }
  79. this.selectedIndex = index
  80. this.$emit('kindAction', idsArr.join(','))
  81. this.$emit('kindsAction', item)
  82. },
  83. showChildrenLayout (kind, index) {
  84. this.selectedIndex = index
  85. if (!kind.children) {
  86. this.show = false
  87. } else {
  88. this.show = true
  89. }
  90. },
  91. hideChildrenLayout () {
  92. this.show = false
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. @import '~assets/scss/variables';
  99. #title-fragment {
  100. padding: 0;
  101. }
  102. #title-fragment .container {
  103. width: 1190px;
  104. padding-left: 0px;
  105. padding-right: 0px;
  106. }
  107. #title-fragment .shop-pcb{
  108. margin-right: 10px;
  109. width: 220px;
  110. border: 1px solid #e8e8e8;
  111. float: left;
  112. text-align: center;
  113. line-height: 210px;
  114. position: relative;
  115. background: #fff;
  116. .pk-list {
  117. height:300px;
  118. position: relative;
  119. left: -1px;
  120. width: 220px;
  121. .pk-item{
  122. height:43px;
  123. line-height:43px;
  124. border-bottom:1px solid #e7e7e7;
  125. cursor:pointer;
  126. text-align: left;
  127. color: #666;
  128. padding-left:20px;
  129. &:hover,
  130. &.active{
  131. background: #d3eafc;
  132. color: #2496f1;
  133. }
  134. &:last-child{
  135. border:none;
  136. }
  137. .iconfont {
  138. float: right;
  139. margin-right: 18px;
  140. }
  141. }
  142. }
  143. .kind-children .kind-children-layout{
  144. width: 963px;
  145. height: 300px;
  146. padding: 15px 0 0 0;
  147. }
  148. .kind-children {
  149. position: absolute;
  150. top: 0;
  151. left: 220px;
  152. z-index: 9;
  153. overflow: hidden;
  154. width: 963px;
  155. height: 300px;
  156. background-color: #ffffff;
  157. -webkit-box-shadow: 0px 0px 5px 0px rgba(51, 51, 51, 0.5);
  158. box-shadow: 0px 0px 5px 0px rgba(51, 51, 51, 0.5);
  159. .kind-children-layout {
  160. background-color: #fff;
  161. width: 963px;
  162. height: 300px;
  163. font-size: 12px;
  164. overflow-y: auto;
  165. a {
  166. color: #000;
  167. }
  168. a:hover {
  169. color: #ff0006;
  170. }
  171. .kind-children-item-wrap {
  172. height: 100%;
  173. width: 100%;
  174. .kind-children-item {
  175. margin-bottom: $md-pad;
  176. dt {
  177. span {
  178. width: 90%;
  179. display: inline-block;
  180. font-weight: bold;
  181. overflow: hidden;
  182. clear: left;
  183. text-align: right;
  184. text-overflow: ellipsis;
  185. white-space: nowrap;
  186. }
  187. i{
  188. font-size: 12px;
  189. }
  190. }
  191. dd {
  192. margin-left: 98px;
  193. text-align: left;
  194. ul {
  195. margin: 0;
  196. padding: 0;
  197. li {
  198. border-left: $border;
  199. margin-bottom: $pad;
  200. span {
  201. margin: 0 $sm-pad;
  202. cursor: pointer;
  203. }
  204. &:first-child {
  205. border-left: none;
  206. }
  207. &:hover span, &.active span{
  208. color: #f31717;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. #title-fragment .pcb-banner {
  219. float: left;
  220. position: relative;
  221. width: 955px;
  222. height: 320px;
  223. border: 1px solid #e8e8e8;
  224. border-left: none;
  225. overflow: hidden;
  226. border-radius: 5px;
  227. img{
  228. width: 955px;
  229. height: 300px;
  230. }
  231. #shop-title{
  232. position: absolute;
  233. top: 50px;
  234. left: 60px;
  235. font-size: 30px;
  236. color: rgb(255,255,255);
  237. }
  238. }
  239. .container{
  240. width: 1190px;
  241. padding: 0;
  242. }
  243. </style>