You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.6 KiB

3 years ago
const app = getApp();
Component({
3 years ago
data: {
3 years ago
brandList: [],
modalList: [],
popShow: false,
currentBrand: '',
3 years ago
history: [],
queryname: '',
3 years ago
alphalist: [],
3 years ago
},
3 years ago
methods: {
modalChoose(e) {
let id = e.currentTarget.dataset.id; //获取点击的id
app.globalData.request({
action: 'getUserSeriesName',
3 years ago
token: wx.getStorageSync('token'),
3 years ago
sBrandName: id
}).then(res => {
this.setData({
modalList: res,
popShow: true,
currentBrand: id,
})
});
},
3 years ago
handlerSearch() {
3 years ago
app.globalData.request({
action: 'getQueryrSeriesName',
3 years ago
token: wx.getStorageSync('token'),
queryname: this.data.queryname
3 years ago
}).then(res => {
3 years ago
//图片少了.png后缀
let arr = []
for (let i = 65; i <= 90; i++) {
arr.push({
name: String.fromCharCode(i),
data: []
});
}
for(let i of res){
for(let j of arr){
if(i.firstword == j.name){
let obj = {
brandname: i.name,
img: i.img+'.png',
data: i.data,
firstword: i.firstword
}
j.data.push(obj)
}
}
};
this.setData({
brandList: arr
});
3 years ago
});
},
toModalInsight(value) {
3 years ago
let id = value.target.dataset.id;
3 years ago
if(wx.getStorageSync('historyModal').length == 0) {
let arr = [id];
wx.setStorageSync('historyModal', arr);
this.setData({history: arr})
} else {
if(wx.getStorageSync('historyModal').indexOf(id) == -1) {
let newArr = [id, ...wx.getStorageSync('historyModal')];
wx.setStorageSync('historyModal', newArr);
this.setData({history: newArr})
} else {
let newArr = wx.getStorageSync('historyModal');
let index = wx.getStorageSync('historyModal').indexOf(id);
newArr.splice(index, 1);
let result = [id, ...newArr];
wx.setStorageSync('historyModal', result);
this.setData({history: result})
}
}
3 years ago
app.globalData.request({
action: 'getBrandName',
3 years ago
token: wx.getStorageSync('token'),
3 years ago
sSeriesName: id
}).then(res => {
wx.setStorageSync('sBrand', res);
});
3 years ago
wx.setStorageSync('sSeriesName', id);
3 years ago
wx.navigateTo({
url: "/pages/insight/pages/modalInsight/index"
})
3 years ago
},
onClose() {
this.setData({
popShow: false
})
3 years ago
},
onChange(e) {
this.setData({queryname: e.detail});
3 years ago
}
3 years ago
},
3 years ago
lifetimes: {
attached() {
3 years ago
if(wx.getStorageSync('historyModal')) {
this.setData({history: wx.getStorageSync('historyModal')})
}
3 years ago
//页面数据
app.globalData.request({
action: 'getUserBrand',
3 years ago
token: wx.getStorageSync('token'),
3 years ago
}).then(res => {
3 years ago
let arr = [];
let alphalist = [];
res.forEach(ele => {
if(ele.firstword != '热门' && alphalist.indexOf(ele.firstword) == -1) {
alphalist.push(ele.firstword)
}
});
alphalist.forEach(ele => {
3 years ago
arr.push({
3 years ago
name: ele,
3 years ago
data: []
});
3 years ago
});
3 years ago
for(let i of res){
for(let j of arr){
if(i.firstword == j.name){
j.data.push(i)
}
}
}
this.setData({
3 years ago
alphalist: alphalist,
brandList: arr
3 years ago
});
});
},
3 years ago
},
})