建材商城系统20241014
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
3.1 KiB

7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
  1. <template>
  2. <view class="page">
  3. <navbar bgColor="#DC2828"/>
  4. <view class="category">
  5. <uv-vtabs
  6. :chain="chain"
  7. :list="category"
  8. keyName="title"
  9. :barItemBadgeStyle="{right:'20px',top:'12px'}"
  10. @change="change">
  11. <uv-vtabs-item>
  12. <view class="category-title">
  13. 租赁
  14. </view>
  15. <view class="list">
  16. <view class="item" v-for="(item,index) in list" :key="index"
  17. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${item.id}`)">
  18. <view class="item-image">
  19. <image
  20. :src="item.image"
  21. mode="aspectFill"></image>
  22. </view>
  23. <view class="item-unit">
  24. <text class="text">{{item.name}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </uv-vtabs-item>
  29. </uv-vtabs>
  30. </view>
  31. <tabber select="category" />
  32. </view>
  33. </template>
  34. <script>
  35. import tabber from '@/components/base/tabbar.vue'
  36. export default {
  37. components: {
  38. tabber,
  39. },
  40. data() {
  41. return {
  42. category: [],
  43. list: [],
  44. chain: false,
  45. value: 0
  46. }
  47. },
  48. computed: {
  49. list2() {
  50. const _list = this.list[this.value]?.childrens;
  51. return _list ? _list : [];
  52. }
  53. },
  54. onLoad() {
  55. this.getCategory()
  56. },
  57. methods: {
  58. // 获取分类列表
  59. getCategory() {
  60. this.$api('getIcon', res => {
  61. if(res.code == 200) {
  62. this.category = res.result
  63. if(this.category.length > 0) {
  64. this.getProductList(this.category[0].id)
  65. }
  66. }
  67. })
  68. },
  69. // 获取商品列表
  70. getProductList(shopIconId) {
  71. this.$api('getProductList', {
  72. shopIconId: shopIconId,
  73. pageNo: 1,
  74. pageSize: 99999
  75. }, res => {
  76. if(res.code == 200) {
  77. this.list = res.result.records
  78. }
  79. })
  80. },
  81. change(index) {
  82. console.log('选项改变:', index)
  83. this.value = index;
  84. if(this.category[index]) {
  85. this.getProductList(this.category[index].id)
  86. }
  87. }
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .page{
  93. /deep/ .uv-vtabs{
  94. height: calc(100vh - 360rpx) !important;
  95. }
  96. /deep/ .uv-vtabs__bar{
  97. height: calc(100vh - 360rpx) !important;
  98. }
  99. /deep/ .uv-vtabs__content{
  100. height: calc(100vh - 360rpx) !important;
  101. }
  102. }
  103. .category {
  104. font-size: 30rpx;
  105. color: #333;
  106. .category-title{
  107. position: relative;
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. height: 120rpx;
  112. &::before,
  113. &::after {
  114. position: absolute;
  115. top: 50%;
  116. content: '';
  117. width: 10%;
  118. border-top: 2rpx solid black;
  119. }
  120. &::before {
  121. left: 25%;
  122. }
  123. &::after {
  124. right: 25%;
  125. }
  126. }
  127. .list{
  128. display: flex;
  129. flex-wrap: wrap;
  130. margin: 0 auto;
  131. width: 490rpx;
  132. .item {
  133. padding: 10rpx 20rpx;
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: center;
  137. align-items: center;
  138. margin-bottom: 20rpx;
  139. .item-image {
  140. width: 120rpx;
  141. height: 120rpx;
  142. image{
  143. height: 100%;
  144. width: 100%;
  145. border-radius: 50%;
  146. }
  147. }
  148. .item-unit {
  149. font-size: 24rpx;
  150. margin-top: 15rpx;
  151. color: #555;
  152. }
  153. }
  154. .gap {
  155. padding: 0 30rpx;
  156. }
  157. }
  158. }
  159. </style>