index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <!-- 分类 -->
  3. <view>
  4. <view class="category">
  5. <view v-for="item in category" :key="item.id" class="section">
  6. <view class="head" @click="goCategoryGoods(item)">
  7. <view class="title">{{ item.name }}</view>
  8. <view class="iconfont icon-xiangyou"></view>
  9. </view>
  10. <view v-if="item.childList" class="body">
  11. <view v-for="value in item.childList" :key="value.id" class="item" @click="goCategoryGoods(value)">
  12. {{ value.name }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view :hidden="!categoryLoading" class="acea-row row-center-wrapper loadingicon">
  17. <text class="iconfont icon-jiazai loading"></text>
  18. </view>
  19. <emptyPage v-if="category.length == 0 && !categoryLoading" mTop="35%" title="暂无商品分类~"
  20. :imgSrc="urlDomain+'crmebimage/presets/noSearch.png'"></emptyPage>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getMerCategoryApi
  26. } from '@/api/merchant.js';
  27. import emptyPage from '@/components/emptyPage.vue'
  28. export default {
  29. components: {
  30. emptyPage
  31. },
  32. props: {
  33. merId: { // 商户id
  34. type: Number,
  35. default: 0
  36. },
  37. },
  38. data() {
  39. return {
  40. category: [],
  41. categoryLoading: false,
  42. urlDomain: this.$Cache.get("imgHost"),
  43. }
  44. },
  45. mounted() {
  46. this.getMerCategory()
  47. },
  48. methods: {
  49. goCategoryGoods(item) {
  50. uni.navigateTo({
  51. url: '/pages/goods/goods_list/index?merId=' + this.merId + '&cid=' +
  52. item.id
  53. })
  54. },
  55. getMerCategory() {
  56. this.categoryLoading = true
  57. getMerCategoryApi(this.merId).then(res => {
  58. this.category = res.data
  59. this.categoryLoading = false
  60. }).catch(err => {
  61. return this.$util.Tips({
  62. title: err
  63. });
  64. this.categoryLoading = false
  65. });
  66. },
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .category {
  72. padding-top: 34rpx;
  73. padding-right: 20rpx;
  74. padding-left: 20rpx;
  75. .section {
  76. border-radius: 10rpx;
  77. margin-bottom: 20rpx;
  78. background-color: #FFFFFF;
  79. .head {
  80. position: relative;
  81. display: flex;
  82. align-items: center;
  83. height: 90rpx;
  84. padding-right: 20rpx;
  85. padding-left: 36rpx;
  86. font-weight: bold;
  87. color: #282828;
  88. &::before {
  89. content: " ";
  90. position: absolute;
  91. top: 50%;
  92. left: 20rpx;
  93. width: 6rpx;
  94. height: 24rpx;
  95. @include main_bg_color(theme);
  96. transform: translateY(-50%);
  97. }
  98. .title {
  99. flex: 1;
  100. min-width: 0;
  101. overflow: hidden;
  102. white-space: nowrap;
  103. text-overflow: ellipsis;
  104. font-size: 30rpx;
  105. }
  106. .iconfont {
  107. font-size: 22rpx;
  108. line-height: 1;
  109. }
  110. }
  111. .body {
  112. display: flex;
  113. flex-wrap: wrap;
  114. justify-content: space-between;
  115. align-items: center;
  116. padding: 9rpx 36rpx 14rpx;
  117. .item {
  118. width: 314rpx;
  119. height: 84rpx;
  120. padding-right: 30rpx;
  121. padding-left: 30rpx;
  122. border-radius: 10rpx;
  123. background-color: #F5F5F5;
  124. margin-bottom: 10rpx;
  125. overflow: hidden;
  126. white-space: nowrap;
  127. text-overflow: ellipsis;
  128. font-weight: 500;
  129. font-size: 26rpx;
  130. line-height: 84rpx;
  131. color: #282828;
  132. }
  133. }
  134. }
  135. }
  136. </style>