|
|
|
@ -25,8 +25,8 @@ Component({
|
|
|
|
|
img: e.currentTarget.dataset.id.img
|
|
|
|
|
}
|
|
|
|
|
let isAdded = false;
|
|
|
|
|
for(let i=0;i<this.data.history.length;i++) { //列表中已存在则移到最前,否则添加到最前
|
|
|
|
|
if(JSON.stringify(this.data.history[i]) == JSON.stringify(o)) {
|
|
|
|
|
for(let i=0;i<this.data.history.length;i++) { //列表中已存在则移到最前,否则在最前添加
|
|
|
|
|
if(this.data.history[i].img == o.img) {
|
|
|
|
|
isAdded = true;
|
|
|
|
|
let arr = wx.getStorageSync('historyBrand');
|
|
|
|
|
arr.splice(i, 1);
|
|
|
|
@ -49,9 +49,6 @@ Component({
|
|
|
|
|
},
|
|
|
|
|
lifetimes: {
|
|
|
|
|
attached() {
|
|
|
|
|
if(wx.getStorageSync('historyBrand')) {
|
|
|
|
|
this.setData({history: wx.getStorageSync('historyBrand')})
|
|
|
|
|
}
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '加载中',
|
|
|
|
|
icon: 'loading',
|
|
|
|
@ -63,12 +60,12 @@ Component({
|
|
|
|
|
token: 't%2BrswgjvzGM=',
|
|
|
|
|
}).then(res => {
|
|
|
|
|
let arr = []
|
|
|
|
|
// let recommandArr = [];
|
|
|
|
|
// res.forEach(ele => {
|
|
|
|
|
// if(ele.firstword == '热门') {
|
|
|
|
|
// recommandArr.push(ele)
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
let recommandArr = [];
|
|
|
|
|
res.forEach(ele => {
|
|
|
|
|
if(ele.firstword == '热门') {
|
|
|
|
|
recommandArr.push(ele)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
for (let i = 65; i <= 90; i++) {
|
|
|
|
|
arr.push({
|
|
|
|
|
name: String.fromCharCode(i),
|
|
|
|
@ -84,8 +81,14 @@ Component({
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
brandList:arr,
|
|
|
|
|
// recommandBrand: recommandArr,
|
|
|
|
|
recommandBrand: recommandArr,
|
|
|
|
|
});
|
|
|
|
|
if(wx.getStorageSync('historyBrand').length != 0) {
|
|
|
|
|
this.setData({history: wx.getStorageSync('historyBrand')})
|
|
|
|
|
} else { //首次加载默认为推荐品牌
|
|
|
|
|
this.setData({history: recommandArr});
|
|
|
|
|
wx.setStorageSync('historyBrand', recommandArr);
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() =>{
|
|
|
|
|
wx.hideToast();
|
|
|
|
|
},500)
|
|
|
|
|