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
90
91
92
93
| <template>
| <view class="hot-types">
| <scroll-view scroll-x class="scroller">
| <view class="inner">
| <view class="item" v-for="item in list" :key="item.id" @tap="toPath(item)">
| <cl-skeleton
| :height="120"
| :width="120"
| :margin="[0, 0, 20, 0]"
| :loading="!item.id"
| :loading-style="{
| borderRadius: '100%',
| }"
| >
| <cl-image :radius="120" :src="item.pic" background-color="#fff" />
| </cl-skeleton>
|
| <cl-skeleton
| :height="28"
| :loading="!item.id"
| :loading-style="{
| width: '90rpx',
| borderRadius: '6rpx',
| }"
| >
| <cl-text :size="24" align="center" block>{{ item.name }}</cl-text>
| </cl-skeleton>
| </view>
| </view>
| </scroll-view>
| </view>
| </template>
|
| <script lang="ts" setup>
| import { onShow } from "@dcloudio/uni-app";
| import { ref } from "vue";
| import { useCool } from "/@/cool";
| import { deepTree } from "/@/cool/utils";
|
| interface Item extends Eps.GoodsTypeEntity {
| children?: Item[];
| }
|
| const { service, router } = useCool();
|
| const list = ref<Item[]>([{}, {}, {}, {}, {}]);
|
| function refresh() {
| service.goods.type.list({ order: "sortNum", sort: "desc" }).then((res) => {
| list.value = deepTree(res);
| });
| }
|
| function toPath(item: Item) {
| if (item.id) {
| router.push({
| path: "/pages/goods/list",
| query: {
| typeId: item.children?.map((e) => e.id).join(","),
| },
| });
| }
| }
|
| onShow(() => {
| refresh();
| });
| </script>
|
| <style lang="scss" scoped>
| .hot-types {
| height: 180rpx;
| overflow: hidden;
| margin: 50rpx 0 50rpx 0;
|
| .scroller {
| height: 200rpx;
|
| .inner {
| display: flex;
| align-items: center;
|
| .item {
| display: flex;
| flex-direction: column;
| align-items: center;
| justify-content: center;
| padding: 0 24rpx;
| }
| }
| }
| }
| </style>
|
|