|
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
eventList: [],
|
|
|
|
result: [],
|
|
|
|
eventData: [],
|
|
|
|
sBrand: '',
|
|
|
|
option1: [{
|
|
|
|
text: '品牌选择',
|
|
|
|
value: ""
|
|
|
|
}, ],
|
|
|
|
option2: [{
|
|
|
|
text: '车型选择',
|
|
|
|
value: ''
|
|
|
|
}, ],
|
|
|
|
option3: [{
|
|
|
|
text: '全部类型',
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '自燃',
|
|
|
|
value: '自燃'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '领导人',
|
|
|
|
value: '领导人'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '维权',
|
|
|
|
value: '维权'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '车展',
|
|
|
|
value: '车展'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '裁员',
|
|
|
|
value: '裁员'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '产品代言',
|
|
|
|
value: '产品代言'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '新车上市',
|
|
|
|
value: '新车上市'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
option4: [
|
|
|
|
{text: '排序方式', value: ''},
|
|
|
|
{text: '影响力排序', value: 0},
|
|
|
|
{text: '时间排序', value: 1}
|
|
|
|
],
|
|
|
|
sSeriesName: '',
|
|
|
|
sQuDao: '',
|
|
|
|
sBrand: '',
|
|
|
|
sSeriesName: '',
|
|
|
|
sTitle: '',
|
|
|
|
totalNum: 0,
|
|
|
|
iTimeType: '',
|
|
|
|
evData: [],
|
|
|
|
},
|
|
|
|
getData() {
|
|
|
|
let eventData = wx.getStorageSync('eventData') || [];
|
|
|
|
let evData = [];
|
|
|
|
eventData.forEach(ele => {
|
|
|
|
if(ele) {
|
|
|
|
evData.push((JSON.parse(ele)).events_id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.setData({
|
|
|
|
evData: evData,
|
|
|
|
});
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getEventList',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
sType: 'HotLibraryC',
|
|
|
|
sBrand: this.data.sBrand,
|
|
|
|
sSeriesName: this.data.sSeriesName,
|
|
|
|
sTitle: this.data.sTitle,
|
|
|
|
sTimeType: 20,
|
|
|
|
sQuDao: this.data.sQuDao,
|
|
|
|
iTimeType: this.data.iTimeType
|
|
|
|
},(res) => {
|
|
|
|
this.setData({totalNum: res.totalNum})
|
|
|
|
}).then(res => {
|
|
|
|
let data = res
|
|
|
|
let deleteIndex = [];
|
|
|
|
for(let i=0;i<data.length;i++) {
|
|
|
|
let n = this.data.evData.indexOf(data[i].events_id);
|
|
|
|
if(n != -1) {
|
|
|
|
deleteIndex.push(n);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if(deleteIndex.length != 0) {
|
|
|
|
data.splice(deleteIndex[0], 1);
|
|
|
|
data.splice(deleteIndex[1]-1, 1);
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
eventList: data,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
checkChange(event) {
|
|
|
|
const {
|
|
|
|
detail
|
|
|
|
} = event;
|
|
|
|
let arr = wx.getStorageSync('eventData');
|
|
|
|
arr.length = 2;
|
|
|
|
if(this.data.switchEvent) {
|
|
|
|
for(let i=0;i<arr.length;i++) {
|
|
|
|
if(arr[i] == JSON.stringify(this.data.switchEvent)) {
|
|
|
|
arr[i] = detail[0]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wx.setStorageSync('eventData', arr);
|
|
|
|
} else {
|
|
|
|
for(let i=0;i<arr.length;i++) {
|
|
|
|
if(!arr[i]) {
|
|
|
|
arr[i] = detail[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
wx.setStorageSync('eventData', arr);
|
|
|
|
}
|
|
|
|
this.triggerEvent('hide');
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
brandChange(e) {
|
|
|
|
let {
|
|
|
|
detail
|
|
|
|
} = e
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getUserSeriesName',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
sBrandName: detail
|
|
|
|
}).then(res => {
|
|
|
|
let arr = [{
|
|
|
|
text: '车型选择',
|
|
|
|
value: ''
|
|
|
|
}]
|
|
|
|
for (let i of res) {
|
|
|
|
let obj = {
|
|
|
|
text: i.name,
|
|
|
|
value: i.name
|
|
|
|
}
|
|
|
|
arr.push(obj)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
option2: arr,
|
|
|
|
sSeriesName: '',
|
|
|
|
sBrand: detail,
|
|
|
|
});
|
|
|
|
this.getData();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sQuDaoChange(e) {
|
|
|
|
let { detail } = e
|
|
|
|
this.setData({
|
|
|
|
sQuDao: detail
|
|
|
|
})
|
|
|
|
this.getData()
|
|
|
|
},
|
|
|
|
sortChange(e) {
|
|
|
|
let { detail } = e
|
|
|
|
this.setData({
|
|
|
|
iTimeType: detail
|
|
|
|
})
|
|
|
|
this.getData()
|
|
|
|
},
|
|
|
|
seriesNameChange(e) {
|
|
|
|
let { detail } = e
|
|
|
|
this.setData({
|
|
|
|
sSeriesName: detail
|
|
|
|
})
|
|
|
|
this.getData();
|
|
|
|
},
|
|
|
|
onChange(e) {
|
|
|
|
let { detail } = e
|
|
|
|
this.setData({
|
|
|
|
sTitle: detail
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onSearch(e) {
|
|
|
|
this.getData()
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
this.getData()
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getUserBrand',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
}).then(res => {
|
|
|
|
let arr = [{
|
|
|
|
text: '品牌选择',
|
|
|
|
value: ""
|
|
|
|
}, ]
|
|
|
|
for (let i of res) {
|
|
|
|
if (i.firstword == '热门') continue
|
|
|
|
let obj = {
|
|
|
|
text: i.brandname,
|
|
|
|
value: i.brandname
|
|
|
|
}
|
|
|
|
arr.push(obj)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
option1: arr
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if (options.switchEvent) {
|
|
|
|
let switchEvent = JSON.parse(options.switchEvent)
|
|
|
|
this.setData({
|
|
|
|
switchEvent
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|