|
|
|
@ -5,22 +5,53 @@ Component({
|
|
|
|
|
brandList: [],
|
|
|
|
|
brandForm: {
|
|
|
|
|
brand: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
history: [],
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
toBrandInsight(e) {
|
|
|
|
|
let id = e.currentTarget.dataset.id; //获取点击的id
|
|
|
|
|
wx.setStorageSync('sBrand', id);
|
|
|
|
|
let name = e.currentTarget.dataset.id.brandname; //获取点击的name
|
|
|
|
|
let obj = {
|
|
|
|
|
brandname: name,
|
|
|
|
|
img: e.currentTarget.dataset.id.img
|
|
|
|
|
};
|
|
|
|
|
if(wx.getStorageSync('historyBrand').length == 0) {
|
|
|
|
|
let arr = [obj];
|
|
|
|
|
wx.setStorageSync('historyBrand', arr);
|
|
|
|
|
this.setData({history: arr})
|
|
|
|
|
} else {
|
|
|
|
|
let o = {
|
|
|
|
|
brandname: name,
|
|
|
|
|
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)) {
|
|
|
|
|
isAdded = true;
|
|
|
|
|
let arr = wx.getStorageSync('historyBrand');
|
|
|
|
|
arr.splice(i, 1);
|
|
|
|
|
let replaceArr = [o, ...arr];
|
|
|
|
|
wx.setStorageSync('historyBrand', replaceArr);
|
|
|
|
|
this.setData({history: replaceArr})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isAdded) {
|
|
|
|
|
let newArr = [o, ...wx.getStorageSync('historyBrand')]
|
|
|
|
|
wx.setStorageSync('historyBrand', newArr);
|
|
|
|
|
this.setData({history: newArr})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wx.setStorageSync('sBrand', name);
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: "/pages/insight/pages/brandInsight/index"
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlerSearch(value) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
lifetimes: {
|
|
|
|
|
attached() {
|
|
|
|
|
if(wx.getStorageSync('historyBrand')) {
|
|
|
|
|
this.setData({history: wx.getStorageSync('historyBrand')})
|
|
|
|
|
}
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '加载中',
|
|
|
|
|
icon: 'loading',
|
|
|
|
@ -32,12 +63,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),
|
|
|
|
@ -53,19 +84,12 @@ Component({
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
brandList:arr,
|
|
|
|
|
recommandBrand: recommandArr,
|
|
|
|
|
// recommandBrand: recommandArr,
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() =>{
|
|
|
|
|
wx.hideToast();
|
|
|
|
|
},500)
|
|
|
|
|
});
|
|
|
|
|
//推荐品牌
|
|
|
|
|
// app.globalData.request({
|
|
|
|
|
// action: 'getRecommendSeries',
|
|
|
|
|
// token: 't%2BrswgjvzGM=',
|
|
|
|
|
// }).then(res => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
// });
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|