zx 3 years ago
parent 0a50938f52
commit 478a3fa72d

@ -7,6 +7,7 @@ Component({
brand: ''
},
history: [],
alphalist: [],
},
methods: {
toBrandInsight(e) {
@ -58,21 +59,26 @@ Component({
//页面数据
app.globalData.request({
action: 'getUserBrand',
token: wx.getStorageSync('token'),
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
}).then(res => {
let arr = []
let recommandArr = [];
let alphalist = [];
res.forEach(ele => {
if(ele.firstword == '热门') {
recommandArr.push(ele)
} else {
if(alphalist.indexOf(ele.firstword) == -1) {
alphalist.push(ele.firstword)
}
}
});
for (let i = 65; i <= 90; i++) {
alphalist.forEach(ele => {
arr.push({
name: String.fromCharCode(i),
name: ele,
data: []
});
}
});
for(let i of res){
for(let j of arr){
if(i.firstword == j.name){
@ -81,6 +87,7 @@ Component({
}
}
this.setData({
alphalist: alphalist,
brandList:arr,
recommandBrand: recommandArr,
});

@ -9,7 +9,7 @@
</view>
</scroll-view>
</view>
<van-index-bar class="bs-bar" sticky-offset-top="40">
<van-index-bar index-list="{{ alphalist }}" class="bs-bar" sticky-offset-top="40">
<view wx:for="{{brandList}}" wx:for-item="item" wx:key="index">
<van-index-anchor index="{{item.name}}" />
<van-cell wx:for="{{item.data}}" wx:for-item="it" wx:key="index" clickable data-id="{{it}}" bind:click="toBrandInsight">

@ -7,6 +7,7 @@ Component({
currentBrand: '',
history: [],
queryname: '',
alphalist: [],
},
methods: {
modalChoose(e) {
@ -106,13 +107,19 @@ Component({
action: 'getUserBrand',
token: wx.getStorageSync('token'),
}).then(res => {
let arr = []
for (let i = 65; i <= 90; i++) {
let arr = [];
let alphalist = [];
res.forEach(ele => {
if(ele.firstword != '热门' && alphalist.indexOf(ele.firstword) == -1) {
alphalist.push(ele.firstword)
}
});
alphalist.forEach(ele => {
arr.push({
name: String.fromCharCode(i),
name: ele,
data: []
});
}
});
for(let i of res){
for(let j of arr){
if(i.firstword == j.name){
@ -121,6 +128,7 @@ Component({
}
}
this.setData({
alphalist: alphalist,
brandList: arr
});
});

@ -11,7 +11,7 @@
</view>
</scroll-view>
</view>
<van-index-bar class="bs-bar" sticky-offset-top="40">
<van-index-bar index-list="{{ alphalist }}" class="bs-bar" sticky-offset-top="40">
<view wx:for="{{brandList}}" wx:for-item="item" wx:key="index">
<van-index-anchor index="{{item.name}}" />
<van-cell wx:for="{{item.data}}" wx:for-item="it" wx:key="brandname" clickable data-id="{{it.brandname}}" bind:click="modalChoose">

Loading…
Cancel
Save