xuxueyang
2024-07-26 f8e8ad7f92b351154ebfbda6380a3254ac76a3ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
  <view class="home-category">
    <view class="flex">
      <view class="t1">06-03(今日)第一场交易中</view>
      <view class="t2">当前在售123435扎</view>
    </view>
    <view class="m-t-12 flex">
      <view class="item" v-for="(item,index) of list" :key="index" @click.stop="toList(item)">
        <image class="icon img100" :src="item.url"></image>
        <view>{{ item.name || '-' }}</view>
      </view>
    </view>
  </view>
</template>
 
<script>
export default {
  beforeMount() {
    // for (var i = 0; i < 10; i++) {
    //     this.list.push({
    //         'url': 'https://hmy-flower.oss-cn-shanghai.aliyuncs.com/e2/e2ee2fa7cdef458ba748261305edc57435549b9113807b6fbbfd4bfa456334d.png',
    //         'name': '玫瑰'
    //     })
    // }
    this.$http.request('get', '/api/customer/flower/category/tree', {}).then(res => {
      var data = res.data
      this.list = []
      var arr = data || []
      for (let i = 0; i < arr.length && i < 10; i++) {
        this.list.push({
          id: arr[i].id,
          name: arr[i].name,
          url: arr[i].imageUrl
        })
      }
    })
  },
  methods: {
    toList(item){
      uni.navigateTo({
        url:'/sub_pages/customer/trade/list?categoryId='+item.id
      })
    }
  },
  data() {
    return {
      list: [],
 
    };
  }
}
</script>
 
<style lang="scss">
.home-category {
  .item {
    text-align: center;
    font-weight: 400;
    font-size: 28rpx;
    color: #000000;
    line-height: 40rpx;
    min-width: 20%;
    margin-bottom: 28rpx;
 
    .icon {
      width: 94rpx;
      height: 94rpx;
      border-radius: 50%;
    }
  }
 
  .t1 {
    font-size: 28rpx;
    color: #333333;
    line-height: 50rpx;
    font-weight: 600;
  }
 
  .t2 {
    margin-left: auto;
    padding: 8rpx;
    font-size: 24rpx;
    color: #5B8C71;
    line-height: 34rpx;
    background: #E1F0E7;
    border-radius: 4rpx;
  }
}
</style>