logo.vue
2.9 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<view style="background: #f7f8faff;">
<view class="">
<view class="flexB" style="margin: 24rpx; ">
<view class="tip">
<image src="../../static/huo.png" style="width: 32rpx; height: 32rpx;" mode=""></image>
</view>
<p>热门品牌</p>
</view>
<!-- <view class="" style="background-color: white; display: flex; flex-wrap: wrap; padding: 24rpx;">
<view class="item" v-for="item in list">
<image :src="item.image_url" style="width: 136rpx; height: 136rpx;" mode=""></image>
<p>{{item.name}}</p>
</view>
</view> -->
</view>
<!-- <u-index-list :scrollTop="scrollTop">
<view v-for="(item, index) in itemArr" :key="index">
<u-index-item v-for="item1 in item">
<u-index-anchor :index="item1.word" />
<view v-for="cell in item1.list">
{{item1.name}}
</view>
</u-index-item>
</view>
</u-index-list> -->
<u-index-list :index-list="indexList">
<template v-for="(item, index) in itemArr">
<u-index-item>
<u-index-anchor :text="item.word"></u-index-anchor>
<view class="list-cell" v-for="(cell, index1) in item.list" @click="backHub(cell,index1)">
{{cell.name}}
<!-- <view class="" v-for="item1 in cell">
{{item1.short_name}}
</view> -->
</view>
</u-index-item>
</template>
</u-index-list>
</view>
</template>
<script>
export default {
data() {
return {
list: [],
// indexList: ["A", "B", "C"],
// itemArr: [
// ['列表A1','列表A2','列表A3'],
// ['列表B1','列表B2','列表B3'],
// ['列表C1','列表C2','列表C3']
// ]
indexList: [],
itemArr: []
}
},
methods: {
backHub(item, idx) {
console.log(item, idx);
//选择品牌后跳转
let pages = getCurrentPages(); //获取所有页面栈实例列表
let prevPage = pages[pages.length - 2]; //上一页页面实例
prevPage.$vm.brand_id = item.id;
prevPage.$vm.brand_name = item.name;
uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
delta: 1
});
}
},
onLoad() {
uni.$u.http.get('/api/index/brand_list').then(res => {
console.log(res);
this.indexList = res.data.word;
this.itemArr = res.data.list
}).catch(err => {
console.log(err);
})
uni.$u.http.get('/api/index/hot_brand').then(res => {
console.log(res);
this.list = res.data
}).catch(err => {
console.log(err);
})
}
}
</script>
<style scoped>
.flexB {
display: flex;
align-items: center;
}
.list-cell {
display: flex;
box-sizing: border-box;
width: 100%;
padding: 10px 24rpx;
overflow: hidden;
color: #323233;
font-size: 14px;
line-height: 24px;
background-color: #fff;
}
.item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-right: 32rpx;
}
</style>