zx 3 years ago
parent 0a50938f52
commit 478a3fa72d

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

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

@ -11,7 +11,7 @@
</view> </view>
</scroll-view> </scroll-view>
</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"> <view wx:for="{{brandList}}" wx:for-item="item" wx:key="index">
<van-index-anchor index="{{item.name}}" /> <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"> <van-cell wx:for="{{item.data}}" wx:for-item="it" wx:key="brandname" clickable data-id="{{it.brandname}}" bind:click="modalChoose">

Loading…
Cancel
Save