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.

221 lines
4.5 KiB

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