GoodsclassBody.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="div ui-category-body" :style="'padding-top:'+navHeight+'px'">
  3. <view class="div category-flex">
  4. <view class="div pb-30" v-if="items">
  5. <view class="div" v-for="item in items" :key="item.id">
  6. <view class="div container pb-5">
  7. <view class='div title pt-5'>
  8. <view class='div storegc_name'>{{item.value}}</view>
  9. </view>
  10. <view class='div child-wrapper pt-5'>
  11. <view class='div child' v-for="(child,index) in item.children" :key='index' >
  12. <view class='childitem' @click="goProduct(child.id)">
  13. {{child.value}}
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { urlencode } from '@/util/common'
  25. import { getStoreGoodsClass } from '../../../api/homestoredetail'
  26. export default {
  27. data () {
  28. return {
  29. navHeight:0,
  30. query:{},
  31. items: false,
  32. currentItem: false
  33. }
  34. },
  35. computed: {
  36. },
  37. mounted(){
  38. // #ifdef MP-WEIXIN
  39. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  40. // #endif
  41. var pages = getCurrentPages()
  42. var page = pages[pages.length - 1]
  43. this.query = page.options
  44. this.getGoodsclassList()
  45. },
  46. methods: {
  47. onItemClick (item) {
  48. this.currentItem = item
  49. },
  50. getGoodsclassList () {
  51. if (!(this.items && this.items.length)) {
  52. uni.showLoading({ title: '加载中' })
  53. }
  54. getStoreGoodsClass(this.query.id).then((res) => {
  55. this.items = res.result.store_goods_class
  56. if (this.items.length > 0) {
  57. this.currentItem = this.items[0]
  58. }
  59. uni.hideLoading()
  60. }, (error) => {
  61. uni.showToast({icon:'none',title: error.message})
  62. uni.hideLoading()
  63. })
  64. },
  65. goProduct (id) {
  66. let params = { id:this.query.id,'gc_id': id }
  67. uni.navigateTo({url: '/pages/home/storegoodslist/Goodslist'+'?'+urlencode( params )})
  68. }
  69. }
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. .ui-category-body{
  74. width: 100%;
  75. position: absolute;
  76. bottom: 0;
  77. top: var(--status-bar-height);
  78. .category-flex {
  79. height: 100%;
  80. box-sizing: border-box;
  81. padding-top:$headerHeight;
  82. background: #fff;
  83. .container {
  84. display: flex;
  85. flex-direction: column;
  86. justify-content: flex-start;
  87. align-items: stretch;
  88. background-color: #fff;
  89. padding: 0 $pageSpace;
  90. .title{
  91. font-size: .8rem;
  92. color: #333;
  93. font-weight: bold;
  94. display: flex;
  95. align-items: center;
  96. }
  97. .child-wrapper{
  98. display: flex;
  99. flex-wrap: wrap;
  100. justify-content: space-between;
  101. .child{
  102. width: 23%;
  103. margin-right: 1%;
  104. font-size: .6rem;
  105. background:#f6f6f6;
  106. border-radius: 1.5rem;
  107. padding: .4rem .3rem;
  108. box-sizing: border-box;
  109. text-align: center;
  110. white-space: nowrap;
  111. margin-bottom: .5rem;
  112. overflow: hidden;
  113. .iconfont{
  114. font-size: .6rem;
  115. margin-right: .2rem;
  116. }
  117. }
  118. .child:not(:nth-child(4n)) {
  119. margin-right: calc(4% / 3);
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </style>